-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
isortRelated to import sortingRelated to import sortingquestionAsking for support or clarificationAsking for support or clarificationuvIncompatibility between Ruff and uvIncompatibility between Ruff and uv
Description
Summary
First party package is not identified as such when sorting imports if it has dashes in the name and the code is parallel to the actual package folder which has an underscore in the name. For instance, on tests files.
(unsure if by design or a bug)
Context
- I am using uv workspaces.
- Some of the packages have dashes in their names.
- I am using ruff for sorting imports
- A minimal folder structure
packages/
├── pyproject.toml
└── example-package/
├── src/
│ └── example_package/
│ ├── __init__.py
│ └── dummy.py
├── tests/
│ └── test_dummy.py
└── pyproject.toml
pyproject.toml
[project]
name = "tmp-iywsagbejg"
version = "0.1.0"
requires-python = ">=3.13"
dependencies = [
"example_package",
]
[tool.uv.workspace]
members = ["packages/*"]
[tool.uv.sources]
example_package = { workspace = true }
[tool.ruff]
lint.select = ["I"]example-package/pyproject.toml
[project]
name = "example-package"
version = "0.1.0"
description = "Example package"
dependencies = [
"requests",
]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"dummy.py
import requests
import example_package
def myfun():
example_package.main()
print(requests.__version__)
return 42test_dummy.py
import example_package
import requests
def test_myfun():
print(example_package.dummy.myfun(), requests.__version__)
Expected
When I run:
vx ruff check --fix .I would expect that example-package is always identified as first party when sorting imports and so order of imports is consistent.
Actual behavior
It is only detected as first party if inside a folder with underscores and not dashes in the name. Thus, for tests (if I want them to live outside the src folder) the imports are sorted differently. (see example files above)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
isortRelated to import sortingRelated to import sortingquestionAsking for support or clarificationAsking for support or clarificationuvIncompatibility between Ruff and uvIncompatibility between Ruff and uv