Update type hints of PEP440Version class#270
Conversation
|
Kudos, SonarCloud Quality Gate passed!
|
|
this seems slightly surprising to me. I guess i've not seen this construction before. I would have expected to add typing appropriate to the derived classes by specialising the derived class signatures, not the base class signatures. adding type annotations to |
|
Pretty annoying to have to implement derived methods just for the sake of the typing, though? The link is hidden in a now-resolved thread but https://mypy.readthedocs.io/en/stable/generics.html#generic-methods-and-generic-self shows more or less exactly this, albeit with a warning that this is 'experimental' meaning that mypy might say wrong things. |
absolutely. I don't have any particular issue with this, just not something i've seen in the wild. |
|
@danieleades A |








This change allows Mypy to infer that methods like
parse()orreplace()on a subclass ofPEP440Versionreturn the same type and not falling back to thePEP440Versionbase type.Example:
Note that poetry-core can only be used with Mypy after merging #269 anyway.