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

Add typing to git_util.py, metadata.py and config.py #391

Merged
merged 4 commits into from
Aug 8, 2023

Conversation

danielhollas
Copy link
Contributor

Step towards #363. I am definitely not a typing expert, taking this work as an opportunity to learn. Would appreciate help to get rid of the type: ignores (although some of them seems to be caused by dulwich package not providing types).

@codecov
Copy link

codecov bot commented Aug 7, 2023

Codecov Report

Patch coverage: 92.68% and project coverage change: +0.26% 🎉

Comparison is base (58a7f29) 59.83% compared to head (1778ee7) 60.09%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #391      +/-   ##
==========================================
+ Coverage   59.83%   60.09%   +0.26%     
==========================================
  Files          23       23              
  Lines        1449     1451       +2     
==========================================
+ Hits          867      872       +5     
+ Misses        582      579       -3     
Flag Coverage Δ
py-3.10 60.09% <92.68%> (+0.26%) ⬆️
py-3.11 60.09% <92.68%> (+0.26%) ⬆️
py-3.8 60.09% <92.68%> (+0.26%) ⬆️
py-3.9 60.09% <92.68%> (+0.26%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
aiidalab/metadata.py 40.98% <72.72%> (+3.88%) ⬆️
aiidalab/config.py 65.51% <100.00%> (+1.23%) ⬆️
aiidalab/git_util.py 46.37% <100.00%> (+0.78%) ⬆️

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

@danielhollas danielhollas marked this pull request as ready for review August 7, 2023 17:22
@danielhollas danielhollas changed the title Add typing to git_util.py Add typing to git_util.py and metadata.py Aug 7, 2023
@danielhollas danielhollas changed the title Add typing to git_util.py and metadata.py Add typing to git_util.py, metadata.py and config.py Aug 7, 2023
Copy link
Member

@unkcpz unkcpz left a comment

Choose a reason for hiding this comment

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

@danielhollas thanks! Just minor requests. I don't think there is too many #type: ignore, as you said they are mostly from other libraries.

aiidalab/config.py Outdated Show resolved Hide resolved
aiidalab/git_util.py Outdated Show resolved Hide resolved
@@ -120,22 +134,22 @@ def git_clone(url, commit, path):


@dataclass
class GitPath(os.PathLike):
class GitPath(os.PathLike): # type: ignore
Copy link
Member

Choose a reason for hiding this comment

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

We may want to avoid to use ignore for subclassing by setting https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-disallow-subclassing-any

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting. Still not sure I fully understand the issue. Let's see how often we need this before making this a global option.

aiidalab/git_util.py Outdated Show resolved Hide resolved
@@ -1,15 +1,17 @@
"""App metadata specification"""
from __future__ import annotations

from configparser import ConfigParser
from configparser import ConfigParser, SectionProxy
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
from configparser import ConfigParser, SectionProxy
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from configparser import ConfigParser, SectionProxy
from pathlib import Path

A minor nitpick, you are the expert on module loading performance, will this improve the loading efficiency?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really, both of these are stdlib modules, which are generally very fast to import. More importantly, pathlib is getting imported all over the place anyway, and you would anyway need to import ConfigParser here.

@danielhollas danielhollas merged commit 0a96b17 into main Aug 8, 2023
13 checks passed
@danielhollas danielhollas deleted the types/git-utils branch August 8, 2023 20: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