Skip to content

[pull] main from astral-sh:main#154

Merged
pull[bot] merged 12 commits intosysfce2:mainfrom
astral-sh:main
Apr 7, 2024
Merged

[pull] main from astral-sh:main#154
pull[bot] merged 12 commits intosysfce2:mainfrom
astral-sh:main

Conversation

@pull
Copy link
Copy Markdown

@pull pull bot commented Apr 7, 2024

See Commits and Changes for more details.


Created by pull[bot]

Can you help keep this open source service alive? 💖 Please sponsor : )

charliermarsh and others added 12 commits April 6, 2024 10:44
## Summary

I think this is using the wrong shadowing, as seen by the change in the
test fixture.
## Summary

Historically, given:

```python
__all__ = [  # noqa: F822
    "Bernoulli",
    "Beta",
    "Binomial",
]
```

The F822 violations would be attached to the `__all__`, so this `# noqa`
would be enforced for _all_ definitions in the list. This changed in
#10525 for the better, in that we
now use the range of each string. But these `# noqa` directives stopped
working.

This PR sets the `__all__` as a parent range in the diagnostic, so that
these directives are respected once again.

Closes #10795.

## Test Plan

`cargo test`
…n `rb` mode (`FURB101`) (#10803)

## Summary

`Path.read_bytes()` does not support any keyword arguments, so `FURB101`
should not be triggered if the file is opened in `rb` mode with any
keyword arguments.

## Test Plan

Move erroneous test to "Non-error" section of fixture.
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Zanie Blue <contact@zanie.dev>
Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
More accurately identify whether a class is a metaclass, a subclass of `collections.abc.Iterator`, or a subclass of `collections.abc.AsyncIterator`
…s well as subclasses of `collections.namedtuple()` (`SLOT002`) (#10808)
…F821`) (#10779)

## Summary

Fixes #3011.

Type checkers currently allow forward references in all contexts in stub
files, and stubs frequently make use of this capability (although it
doesn't actually seem to be specc'd anywhere --neither in PEP 484, nor
https://typing.readthedocs.io/en/latest/source/stubs.html#id6, nor the
CPython typing docs). Implementing it so that Ruff allows forward
references in _all contexts_ in stub files seems non-trivial, however
(or at least, I couldn't figure out how to do it easily), so this PR
does not do that. Perhaps it _should_; if we think this apporach isn't
principled enough, I'm happy to close it and postpone changing anything
here.

However, this does reduce the number of F821 errors Ruff emits on
typeshed down from 76 to 2, which would mean that we could enable the
rule at typeshed. The remaining 2 F821 errors can be trivially fixed at
typeshed by moving definitions around; forward references in class bases
were really the only remaining places where there was a real _use case_
for forward references in stub files that Ruff wasn't yet allowing.

## Test plan

`cargo test`. I also ran this PR branch on typeshed to check to see if
there were any new false positives caused by the changes here; there
were none.
…`) (#10526)

## Summary
Lint about function like expressions which are equivalent to
`operator.itemgetter`.
See:
#1348 (comment)

## Test Plan
cargo test
@pull pull bot added the ⤵️ pull label Apr 7, 2024
@pull pull bot merged commit 6050bab into sysfce2:main Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants