Treat .pyi files as __future__ annotations-enabled (#1616)

This commit is contained in:
Charlie Marsh 2023-01-03 21:27:26 -05:00 committed by GitHub
parent 60359c6adf
commit 0d27c0be27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 1 deletions

View file

@ -0,0 +1,3 @@
class Pool:
@classmethod
def create(cls) -> Pool: ...

View file

@ -151,7 +151,7 @@ impl<'a> Checker<'a> {
in_subscript: false, in_subscript: false,
seen_import_boundary: false, seen_import_boundary: false,
futures_allowed: true, futures_allowed: true,
annotations_future_enabled: false, annotations_future_enabled: path.extension().map_or(false, |ext| ext == "pyi"),
except_handlers: vec![], except_handlers: vec![],
// Check-specific state. // Check-specific state.
flake8_bugbear_seen: vec![], flake8_bugbear_seen: vec![],

View file

@ -98,6 +98,7 @@ mod tests {
#[test_case(CheckCode::F821, Path::new("F821_5.py"); "F821_5")] #[test_case(CheckCode::F821, Path::new("F821_5.py"); "F821_5")]
#[test_case(CheckCode::F821, Path::new("F821_6.py"); "F821_6")] #[test_case(CheckCode::F821, Path::new("F821_6.py"); "F821_6")]
#[test_case(CheckCode::F821, Path::new("F821_7.py"); "F821_7")] #[test_case(CheckCode::F821, Path::new("F821_7.py"); "F821_7")]
#[test_case(CheckCode::F821, Path::new("F821_8.pyi"); "F821_8")]
#[test_case(CheckCode::F822, Path::new("F822.py"); "F822")] #[test_case(CheckCode::F822, Path::new("F822.py"); "F822")]
#[test_case(CheckCode::F823, Path::new("F823.py"); "F823")] #[test_case(CheckCode::F823, Path::new("F823.py"); "F823")]
#[test_case(CheckCode::F841, Path::new("F841_0.py"); "F841_0")] #[test_case(CheckCode::F841, Path::new("F841_0.py"); "F841_0")]

View file

@ -0,0 +1,6 @@
---
source: src/pyflakes/mod.rs
expression: checks
---
[]