Skip to content
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

Tweak relative-imports message #9365

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ impl Violation for RelativeImports {
#[derive_message_formats]
fn message(&self) -> String {
match self.strictness {
Strictness::Parents => format!("Relative imports from parent modules are banned"),
Strictness::All => format!("Relative imports are banned"),
Strictness::Parents => {
format!("Prefer absolute imports over relative imports from parent modules")
}
Strictness::All => format!("Prefer absolute imports over relative imports"),
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/ruff_linter/src/rules/flake8_tidy_imports/mod.rs
---
TID252.py:7:1: TID252 Relative imports are banned
TID252.py:7:1: TID252 Prefer absolute imports over relative imports
|
6 | # TID252
7 | from . import sibling
Expand All @@ -11,7 +11,7 @@ TID252.py:7:1: TID252 Relative imports are banned
|
= help: Replace relative imports with absolute imports

TID252.py:8:1: TID252 Relative imports are banned
TID252.py:8:1: TID252 Prefer absolute imports over relative imports
|
6 | # TID252
7 | from . import sibling
Expand All @@ -22,7 +22,7 @@ TID252.py:8:1: TID252 Relative imports are banned
|
= help: Replace relative imports with absolute imports

TID252.py:9:1: TID252 Relative imports are banned
TID252.py:9:1: TID252 Prefer absolute imports over relative imports
|
7 | from . import sibling
8 | from .sibling import example
Expand All @@ -33,7 +33,7 @@ TID252.py:9:1: TID252 Relative imports are banned
|
= help: Replace relative imports with absolute imports

TID252.py:10:1: TID252 Relative imports are banned
TID252.py:10:1: TID252 Prefer absolute imports over relative imports
|
8 | from .sibling import example
9 | from .. import parent
Expand All @@ -44,7 +44,7 @@ TID252.py:10:1: TID252 Relative imports are banned
|
= help: Replace relative imports with absolute imports

TID252.py:11:1: TID252 Relative imports are banned
TID252.py:11:1: TID252 Prefer absolute imports over relative imports
|
9 | from .. import parent
10 | from ..parent import example
Expand All @@ -55,7 +55,7 @@ TID252.py:11:1: TID252 Relative imports are banned
|
= help: Replace relative imports with absolute imports

TID252.py:12:1: TID252 Relative imports are banned
TID252.py:12:1: TID252 Prefer absolute imports over relative imports
|
10 | from ..parent import example
11 | from ... import grandparent
Expand All @@ -66,7 +66,7 @@ TID252.py:12:1: TID252 Relative imports are banned
|
= help: Replace relative imports with absolute imports

TID252.py:13:1: TID252 Relative imports are banned
TID252.py:13:1: TID252 Prefer absolute imports over relative imports
|
11 | from ... import grandparent
12 | from ...grandparent import example
Expand All @@ -77,7 +77,7 @@ TID252.py:13:1: TID252 Relative imports are banned
|
= help: Replace relative imports with absolute imports

TID252.py:14:1: TID252 Relative imports are banned
TID252.py:14:1: TID252 Prefer absolute imports over relative imports
|
12 | from ...grandparent import example
13 | from .parent import hello
Expand All @@ -90,7 +90,7 @@ TID252.py:14:1: TID252 Relative imports are banned
|
= help: Replace relative imports with absolute imports

TID252.py:17:1: TID252 Relative imports are banned
TID252.py:17:1: TID252 Prefer absolute imports over relative imports
|
15 | parent import \
16 | hello_world
Expand All @@ -104,7 +104,7 @@ TID252.py:17:1: TID252 Relative imports are banned
|
= help: Replace relative imports with absolute imports

TID252.py:21:1: TID252 Relative imports are banned
TID252.py:21:1: TID252 Prefer absolute imports over relative imports
|
19 | import \
20 | world_hello
Expand All @@ -115,7 +115,7 @@ TID252.py:21:1: TID252 Relative imports are banned
|
= help: Replace relative imports with absolute imports

TID252.py:22:1: TID252 Relative imports are banned
TID252.py:22:1: TID252 Prefer absolute imports over relative imports
|
20 | world_hello
21 | from ..... import ultragrantparent
Expand All @@ -126,7 +126,7 @@ TID252.py:22:1: TID252 Relative imports are banned
|
= help: Replace relative imports with absolute imports

TID252.py:23:1: TID252 Relative imports are banned
TID252.py:23:1: TID252 Prefer absolute imports over relative imports
|
21 | from ..... import ultragrantparent
22 | from ...... import ultragrantparent
Expand All @@ -137,7 +137,7 @@ TID252.py:23:1: TID252 Relative imports are banned
|
= help: Replace relative imports with absolute imports

TID252.py:24:1: TID252 Relative imports are banned
TID252.py:24:1: TID252 Prefer absolute imports over relative imports
|
22 | from ...... import ultragrantparent
23 | from ....... import ultragrantparent
Expand All @@ -148,7 +148,7 @@ TID252.py:24:1: TID252 Relative imports are banned
|
= help: Replace relative imports with absolute imports

TID252.py:25:1: TID252 Relative imports are banned
TID252.py:25:1: TID252 Prefer absolute imports over relative imports
|
23 | from ....... import ultragrantparent
24 | from ......... import ultragrantparent
Expand All @@ -159,7 +159,7 @@ TID252.py:25:1: TID252 Relative imports are banned
|
= help: Replace relative imports with absolute imports

TID252.py:26:1: TID252 Relative imports are banned
TID252.py:26:1: TID252 Prefer absolute imports over relative imports
|
24 | from ......... import ultragrantparent
25 | from ........................... import ultragrantparent
Expand All @@ -170,7 +170,7 @@ TID252.py:26:1: TID252 Relative imports are banned
|
= help: Replace relative imports with absolute imports

TID252.py:27:1: TID252 Relative imports are banned
TID252.py:27:1: TID252 Prefer absolute imports over relative imports
|
25 | from ........................... import ultragrantparent
26 | from .....parent import ultragrantparent
Expand All @@ -180,7 +180,7 @@ TID252.py:27:1: TID252 Relative imports are banned
|
= help: Replace relative imports with absolute imports

TID252.py:28:1: TID252 Relative imports are banned
TID252.py:28:1: TID252 Prefer absolute imports over relative imports
|
26 | from .....parent import ultragrantparent
27 | from .........parent import ultragrantparent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/ruff_linter/src/rules/flake8_tidy_imports/mod.rs
---
TID252.py:9:1: TID252 Relative imports from parent modules are banned
TID252.py:9:1: TID252 Prefer absolute imports over relative imports from parent modules
|
7 | from . import sibling
8 | from .sibling import example
Expand All @@ -12,7 +12,7 @@ TID252.py:9:1: TID252 Relative imports from parent modules are banned
|
= help: Replace relative imports from parent modules with absolute imports

TID252.py:10:1: TID252 Relative imports from parent modules are banned
TID252.py:10:1: TID252 Prefer absolute imports over relative imports from parent modules
|
8 | from .sibling import example
9 | from .. import parent
Expand All @@ -23,7 +23,7 @@ TID252.py:10:1: TID252 Relative imports from parent modules are banned
|
= help: Replace relative imports from parent modules with absolute imports

TID252.py:11:1: TID252 Relative imports from parent modules are banned
TID252.py:11:1: TID252 Prefer absolute imports over relative imports from parent modules
|
9 | from .. import parent
10 | from ..parent import example
Expand All @@ -34,7 +34,7 @@ TID252.py:11:1: TID252 Relative imports from parent modules are banned
|
= help: Replace relative imports from parent modules with absolute imports

TID252.py:12:1: TID252 Relative imports from parent modules are banned
TID252.py:12:1: TID252 Prefer absolute imports over relative imports from parent modules
|
10 | from ..parent import example
11 | from ... import grandparent
Expand All @@ -45,7 +45,7 @@ TID252.py:12:1: TID252 Relative imports from parent modules are banned
|
= help: Replace relative imports from parent modules with absolute imports

TID252.py:17:1: TID252 Relative imports from parent modules are banned
TID252.py:17:1: TID252 Prefer absolute imports over relative imports from parent modules
|
15 | parent import \
16 | hello_world
Expand All @@ -59,7 +59,7 @@ TID252.py:17:1: TID252 Relative imports from parent modules are banned
|
= help: Replace relative imports from parent modules with absolute imports

TID252.py:21:1: TID252 Relative imports from parent modules are banned
TID252.py:21:1: TID252 Prefer absolute imports over relative imports from parent modules
|
19 | import \
20 | world_hello
Expand All @@ -70,7 +70,7 @@ TID252.py:21:1: TID252 Relative imports from parent modules are banned
|
= help: Replace relative imports from parent modules with absolute imports

TID252.py:22:1: TID252 Relative imports from parent modules are banned
TID252.py:22:1: TID252 Prefer absolute imports over relative imports from parent modules
|
20 | world_hello
21 | from ..... import ultragrantparent
Expand All @@ -81,7 +81,7 @@ TID252.py:22:1: TID252 Relative imports from parent modules are banned
|
= help: Replace relative imports from parent modules with absolute imports

TID252.py:23:1: TID252 Relative imports from parent modules are banned
TID252.py:23:1: TID252 Prefer absolute imports over relative imports from parent modules
|
21 | from ..... import ultragrantparent
22 | from ...... import ultragrantparent
Expand All @@ -92,7 +92,7 @@ TID252.py:23:1: TID252 Relative imports from parent modules are banned
|
= help: Replace relative imports from parent modules with absolute imports

TID252.py:24:1: TID252 Relative imports from parent modules are banned
TID252.py:24:1: TID252 Prefer absolute imports over relative imports from parent modules
|
22 | from ...... import ultragrantparent
23 | from ....... import ultragrantparent
Expand All @@ -103,7 +103,7 @@ TID252.py:24:1: TID252 Relative imports from parent modules are banned
|
= help: Replace relative imports from parent modules with absolute imports

TID252.py:25:1: TID252 Relative imports from parent modules are banned
TID252.py:25:1: TID252 Prefer absolute imports over relative imports from parent modules
|
23 | from ....... import ultragrantparent
24 | from ......... import ultragrantparent
Expand All @@ -114,7 +114,7 @@ TID252.py:25:1: TID252 Relative imports from parent modules are banned
|
= help: Replace relative imports from parent modules with absolute imports

TID252.py:26:1: TID252 Relative imports from parent modules are banned
TID252.py:26:1: TID252 Prefer absolute imports over relative imports from parent modules
|
24 | from ......... import ultragrantparent
25 | from ........................... import ultragrantparent
Expand All @@ -125,7 +125,7 @@ TID252.py:26:1: TID252 Relative imports from parent modules are banned
|
= help: Replace relative imports from parent modules with absolute imports

TID252.py:27:1: TID252 Relative imports from parent modules are banned
TID252.py:27:1: TID252 Prefer absolute imports over relative imports from parent modules
|
25 | from ........................... import ultragrantparent
26 | from .....parent import ultragrantparent
Expand All @@ -135,7 +135,7 @@ TID252.py:27:1: TID252 Relative imports from parent modules are banned
|
= help: Replace relative imports from parent modules with absolute imports

TID252.py:28:1: TID252 Relative imports from parent modules are banned
TID252.py:28:1: TID252 Prefer absolute imports over relative imports from parent modules
|
26 | from .....parent import ultragrantparent
27 | from .........parent import ultragrantparent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/ruff_linter/src/rules/flake8_tidy_imports/mod.rs
---
application.py:5:1: TID252 Relative imports from parent modules are banned
application.py:5:1: TID252 Prefer absolute imports over relative imports from parent modules
|
3 | import attrs
4 |
Expand All @@ -12,7 +12,7 @@ application.py:5:1: TID252 Relative imports from parent modules are banned
|
= help: Replace relative imports from parent modules with absolute imports

application.py:6:1: TID252 [*] Relative imports from parent modules are banned
application.py:6:1: TID252 [*] Prefer absolute imports over relative imports from parent modules
|
5 | from ....import unknown
6 | from ..protocol import commands, definitions, responses
Expand All @@ -32,7 +32,7 @@ application.py:6:1: TID252 [*] Relative imports from parent modules are banned
8 8 | from .. import server
9 9 | from . import logger, models

application.py:6:1: TID252 [*] Relative imports from parent modules are banned
application.py:6:1: TID252 [*] Prefer absolute imports over relative imports from parent modules
|
5 | from ....import unknown
6 | from ..protocol import commands, definitions, responses
Expand All @@ -52,7 +52,7 @@ application.py:6:1: TID252 [*] Relative imports from parent modules are banned
8 8 | from .. import server
9 9 | from . import logger, models

application.py:6:1: TID252 [*] Relative imports from parent modules are banned
application.py:6:1: TID252 [*] Prefer absolute imports over relative imports from parent modules
|
5 | from ....import unknown
6 | from ..protocol import commands, definitions, responses
Expand All @@ -72,7 +72,7 @@ application.py:6:1: TID252 [*] Relative imports from parent modules are banned
8 8 | from .. import server
9 9 | from . import logger, models

application.py:7:1: TID252 [*] Relative imports from parent modules are banned
application.py:7:1: TID252 [*] Prefer absolute imports over relative imports from parent modules
|
5 | from ....import unknown
6 | from ..protocol import commands, definitions, responses
Expand All @@ -93,7 +93,7 @@ application.py:7:1: TID252 [*] Relative imports from parent modules are banned
9 9 | from . import logger, models
10 10 | from ..protocol.UpperCaseModule import some_function

application.py:8:1: TID252 [*] Relative imports from parent modules are banned
application.py:8:1: TID252 [*] Prefer absolute imports over relative imports from parent modules
|
6 | from ..protocol import commands, definitions, responses
7 | from ..server import example
Expand All @@ -113,7 +113,7 @@ application.py:8:1: TID252 [*] Relative imports from parent modules are banned
9 9 | from . import logger, models
10 10 | from ..protocol.UpperCaseModule import some_function

application.py:10:1: TID252 [*] Relative imports from parent modules are banned
application.py:10:1: TID252 [*] Prefer absolute imports over relative imports from parent modules
|
8 | from .. import server
9 | from . import logger, models
Expand Down
Loading