Enabled flake8-tidy-import rule for ruff linter by JayeshHire · Pull Request #5019 · open-telemetry/opentelemetry-python
Description
I have added the "TID" rule for the ruff linter. The main use case of this rule is that it warns about the relative imports in the program and enforces the user to use absolute imports from parent modules. Other use cases includes enforcing 'banned-api' and 'banned-module-level-import' rules. The later mentioned rules are not configured in this PR as I don't see a need for them now. This PR is the part of the ongoing migration from old lint tools onto ruff under #4227 .
The tests directory had many files which violated the TID252 (prefers absolute import over relative imports from parent modules). Since, the tests have only imported the utility functions and some TestCase classes using relative imports and the actual module being tested is not imported relatively, hence I have excluded that directory for the TID252 rule check.
Contributes to #4227
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
- Test A
Tested this by running the below command.
uv run ruff check
All tests have passed successfully.