Skip to content

Conversation

@ayushm98
Copy link

Description of changes

Fixes #2334

This PR adds flake8-tidy-imports to the pre-commit flake8 hook with the --ban-relative-imports=true flag to enforce absolute imports throughout the codebase.

Changes

  • Added flake8-tidy-imports>=4.10.0 as an additional dependency to the flake8 pre-commit hook
  • Added --ban-relative-imports=true argument to enforce absolute imports

Why?

  • Absolute imports are more explicit and easier to understand
  • They avoid confusion about where modules are located
  • They're more consistent across the codebase
  • They help prevent circular import issues

Test plan

The pre-commit hook will now flag any relative imports (e.g., from . import foo or from .module import bar).

Add flake8-tidy-imports plugin to the pre-commit flake8 hook
with --ban-relative-imports=true to enforce absolute imports
throughout the codebase.

This helps maintain consistency and makes imports more explicit.

Fixes chroma-core#2334
@github-actions
Copy link

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

@propel-code-bot
Copy link
Contributor

Enforce absolute imports via flake8 tidy imports in pre-commit

Updates the flake8 pre-commit hook to load the flake8-tidy-imports plugin and pass --ban-relative-imports=true. This change ensures future commits are linted against relative import usage.

Key Changes

• Added --ban-relative-imports=true to the flake8 hook arguments in .pre-commit-config.yaml
• Declared flake8-tidy-imports>=4.10.0 in additional_dependencies for the flake8 pre-commit hook

Affected Areas

• .pre-commit-config.yaml

This summary was automatically generated by @propel-code-bot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BLD] add flake8 rule to ban relative imports

1 participant