Skip to content

Enabled flake8-tidy-imports for ruff linter#4395

Open
JayeshHire wants to merge 7 commits intoopen-telemetry:mainfrom
JayeshHire:TID-rule
Open

Enabled flake8-tidy-imports for ruff linter#4395
JayeshHire wants to merge 7 commits intoopen-telemetry:mainfrom
JayeshHire:TID-rule

Conversation

@JayeshHire
Copy link
Copy Markdown

@JayeshHire JayeshHire commented Apr 3, 2026

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.

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.

Note: This rule has already been added inside the opentelemetry-python repo.

contributes to opentelemetry-python/issues/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.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated

@JayeshHire JayeshHire requested a review from a team as a code owner April 3, 2026 17:56
@github-project-automation github-project-automation bot moved this to Approved PRs in Python PR digest Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Approved PRs

Development

Successfully merging this pull request may close these issues.

3 participants