Skip to content

Conversation

@hauntsaninja
Copy link
Collaborator

@github-actions

This comment has been minimized.

@hauntsaninja
Copy link
Collaborator Author

hauntsaninja commented Dec 27, 2024

Prefect crash minimised is:

from typing import Protocol

class CP(Protocol):
    def __call__(self, parameters: str) -> str: ...

class NotSet: ...

class Task:
    def with_opt(self, trn: CP | type[NotSet] | None):
        if trn is not NotSet:
            reveal_type(trn)

@hauntsaninja
Copy link
Collaborator Author

hauntsaninja commented Dec 27, 2024

CPython is a true positive, you get a TypeError with:

from libclinic.cli import *
parse_file("x.py", limited_capi=True)

cloud-init is also arguably a true positive, since they're testing that it raises TypeError

The diagnostics could be much better though.

@python python deleted a comment from github-actions bot Dec 27, 2024
@github-actions

This comment has been minimized.

@hauntsaninja hauntsaninja marked this pull request as ready for review December 28, 2024 02:52
@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

CPython (Argument Clinic) (https://github.com/python/cpython)
+ Tools/clinic/libclinic/cli.py:46: error: Incompatible types in assignment (expression has type "type[PythonLanguage]", target has type "Callable[[str], Language]")  [assignment]

pytest (https://github.com/pytest-dev/pytest)
+ testing/test_monkeypatch.py:418: error: Unused "type: ignore" comment  [unused-ignore]

cloud-init (https://github.com/canonical/cloud-init)
+ tests/unittests/reporting/test_reporting.py:181: error: Argument 3 to "assertRaisesRegex" of "TestCase" has incompatible type "type[ReportingHandler]"; expected "Callable[..., object]"  [arg-type]

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.

1 participant