Skip to content

Adjust urllib3.util.url #8460

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 3 commits into from
Aug 2, 2022
Merged

Conversation

gruebel
Copy link
Contributor

@gruebel gruebel commented Aug 1, 2022

Added the missing type hints in urllib3.util.url and changed the attributes of Url to reflect the actual attributes, which come from the subclassed namedtuple

@github-actions

This comment has been minimized.

Comment on lines 7 to 14
class Url:
slots: Any
auth: str | None
fragment: str | None
host: str | None
path: str | None
port: str | None
query: str | None
scheme: str | None
Copy link
Member

@AlexWaygood AlexWaygood Aug 2, 2022

Choose a reason for hiding this comment

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

At runtime, Url is a class that inherits from a NamedTuple that is also called Url. We can't mimic that in the stub exactly, but we can come pretty close by doing something like this:

class _UrlBase(NamedTuple):
    auth: str | None
    fragment: str | None
    host: str | None
    path: str | None
    port: str | None
    query: str | None
    scheme: str | None

class Url(_UrlBase):
    # rest of the class definition as it is in the stub already

(GitHub won't let me use the "suggested changes" feature here because this line range includes some deleted lines.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

very interesting, thanks for the suggestion 👍

@github-actions
Copy link
Contributor

github-actions bot commented Aug 2, 2022

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

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.

Thanks!

@AlexWaygood AlexWaygood merged commit 7148ee8 into python:master Aug 2, 2022
@gruebel gruebel deleted the adjust-urllib-url-attrs branch August 2, 2022 22:58
@gruebel
Copy link
Contributor Author

gruebel commented Aug 2, 2022

@AlexWaygood just out of curiosity, when do you decide to create and publish a new version of third party stubs?

@AlexWaygood
Copy link
Member

@AlexWaygood just out of curiosity, when do you decide to create and publish a new version of third party stubs?

The magic typeshed bots automatically create and publish the stubs packages. I think the workflow runs once every few hours, but I'm not sure :)

@gruebel
Copy link
Contributor Author

gruebel commented Aug 2, 2022

@AlexWaygood just out of curiosity, when do you decide to create and publish a new version of third party stubs?

The magic typeshed bots automatically create and publish the stubs packages. I think the workflow runs once every few hours, but I'm not sure :)

Nice, thanks! Looking forward to see the magic 😄

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