Skip to content

Add types for zxcvbn #8089

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

Merged
merged 7 commits into from
Jun 21, 2022
Merged

Add types for zxcvbn #8089

merged 7 commits into from
Jun 21, 2022

Conversation

srittau
Copy link
Collaborator

@srittau srittau commented Jun 16, 2022

No description provided.

@github-actions

This comment has been minimized.

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Mostly looks good, but I'm not sure about the huge _Match TypedDict in matching.pyi. It seems like we could probably have a smaller base TypedDict, and return subtypes of that TypedDict from specific functions where _Match always has certain other keys.

@srittau
Copy link
Collaborator Author

srittau commented Jun 18, 2022

Mostly looks good, but I'm not sure about the huge _Match TypedDict in matching.pyi. It seems like we could probably have a smaller base TypedDict, and return subtypes of that TypedDict from specific functions where _Match always has certain other keys.

Basically everything except the zxcvbn() function in __init__.py is internal API anyway, so I wouldn't want to put the work in for a finer-grained API.

srittau added 2 commits June 18, 2022 16:46
Theorically, this supports more types, but I don't think that's important here.
@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@srittau
Copy link
Collaborator Author

srittau commented Jun 20, 2022

Ideally we'd be able to return DateMatch | DictionaryMatch | ..., but I don't think type checkers support discriminating result by typed dict field (pattern in this case).

@github-actions

This comment has been minimized.

@AlexWaygood
Copy link
Member

What do you want to do here?

  1. Wait until pyre/pytype have PEP 655 support?
  2. Rewrite the PR to use TypedDict inheritance for now?
  3. YOLO it and go with PEP 655 even though pytype/pyre don't fully support it yet?

@srittau
Copy link
Collaborator Author

srittau commented Jun 20, 2022

I honestly think, we could just merge it. pytype should just assume Any if I understand pytype's type handling correctly. We can wait for pyre support, but on the other hand this is a new package, so it not working for a few weeks is not a regression.

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

A few small comments

@github-actions

This comment has been minimized.

1 similar comment
@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@JelleZijlstra JelleZijlstra merged commit 678c231 into python:master Jun 21, 2022
@srittau srittau deleted the zxcvbn branch June 21, 2022 11:36
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.

3 participants