Skip to content

"already defined" errors when adding type annotations in multiple code paths #1191

Closed
@timabbott

Description

@timabbott

While trying to debug something, I ended up adding type annotations for the definitions of an object in both code paths, and got a /home/tabbott/foo.py:10: error: Name 'child_pid' already defined with this (simplified) code:

if True:
    child_pid = os.fork() # type: int
    # Do stuff
else:
    child_pid = None # type: int

Since the types are the same, it seems like this shouldn't be an error.

This may be a variant of #1153.

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