Conversation
4ad2104 to
e08ac2d
Compare
src/_pytest/main.py
Outdated
| _fixturemanager = None # type: FixtureManager | ||
|
|
||
| def __init__(self, config): | ||
| def __init__(self, config) -> None: |
There was a problem hiding this comment.
Out of curiosity, is considered good practice to annotate the return value of all functions even if they return None?
There was a problem hiding this comment.
It has to be for the function to be considered to be typed.
I've amended it to also type config (the arg) explicitly, although done via base class.
There was a problem hiding this comment.
I see, thanks makes sense, it is the only annotation.
Now it brings the next question, is:
def __init__(self, config: Config):enough for it to be considered typed?
There was a problem hiding this comment.
Yes (AFAIK), but might fail with strict options etc?! /cc @bluetech
There was a problem hiding this comment.
btw: reveal_type(var) is very useful in that regard.
Pulled out of pytest-dev#6491.
e08ac2d to
bd6ba3f
Compare
|
|
||
| # Keep track of any collected nodes in here, so we don't duplicate fixtures | ||
| self._node_cache = {} | ||
| self._node_cache = {} # type: Dict[str, List[Node]] |
There was a problem hiding this comment.
Apparently sometimes the key can be tuple so the type is not exactly correct:
Lines 574 to 579 in ad02f6f
I am working on some annotations and will include a fix for this, hopefully tomorrow.
Pulled out of #6491.