Skip to content

fix(types): a few updates to typing#111

Open
henryiii wants to merge 1 commit intocpburnz:masterfrom
henryiii:henryiii/fix/types1
Open

fix(types): a few updates to typing#111
henryiii wants to merge 1 commit intocpburnz:masterfrom
henryiii:henryiii/fix/types1

Conversation

@henryiii
Copy link
Contributor

@henryiii henryiii commented Mar 6, 2026

Just a few quick updates from running mypy. The biggest one is + currently assumes you can add the Sequence's, which is not true for arbitrary Sequence.

Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
"""

def __add__(self: Self, other: PathSpec) -> Self:
def __add__(self: Self, other: object) -> Self:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's best to keep other: PathSpec.

If it's changed to other: object, then PyCharm will no longer flag:

spec2 = spec + 123  # Expected type 'PathSpec', got 'int' instead 

Does mypy complain about other not being hinted as object?

return NotImplemented

def __iadd__(self: Self, other: PathSpec) -> Self:
def __iadd__(self: Self, other: object) -> Self:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's best to keep other: PathSpec.

Unfortunately PyCharm does not flag this as an error even though type-wise it's wrong:

spec += 123

Does mypy complain about other not being hinted as object?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants