-
Notifications
You must be signed in to change notification settings - Fork 9
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Request
Context
As discussed in y-scope/clp#1640, we should ban all relative imports in favor of absolute imports for better code explicitness and maintainability.
Rationale
Per PEP8 Import section:
Absolute imports are recommended, as they are usually more readable and tend to be better behaved (or at least give better error messages)
While explicit relative imports are acceptable for complex package layouts, our projects don't have deeply nested modules that would necessitate this compromise.
Benefits
- IDEs and humans can easily catch and modify import paths when files are moved
- Linters can catch inconsistent ways of writing the same code
- Better error messages and more explicit code
Related
- PR: style(clp-package): Use absolute imports for all Python sources; Bump
yscope-dev-utilsto y-scope/yscope-dev-utils@307e711. clp#1640 - Requester: @junhaoliao"
Possible implementation
Update exports/lint-configs/python/ruff.toml to set:
[lint.flake8-tidy-imports]
# Disallow all relative imports.
ban-relative-imports = "all"Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request