Skip to content

Commit

Permalink
fix __future__ edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
diceroll123 committed Nov 29, 2023
1 parent 07e0d31 commit 2f5c77c
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import _private
import _private as _p
from _private import _private
from lib import _private
from lib import _private as _p
from lib._private import _private
from lib._private import _private as _p
from lib._private import _private, _private as _p
from __future__ import annotations # Ok

import _private # PLC2701
import _private as _p # PLC2701
from _private import _private # PLC2701
from lib import _private # PLC2701
from lib import _private as _p # PLC2701
from lib._private import _private # PLC2701
from lib._private import _private as _p # PLC2701
from lib._private import _private, _private as _p # PLC2701
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ pub(crate) fn import_private_name(checker: &mut Checker, stmt: &Stmt) {
}

if let Some(identifier) = module {
if identifier == "__future__" {
return;
}
if identifier.starts_with('_') {
checker.diagnostics.push(Diagnostic::new(
ImportPrivateName {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
---
source: crates/ruff_linter/src/rules/pylint/mod.rs
assertion_line: 172
---
import_private_name.py:3:8: PLC2701 Imported private module
|
1 | from __future__ import annotations # Ok
2 |
3 | import _private # PLC2701
| ^^^^^^^^ PLC2701
4 | import _private as _p # PLC2701
5 | from _private import _private # PLC2701
|

import_private_name.py:4:8: PLC2701 Imported private module
|
3 | import _private # PLC2701
4 | import _private as _p # PLC2701
| ^^^^^^^^ PLC2701
5 | from _private import _private # PLC2701
6 | from lib import _private # PLC2701
|

import_private_name.py:5:6: PLC2701 Imported private module
|
3 | import _private # PLC2701
4 | import _private as _p # PLC2701
5 | from _private import _private # PLC2701
| ^^^^^^^^ PLC2701
6 | from lib import _private # PLC2701
7 | from lib import _private as _p # PLC2701
|

import_private_name.py:5:22: PLC2701 Imported private object
|
3 | import _private # PLC2701
4 | import _private as _p # PLC2701
5 | from _private import _private # PLC2701
| ^^^^^^^^ PLC2701
6 | from lib import _private # PLC2701
7 | from lib import _private as _p # PLC2701
|

import_private_name.py:6:17: PLC2701 Imported private object
|
4 | import _private as _p # PLC2701
5 | from _private import _private # PLC2701
6 | from lib import _private # PLC2701
| ^^^^^^^^ PLC2701
7 | from lib import _private as _p # PLC2701
8 | from lib._private import _private # PLC2701
|

import_private_name.py:7:17: PLC2701 Imported private object
|
5 | from _private import _private # PLC2701
6 | from lib import _private # PLC2701
7 | from lib import _private as _p # PLC2701
| ^^^^^^^^ PLC2701
8 | from lib._private import _private # PLC2701
9 | from lib._private import _private as _p # PLC2701
|

import_private_name.py:8:6: PLC2701 Imported from private module
|
6 | from lib import _private # PLC2701
7 | from lib import _private as _p # PLC2701
8 | from lib._private import _private # PLC2701
| ^^^^^^^^^^^^ PLC2701
9 | from lib._private import _private as _p # PLC2701
10 | from lib._private import _private, _private as _p # PLC2701
|

import_private_name.py:8:26: PLC2701 Imported private object
|
6 | from lib import _private # PLC2701
7 | from lib import _private as _p # PLC2701
8 | from lib._private import _private # PLC2701
| ^^^^^^^^ PLC2701
9 | from lib._private import _private as _p # PLC2701
10 | from lib._private import _private, _private as _p # PLC2701
|

import_private_name.py:9:6: PLC2701 Imported from private module
|
7 | from lib import _private as _p # PLC2701
8 | from lib._private import _private # PLC2701
9 | from lib._private import _private as _p # PLC2701
| ^^^^^^^^^^^^ PLC2701
10 | from lib._private import _private, _private as _p # PLC2701
|

import_private_name.py:9:26: PLC2701 Imported private object
|
7 | from lib import _private as _p # PLC2701
8 | from lib._private import _private # PLC2701
9 | from lib._private import _private as _p # PLC2701
| ^^^^^^^^ PLC2701
10 | from lib._private import _private, _private as _p # PLC2701
|

import_private_name.py:10:6: PLC2701 Imported from private module
|
8 | from lib._private import _private # PLC2701
9 | from lib._private import _private as _p # PLC2701
10 | from lib._private import _private, _private as _p # PLC2701
| ^^^^^^^^^^^^ PLC2701
|

import_private_name.py:10:26: PLC2701 Imported private object
|
8 | from lib._private import _private # PLC2701
9 | from lib._private import _private as _p # PLC2701
10 | from lib._private import _private, _private as _p # PLC2701
| ^^^^^^^^ PLC2701
|

import_private_name.py:10:36: PLC2701 Imported private object
|
8 | from lib._private import _private # PLC2701
9 | from lib._private import _private as _p # PLC2701
10 | from lib._private import _private, _private as _p # PLC2701
| ^^^^^^^^ PLC2701
|


0 comments on commit 2f5c77c

Please sign in to comment.