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-importssetting 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
isortimplementation to limitlines-after-importsto 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
isortconfiguration is intended to be black/ruff formatter compatible by default (isortprofile 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 havepyifiles and are unaffected by the change. The following repositories contain pyi files and uselines-after-imports=2lines-after-importssetting was removed upstream in feat: support traffic.max_concurrency for api server and runner bentoml/BentoML#3864 -> No longer an issuepyifiles are empty__init__.pyifiles (contain no imports)__init__.pyifiles 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=2with typing files isn't common, but at least two projects would see new errors after upgrading.Test Plan
Added test