Skip to content

Lint Python: Ignore ruff rule PLC0415#3195

Merged
legendecas merged 1 commit intomainfrom
Lint-Python-Ignore-ruff-rule-PLC0415
Aug 13, 2025
Merged

Lint Python: Ignore ruff rule PLC0415#3195
legendecas merged 1 commit intomainfrom
Lint-Python-Ignore-ruff-rule-PLC0415

Conversation

@cclauss
Copy link
Copy Markdown
Contributor

@cclauss cclauss commented Aug 13, 2025

https://docs.astral.sh/ruff/rules/import-outside-top-level

There are several valid reasons for conditionally importing Python modules, especially for OS-specific code, so let's intentionally ignore this rule.

% ruff check --select=PLC0415

Error: gyp/pylib/gyp/MSVSVersion.py:222:5: PLC0415 `import` should be at the top-level of a file
Error: gyp/pylib/gyp/__init__.py:492:9: PLC0415 `import` should be at the top-level of a file
Error: gyp/pylib/gyp/generator/make.py:81:9: PLC0415 `import` should be at the top-level of a file
Error: gyp/pylib/gyp/generator/ninja.py:1998:9: PLC0415 `import` should be at the top-level of a file
Error: gyp/pylib/gyp/generator/ninja.py:2021:9: PLC0415 `import` should be at the top-level of a file
Error: gyp/pylib/gyp/generator/ninja.py:2091:9: PLC0415 `import` should be at the top-level of a file
Error: gyp/pylib/gyp/mac_tool.py:145:9: PLC0415 `import` should be at the top-level of a file
Error: gyp/test_gyp.py:151:9: PLC0415 `import` should be at the top-level of a file
Error: gyp/test_gyp.py:157:9: PLC0415 `import` should be at the top-level of a file
Checklist
  • npm install && npm run lint && npm test passes
  • tests are included
  • documentation is changed or added
  • commit message follows commit guidelines
Description of change

https://docs.astral.sh/ruff/rules/import-outside-top-level

There are several valid reasons for conditionally importing Python modules, especially for OS-specific code, so let's intentionally ignore this rule.

% `ruff check --select=PLC0415`
```
Error: gyp/pylib/gyp/MSVSVersion.py:222:5: PLC0415 `import` should be at the top-level of a file
Error: gyp/pylib/gyp/__init__.py:492:9: PLC0415 `import` should be at the top-level of a file
Error: gyp/pylib/gyp/generator/make.py:81:9: PLC0415 `import` should be at the top-level of a file
Error: gyp/pylib/gyp/generator/ninja.py:1998:9: PLC0415 `import` should be at the top-level of a file
Error: gyp/pylib/gyp/generator/ninja.py:2021:9: PLC0415 `import` should be at the top-level of a file
Error: gyp/pylib/gyp/generator/ninja.py:2091:9: PLC0415 `import` should be at the top-level of a file
Error: gyp/pylib/gyp/mac_tool.py:145:9: PLC0415 `import` should be at the top-level of a file
Error: gyp/test_gyp.py:151:9: PLC0415 `import` should be at the top-level of a file
Error: gyp/test_gyp.py:157:9: PLC0415 `import` should be at the top-level of a file
```
@legendecas legendecas merged commit 71a910e into main Aug 13, 2025
86 of 88 checks passed
@legendecas legendecas deleted the Lint-Python-Ignore-ruff-rule-PLC0415 branch August 13, 2025 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants