8000 Add typing to aiidalab.registry module by danielhollas · Pull Request #511 · aiidalab/aiidalab · GitHub
[go: up one dir, main page]

Skip to content

Add typing to aiidalab.registry module - #511

Merged
danielhollas merged 3 commits into
mainfrom
update-mypy
May 28, 2026
Merged

danielhollas merged 3 commits into
mainfrom
update-mypy

Conversation

@danielhollas
Copy link
Copy Markdown
Contributor

This adds a minimum-effort typing to the aiidalab.registry module, hopefully making future changes a bit safer.

@codecov
codecov Bot commented May 28, 2026 •
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.67%. Comparing base (3a83e0b) to head (9c55aa4).
⚠️ Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
aiidalab/registry/apps_index.py 90.00% 1 Missing ⚠️
aiidalab/utils.py 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #511      +/-   ##
==========================================
+ Coverage   72.47%   72.67%   +0.20%     
==========================================
  Files          18       18              
  Lines        1653     1669      +16     
==========================================
+ Hits         1198     1213      +15     
- Misses        455      456       +1     
Flag Coverage Δ
py-3.12 72.67% <96.00%> (+0.20%) ⬆️
py-3.9 72.67% <96.00%> (+0.20%) ⬆️

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

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@edan-bainglass edan-bainglass left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! Left a few comments/questions.

Comment thread aiidalab/registry/yaml.py
safe_yaml = YAML(typ="safe")

def __call__(self, uri, **kwargs):
def __call__(self, uri: str, **kwargs: Any) -> Any:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it worth typing kwargs, or rather, is it standard practice?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

mypy would otherwise complained about untyped function definition (and more importantly, unless the function definition is fully typed, mypy doesn't check it at all by default)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Interesting

Comment thread aiidalab/utils.py Resolved
Comment thread aiidalab/utils.py Outdated
def __init__(self, calls_per_second: int = 1):
self.calls_per_second = calls_per_second
self.last_start = defaultdict(lambda: -1) # type: ignore
self.last_start = defaultdict(lambda: -1.0) # type: ignore
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is the type ignore still required then? I guess it's for something else?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Mypy wanted an explicit type annotation, so I added one and removed the type ignore

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm confused. Looks like the type ignore is still there? And no type annotation?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You were probably looking at the outdated version of the code

image

@danielhollas
danielhollas merged commit 035586e into main May 28, 2026
12 of 13 checks passed
@danielhollas
danielhollas deleted the update-mypy branch May 28, 2026 23:23
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.

2 participants

0