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

#8: Enable flake8 annotations. #119

Merged
merged 11 commits into from
Nov 21, 2023
Merged

#8: Enable flake8 annotations. #119

merged 11 commits into from
Nov 21, 2023

Conversation

perrygoy
Copy link
Member

@perrygoy perrygoy commented Nov 9, 2023

Well we saved the best for last. This PR enables flake8-annotations and adds the mypy config disallow-untyped-defs to the tests directory. Phew!

This PR also removes the isort, pylint, and flake8 tools from the dev dependencies list, since we don't use them in linting anymore.

@perrygoy perrygoy requested review from bandophahita and a team November 9, 2023 15:44
@perrygoy perrygoy marked this pull request as draft November 9, 2023 15:44
@perrygoy
Copy link
Member Author

perrygoy commented Nov 9, 2023

There are still a couple mypy issues that i'm having trouble figuring out:

mypy.....................................................................Failed
- hook id: mypy
- exit code: 1

tests/test_resolutions.py:149: error: Argument 1 to "ContainsTheEntry" has incompatible type "str"; expected <nothing>  [arg-type]
tests/test_resolutions.py:149: error: Argument 2 to "ContainsTheEntry" has incompatible type "bool"; expected <nothing>  [arg-type]
tests/test_resolutions.py:161: error: Argument 1 to "ContainsTheEntry" has incompatible type "str"; expected <nothing>  [arg-type]
tests/test_resolutions.py:161: error: Argument 2 to "ContainsTheEntry" has incompatible type "bool"; expected <nothing>  [arg-type]
tests/test_resolutions.py:203: error: Need type annotation for "cti_matcher"  [var-annotated]

Until those are resolved, i'll leave this as a draft.

@bandophahita
Copy link
Contributor

There are still a couple mypy issues that i'm having trouble figuring out:

This makes me think we need to update the github action to run mypy checks against the tests as well.

@@ -2,13 +2,13 @@ files: '(screenpy|tests)/.*'
fail_fast: false
repos:
- repo: https://github.com/psf/black
rev: 23.10.1
rev: 23.11.0
hooks:
- id: black
language_version: python3.11
Copy link
Contributor

Choose a reason for hiding this comment

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

It occurs to me that we have the [tool.black] target-version = ['py312'] but pre-commit only uses 3.11.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated!

@@ -106,11 +103,8 @@ dev_all = [
"autodoc-pydantic",
"black",
"coverage",
"flake8",
"isort",
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we are removing isort, the makefile should get updated as well. It's not required for this PR, but if you can that'd be good.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, updated!

@@ -31,7 +31,8 @@ def perform_as(self, _: Actor) -> None:
"""Direct the Narrator to attach a file."""
the_narrator.attaches_a_file(self.filepath, **self.attach_kwargs)

def __init__(self, filepath: str, **kwargs: Any) -> None:
# ANN401 ignored here to allow for new adapters to use any kwargs.
def __init__(self, filepath: str, **kwargs: Any) -> None: # noqa: ANN401
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think we can use object here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure i fully understand when it's best to use object over Any, but all the times i've tried have ended in disaster.

@perrygoy perrygoy marked this pull request as ready for review November 16, 2023 00:57
@perrygoy
Copy link
Member Author

I'd like to release now, so i'm gonna use my privileges @bandophahita. If you have any concerns from this PR, let's address them in the next one!

@perrygoy perrygoy merged commit aaea650 into trunk Nov 21, 2023
23 checks passed
@perrygoy perrygoy deleted the 8/enable-flake8-annotations branch November 21, 2023 02:51
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