-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement PYI047 #6134
Merged
Merged
Implement PYI047 #6134
Commits on Jul 27, 2023
-
/// ## What it does /// Checks for the presence of unused private `typing.TypeAlias` definitions. /// /// ## Why is this bad? /// A private `typing.TypeAlias` that is defined but not used is likely a /// mistake, and should either be used, made public, or removed to avoid /// confusion. /// /// ## Example /// ```python /// import typing /// /// _UnusedTypeAlias: typing.TypeAlias = int /// ``` /// /// Use instead: /// ```python /// import typing /// /// _UsedTypeAlias: typing.TypeAlias = int /// /// def func(arg: _UsedTypeAlias) -> _UsedTypeAlias: /// ... /// ```
Configuration menu - View commit details
-
Copy full SHA for 3d80969 - Browse repository at this point
Copy the full SHA 3d80969View commit details -
Configuration menu - View commit details
-
Copy full SHA for b99a560 - Browse repository at this point
Copy the full SHA b99a560View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1fe05f6 - Browse repository at this point
Copy the full SHA 1fe05f6View commit details
Commits on Jul 28, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 0a61d87 - Browse repository at this point
Copy the full SHA 0a61d87View commit details -
Only run unused private type rules over finalized bindings (astral-sh…
…#6142) In astral-sh#6134 and astral-sh#6136, we see some false positives for "shadowed" class definitions. For example, here, the first definition is flagged as unused, since from the perspective of the semantic model (which doesn't understand branching), it appears to be immediately shadowed in the `else`, and thus never used: ```python if sys.version_info >= (3, 11): class _RootLoggerConfiguration(TypedDict, total=False): level: _Level filters: Sequence[str | _FilterType] handlers: Sequence[str] else: class _RootLoggerConfiguration(TypedDict, total=False): level: _Level filters: Sequence[str] handlers: Sequence[str] ``` Instead of looking at _all_ bindings, we should instead look at the "live" bindings, which is similar to how other rules (like unused variables detection) is structured. We thus move the rule from `bindings.rs` (which iterates over _all_ bindings, regardless of whether they're shadowed) to `deferred_scopes.rs`, which iterates over all "live" bindings once a scope has been fully analyzed. `cargo test`
Configuration menu - View commit details
-
Copy full SHA for ad3081d - Browse repository at this point
Copy the full SHA ad3081dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 74cdfdb - Browse repository at this point
Copy the full SHA 74cdfdbView commit details -
Avoid refactoring
x[:1]
-like slices in RUF015 (astral-sh#6150)## Summary Right now, `RUF015` will try to rewrite `x[:1]` as `[next(x)]`. This isn't equivalent if `x`, for example, is empty, where slicing like `x[:1]` is forgiving, but `next` raises `StopIteration`. For me this is a little too much of a deviation to be comfortable with, and most of the value in this rule is the `x[0]` to `next(x)` conversion anyway. Closes astral-sh#6148.
Configuration menu - View commit details
-
Copy full SHA for c93bbbf - Browse repository at this point
Copy the full SHA c93bbbfView commit details -
/// ## What it does /// Checks for the presence of unused private `typing.TypeAlias` definitions. /// /// ## Why is this bad? /// A private `typing.TypeAlias` that is defined but not used is likely a /// mistake, and should either be used, made public, or removed to avoid /// confusion. /// /// ## Example /// ```python /// import typing /// /// _UnusedTypeAlias: typing.TypeAlias = int /// ``` /// /// Use instead: /// ```python /// import typing /// /// _UsedTypeAlias: typing.TypeAlias = int /// /// def func(arg: _UsedTypeAlias) -> _UsedTypeAlias: /// ... /// ```
Configuration menu - View commit details
-
Copy full SHA for 926562a - Browse repository at this point
Copy the full SHA 926562aView commit details -
Configuration menu - View commit details
-
Copy full SHA for b5a3e85 - Browse repository at this point
Copy the full SHA b5a3e85View commit details -
Configuration menu - View commit details
-
Copy full SHA for 99c0347 - Browse repository at this point
Copy the full SHA 99c0347View commit details
Commits on Jul 29, 2023
-
Configuration menu - View commit details
-
Copy full SHA for f82dc02 - Browse repository at this point
Copy the full SHA f82dc02View commit details -
Configuration menu - View commit details
-
Copy full SHA for b8943f9 - Browse repository at this point
Copy the full SHA b8943f9View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.