Skip to content
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

Enforce import sorting #608

Merged
merged 7 commits into from
Oct 15, 2024
Merged

Enforce import sorting #608

merged 7 commits into from
Oct 15, 2024

Conversation

ff137
Copy link
Contributor

@ff137 ff137 commented Sep 20, 2024

Noticed that pyproject.toml configures isort. But, imports weren't sorted.

So, just runs isort (ensuring the config is used), and ran autoflake --remove-all-unused-imports for good measure. Just some artsy cleanup.

Edit: and adds isort check to cicd

@caspervonb
Copy link
Collaborator

caspervonb commented Sep 24, 2024

Just a note to self: we should run these as part of CI to ensure there's no drift (#568).

Copy link
Collaborator

@caspervonb caspervonb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@caspervonb caspervonb changed the title 🎨 clean up imports Sort and remove unused imports Sep 24, 2024
@ff137 ff137 force-pushed the art/imports branch 2 times, most recently from c6ff2c5 to 27dfe05 Compare September 24, 2024 20:24
@ff137 ff137 mentioned this pull request Sep 24, 2024
@ff137
Copy link
Contributor Author

ff137 commented Sep 24, 2024

@caspervonb I've rebased 👌

I also tried adding an isort check to the cicd.
For that, I need to add isort as a dev dependency to the Pipfile.
And, define a .isort.cfg file which includes the pyproject.toml [tool.isort] settings, because they weren't being picked up.
With this, I could get the isort check to pass in CICD.

But, I had to update the lock file. And it looks like it hasn't updated in quite a while (lots of version bumps), and some tests seem to be failing as a result. So ... it's a bit too much to try squeeze in to this PR, so I'll make a separate one for that: #611

The lockfile update and test fix should probably be done separately. I'll see if I can take a quick crack at it

Edit: or, it looks like something else went wrong, causing the new tests to fail. First thought it was the lockfile update

@ff137
Copy link
Contributor Author

ff137 commented Sep 24, 2024

Oops. autoflake removed the aiohttp import in test_client_websocket.py:

try:
    import aiohttp
    aiohttp_installed = True
except ModuleNotFoundError:
    aiohttp_installed = False

which broke one of the tests. My bad, missed that

@caspervonb
Copy link
Collaborator

I'm going to go ahead and merge this today but before I do I'll add a check to GitHub workflows, otherwise it's a shifting target.

@ff137
Copy link
Contributor Author

ff137 commented Sep 30, 2024

@caspervonb I already took a crack at it: #611

@caspervonb
Copy link
Collaborator

I ran yapf on everything and caused some conflicts, apologies.

@ff137
Copy link
Contributor Author

ff137 commented Oct 1, 2024

rebased 👌

@ff137 ff137 changed the title Sort and remove unused imports Enforce import sorting Oct 1, 2024
@ff137
Copy link
Contributor Author

ff137 commented Oct 1, 2024

@caspervonb I cherry-picked the commits from #611 here, and moved the cicd check to the new check.yaml

@caspervonb
Copy link
Collaborator

Thank you, on the list for today.

@caspervonb
Copy link
Collaborator

I've been thinking of replacing isort with ruff, as it'll serve as a replacement for flake, isort and yapf. But I'm okay with merging this in the meantime.

@caspervonb caspervonb merged commit 3aa879e into nats-io:main Oct 15, 2024
7 checks passed
@ff137
Copy link
Contributor Author

ff137 commented Oct 15, 2024

I've been thinking of replacing isort with ruff, as it'll serve as a replacement for flake, isort and yapf. But I'm okay with merging this in the meantime.

Good stuff, I actually wanted to recommend ruff instead of isort/pyflake/yapf, but didn't want to impose 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants