-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Limit isort.lines-after-imports
to 1 for stub files
#9971
Conversation
7336890
to
d00bb85
Compare
|
d00bb85
to
91222f5
Compare
To confirm my understanding: if a project today doesn't set |
Is this a very friendly hint that my implementation is wrong because it is wrong ;) It uses -1 which uses 2 empty lines if the following statement is a class or function. I have to add a test and fix the implementation. |
91222f5
to
51d4857
Compare
I think I know understand why you asked this question... Yes, the change isn't just a breaking change when using I think that's reason enough for us to wait with merging until 0.3 |
I asked because my guess was that it wasn't a breaking change for files that don't set |
Summary
Setting the
isort.lines-after-imports
setting to a value larger than 1 leads to formatter incompatibilities when formatting typing stub files becausethe formatter enforces at most one blank line for stub files according to typeshed's style guide.
This PR changes our
isort
implementation to limitlines-after-imports
to 1 for stub files the same as isort does for black (commit, code).Fixes #9353
Breaking Change?
This is a breaking change and we may need to wait for 0.3 to merge. The only "excuse" not to consider this a breaking change is that we say our
isort
configuration is intended to be black/ruff formatter compatible by default (isort
profile black). In this case, this is a bug fix.I did a code search on GitHub for
lines-after-imports=2
(I didn't find any usages with values > 2). Most repositories don't havepyi
files and are unaffected by the change. The following repositories contain pyi files and uselines-after-imports=2
lines-after-imports
setting was removed upstream in feat: support traffic.max_concurrency for api server and runner bentoml/BentoML#3864 -> No longer an issuepyi
files are empty__init__.pyi
files (contain no imports)__init__.pyi
files that contain imports. They added two blank lines when migrating to ruff ;( sdss/lvmgort@ca8206aFrom that it seems safe to conclude that using
lines-after-imports=2
with typing files isn't common, but at least two projects would see new errors after upgrading.Test Plan
Added test