"Signature of a method incompatible with supertype" vs pytest fixtures #10074
Unanswered
serhiy-storchaka
asked this question in
General
Replies: 1 comment 5 replies
-
This doesn't seem like something pytest can do anything about. Maybe it should be a discussion rather than an issue? I've seen this message being disputed for other reasons too: Note that mypy supports adding error codes to type ignores. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I don't know whether it is idiomatic or not, but I use the following approach to parametrize
pytest
tests. Tests are defined as method in a class. Parameters are defined as fixtures in a class. Fixtures are overridden in subclasses to run tests with different parameters.For example:
TestA.test_foo
andTestB.test_foo
are executed with different values offoo
. The problem is that fixtures can depend on other fixtures, and signatures for methods defining fixture can be different. MyPy complains:It is not real error in the user code that the methods have different signatures. These methods are not called directly. They are called by pytest which provides all arguments.
I can add "# type: ignore", but I do not want to lose static type checking completely. It is useful to check that the type of the parameter matches the returning type of corresponding fixture function.
mypy 0.961 (compiled: yes)
pytest 7.1.2
Python 3.9.13
Beta Was this translation helpful? Give feedback.
All reactions