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

Remove convenience type aliases #80

Merged
merged 1 commit into from
Jun 8, 2023
Merged

Remove convenience type aliases #80

merged 1 commit into from
Jun 8, 2023

Conversation

samueljsb
Copy link
Contributor

@samueljsb samueljsb commented Jun 8, 2023

Prior to this change, these aliases are sometimes used by users to
construct date/datetime objects, with the appearance that they are
constructing a timezone aware object. However, this is not the case,
since they are just aliases for the stdlib:

>>> my_datetime = localtime.DateTime(2023, 6, 8, 11, 32)
>>> my_datetime
datetime.datetime(2023, 6, 8, 11, 32)
>>> repr(my_datetime.tzinfo)
'None'

This change removes these type aliases. This makes the module more
consistent (the stdlib imports were used for some type annotations) and
removes this footgun.

Prior to this change, these aliases are sometimes used by users to
construct date/datetime objects, with the appearance that they are
constructing a timezone aware object. However, this is not the case,
since they are just aliases for the stdlib:

    >>> my_datetime = localtime.DateTime(2023, 6, 8, 11, 32)
    >>> my_datetime
    datetime.datetime(2023, 6, 8, 11, 32)
    >>> repr(my_datetime.tzinfo)
    'None'

This change removes these type aliases. This makes the module more
consistent (the stdlib imports were used for some type annotations) and
removes this footgun.
@samueljsb samueljsb requested a review from a team June 8, 2023 08:46
Copy link
Contributor

@pydanny pydanny left a comment

Choose a reason for hiding this comment

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

I was always weirded out by this segment, just couldn't articulate my complaint. Thanks Sam for doing things the right way. 👍🏻

@samueljsb samueljsb merged commit b809a5e into main Jun 8, 2023
@samueljsb samueljsb deleted the remove-type-aliases branch June 8, 2023 12:40
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