Skip to content

Finish typing of aiidalab.app and aiidalab.__main__ modules#453

Merged
danielhollas merged 8 commits intoaiidalab:mainfrom
danielhollas:types-main
Aug 30, 2024
Merged

Finish typing of aiidalab.app and aiidalab.__main__ modules#453
danielhollas merged 8 commits intoaiidalab:mainfrom
danielhollas:types-main

Conversation

@danielhollas
Copy link
Contributor

@danielhollas danielhollas commented Aug 21, 2024

Towards #363, almost done!

@codecov
Copy link

codecov bot commented Aug 21, 2024

Codecov Report

Attention: Patch coverage is 79.24528% with 11 lines in your changes missing coverage. Please review.

Project coverage is 71.76%. Comparing base (dbfb853) to head (8d8cef4).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
aiidalab/app.py 75.86% 7 Missing ⚠️
aiidalab/__main__.py 83.33% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #453      +/-   ##
==========================================
- Coverage   72.00%   71.76%   -0.25%     
==========================================
  Files          18       18              
  Lines        1611     1622      +11     
==========================================
+ Hits         1160     1164       +4     
- Misses        451      458       +7     
Flag Coverage Δ
py-3.11 71.76% <79.24%> (-0.25%) ⬇️
py-3.12 71.76% <79.24%> (-0.25%) ⬇️
py-3.9 71.76% <79.24%> (-0.25%) ⬇️

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

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

self.app = app

def on_any_event(self, event):
def on_any_event(self, event: FileSystemEvent) -> None:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked inside the watchdog package to see the correct type here.

- types-requests
- types-toml
- types-click
- traitlets~=5.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

pre-commit runs mypy from an isolated virtual environment so it doesn't have access to the installed dependencies, and thus we need to add them here manually. This is highly problematic, as we are essentially duplicating info from setup.cfg. In the future, we probably have to switch to an approach used in aiida-core, where mypy is installed as dev dependency of aiidalab, instead of being installed by pre-commit.

self.dependencies_to_install = self._app.find_dependencies_to_install(
self.version_to_install
)
if self.version_to_install:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This could be None so mypy got rightfully mad that we're passing a possible None value to a function that did not expect it. In other words, this was a bug.

@danielhollas danielhollas changed the title Finish typing of aiidalab.app module Finish typing of aiidalab.app and aiidalab.__main__ modules Aug 22, 2024
@BoboTiG
Copy link

BoboTiG commented Aug 28, 2024

I released watchdog v5.0.0 that contains a full types coverage, it should ease your job here :)

And, again, thank you for testing the master branch at the time, it helped catch a bunch of problems.

@danielhollas
Copy link
Contributor Author

@superstar54 will you have time to look at this? I'd like to include this in the next release this week.

@danielhollas
Copy link
Contributor Author

I released watchdog v5.0.0 that contains a full types coverage, it should ease your job here :)

@BoboTiG thanks, that's great. Happy to have been of some help.

Just a note for me and the reviewers, I will deal with watchdog version bump in a separate PR, #454


from . import __version__
from .app import AppVersion
from .app import _AiidaLabApp as AiidaLabApp
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This renaming was super confusing.

@danielhollas danielhollas enabled auto-merge (squash) August 28, 2024 23:48
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.

Thanks @danielhollas, just a minor request, all good then.


@contextmanager
def _mock_schemas_endpoints():
def _mock_schemas_endpoints() -> Generator[None, None, None]:
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
def _mock_schemas_endpoints() -> Generator[None, None, None]:
def _mock_schemas_endpoints() -> Iterator[None]:

I think this is simpler?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I guess you're right, and mypy accepts this. However, since we use the Generator type in many other places now, I'd like to keep things consistent for now. Later if we like we can go through and simplify this accross the code base.

Copy link
Member

Choose a reason for hiding this comment

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

sure!


@contextmanager
def _show_busy(self):
def _show_busy(self) -> Generator[None, None, None]:
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
def _show_busy(self) -> Generator[None, None, None]:
def _show_busy(self) -> Iterator[None]:

@danielhollas danielhollas merged commit b39a76d into aiidalab:main Aug 30, 2024
@danielhollas danielhollas deleted the types-main branch August 30, 2024 12:58
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