-
Notifications
You must be signed in to change notification settings - Fork 6
feat: type annotations #28
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, although @bbayles probably has more knowledge on this than me.
ada_url/ada_adapter.py
Outdated
@@ -290,7 +320,9 @@ def normalize_url(s): | |||
return parse_url(s, attributes=('href',))['href'] | |||
|
|||
|
|||
def parse_url(s, attributes=PARSE_ATTRIBUTES): | |||
# FIXME constrain `attributes`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# FIXME constrain `attributes`` | |
# FIXME constrain `attributes` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here - the docstring says unrecognized requests are ignored; we need not constrain with the type if we preserve that behavior.
ada_url/ada_adapter.py
Outdated
@@ -354,7 +386,8 @@ def parse_url(s, attributes=PARSE_ATTRIBUTES): | |||
return ret | |||
|
|||
|
|||
def replace_url(s, **kwargs): | |||
# FIXME constrain key of `**kwargs` by `URL_ATTRIBUTES` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring says that unknown keys are ignored; I'd like to preserve this behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, but typing isn't just about error checking; constraints make auto suggestions work better.
If you insist, I'll just delete the comment; or I'll use Union[Literal["href"], ...]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove the comments and create a GitHub issue to help make auto suggestions (what editor?) better.
Is it ready to merge? |
I'd like to add tests of the annotations with mypy, but we can do that in another PR. |
🚀 |
Fix #27