-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tidy First] Use
isort
to order/format/de-dupe python imports (#10085)
* Add `isort` as a dev-req and pre-commit hook The tool `isort` reorders imports to be in alphabetical order. I've added it because our imports in most files are in random order. The lack of order meant that: - sometimes the same module would be imported from twice - figuring out if a a module was already being imported from took longer In the next commit I'll actually run isort to order everything. The best part is that when developing, we don't have to put them in correct order. Though you can if you want. However, `isort` will take care of re-ordering things at commit time :) * Improve isort functionality by setting initial `.isort.cfg` Specifically we set two config values: `extend_skip_glob` and `known_first_party`. The `extend_skip_glob` extends the default skipped paths. The defaults can be seen here https://pycqa.github.io/isort/docs/configuration/options.html#skip. We are skipping third party stubs because these are more so provided (I believe). We are skipping `.github` and `scripts` as they feel out of scope and things we can be less strict with. The `known_first_party` setting makes it so that these imports get grouped separately from all other imports, which is useful visually of "this comes from us" vs "this comes from someone/somewhere else". * Add profile `black` to isort config I was seeing some odd behavior where running pre-commit, adding the modified files, and then running pre-commit again would result making more modifications to some of the same files. This felt odd. You shouldn't have to run pre-commit more multiple times for it to eventually come to a final "solution". I believe the problem was because we are using the tool `black` to format things, but weren't registering the black profile with `isort` this lead to some conflicting formatting rules, and the two tools had to negotiate a few times before being both satisfied. Registering the profile `black` with `isort` resolved this problem. * Reorder, merge-duplicate, and format module imports using `isort` This was done by running `pre-commit run --all`. I ran it separately from the commit process itself because I wanted to run it against all files instead of only changed files. Of note, this not only reordered and formatted our imports. But we also had 60 distinct duplicate module import paths across 50 files, which this took care of. When I say "distinct duplicate module import paths" I mean when `from x.y.z import` was imported more than once in a single file.
- Loading branch information
Showing
477 changed files
with
2,892 additions
and
2,941 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[settings] | ||
profile=black | ||
extend_skip_glob=.github/*,third-party-stubs/*,scripts/* | ||
known_first_party=dbt,dbt_adapters,dbt_common,dbt_extractor,dbt_semantic_interface |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 7 additions & 3 deletions
10
core/dbt/artifacts/resources/v1/semantic_layer_components.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.