Skip to content

Improve type annotations (drop python 2?) #117

@mfosterw

Description

@mfosterw

The collections in this package PatchSet and PatchedFile do not annotate the type of their elements, so iterating over them creates a variable of type Any. For my code, this means either not getting any type hints when working with those elements or manually annotating them when they are accessed (usually by putting a type definition right after the start of a loop).

for file in patchset: # type of 'file' is 'Any'
    file: PatchedFile # type is 'PatchedFile | Any'
    file = cast(PatchedFile, file) # type is 'PatchedFile'

It appears fixing this would require switching to Python 3 type annotations, rather than the current ones which are compatible with Python 2. What are your thoughts on dropping Python 2 support? I understand not wanting to stop supporting any versions, especially for a problem as simple as this one, but it seems to me the value of continuing to support Python 2 is very limited at this point, and continues to fall, and anyone still using it probably isn't updating their packages anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions