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

Running mypy in tests/ #921

Merged
merged 1 commit into from
Mar 1, 2022
Merged

Running mypy in tests/ #921

merged 1 commit into from
Mar 1, 2022

Conversation

gsegatti
Copy link
Contributor

@gsegatti gsegatti commented Mar 1, 2022

Apparently tests/ was not being reviewed by Mypy. Added the folder to the respective line on the CI and tried to correct most of the stuff pointed by Mypy.

Will leave a few comments because some of the errors are not necessarily crystal clear, a few things are still open issues so it seems.

Please feel free to leave suggestions on better approaches.

tests/test_config_parser.py Outdated Show resolved Hide resolved
@@ -468,7 +473,7 @@ class MkosiConfigDistro(MkosiConfigOne):
- --distribution
"""

def __init__(self, subdir_name=None, alldir_name=None):
def __init__(self, subdir_name: str = "", alldir_name: str = "") -> 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.

alldir_name is never used so maybe this can be removed.

@gsegatti gsegatti marked this pull request as ready for review March 1, 2022 12:05
@gsegatti gsegatti changed the title Running mypy in the tests/ folder Running mypy in tests/ Mar 1, 2022
for dist in Distribution:
assert parse(["-d", dist.name]).distribution == dist

with pytest.raises((argparse.ArgumentError, SystemExit)):
with pytest.raises(tuple((argparse.ArgumentError, SystemExit))):
Copy link
Contributor

Choose a reason for hiding this comment

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

What error did you get here that mad you add the tuple keyword?

Copy link
Contributor

@DaanDeMeyer DaanDeMeyer left a comment

Choose a reason for hiding this comment

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

I don't wanna waste too much time on those overengineered config parser tests in test_confg_parser and conftest so I don't mind a few Any's in there to make it pass type checking.

I have one comment on the use of the tuple keyword aside from that it looks fine

@gsegatti
Copy link
Contributor Author

gsegatti commented Mar 1, 2022

This is what I got without the tuple:

error: Argument 1 to "raises" has incompatible type "Tuple[Type[ArgumentError], Type[SystemExit]]";
expected "Union[Type[], Tuple[Type[], ...]]" [arg-type]
with pytest.raises((argparse.ArgumentError, SystemExit)):
^

@DaanDeMeyer DaanDeMeyer merged commit 50ea7a8 into systemd:main Mar 1, 2022
@gsegatti gsegatti deleted the mypy-tests branch April 4, 2022 09:02
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