-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
Detect duplicate method names in CI #505
Comments
We can do something like this with Flake8's F811 check:
Currently detects 132 things: Details
|
Or the same thing using Ruff to check F811, which is quicker: Time to install and run pre-commit on CI: |
Going throught the list. I found several entries that are real problems (by "real problems" I mean: things that alter the runtime behavior in unexpected ways):
Plus, there are multiple imports that can be removed. I will send a PR for that later. |
Thanks for checking these. We should backport the test fixes to at least 3.11. And maybe for the security-only releases too? It's usually better to run tests than accidentally skip them :) |
I'd suggest that we only run pyflakes/the Ruff equivalent on
I looked at this a while back -- I think a common source of false positives was things like this in tests: def test_bad_class(self):
with self.assertRaises(TypeError):
class C(BadBaseClass): pass
with self.assertRaises(TypeError):
class C(OtherBadBadClass): pass # pyflakes reports redefinition of unused class "C" That kind of thing is trivial to resolve -- the second |
I think that our own
I can write a prototype by today's evening (right after my lecture today). |
I predict that at some point somebody will propose writing tests for the custom linter, at which point we'll be writing a test for the test testing the tests 😆 But, sounds good! |
Sometimes, when tests which were disabled for long time are enabled again, they start to fail randomly and need be fixed. I dislike the idea of enabling in stable branches. |
I slightly prefer using an existing linter (if suitable) than a custom one:
Although potentially they might not run on pre-release Python code that is under development, like failing to parse new syntax. |
I remembered that @vstinner already had a prototype, so here's mine based on python/cpython#105560 (comment) Code: https://gist.github.com/sobolevn/967ac61b8b2575e26a33f5a6bf5df201 Output:
Cases listed in |
For tests specifically, couldn't a |
@gpshead technically, we can. It might break some 3rd party But, |
@gpshead: i wrote python/cpython#105560 metaclass to detect duplicates. |
Please see python/cpython#109161 to check for F811 with Ruff via pre-commit. |
Originally posted by @vstinner in python/cpython#105560 (comment)
The text was updated successfully, but these errors were encountered: