Skip to content

Conversation

@jkklapp
Copy link
Contributor

@jkklapp jkklapp commented Apr 5, 2021

Closes #1384

@felix-hilden
Copy link
Contributor

Nice! Two thoughts based on the original issue:

  • perhaps the new default should be imported all the way up to the top level for it to be considered public
  • as this parameter is to replace UNSET, maybe the kwargs approach could also be introduced to the remaining cases and UNSET be removed altogether (assuming you'd like to deal with the whole issue at once, otherwise "closes 1384" doesn't entirely apply)

I see that beyond a couple of thumbs up, an explicit consensus was not necessarily reached in the original issue. But I agree that this is a sensible way of doing it. What do the maintainers think?

Copy link
Contributor

@lovelydinosaur lovelydinosaur left a comment

Choose a reason for hiding this comment

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

Okay, so the one remaining issue with this is the places in the Timeout class, where USE_CLIENT_DEFAULT is being used. In that context it doesn't actually make sense, because that's not what it's doing there.

For the purposes of this pull request I'd suggest we probably want to keep UnsetType/UNSET, and continue to use them for the Timeout cases without any change. (While also adding the ClientDefaultType/USE_CLIENT_DEFAULT as done here.)

auth: typing.Union[AuthTypes, UnsetType] = UNSET,
auth: typing.Union[AuthTypes, ClientDefaultType] = USE_CLIENT_DEFAULT,
allow_redirects: bool = True,
timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,
Copy link
Contributor

Choose a reason for hiding this comment

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

So, these cases in _client.py should be:

    timeout: typing.Union[TimeoutTypes, ClientDefaultType] = USE_CLIENT_DEFAULT,

(But the signature of the arguments in the Timeout class should keep using UNSET)

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually thinking about this, it's probably also a good idea to move ClientDefaultType and USE_CLIENT_DEFAULT out of _types.py, and into this module, to keep them close to where they're actually used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, these cases in _client.py should be:

    timeout: typing.Union[TimeoutTypes, ClientDefaultType] = USE_CLIENT_DEFAULT,

(But the signature of the arguments in the Timeout class should keep using UNSET)

If I do that I need to also change the the types in the Timeout class, otherwise mypy complains.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, I'll take a look.

@jkklapp jkklapp force-pushed the use_better_variable_name_in_default_param branch from 947cc68 to c97e220 Compare April 24, 2021 18:01
@lovelydinosaur
Copy link
Contributor

Closed via #1634 - Thanks for taking a punt at this!

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.

Reconsider UNSET?

3 participants