bskinn / flake8-bot

Bot to automatically generate and maintain various lists of flake8 plugin entry points, and to tweet new/updated packages to @Flake8Plugins
https://twitter.com/Flake8Plugins
MIT License
7 stars 0 forks source link

Not all packages with extensions are recognized #22

Open GideonBear opened 1 year ago

GideonBear commented 1 year ago

I found at least 9 packages in f8.list that register an extension, but are not listed in ec_sort.md or bad_errorcodes.md. They are: flake8-docstrings-catnado: https://github.com/tylertrussell/flake8-docstrings-catnado/blob/76a9e202a93c8dfb11994c95911487b3722d75c9/setup.py flake8-cohesion: https://github.com/sasanjac/flake8-cohesion/blob/0927f1d005186006fe7839a02977f62464517e8e/pyproject.toml flake8-errmsg: https://github.com/henryiii/flake8-errmsg/blob/400ea1ee53ef6eb0dc5a6179ffbad33cb52c23ea/pyproject.toml flake8-noreturn: https://github.com/izikeros/flake8-noreturn/blob/f101ff38bcfcbac2d1792dd6bb50dd5961c53b0e/pyproject.toml flake8-airflow: https://github.com/bradleybonitatibus/flake8-airflow/blob/cae970cb14395e8fb8e9124862264cdce4e20241/setup.cfg flake8-assert-check: https://gist.github.com/GideonBear/96cedf735c98ea77e8ab3703f3ecde11 flake8-cgx: https://gist.github.com/GideonBear/1392f8326453ef8a27ffc9f114cc3258

Thanks for this repo!

GideonBear commented 1 year ago

How are you finding the entry points from the packages?

GideonBear commented 1 year ago

I found all of them: flake8-qchecker: https://github.com/James-Ansley/flake8-qchecker/blob/7876205df89eb016fa17a4173d80ebc112d059bf/setup.cfg flake8-obey-import-goat: https://github.com/Melevir/flake8-obey-import-goat/blob/f33370ec4367b227463d6f4a0469f623eeeede2d/setup.py flake8-match: https://github.com/asottile/flake8-match/blob/0693036af1202318107381b8d1fd7952e1f92540/setup.cfg flake8-num-positional-args: https://gist.github.com/GideonBear/7fc1d5894c9b8588c8269d2ad8eebb02

bskinn commented 1 year ago

How are you finding the entry points from the packages?

Brute force. I install them no-deps one-by-one into the CI environment, inspect/extract any new entry points that show up, then uninstall before moving on to the next.

Impressive that they can install extensions in a way that's invisible to that approach.

Thanks for the report, I'll take a look!

GideonBear commented 1 year ago

Brute force. I install them no-deps one-by-one into the CI environment, inspect/extract any new entry points that show up, then uninstall before moving on to the next.

Ah, so you're relying on importlib.metadata? Maybe this is a bug there then... I haven't actually checked if the extensions work, but I'm assuming they do (otherwise the plugins are completely useless).

GideonBear commented 1 year ago

ilmd.entry_points().get('flake8.extension') is working for me: EntryPoint(name='Q', value='flake8_qchecker:Plugin', group='flake8.extension') There is a deprecation warning though: <stdin>:1: DeprecationWarning: SelectableGroups dict interface is deprecated. Use select.

bskinn commented 1 year ago

Ok, thanks for your work digging into this. I'll take a look when I have a chance & try to get this working correctly.

Very likely this is due to me using some old interface here -- I really need to freshen the whole thing...it's still on Python 3.8!

GideonBear commented 1 year ago

flake8-unused-globals was recently added to f8.list, but not to the .md files. Seems like this is a pretty common problem...

bskinn commented 1 year ago

I might need to completely reevaluate the approach and re-implement. E.g., there's something odd afoot around part of #23, too.

GideonBear commented 1 year ago

@bskinn I would be glad to help if needed.

bskinn commented 1 year ago

Much appreciated, @GideonBear, thanks!

I implemented the thing in a more-complex-than-is-ideal way with regard to passing the historical data along from run-to-run of the CI, so it's going to be somewhat tricky to do the surgery needed to upgrade. I'm going to have to get deeply back into the code to remember exactly how it all lies together; at that point, I'll reach out if I can use a hand on the implementation.

For now, I think the best thing you can do is to document what the best approach is that you can find for correctly filtering packages that show up in the simple API into either "yes, report this" or "no, don't report this" categories. Also looping the needs of #23 into this would be terrific.

GideonBear commented 1 year ago

Deleted packages on the JSON API give the same response as non-existent packages, while the simple API responds with an empty list of links. I think it's better to use the JSON API than the simple API, as it was made to replace the simple API. An alternative is to use the RSS feed to only get the data we want. I don't use RSS often, so I don't know exactly how to set that up, but it might be even better:

For periodically checking for new packages or updates to existing packages, use our RSS feeds.

We could query it for new updates (which includes new packages (with at least one release)) and removals, filter them to contain flake(8), extract the entry points from updated packages, and replace the old entry points of that package.

I cannot find anywhere how to get older items on (PyPI) RSS though, so it might be impossible.

bskinn commented 1 year ago

I cannot find anywhere how to get older items on (PyPI) RSS though, so it might be impossible.

Yeah, IIRC that was the problem I had with trying to use the RSS feed to supply the inputs for the bot here---I had no way to guarantee I would be able to query the RSS quickly enough to be sure it didn't miss anything.

I agree, the new JSON API likely is a better option, I'll look into doing it that way.

GideonBear commented 1 year ago

pypi-simple (an API wrapper for the PyPI API) might also be useful.