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

Make datetime.tzinfo non-optional for TZAware #233

Merged
merged 2 commits into from
Sep 24, 2022

Conversation

antonagestam
Copy link
Owner

@antonagestam antonagestam commented Sep 24, 2022

This PR makes it so that accessing .tzinfo on a datetime.datetime object that has been narrowed to TZAware has the type datetime.tzinfo instead of datetime.tzinfo | None. This is safe because this check is already part of the predicate, ie by definition of isinstance(_, TZAware).

It also addresses #84 for TZAware and TZNaive, by checking that accessing an attribute from datetime.datetime does not raise a static type checking error.

@codecov-commenter
Copy link

codecov-commenter commented Sep 24, 2022

Codecov Report

Merging #233 (e160e7d) into main (0cadc67) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main      #233   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           24        24           
  Lines          820       821    +1     
  Branches       172       172           
=========================================
+ Hits           820       821    +1     
Impacted Files Coverage Δ
src/phantom/datetime.py 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@antonagestam antonagestam marked this pull request as ready for review September 24, 2022 10:29
@antonagestam antonagestam merged commit 1eee5f3 into main Sep 24, 2022
@antonagestam antonagestam deleted the feature/non-optional-tzinfo branch September 24, 2022 10:33
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.

None yet

2 participants