Add type annotations to _pytest.config.argparsing and corresponding Config code#6241
Conversation
This feature was added in commit 007a77c, but was never used in pytest itself. A GitHub code search doesn't find any users either (only pytest repo copies). It seems safe to clean up.
| return group | ||
|
|
||
| def addoption(self, *opts, **attrs): | ||
| def addoption(self, *opts: str, **attrs: Any) -> None: |
There was a problem hiding this comment.
Would be great if attrs could be typed. Would be the same as with Argument.__init__'s attrs then.
There was a problem hiding this comment.
Yeah, TypeScript has this feature, but mypy doesn't AFAIK. The other option is to duplicate, but I wouldn't want to do that.
There was a problem hiding this comment.
Could a typevar be used here, to be used in those (3+) places?
But this could also be done later anyway - I've just thought it would be really helpful with completion of those functions.
(You have probably noticed also that documentation in this regard is outdated etc, and it's messy in general, so that would help there.)
There was a problem hiding this comment.
Could a typevar be used here, to be used in those (3+) places?
Not that I know of...
e3e2333 to
b6682c8
Compare
b6682c8 to
dac16cd
Compare
|
@blueyed I missed a couple of places that can take a |
How does that behave by now? IIRC it's handled as I think it makes sense therefore to type |
It's still
That would be good, it does show up everywhere in pytest. I'm not entirely sure we should add it in pytest - what would happen when we finally publish our types and a user encounters |
The first commit cleans up some old feature that slightly interfered with the types. The second commit adds annotations to the argument parsing code.