mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-17 00:50:16 +00:00
Add semantic analysis of type aliases and parameters (#6109)
Requires https://github.com/astral-sh/RustPython-Parser/pull/42 Related https://github.com/PyCQA/pyflakes/pull/778 [PEP-695](https://peps.python.org/pep-0695) Part of #5062 <!-- Thank you for contributing to Ruff! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary <!-- What's the purpose of the change? What does it do, and why? --> Adds a scope for type parameters, a type parameter binding kind, and checker visitation of type parameters in type alias statements, function definitions, and class definitions. A few changes were necessary to ensure correctness following the insertion of a new scope between function and class scopes and their parent. ## Test Plan <!-- How was it tested? --> Undefined name snapshots. Unused type parameter rule will be added as follow-up.
This commit is contained in:
parent
134d447d4c
commit
047c211837
11 changed files with 405 additions and 18 deletions
|
@ -413,6 +413,18 @@ pub enum BindingKind<'a> {
|
|||
/// ```
|
||||
Assignment,
|
||||
|
||||
/// A binding for a generic type parameter, like `X` in:
|
||||
/// ```python
|
||||
/// def foo[X](x: X):
|
||||
/// ...
|
||||
///
|
||||
/// class Foo[X](x: X):
|
||||
/// ...
|
||||
///
|
||||
/// type Foo[X] = ...
|
||||
/// ```
|
||||
TypeParam,
|
||||
|
||||
/// A binding for a for-loop variable, like `x` in:
|
||||
/// ```python
|
||||
/// for x in range(10):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue