python-trio / flake8-async

Highly opinionated linter for Trio code
https://flake8-async.readthedocs.io
MIT License
17 stars 2 forks source link

`trio200-blocking-calls =` is loaded but not parsed from a config file #84

Closed Zac-HD closed 1 year ago

Zac-HD commented 1 year ago

I get an error on line 1353 because it hasn't been parsed from list-of-strings into a dict:

https://github.com/Zac-HD/flake8-trio/blob/7cdd9180e3aefca89d1a58d197022f266b45868c/flake8_trio.py#L1350-L1356

I also started on a quick regression test, but don't have time to finish it right now: https://github.com/Zac-HD/flake8-trio/compare/config-error

jakkdl commented 1 year ago

I think the actual problem here is flake8's comma_separated_list .. apparently treating spaces as commas?

flake8 --no-checkpoint-warning-decorators="a b, c d" <file>
ipdb> self.options.no_checkpoint_warning_decorators
['a', 'b', 'c', 'd']

EDIT: No, I think that's a separate problem? Maybe.

jakkdl commented 1 year ago

New try: It looks like the action parameter to flake8.options.manager.OptionManager.add_option() is entirely ignored when parsing a config file. The supplied function is never called, and it's the same thing with ListOfIdentifiers for --startable-in-context-manager, invalid identifiers aren't flagged. Instead the values are just accepted straight up. Passing the same values at the command line works as expected.

Will delve more into flake8's internals to figure out what's going on, and probs open an issue over there. I'm opening a PR with a dirty workaround, travelling to family for holidays in the coming days so a more thorough exploration might be delayed.

(and then also fix spaces)

jakkdl commented 1 year ago

Opened https://github.com/PyCQA/flake8/issues/1770 and https://github.com/PyCQA/flake8/issues/1771

Zac-HD commented 1 year ago

Apparently we should just avoid action entirely and use type instead https://github.com/PyCQA/flake8/issues/1770#issuecomment-1358067558 🤷