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

Now able to run as a standalone module or shell program, with limited functionality #146

Merged
merged 1 commit into from
Mar 4, 2023

Conversation

jakkdl
Copy link
Member

@jakkdl jakkdl commented Mar 2, 2023

First steps towards having it run as a standalone program, which is required for autofixing.

  • takes basic structure from shed, copying _get_git_repo_root.
  • Add some magic to get argparsing to work both as standalone and as a plugin
  • add flake8_trio/__main__ to run as a module, and a console_scripts entry point
  • moved out config testing from test_flake8_trio, and added a couple tests to test the above
    • crossing my fingers that git tests will magically work in the CI environment as well

Also:

  • Remove flake8-bandit - running git directly is .. kinda sus https://flake8.codes/S607/ ; but if shed does it I'm not gonna bother, and I'm very much just disabling ~all errors bandit throws, so it's not really contributing anything.
  • reportUnusedCallResult is frustrating, byebye~

Remaining steps:

  • Color support - I was most of the way to replicating flake8's color printing, but once it got into testing/coverage and windows support I abandoned it and threw it out. For a later PR, if ever.
  • Disable visitors with other ways than --enable-visitor-codes-regex
  • pre-commit support
  • read config
    added these to OP in Switch backend to libCST #124

Copy link
Member

@Zac-HD Zac-HD left a comment

Choose a reason for hiding this comment

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

Merging this as the only comments here are tiny nitpicks and I'm really excited to see where it's going 🎉

Comment on lines +89 to +90
# TODO: go through subdirectories if directory/ies specified
all_filenames = args.files
Copy link
Member

Choose a reason for hiding this comment

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

🤷‍♂️, I'm pretty happy to say that you have to pass exact files if you're passing files.

Copy link
Member Author

Choose a reason for hiding this comment

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

I figured, since that's how shed does it, but I would like to support as much of flake8's functionality as possible to ease any transition from running [name of this project] as a flake8 plugin to running it standalone. Ofc flake8 is kinda crazy so I won't bother supporting everything (e.g. --extend-ignore, --ignore, --select, --extend-select I think kinda just makes everything more complicated), but I think supporting directories shouldn't be very complicated and doesn't have much downsides.

Comment on lines +109 to +112
for file in all_filenames:
plugin = Plugin.from_filename(file)
for error in sorted(plugin.run()):
print(f"{file}:{error}")
Copy link
Member

Choose a reason for hiding this comment

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

A small ProcessPoolExecutor invocation here can make it n_cores times faster for large repos... although we'd still want to sort by file and lineno. Let's do that later.

flake8_trio/__init__.py Show resolved Hide resolved
@Zac-HD Zac-HD merged commit 0f41c5e into python-trio:main Mar 4, 2023
@jakkdl jakkdl deleted the autofix branch March 6, 2023 11:43
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