-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ruff linter: Unexcluded _sync
folders, Used default line-length
#887
base: master
Are you sure you want to change the base?
Conversation
|
||
[tool.ruff.lint.per-file-ignores] | ||
# needed for unasync.py | ||
"httpcore/_sync/*" = ["I001"] | ||
"tests/_sync/*" = ["I001"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If remove this section, result will be:
>ruff check
httpcore\_sync\connection.py:1:1: I001 [*] Import block is un-sorted or un-formatted
httpcore\_sync\connection_pool.py:1:1: I001 [*] Import block is un-sorted or un-formatted
httpcore\_sync\socks_proxy.py:1:1: I001 [*] Import block is un-sorted or un-formatted
tests\_sync\test_connection.py:1:1: I001 [*] Import block is un-sorted or un-formatted
tests\_sync\test_connection_pool.py:1:1: I001 [*] Import block is un-sorted or un-formatted
Found 5 errors.
[*] 5 fixable with the `--fix` option.
Maybe we also could use in-file rule ignore for them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to avoid excluding sync directories? When we need to format/lint them? they are auto generated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are pre-generated. it means currently, they are already available in sdist, wheels and repository.
It doesn't look good that readers navigate through unformatted sources after installation.
For example, after installation, I'll navigate to site-packages/httpcore
then in _sync
folder's contents I open a single file, then I'll see linter/formatter warnings in my IDE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When it's possible to have them, why excluding them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll navigate to site-packages/httpcore then in _sync folder's contents I open a single file, then I'll see linter/formatter warnings in my IDE.
I believe it is typical to see such situations because IDE rules and rules used for linting source files are not always in sync.
When it's possible to have them, why excluding them?
We can, for the time being, ignore I001 for those files, but we don't know how many additional rules may be broken when introducing a new feature. We need add new rules that break sync files into the configuration every time, which makes the maintenance process more difficult.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't know how many additional rules may be broken when introducing a new feature. We need add new rules that break sync files into the configuration every time, which makes the maintenance process more difficult.
The codebase is almost stable, I think the only violation rule would be import sorting violation. by checking unasync.py
script I don't except new violation happening when adding new feature other than I001 (and F811 which can be in-line ignoring this without changing pyproject.toml
)
IMO, we could give it a try, since always doable in future to revert this change.
_sync
folders, Used default line-length
Summary
Same as what's done on httpx: encode/httpx#2922
Checklist