Skip to content

Strict type checking and re-enable mypy #16

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Avasam
Copy link
Contributor

@Avasam Avasam commented Feb 8, 2025

Closes #15 , closes #11 , closes #17

Ref: jaraco/skeleton#143

conftest.py Outdated
_host, port = addr = ('', portend.find_available_local_port())
Handler = functools.partial(QuietHTTPRequestHandler, directory=path)
Handler = functools.partial(QuietHTTPRequestHandler, directory=path) # type: ignore[arg-type] # python/typeshed#13477
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +158 to +163
# reversed makes cmgrs no longer variadic, breaking type validation
# Mypy infers compose_two as Callable[[function, function], function]. See:
# - https://github.com/python/typeshed/issues/7580
# - https://github.com/python/mypy/issues/8240
return functools.reduce(compose_two, reversed(cmgrs)) # type: ignore[return-value, arg-type]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -13,3 +13,11 @@ explicit_package_bases = True
disable_error_code =
# Disable due to many false positives
overload-overlap,

# jaraco/backports.tarfile#1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[mypy-backports.*]
follow_untyped_imports = True

# jaraco/portend#17
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Avasam Avasam force-pushed the Strict-type-checking-and-re-enable-mypy branch 4 times, most recently from 34b4f82 to 2c189f1 Compare February 8, 2025 21:08
@Avasam Avasam force-pushed the Strict-type-checking-and-re-enable-mypy branch from 2c189f1 to 3206ddc Compare February 8, 2025 21:38
Comment on lines -253 to 312
def __exit__(self, *exc_info):
type = exc_info[0]
matches = type and issubclass(type, self.exceptions)
def __exit__(
self,
*exc_info: Unpack[_UnpackableOptExcInfo], # noqa: PYI036 # We can do better than object
) -> builtins.type[BaseException] | None | bool:
exc_type = exc_info[0]
matches = exc_type and issubclass(exc_type, self.exceptions)
if matches:
self.exc_info = exc_info
self.exc_info = exc_info # type: ignore[assignment]
return matches
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternatively:

    def __exit__(
        self,
        exc_type: builtins.type[BaseException] | None,
        exc: BaseException | None,
        exc_tb: TracebackType | None,
    ) -> builtins.type[BaseException] | None | bool:
        matches = exc_type and issubclass(exc_type, self.exceptions)
        if matches:
            self.exc_info = (exc_type, exc, exc_tb)  # type: ignore[assignment]
        return matches

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.

Lack of parameter annotations makes mypy consider functions as untyped Migrate to new type aliases
1 participant