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

Address some mypy type hinting issues #2314

Merged
merged 17 commits into from
Jun 30, 2024

Conversation

AitElBadaoui
Copy link
Contributor

@AitElBadaoui AitElBadaoui commented Jun 30, 2024

Summary of Changes

This merge request addresses some of the type hinting issues identified by MyPy.
Ref: #782.

Requirements

Notes

@buildbot-princeton
Copy link
Collaborator

Can one of the admins verify this patch?

Copy link

codecov bot commented Jun 30, 2024

Codecov Report

Attention: Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 99.06%. Comparing base (afde9a8) to head (0240058).

Files Patch % Lines
src/quacc/recipes/gulp/_base.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2314      +/-   ##
==========================================
- Coverage   99.08%   99.06%   -0.03%     
==========================================
  Files          84       84              
  Lines        3515     3519       +4     
==========================================
+ Hits         3483     3486       +3     
- Misses         32       33       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@AitElBadaoui AitElBadaoui marked this pull request as draft June 30, 2024 11:07
@AitElBadaoui
Copy link
Contributor Author

AitElBadaoui commented Jun 30, 2024

Hello @Andrew-S-Rosen
The missing line in the coverage is because none of the jobs call the run_and_summarize function with a None value in option_defaults. I'm not sure if it's worth it to mock a job just to cover this one line of code. Please let me know what you think.

To resolve the remaining MyPy issues, I need to understand the objective of this MR: #1903. The changes introduced have led to multiple MyPy errors due to assigning tuples as default values to variables of different data types. Is _DEFAULT_SETTING meant to always be empty ?

Thank you !

@AitElBadaoui AitElBadaoui marked this pull request as ready for review June 30, 2024 11:20
@Andrew-S-Rosen
Copy link
Member

Hi @AitElBadaoui! Thank you so much for putting together this PR. I really appreciate it!! These all look like great changes and, in fact, may even reduce some bugs.

As for the test coverage, don't worry about it for this PR. No need to worry about test coverage for type hinting changes here.

As for PR #1903, I can see how that might introduce some problems in hindsight. The reasoning behind the PR was that I thought _DEFAULT_SETTING (rather than None) would make it clearer to the end-user that a default setting was being used (quacc has a set of default settings it imports at runtime). However, I see the problem with the type hinting. I chose to use () as a placeholder because () was simple and immutable. I also thought this approach would be nice because then None could actually mean something distinct from using the defaults. But the problem is that something like qchem_cmd: str = _DEFAULT_SETTING is clearly going to be flagged as a problem by mypy since _DEFAULT_SETTING is a tuple (even though the actual setting being used at runtime is indeed a str).

I guess since the type hint is now "wrong", would you recommend that I switch back to None in those cases? I can do that in a separate PR if you think that is the best approach.

Copy link
Member

@Andrew-S-Rosen Andrew-S-Rosen left a comment

Choose a reason for hiding this comment

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

As for a review, here are my (minor) comments. Otherwise, this is in great shape for merging!

src/quacc/runners/prep.py Outdated Show resolved Hide resolved
src/quacc/runners/prep.py Outdated Show resolved Hide resolved
@AitElBadaoui
Copy link
Contributor Author

Yes, I agree that we should switch back to None. After that, I can create a new PR to address other mypy issues.
Thank you for the review!

@Andrew-S-Rosen
Copy link
Member

Andrew-S-Rosen commented Jun 30, 2024

@AitElBadaoui: wonderful! I will take care of that and merge this PR when I'm back at my computer in an hour or two. 👍

@Andrew-S-Rosen
Copy link
Member

Merging this one. Thanks!

@Andrew-S-Rosen Andrew-S-Rosen merged commit c8074b0 into Quantum-Accelerators:main Jun 30, 2024
19 of 20 checks passed
@AitElBadaoui AitElBadaoui deleted the issue-782 branch July 1, 2024 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants