Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typehints are inconsistent and/or incomplete #192

Closed
kuwv opened this issue Apr 30, 2024 · 1 comment · Fixed by #198
Closed

Typehints are inconsistent and/or incomplete #192

kuwv opened this issue Apr 30, 2024 · 1 comment · Fixed by #198
Assignees

Comments

@kuwv
Copy link

kuwv commented Apr 30, 2024

Some typehints within dpath are not denoted as Optional even though they are defaulted to None. This causes incorrect handling on consuming side of the API.

Argument "afilter" to "merge" has incompatible type "None"; expected "Callable[[Any], bool]"  [arg-type]
@moomoohk
Copy link
Collaborator

Hi,
This is probably due to an update to PEP484 that I hadn't noticed:

A past version of this PEP allowed type checkers to assume an optional type when the default value is None, as in this code:

def handle_employee(e: Employee = None): ...
This would have been treated as equivalent to:

def handle_employee(e: Optional[Employee] = None) -> None: ...
This is no longer the recommended behavior. Type checkers should move towards requiring the optional type to be made explicit.

Thanks for bringing this to my attention.

@moomoohk moomoohk self-assigned this Jun 12, 2024
@moomoohk moomoohk linked a pull request Jun 12, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants