diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..2a4a0579d --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +conformance/results/results.html linguist-generated diff --git a/.github/ISSUE_TEMPLATE/documentation-issue.md b/.github/ISSUE_TEMPLATE/documentation-issue.md index 6122c8f56..e8d7bc938 100644 --- a/.github/ISSUE_TEMPLATE/documentation-issue.md +++ b/.github/ISSUE_TEMPLATE/documentation-issue.md @@ -1,6 +1,6 @@ --- name: Documentation issue -about: Report a problem or suggest changes for the documentation at https://typing.readthedocs.io/ +about: Report a problem or suggest changes for the documentation at https://typing.python.org/ title: '' labels: 'topic: documentation' assignees: '' diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index c8e166a4f..7e430797e 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -13,14 +13,14 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v7 with: - python-version: 3.9 + python-version: "3.14" - name: Install dependencies run: | pip install --upgrade pip - pip install -r docs/requirements.txt + pip install --group docs - name: Build the documentation run: make -C docs html diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 41ffb78a8..b7f19bdcd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,18 +14,16 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Set up Python 3 - uses: actions/setup-python@v5 + - uses: actions/checkout@v7 + - uses: actions/setup-python@v7 with: - python-version: 3 + python-version: "3.14" cache: "pip" - cache-dependency-path: "test-requirements.txt" - name: Install dependencies run: | pip install --upgrade pip - pip install -r test-requirements.txt + pip install --group test - name: Lint implementation run: flake8 diff --git a/.github/workflows/conformance.yml b/.github/workflows/conformance.yml new file mode 100644 index 000000000..da948d918 --- /dev/null +++ b/.github/workflows/conformance.yml @@ -0,0 +1,47 @@ +name: Conformance + +on: + push: + pull_request: + +permissions: + contents: read + +jobs: + conformance: + name: Run conformance suite + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v7 + + - name: Set up Python 3.12 + uses: actions/setup-python@v7 + with: + python-version: "3.12" + cache: "pip" + + - name: Install uv + run: | + python -m pip install --upgrade pip + python -m pip install uv + + - name: Run conformance suite + working-directory: conformance + run: | + uv sync --python 3.12 --frozen + uv run --python 3.12 --frozen python src/main.py + + - name: Validate conformance invariants + working-directory: conformance + run: | + uv run --python 3.12 --frozen python src/validate_results.py + + - name: Assert conformance results are up to date + run: | + if [ -n "$(git status --porcelain -- conformance/results)" ]; then + git status --short conformance/results + git diff -- conformance/results + echo "Conformance results are out of date. Run conformance/src/main.py and commit updated results." + exit 1 + fi diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2bdf5973f..61b8f596b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: trailing-whitespace exclude: conformance/results/.*/.*\.toml diff --git a/.readthedocs.yaml b/.readthedocs.yaml index b6c9041cf..5618e1cb1 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -4,13 +4,17 @@ version: 2 build: - os: ubuntu-22.04 + os: ubuntu-26.04 tools: python: "3" + jobs: + install: + - uv sync --group docs sphinx: configuration: docs/conf.py python: install: - - requirements: docs/requirements.txt + - method: uv + command: sync diff --git a/README.md b/README.md index 09fb4f1b0..7380429d8 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ## Documentation and Support The documentation for Python's static typing can be found at -[typing.readthedocs.io](https://typing.readthedocs.io/). You can get +[typing.python.org](https://typing.python.org/). You can get help in our [support forum](https://github.com/python/typing/discussions). Improvements to the type system should be discussed on @@ -11,19 +11,17 @@ Improvements to the type system should be discussed on tracked in the [issues](https://github.com/python/typing/issues) in this repository. -For conversations that are more suitable to a chat platform, you can use one of the following: - -- [gitter](https://gitter.im/python/typing) -- [discord](https://discord.com/channels/267624335836053506/891788761371906108) `#type-hinting` channel +For conversations that are more suitable to a chat platform, you can use the +[#type-hinting](https://discord.com/channels/267624335836053506/891788761371906108) channel of the [Python Discord server](https://discord.com/invite/python). ## Repository Content This GitHub repository is used for several things: -- The documentation at [typing.readthedocs.io](https://typing.readthedocs.io/) +- The documentation at [typing.python.org](https://typing.python.org/) is maintained in the [docs directory](./docs). This includes the - [specification](https://typing.readthedocs.io/en/latest/spec/index.html) for the - type system. See especially [the update procedure](https://typing.readthedocs.io/en/latest/spec/meta.html) + [specification](https://typing.python.org/en/latest/spec/index.html) for the + type system. See especially [the update procedure](https://typing.python.org/en/latest/spec/meta.html) for the spec. - A [discussion forum](https://github.com/python/typing/discussions) for typing-related user diff --git a/conformance/.gitignore b/conformance/.gitignore index 5eae7a458..6a000697b 100644 --- a/conformance/.gitignore +++ b/conformance/.gitignore @@ -32,8 +32,6 @@ MANIFEST # Tools .mypy_cache -.pyre_configuration -.pyre .coverage htmlcov diff --git a/conformance/README.md b/conformance/README.md index 260b5ca03..7f28150dd 100644 --- a/conformance/README.md +++ b/conformance/README.md @@ -2,7 +2,7 @@ ## Motivation -[PEP 729](https://peps.python.org/pep-0729/) provides a structured and documented way to specify and evolve the Python type system. In support of this effort, an official [Python typing spec](https://github.com/python/typing/tree/main/docs/spec) has been drafted. This spec consolidates details from various historical typing-related PEPs. The spec will be modified over time to clarify unspecified and under-specified parts of the type system. It will also be extended to cover new features of the type system. +[PEP 729](https://peps.python.org/pep-0729/) provides a structured and documented way to specify and evolve the Python type system. In support of this effort, an official [Python typing spec](https://typing.python.org/en/latest/spec/) has been drafted. This spec consolidates details from various historical typing-related PEPs. The spec will be modified over time to clarify unspecified and under-specified parts of the type system. It will also be extended to cover new features of the type system. Accompanying the typing specification is this conformance test suite which validates the behavior of static type checkers against the specification. @@ -10,26 +10,27 @@ Accompanying the typing specification is this conformance test suite which valid This project contains test cases for behaviors defined in the Python typing spec. Tests are structured and grouped in accordance with the specification's chapter headings. -* [concepts](https://typing.readthedocs.io/en/latest/spec/concepts.html) -* [annotations](https://typing.readthedocs.io/en/latest/spec/annotations.html) -* [specialtypes](https://typing.readthedocs.io/en/latest/spec/special-types.html) -* [generics](https://typing.readthedocs.io/en/latest/spec/generics.html) -* [qualifiers](https://typing.readthedocs.io/en/latest/spec/qualifiers.html) -* [classes](https://typing.readthedocs.io/en/latest/spec/class-compat.html) -* [aliases](https://typing.readthedocs.io/en/latest/spec/aliases.html) -* [literals](https://typing.readthedocs.io/en/latest/spec/literal.html) -* [protocols](https://typing.readthedocs.io/en/latest/spec/protocol.html) -* [callables](https://typing.readthedocs.io/en/latest/spec/callables.html) -* [constructors](https://typing.readthedocs.io/en/latest/spec/constructors.html) -* [overloads](https://typing.readthedocs.io/en/latest/spec/overload.html) -* [dataclasses](https://typing.readthedocs.io/en/latest/spec/dataclasses.html) -* [typeddicts](https://typing.readthedocs.io/en/latest/spec/typeddict.html) -* [tuples](https://typing.readthedocs.io/en/latest/spec/tuples.html) -* [namedtuples](https://typing.readthedocs.io/en/latest/spec/namedtuples.html) -* [narrowing](https://typing.readthedocs.io/en/latest/spec/narrowing.html) -* [directives](https://typing.readthedocs.io/en/latest/spec/directives.html) -* [distribution](https://typing.readthedocs.io/en/latest/spec/distributing.html) -* [historical](https://typing.readthedocs.io/en/latest/spec/historical.html) +* [concepts](https://typing.python.org/en/latest/spec/concepts.html) +* [annotations](https://typing.python.org/en/latest/spec/annotations.html) +* [typeforms](https://typing.python.org/en/latest/spec/type-forms.html) +* [specialtypes](https://typing.python.org/en/latest/spec/special-types.html) +* [generics](https://typing.python.org/en/latest/spec/generics.html) +* [qualifiers](https://typing.python.org/en/latest/spec/qualifiers.html) +* [classes](https://typing.python.org/en/latest/spec/class-compat.html) +* [aliases](https://typing.python.org/en/latest/spec/aliases.html) +* [literals](https://typing.python.org/en/latest/spec/literal.html) +* [protocols](https://typing.python.org/en/latest/spec/protocol.html) +* [callables](https://typing.python.org/en/latest/spec/callables.html) +* [constructors](https://typing.python.org/en/latest/spec/constructors.html) +* [overloads](https://typing.python.org/en/latest/spec/overload.html) +* [dataclasses](https://typing.python.org/en/latest/spec/dataclasses.html) +* [typeddicts](https://typing.python.org/en/latest/spec/typeddict.html) +* [tuples](https://typing.python.org/en/latest/spec/tuples.html) +* [namedtuples](https://typing.python.org/en/latest/spec/namedtuples.html) +* [narrowing](https://typing.python.org/en/latest/spec/narrowing.html) +* [directives](https://typing.python.org/en/latest/spec/directives.html) +* [distribution](https://typing.python.org/en/latest/spec/distributing.html) +* [historical](https://typing.python.org/en/latest/spec/historical.html) A test file is a ".py" file. The file name should start with one of the above names followed by a description of the test (with words separated by underscores). For example, `generics_paramspec_basic_usage.py` would contain the basic usage tests for `ParamSpec`. Each test file can contain multiple individual unit tests, but these tests should be related to each other. If the number of unit tests in a single test file exceeds ten, it may be desirable to split it into separate test files. This will help maintain a consistent level of granularity across tests. @@ -46,27 +47,43 @@ Test cases use the following conventions: * Lines that are expected to produce a type checker error should have a comment starting with # E", either by itself or followed by an explanation after a colon (e.g., "# E: int is not a subtype of str"). Such explanatory comments are purely for human understanding, but type checkers are not - expected to use their exact wording. + expected to use their exact wording. There are several syntactic variations; see "Test Case Syntax" + below. * Lines that may produce an error (e.g., because the spec allows multiple behaviors) should be marked with "# E?" instead of "# E". * If a test case tests conformance with a specific passage in the spec, that passage should be quoted in a comment prefixed with "# > ". +## Test Case Syntax + +Test cases support the following special comments for declaring where errors should be raised: + +* `# E`: an error must be raised on this line +* `# E?`: an error may be raised on this line +* `# E[tag]`, where `tag` is an arbitrary string: must appear multiple times in a file with the same tag. + Exactly one line with this tag must raise an error. +* `# E[tag+]`: like `# E[tag]`, but errors may be raised on multiple lines. +* `# E[tag!]`: like `# E[tag]`, but zero or more lines with this tag may raise + an error while at least line must not raise an error. + +Each comment may be followed by a colon plus an explanation of the error; the explanation is ignored +by the scoring system. + ## Running the Conformance Test Tool To run the conformance test suite: * Clone the https://github.com/python/typing repo. -* Create and activate a Python 3.12 virtual environment. -* Switch to the `conformance` subdirectory and install all dependencies (`pip install -r requirements.txt`). -* Switch to the `src` subdirectory and run `python main.py`. +* Install [uv](https://docs.astral.sh/uv/) and ensure Python 3.12 is available. +* Switch to the `conformance` subdirectory and install locked dependencies (`uv sync --python 3.12 --frozen`). +* Run the conformance tool (`uv run --python 3.12 --frozen python src/main.py`). -Note that some type checkers may not run on some platforms. For example, pytype cannot be installed on Windows. If a type checker fails to install, tests will be skipped for that type checker. +Note that some type checkers may not run on some platforms. If a type checker fails to install, tests will be skipped for that type checker. ## Reporting Conformance Results Different type checkers report errors in different ways (with different wording in error messages and different line numbers or character ranges for errors). This variation makes it difficult to fully automate test validation given that tests will want to check for both false positive and false negative type errors. Some level of manual inspection will therefore be needed to determine whether a type checker is fully conformant with all tests in any given test file. This "scoring" process is required only when the output of a test changes — e.g. when a new version of that type checker is released and the tests are rerun. We assume that the output of a type checker will be the same from one run to the next unless/until a new version is released that fixes or introduces a bug. In this case, the output will need to be manually inspected and the conformance results re-scored for those tests whose output has changed. -Conformance results are reported and summarized for each supported type checker. Currently, results are reported for mypy, pyre, pyright, and pytype. It is the goal and desire to add additional type checkers over time. +[Conformance results](https://htmlpreview.github.io/?https://github.com/python/typing/blob/main/conformance/results/results.html) are reported and summarized for each supported type checker. Currently, results are reported for mypy, pyrefly, pyright, zuban, ty, and pycroscope. It is the goal and desire to add additional type checkers over time. ## Adding a New Test Case @@ -78,7 +95,22 @@ If a test is updated (augmented or fixed), the process is similar to when adding ## Updating a Type Checker -If a new version of a type checker is released, re-run the test tool with the new version. If the type checker output has changed for any test cases, the tool will supply the old and new outputs. Examine these to determine whether the conformance status has changed. Once the conformance status has been updated, re-run the test tool again to regenerate the summary report. +Type checker versions are locked in `uv.lock`. + +To bump all supported checkers to their latest released versions: + +```bash +python scripts/bump_type_checkers.py +``` + +After bumping, install the new lockfile and rerun conformance: + +```bash +uv sync --python 3.12 --frozen +uv run --python 3.12 --frozen python src/main.py +``` + +If checker output changes for any test cases, examine those deltas to determine whether the conformance status has changed. Once the conformance status has been updated, rerun the tool to regenerate the summary report. ## Automated Conformance Checking diff --git a/conformance/pyproject.toml b/conformance/pyproject.toml new file mode 100644 index 000000000..e433eadb7 --- /dev/null +++ b/conformance/pyproject.toml @@ -0,0 +1,20 @@ +[project] +name = "typing-conformance" +version = "0.1.0" +requires-python = "==3.12.*" +dependencies = [ + "jinja2", + "markdown", + "mypy", + "pycroscope", + "pyrefly", + "pyright", + "tomlkit", + "ty", + "types-markdown", + "typing-extensions>=4.16.0", + "zuban", +] + +[tool.uv] +package = false diff --git a/conformance/requirements.txt b/conformance/requirements.txt deleted file mode 100644 index 179cd8de6..000000000 --- a/conformance/requirements.txt +++ /dev/null @@ -1,7 +0,0 @@ -tomli -tomlkit -tqdm -pyright -mypy -pyre-check -pytype; platform_system != "Windows" diff --git a/conformance/results/mypy/aliases_explicit.toml b/conformance/results/mypy/aliases_explicit.toml index a71905fff..ee057629f 100644 --- a/conformance/results/mypy/aliases_explicit.toml +++ b/conformance/results/mypy/aliases_explicit.toml @@ -7,12 +7,13 @@ aliases_explicit.py:67: error: Bad number of arguments for type alias, expected aliases_explicit.py:68: error: Bad number of arguments for type alias, expected 0, given 1 [type-arg] aliases_explicit.py:69: error: Bad number of arguments for type alias, expected 1, given 2 [type-arg] aliases_explicit.py:70: error: Bad number of arguments for type alias, expected 1, given 2 [type-arg] -aliases_explicit.py:71: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "int" [misc] +aliases_explicit.py:71: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "int" [valid-type] aliases_explicit.py:79: error: Invalid type alias: expression is not a valid type [valid-type] aliases_explicit.py:80: error: Bracketed expression "[...]" is not valid as a type [valid-type] aliases_explicit.py:81: error: Invalid type alias: expression is not a valid type [valid-type] aliases_explicit.py:82: error: Invalid type alias: expression is not a valid type [valid-type] -aliases_explicit.py:83: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_explicit.py:83: error: Inline TypedDict is experimental, must be enabled with --enable-incomplete-feature=InlineTypedDict [misc] +aliases_explicit.py:83: error: Name "b" is not defined [name-defined] aliases_explicit.py:84: error: Invalid type alias: expression is not a valid type [valid-type] aliases_explicit.py:85: error: Invalid type alias: expression is not a valid type [valid-type] aliases_explicit.py:86: error: Invalid type alias: expression is not a valid type [valid-type] @@ -23,13 +24,11 @@ aliases_explicit.py:89: error: Invalid type: try using Literal[1] instead? [val aliases_explicit.py:90: error: Invalid type alias: expression is not a valid type [valid-type] aliases_explicit.py:90: error: Function "list" could always be true in boolean context [truthy-function] aliases_explicit.py:91: error: Invalid type alias: expression is not a valid type [valid-type] -aliases_explicit.py:101: error: "" not callable [operator] +aliases_explicit.py:101: error: "UnionType[list[Any], set[Any]]" not callable [operator] aliases_explicit.py:102: error: Bad number of arguments for type alias, expected 0, given 1 [type-arg] """ conformance_automated = "Fail" errors_diff = """ Line 100: Expected 1 errors """ -ignore_errors = [ - 'Function "list" could always be true in boolean context', -] +ignore_errors = ["Function \"list\" could always be true in boolean context"] diff --git a/conformance/results/mypy/aliases_implicit.toml b/conformance/results/mypy/aliases_implicit.toml index f20f1a776..98f363428 100644 --- a/conformance/results/mypy/aliases_implicit.toml +++ b/conformance/results/mypy/aliases_implicit.toml @@ -4,7 +4,7 @@ aliases_implicit.py:76: error: Bad number of arguments for type alias, expected aliases_implicit.py:77: error: Bad number of arguments for type alias, expected 0, given 1 [type-arg] aliases_implicit.py:78: error: Bad number of arguments for type alias, expected 1, given 2 [type-arg] aliases_implicit.py:79: error: Bad number of arguments for type alias, expected 1, given 2 [type-arg] -aliases_implicit.py:80: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "int" [misc] +aliases_implicit.py:80: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "int" [valid-type] aliases_implicit.py:81: error: Type argument "str" of "GoodTypeAlias12" must be a subtype of "float" [type-var] aliases_implicit.py:100: error: Function "list" could always be true in boolean context [truthy-function] aliases_implicit.py:106: error: Variable "aliases_implicit.BadTypeAlias1" is not valid as a type [valid-type] @@ -35,7 +35,7 @@ aliases_implicit.py:118: error: Variable "aliases_implicit.BadTypeAlias13" is no aliases_implicit.py:118: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases aliases_implicit.py:119: error: Variable "aliases_implicit.BadTypeAlias14" is not valid as a type [valid-type] aliases_implicit.py:119: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -aliases_implicit.py:133: error: "" not callable [operator] +aliases_implicit.py:133: error: "UnionType[list[Any], set[Any]]" not callable [operator] aliases_implicit.py:135: error: Bad number of arguments for type alias, expected 0, given 1 [type-arg] """ conformance_automated = "Pass" diff --git a/conformance/results/mypy/aliases_newtype.toml b/conformance/results/mypy/aliases_newtype.toml index ed1e9a0d3..f4c4bc856 100644 --- a/conformance/results/mypy/aliases_newtype.toml +++ b/conformance/results/mypy/aliases_newtype.toml @@ -1,21 +1,25 @@ -conformant = "Pass" +conformant = "Partial" +notes = """ +`NewType`s are incorrectly considered to be classes. +""" output = """ aliases_newtype.py:11: error: Argument 1 to "UserId" has incompatible type "str"; expected "int" [arg-type] aliases_newtype.py:12: error: Incompatible types in assignment (expression has type "int", variable has type "UserId") [assignment] -aliases_newtype.py:20: error: Cannot use isinstance() with NewType type [misc] -aliases_newtype.py:23: error: Cannot subclass "NewType" [misc] -aliases_newtype.py:32: error: String argument 1 "BadName" to NewType(...) does not match variable name "GoodName" [misc] -aliases_newtype.py:38: error: "GoodNewType1" expects no type arguments, but 1 given [type-arg] -aliases_newtype.py:44: error: Argument 2 to NewType(...) must be subclassable (got "int | str") [valid-newtype] -aliases_newtype.py:47: error: Type variable "aliases_newtype.T" is unbound [valid-type] -aliases_newtype.py:47: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) -aliases_newtype.py:47: note: (Hint: Use "T" in function signature to bind "T" inside a function) -aliases_newtype.py:49: error: NewType cannot be used with protocol classes [misc] -aliases_newtype.py:51: error: Argument 2 to NewType(...) must be subclassable (got "Literal[7]") [valid-newtype] -aliases_newtype.py:58: error: Argument 2 to NewType(...) must be subclassable (got "TD1") [valid-newtype] -aliases_newtype.py:60: error: NewType(...) expects exactly two positional arguments [misc] -aliases_newtype.py:62: error: Argument 2 to NewType(...) must be subclassable (got "Any") [valid-newtype] +aliases_newtype.py:23: error: Cannot use isinstance() with NewType type [misc] +aliases_newtype.py:26: error: Cannot subclass "NewType" [misc] +aliases_newtype.py:35: error: String argument 1 "BadName" to NewType(...) does not match variable name "GoodName" [misc] +aliases_newtype.py:41: error: "GoodNewType1" expects no type arguments, but 1 given [type-arg] +aliases_newtype.py:47: error: Argument 2 to NewType(...) must be subclassable (got "int | str") [valid-newtype] +aliases_newtype.py:50: error: Type variable "aliases_newtype.T" is unbound [valid-type] +aliases_newtype.py:50: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) +aliases_newtype.py:50: note: (Hint: Use "T" in function signature to bind "T" inside a function) +aliases_newtype.py:52: error: NewType cannot be used with protocol classes [misc] +aliases_newtype.py:54: error: Argument 2 to NewType(...) must be subclassable (got "Literal[7]") [valid-newtype] +aliases_newtype.py:61: error: Argument 2 to NewType(...) must be subclassable (got "TD1") [valid-newtype] +aliases_newtype.py:63: error: NewType(...) expects exactly two positional arguments [misc] +aliases_newtype.py:65: error: Argument 2 to NewType(...) must be subclassable (got "Any") [valid-newtype] """ -conformance_automated = "Pass" +conformance_automated = "Fail" errors_diff = """ +Line 18: Expected 1 errors """ diff --git a/conformance/results/mypy/aliases_recursive.toml b/conformance/results/mypy/aliases_recursive.toml index 01af644dc..d8c763cad 100644 --- a/conformance/results/mypy/aliases_recursive.toml +++ b/conformance/results/mypy/aliases_recursive.toml @@ -3,7 +3,7 @@ output = """ aliases_recursive.py:19: error: Dict entry 1 has incompatible type "str": "complex"; expected "str": "int | str | float | list[Json] | dict[str, Json] | None" [dict-item] aliases_recursive.py:20: error: List item 1 has incompatible type "complex"; expected "int | str | float | list[Json] | dict[str, Json] | None" [list-item] aliases_recursive.py:38: error: Incompatible types in assignment (expression has type "tuple[int, tuple[str, int], tuple[int, tuple[int, list[int]]]]", variable has type "RecursiveTuple") [assignment] -aliases_recursive.py:39: error: Name "t6" already defined on line 38 [no-redef] +aliases_recursive.py:39: error: Incompatible types in assignment (expression has type "tuple[int, list[int]]", variable has type "RecursiveTuple") [assignment] aliases_recursive.py:50: error: Dict entry 0 has incompatible type "str": "list[int]"; expected "str": "str | int | Mapping[str, RecursiveMapping]" [dict-item] aliases_recursive.py:51: error: Dict entry 2 has incompatible type "str": "list[int]"; expected "str": "str | int | Mapping[str, RecursiveMapping]" [dict-item] aliases_recursive.py:52: error: Dict entry 2 has incompatible type "str": "list[int]"; expected "str": "str | int | Mapping[str, RecursiveMapping]" [dict-item] diff --git a/conformance/results/mypy/aliases_type_statement.toml b/conformance/results/mypy/aliases_type_statement.toml index b43771b11..b69d735a7 100644 --- a/conformance/results/mypy/aliases_type_statement.toml +++ b/conformance/results/mypy/aliases_type_statement.toml @@ -1,97 +1,36 @@ -conformant = "Unsupported" -notes = """ -Does not support `type` statement. -""" +conformant = "Pass" output = """ -aliases_type_statement.py: error: Cannot assign multiple types to name "BadTypeAlias14" without an explicit "Type[...]" annotation [misc] -aliases_type_statement.py:8: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:9: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:9: error: Name "S3" is not defined [name-defined] -aliases_type_statement.py:9: error: Name "S1" is not defined [name-defined] -aliases_type_statement.py:9: error: Name "S2" is not defined [name-defined] -aliases_type_statement.py:10: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:10: error: Value of type "UnionType" is not indexable [index] -aliases_type_statement.py:14: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:21: error: "type[int]" has no attribute "__value__" [attr-defined] -aliases_type_statement.py:23: error: "type[int]" has no attribute "other_attrib" [attr-defined] -aliases_type_statement.py:37: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:38: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:39: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:40: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:41: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:42: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:43: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:44: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:45: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:46: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:47: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:48: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:48: error: Function "list" could always be true in boolean context [truthy-function] -aliases_type_statement.py:49: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:52: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:54: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:58: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:64: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:64: error: Name "K" is not defined [name-defined] -aliases_type_statement.py:69: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:72: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:72: error: Name "T" is not defined [name-defined] -aliases_type_statement.py:72: error: Variable "aliases_type_statement.RecursiveTypeAlias1" is not valid as a type [valid-type] -aliases_type_statement.py:72: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -aliases_type_statement.py:74: error: Variable "aliases_type_statement.RecursiveTypeAlias1" is not valid as a type [valid-type] -aliases_type_statement.py:74: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -aliases_type_statement.py:75: error: Variable "aliases_type_statement.RecursiveTypeAlias1" is not valid as a type [valid-type] -aliases_type_statement.py:75: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -aliases_type_statement.py:77: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:77: error: Name "P" is not defined [name-defined] -aliases_type_statement.py:77: error: Name "T" is not defined [name-defined] -aliases_type_statement.py:77: error: Name "S" is not defined [name-defined] -aliases_type_statement.py:77: error: Variable "aliases_type_statement.RecursiveTypeAlias2" is not valid as a type [valid-type] -aliases_type_statement.py:77: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -aliases_type_statement.py:79: error: Unexpected "..." [misc] -aliases_type_statement.py:79: error: Variable "aliases_type_statement.RecursiveTypeAlias2" is not valid as a type [valid-type] -aliases_type_statement.py:79: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -aliases_type_statement.py:80: error: Unexpected "..." [misc] -aliases_type_statement.py:80: error: Variable "aliases_type_statement.RecursiveTypeAlias2" is not valid as a type [valid-type] -aliases_type_statement.py:80: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -aliases_type_statement.py:81: error: Unexpected "..." [misc] -aliases_type_statement.py:81: error: Variable "aliases_type_statement.RecursiveTypeAlias2" is not valid as a type [valid-type] -aliases_type_statement.py:81: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -aliases_type_statement.py:82: error: Bracketed expression "[...]" is not valid as a type [valid-type] -aliases_type_statement.py:82: error: Variable "aliases_type_statement.RecursiveTypeAlias2" is not valid as a type [valid-type] -aliases_type_statement.py:82: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -aliases_type_statement.py:84: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:84: error: Name "RecursiveTypeAlias3" is not defined [name-defined] -aliases_type_statement.py:86: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:86: error: Name "T" is not defined [name-defined] -aliases_type_statement.py:86: error: Cannot determine type of "RecursiveTypeAlias4" [has-type] -aliases_type_statement.py:88: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:88: error: Name "T" is not defined [name-defined] -aliases_type_statement.py:88: error: Variable "aliases_type_statement.RecursiveTypeAlias5" is not valid as a type [valid-type] -aliases_type_statement.py:88: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -aliases_type_statement.py:90: error: PEP 695 type aliases are not yet supported [valid-type] -aliases_type_statement.py:90: error: Cannot resolve name "RecursiveTypeAlias7" (possible cyclic definition) [misc] -aliases_type_statement.py:90: error: Name "RecursiveTypeAlias7" is used before definition [used-before-def] -aliases_type_statement.py:91: error: PEP 695 type aliases are not yet supported [valid-type] +aliases_type_statement.py:17: error: "TypeAliasType" has no attribute "bit_count" [attr-defined] +aliases_type_statement.py:19: error: "TypeAliasType" not callable [operator] +aliases_type_statement.py:23: error: "TypeAliasType" has no attribute "other_attrib" [attr-defined] +aliases_type_statement.py:26: error: Type alias defined using "type" statement not valid as base class [misc] +aliases_type_statement.py:31: error: Parameterized generics cannot be used with class or instance checks [misc] +aliases_type_statement.py:31: error: Argument 2 to "isinstance" has incompatible type "TypeAliasType"; expected "_ClassInfo" [arg-type] +aliases_type_statement.py:37: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_type_statement.py:38: error: Bracketed expression "[...]" is not valid as a type [valid-type] +aliases_type_statement.py:39: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_type_statement.py:40: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_type_statement.py:41: error: Inline TypedDict is experimental, must be enabled with --enable-incomplete-feature=InlineTypedDict [misc] +aliases_type_statement.py:41: error: Name "b" is not defined [name-defined] +aliases_type_statement.py:42: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_type_statement.py:43: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_type_statement.py:44: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_type_statement.py:45: error: Variable "aliases_type_statement.var1" is not valid as a type [valid-type] +aliases_type_statement.py:45: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +aliases_type_statement.py:46: error: Invalid type: try using Literal[True] instead? [valid-type] +aliases_type_statement.py:47: error: Invalid type: try using Literal[1] instead? [valid-type] +aliases_type_statement.py:48: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_type_statement.py:49: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_type_statement.py:53: error: All type parameters should be declared ("V" not declared) [valid-type] +aliases_type_statement.py:58: error: All type parameters should be declared ("T1" not declared) [valid-type] +aliases_type_statement.py:68: error: Type argument "str" of "RecursiveTypeAlias2" must be a subtype of "int" [type-var] +aliases_type_statement.py:70: error: Type argument "int" of "RecursiveTypeAlias2" must be a subtype of "str" [type-var] +aliases_type_statement.py:73: error: Cannot resolve name "RecursiveTypeAlias3" (possible cyclic definition) [misc] +aliases_type_statement.py:75: error: Invalid recursive alias: a union item of itself [misc] +aliases_type_statement.py:79: error: Cannot resolve name "RecursiveTypeAlias6" (possible cyclic definition) [misc] +aliases_type_statement.py:79: error: Cannot resolve name "RecursiveTypeAlias7" (possible cyclic definition) [misc] +aliases_type_statement.py:80: error: Cannot resolve name "RecursiveTypeAlias7" (possible cyclic definition) [misc] """ -conformance_automated = "Fail" +conformance_automated = "Pass" errors_diff = """ -Line 17: Expected 1 errors -Line 19: Expected 1 errors -Line 26: Expected 1 errors -Line 31: Expected 1 errors -Line 8: Unexpected errors ['aliases_type_statement.py:8: error: PEP 695 type aliases are not yet supported [valid-type]'] -Line 9: Unexpected errors ['aliases_type_statement.py:9: error: PEP 695 type aliases are not yet supported [valid-type]', 'aliases_type_statement.py:9: error: Name "S3" is not defined [name-defined]', 'aliases_type_statement.py:9: error: Name "S1" is not defined [name-defined]', 'aliases_type_statement.py:9: error: Name "S2" is not defined [name-defined]'] -Line 10: Unexpected errors ['aliases_type_statement.py:10: error: PEP 695 type aliases are not yet supported [valid-type]', 'aliases_type_statement.py:10: error: Value of type "UnionType" is not indexable [index]'] -Line 14: Unexpected errors ['aliases_type_statement.py:14: error: PEP 695 type aliases are not yet supported [valid-type]'] -Line 21: Unexpected errors ['aliases_type_statement.py:21: error: "type[int]" has no attribute "__value__" [attr-defined]'] -Line 54: Unexpected errors ['aliases_type_statement.py:54: error: PEP 695 type aliases are not yet supported [valid-type]'] -Line 72: Unexpected errors ['aliases_type_statement.py:72: error: PEP 695 type aliases are not yet supported [valid-type]', 'aliases_type_statement.py:72: error: Name "T" is not defined [name-defined]', 'aliases_type_statement.py:72: error: Variable "aliases_type_statement.RecursiveTypeAlias1" is not valid as a type [valid-type]'] -Line 74: Unexpected errors ['aliases_type_statement.py:74: error: Variable "aliases_type_statement.RecursiveTypeAlias1" is not valid as a type [valid-type]'] -Line 75: Unexpected errors ['aliases_type_statement.py:75: error: Variable "aliases_type_statement.RecursiveTypeAlias1" is not valid as a type [valid-type]'] -Line 77: Unexpected errors ['aliases_type_statement.py:77: error: PEP 695 type aliases are not yet supported [valid-type]', 'aliases_type_statement.py:77: error: Name "P" is not defined [name-defined]', 'aliases_type_statement.py:77: error: Name "T" is not defined [name-defined]', 'aliases_type_statement.py:77: error: Name "S" is not defined [name-defined]', 'aliases_type_statement.py:77: error: Variable "aliases_type_statement.RecursiveTypeAlias2" is not valid as a type [valid-type]'] -Line 80: Unexpected errors ['aliases_type_statement.py:80: error: Unexpected "..." [misc]', 'aliases_type_statement.py:80: error: Variable "aliases_type_statement.RecursiveTypeAlias2" is not valid as a type [valid-type]'] -Line 82: Unexpected errors ['aliases_type_statement.py:82: error: Bracketed expression "[...]" is not valid as a type [valid-type]', 'aliases_type_statement.py:82: error: Variable "aliases_type_statement.RecursiveTypeAlias2" is not valid as a type [valid-type]'] -Line 88: Unexpected errors ['aliases_type_statement.py:88: error: PEP 695 type aliases are not yet supported [valid-type]', 'aliases_type_statement.py:88: error: Name "T" is not defined [name-defined]', 'aliases_type_statement.py:88: error: Variable "aliases_type_statement.RecursiveTypeAlias5" is not valid as a type [valid-type]'] -Line 91: Unexpected errors ['aliases_type_statement.py:91: error: PEP 695 type aliases are not yet supported [valid-type]'] """ diff --git a/conformance/results/mypy/aliases_typealiastype.toml b/conformance/results/mypy/aliases_typealiastype.toml index 590610a41..b757d9edd 100644 --- a/conformance/results/mypy/aliases_typealiastype.toml +++ b/conformance/results/mypy/aliases_typealiastype.toml @@ -1,16 +1,13 @@ conformant = "Partial" notes = """ -Incorrectly rejects some recursive type aliases using TypeAliasType. -Incorrectly rejects the use of a class-scoped TypeVar in a TypeAliasType definition. -Generates error when accessing `__value__` attribute of TypeAliasType. +Incorrectly rejects some recursive type aliases using `TypeAliasType`. +Incorrectly rejects the use of a class-scoped `TypeVar` in a `TypeAliasType` definition. """ output = """ -aliases_typealiastype.py:19: error: Cannot resolve name "GoodAlias4" (possible cyclic definition) [misc] aliases_typealiastype.py:20: error: Cannot resolve name "GoodAlias5" (possible cyclic definition) [misc] aliases_typealiastype.py:22: error: Cannot resolve name "GoodAlias5" (possible cyclic definition) [misc] aliases_typealiastype.py:27: error: Type variable "T" is not included in type_params [valid-type] -aliases_typealiastype.py:30: error: "type[int]" has no attribute "__value__" [attr-defined] -aliases_typealiastype.py:32: error: "type[int]" has no attribute "other_attrib" [attr-defined] +aliases_typealiastype.py:32: error: "TypeAliasType" has no attribute "other_attrib" [attr-defined] aliases_typealiastype.py:40: error: Type argument "int" of "GoodAlias5" must be a subtype of "str" [type-var] aliases_typealiastype.py:43: error: Type variable "S" is not included in type_params [valid-type] aliases_typealiastype.py:44: error: Type variable "S" is not included in type_params [valid-type] @@ -19,13 +16,13 @@ aliases_typealiastype.py:46: error: Cannot resolve name "BadAlias4" (possible cy aliases_typealiastype.py:47: error: Invalid recursive alias: a union item of itself [misc] aliases_typealiastype.py:48: error: Cannot resolve name "BadAlias6" (possible cyclic definition) [misc] aliases_typealiastype.py:48: error: Cannot resolve name "BadAlias7" (possible cyclic definition) [misc] -aliases_typealiastype.py:48: error: Name "BadAlias7" is used before definition [used-before-def] aliases_typealiastype.py:49: error: Cannot resolve name "BadAlias7" (possible cyclic definition) [misc] aliases_typealiastype.py:52: error: Invalid type alias: expression is not a valid type [valid-type] aliases_typealiastype.py:53: error: Bracketed expression "[...]" is not valid as a type [valid-type] aliases_typealiastype.py:54: error: Invalid type alias: expression is not a valid type [valid-type] aliases_typealiastype.py:55: error: Invalid type alias: expression is not a valid type [valid-type] -aliases_typealiastype.py:56: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_typealiastype.py:56: error: Inline TypedDict is experimental, must be enabled with --enable-incomplete-feature=InlineTypedDict [misc] +aliases_typealiastype.py:56: error: Name "b" is not defined [name-defined] aliases_typealiastype.py:57: error: Invalid type alias: expression is not a valid type [valid-type] aliases_typealiastype.py:58: error: Invalid type alias: expression is not a valid type [valid-type] aliases_typealiastype.py:59: error: Invalid type alias: expression is not a valid type [valid-type] @@ -36,12 +33,11 @@ aliases_typealiastype.py:62: error: Invalid type: try using Literal[1] instead? aliases_typealiastype.py:63: error: Invalid type alias: expression is not a valid type [valid-type] aliases_typealiastype.py:63: error: Function "list" could always be true in boolean context [truthy-function] aliases_typealiastype.py:64: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_typealiastype.py:66: error: Cannot resolve name "BadAlias21" (possible cyclic definition) [misc] """ conformance_automated = "Fail" errors_diff = """ -Line 19: Unexpected errors ['aliases_typealiastype.py:19: error: Cannot resolve name "GoodAlias4" (possible cyclic definition) [misc]'] Line 20: Unexpected errors ['aliases_typealiastype.py:20: error: Cannot resolve name "GoodAlias5" (possible cyclic definition) [misc]'] Line 22: Unexpected errors ['aliases_typealiastype.py:22: error: Cannot resolve name "GoodAlias5" (possible cyclic definition) [misc]'] Line 27: Unexpected errors ['aliases_typealiastype.py:27: error: Type variable "T" is not included in type_params [valid-type]'] -Line 30: Unexpected errors ['aliases_typealiastype.py:30: error: "type[int]" has no attribute "__value__" [attr-defined]'] """ diff --git a/conformance/results/mypy/annotations_forward_refs.toml b/conformance/results/mypy/annotations_forward_refs.toml index 53c4e301e..b74ef2246 100644 --- a/conformance/results/mypy/annotations_forward_refs.toml +++ b/conformance/results/mypy/annotations_forward_refs.toml @@ -1,8 +1,15 @@ conformant = "Partial" notes = """ Does not report error for a forward reference that is not enclosed in quotes. -Does not report error for use of quoted type with "|" operator (runtime error). -Incorrectly generates error for quoted type defined in class scope. +Does not report error for use of quoted type with `|` operator (runtime error). +Resolves some forward references in type annotations in classes at the point of definition instead of end-of-scope +""" +conformance_automated = "Fail" +errors_diff = """ +Line 24: Expected 1 errors +Line 25: Expected 1 errors +Line 94: Expected 1 errors +Line 96: Expected 1 errors """ output = """ annotations_forward_refs.py:41: error: Invalid type comment or annotation [valid-type] @@ -22,20 +29,9 @@ annotations_forward_refs.py:53: error: Invalid type comment or annotation [vali annotations_forward_refs.py:54: error: Invalid type comment or annotation [valid-type] annotations_forward_refs.py:55: error: Module "types" is not valid as a type [valid-type] annotations_forward_refs.py:55: note: Perhaps you meant to use a protocol matching the module structure? -annotations_forward_refs.py:80: error: Name "ClassF" is not defined [name-defined] -annotations_forward_refs.py:87: error: Function "annotations_forward_refs.ClassD.int" is not valid as a type [valid-type] -annotations_forward_refs.py:87: note: Perhaps you need "Callable[...]" or a callback protocol? -annotations_forward_refs.py:89: error: Function "annotations_forward_refs.ClassD.int" is not valid as a type [valid-type] -annotations_forward_refs.py:89: note: Perhaps you need "Callable[...]" or a callback protocol? -annotations_forward_refs.py:93: error: Expression is of type int?, not "int" [assert-type] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 22: Expected 1 errors -Line 23: Expected 1 errors -Line 24: Expected 1 errors -Line 25: Expected 1 errors -Line 66: Expected 1 errors -Line 87: Unexpected errors ['annotations_forward_refs.py:87: error: Function "annotations_forward_refs.ClassD.int" is not valid as a type [valid-type]'] -Line 93: Unexpected errors ['annotations_forward_refs.py:93: error: Expression is of type int?, not "int" [assert-type]'] +annotations_forward_refs.py:92: error: Name "ClassF" is not defined; did you mean "ClassA", "ClassB", or "ClassC"? [name-defined] +annotations_forward_refs.py:101: error: Function "annotations_forward_refs.ClassD.int" is not valid as a type [valid-type] +annotations_forward_refs.py:101: note: Perhaps you need "Callable[...]" or a callback protocol? +annotations_forward_refs.py:103: error: Function "annotations_forward_refs.ClassD.int" is not valid as a type [valid-type] +annotations_forward_refs.py:103: note: Perhaps you need "Callable[...]" or a callback protocol? """ diff --git a/conformance/results/mypy/annotations_future_import.toml b/conformance/results/mypy/annotations_future_import.toml new file mode 100644 index 000000000..88012982f --- /dev/null +++ b/conformance/results/mypy/annotations_future_import.toml @@ -0,0 +1,15 @@ +conformant = "Partial" +notes = """ +Resolves some forward references in type annotations in classes at the point of definition instead of end-of-scope +""" +conformance_automated = "Fail" +errors_diff = """ +Line 37: Expected 1 errors +Line 39: Expected 1 errors +""" +output = """ +annotations_future_import.py:44: error: Function "annotations_future_import.ClassB.int" is not valid as a type [valid-type] +annotations_future_import.py:44: note: Perhaps you need "Callable[...]" or a callback protocol? +annotations_future_import.py:46: error: Function "annotations_future_import.ClassB.int" is not valid as a type [valid-type] +annotations_future_import.py:46: note: Perhaps you need "Callable[...]" or a callback protocol? +""" diff --git a/conformance/results/mypy/annotations_generators.toml b/conformance/results/mypy/annotations_generators.toml index 475411412..3e86b6ced 100644 --- a/conformance/results/mypy/annotations_generators.toml +++ b/conformance/results/mypy/annotations_generators.toml @@ -1,6 +1,6 @@ conformant = "Partial" notes = """ -Does not report incompatible Generator type in `yield from` statement. +Does not report incompatible `Generator` type in `yield from` statement. """ output = """ annotations_generators.py:51: error: Missing return statement [return] @@ -16,7 +16,5 @@ annotations_generators.py:119: error: Incompatible types in "yield from" (actual """ conformance_automated = "Fail" errors_diff = """ -Line 87: Expected 1 errors -Line 92: Expected 1 errors Line 135: Expected 1 errors """ diff --git a/conformance/results/mypy/callables_annotation.toml b/conformance/results/mypy/callables_annotation.toml index c8af71583..f19579654 100644 --- a/conformance/results/mypy/callables_annotation.toml +++ b/conformance/results/mypy/callables_annotation.toml @@ -1,7 +1,7 @@ conformant = "Partial" notes = """ -Incorrectly treats "*args: T, **kwargs: T" as "..." when T is specialized to Any. -Does not treat "*args: Any, **kargs: Any" as "..." when separated by keyword parameter. +Incorrectly treats `*args: T, **kwargs: T` as `...` when `T` is specialized to `Any`. +Does not treat `*args: Any, **kargs: Any` as `...` when separated by keyword parameter. """ output = """ callables_annotation.py:25: error: Too few arguments [call-arg] @@ -17,17 +17,17 @@ callables_annotation.py:57: error: Bracketed expression "[...]" is not valid as callables_annotation.py:57: note: Did you mean "List[...]"? callables_annotation.py:58: error: Please use "Callable[[], ]" or "Callable" [misc] callables_annotation.py:59: error: Unexpected "..." [misc] -callables_annotation.py:91: error: Incompatible types in assignment (expression has type "Callable[[], str]", variable has type "Callable[[int, VarArg(Any), KwArg(Any)], str]") [assignment] -callables_annotation.py:93: error: Incompatible types in assignment (expression has type "Callable[[NamedArg(int, 'a')], str]", variable has type "Callable[[int, VarArg(Any), KwArg(Any)], str]") [assignment] +callables_annotation.py:91: error: Incompatible types in assignment (expression has type "Callable[[], str]", variable has type "def (int, /, *Any, **Any) -> str") [assignment] +callables_annotation.py:93: error: Incompatible types in assignment (expression has type "def test_cb4(*, a: int) -> str", variable has type "def (int, /, *Any, **Any) -> str") [assignment] callables_annotation.py:157: error: Incompatible types in assignment (expression has type "Proto7", variable has type "Proto6") [assignment] callables_annotation.py:157: note: Following member(s) of "Proto7" have conflicts: callables_annotation.py:157: note: Expected: callables_annotation.py:157: note: def __call__(self, int, /, *args: Any, k: str, **kwargs: Any) -> None callables_annotation.py:157: note: Got: callables_annotation.py:157: note: def __call__(self, float, /, b: int, *, k: str, m: str) -> None -callables_annotation.py:172: error: Incompatible types in assignment (expression has type "Callable[[], str]", variable has type "Callable[[int, VarArg(Any), KwArg(Any)], str]") [assignment] -callables_annotation.py:187: error: Incompatible types in assignment (expression has type "Callable[[int, str], str]", variable has type "Callable[[str, VarArg(Any), KwArg(Any)], str]") [assignment] -callables_annotation.py:189: error: Incompatible types in assignment (expression has type "Callable[[int, str], str]", variable has type "Callable[[str, VarArg(Any), KwArg(Any)], str]") [assignment] +callables_annotation.py:172: error: Incompatible types in assignment (expression has type "Callable[[], str]", variable has type "def (int, /, *Any, **Any) -> str") [assignment] +callables_annotation.py:187: error: Incompatible types in assignment (expression has type "Callable[[int, str], str]", variable has type "def (str, /, *Any, **Any) -> str") [assignment] +callables_annotation.py:189: error: Incompatible types in assignment (expression has type "Callable[[int, str], str]", variable has type "def (str, /, *Any, **Any) -> str") [assignment] """ conformance_automated = "Fail" errors_diff = """ diff --git a/conformance/results/mypy/callables_kwargs.toml b/conformance/results/mypy/callables_kwargs.toml index 1b2578dd6..d34b72732 100644 --- a/conformance/results/mypy/callables_kwargs.toml +++ b/conformance/results/mypy/callables_kwargs.toml @@ -1,10 +1,12 @@ -conformant = "Pass" +conformant = "Partial" +notes = """ +Allows callable without kwargs to be assigned to callable with unpacked kwargs. +""" output = """ -callables_kwargs.py:22: note: "func1" defined here callables_kwargs.py:46: error: Missing named argument "v1" for "func1" [call-arg] callables_kwargs.py:46: error: Missing named argument "v3" for "func1" [call-arg] callables_kwargs.py:51: error: Unexpected keyword argument "v4" for "func1" [call-arg] -callables_kwargs.py:52: error: Too many positional arguments for "func1" [misc] +callables_kwargs.py:52: error: Too many positional arguments for "func1" [call-arg] callables_kwargs.py:58: error: Argument 1 to "func1" has incompatible type "**dict[str, str]"; expected "int" [arg-type] callables_kwargs.py:61: error: Argument 1 to "func1" has incompatible type "**dict[str, object]"; expected "int" [arg-type] callables_kwargs.py:61: error: Argument 1 to "func1" has incompatible type "**dict[str, object]"; expected "str" [arg-type] @@ -12,15 +14,16 @@ callables_kwargs.py:63: error: "func1" gets multiple values for keyword argument callables_kwargs.py:64: error: "func2" gets multiple values for keyword argument "v3" [misc] callables_kwargs.py:64: error: Argument 1 to "func2" has incompatible type "int"; expected "str" [arg-type] callables_kwargs.py:65: error: "func2" gets multiple values for keyword argument "v1" [misc] -callables_kwargs.py:101: error: Incompatible types in assignment (expression has type "Callable[[KwArg(TD2)], None]", variable has type "TDProtocol3") [assignment] -callables_kwargs.py:101: note: "TDProtocol3.__call__" has type "Callable[[NamedArg(int, 'v1'), NamedArg(int, 'v2'), NamedArg(str, 'v3')], None]" -callables_kwargs.py:102: error: Incompatible types in assignment (expression has type "Callable[[KwArg(TD2)], None]", variable has type "TDProtocol4") [assignment] -callables_kwargs.py:102: note: "TDProtocol4.__call__" has type "Callable[[NamedArg(int, 'v1')], None]" -callables_kwargs.py:103: error: Incompatible types in assignment (expression has type "Callable[[KwArg(TD2)], None]", variable has type "TDProtocol5") [assignment] -callables_kwargs.py:103: note: "TDProtocol5.__call__" has type "Callable[[Arg(int, 'v1'), Arg(str, 'v3')], None]" -callables_kwargs.py:111: error: Overlap between argument names and ** TypedDict items: "v1" [misc] -callables_kwargs.py:122: error: Unpack item in ** argument must be a TypedDict [misc] +callables_kwargs.py:101: error: Incompatible types in assignment (expression has type "def func1(**kwargs: **TD2) -> None", variable has type "TDProtocol3") [assignment] +callables_kwargs.py:101: note: "TDProtocol3.__call__" has type "def __call__(self, *, v1: int, v2: int, v3: str) -> None" +callables_kwargs.py:102: error: Incompatible types in assignment (expression has type "def func1(**kwargs: **TD2) -> None", variable has type "TDProtocol4") [assignment] +callables_kwargs.py:102: note: "TDProtocol4.__call__" has type "def __call__(self, *, v1: int) -> None" +callables_kwargs.py:103: error: Incompatible types in assignment (expression has type "def func1(**kwargs: **TD2) -> None", variable has type "TDProtocol5") [assignment] +callables_kwargs.py:103: note: "TDProtocol5.__call__" has type "def __call__(self, v1: int, v3: str) -> None" +callables_kwargs.py:111: error: Overlap between parameter names and ** TypedDict items: "v1" [misc] +callables_kwargs.py:122: error: Unpack item in ** parameter must be a TypedDict [misc] """ -conformance_automated = "Pass" +conformance_automated = "Fail" errors_diff = """ +Line 134: Expected 1 errors """ diff --git a/conformance/results/mypy/callables_protocol.toml b/conformance/results/mypy/callables_protocol.toml index 0f2f42132..8fc8dcea4 100644 --- a/conformance/results/mypy/callables_protocol.toml +++ b/conformance/results/mypy/callables_protocol.toml @@ -1,36 +1,36 @@ conformant = "Pass" output = """ -callables_protocol.py:35: error: Incompatible types in assignment (expression has type "Callable[[VarArg(bytes), NamedArg(int | None, 'max_items')], list[bytes]]", variable has type "Proto1") [assignment] -callables_protocol.py:35: note: "Proto1.__call__" has type "Callable[[VarArg(bytes), DefaultNamedArg(int | None, 'max_len')], list[bytes]]" -callables_protocol.py:36: error: Incompatible types in assignment (expression has type "Callable[[VarArg(bytes)], list[bytes]]", variable has type "Proto1") [assignment] -callables_protocol.py:36: note: "Proto1.__call__" has type "Callable[[VarArg(bytes), DefaultNamedArg(int | None, 'max_len')], list[bytes]]" -callables_protocol.py:37: error: Incompatible types in assignment (expression has type "Callable[[VarArg(bytes), NamedArg(str | None, 'max_len')], list[bytes]]", variable has type "Proto1") [assignment] -callables_protocol.py:37: note: "Proto1.__call__" has type "Callable[[VarArg(bytes), DefaultNamedArg(int | None, 'max_len')], list[bytes]]" -callables_protocol.py:67: error: Incompatible types in assignment (expression has type "Callable[[VarArg(bytes)], Any]", variable has type "Proto2") [assignment] -callables_protocol.py:67: note: "Proto2.__call__" has type "Callable[[VarArg(bytes), KwArg(str)], None]" -callables_protocol.py:68: error: Incompatible types in assignment (expression has type "Callable[[VarArg(str), KwArg(str)], Any]", variable has type "Proto2") [assignment] -callables_protocol.py:68: note: "Proto2.__call__" has type "Callable[[VarArg(bytes), KwArg(str)], None]" -callables_protocol.py:69: error: Incompatible types in assignment (expression has type "Callable[[VarArg(bytes), KwArg(bytes)], Any]", variable has type "Proto2") [assignment] -callables_protocol.py:69: note: "Proto2.__call__" has type "Callable[[VarArg(bytes), KwArg(str)], None]" -callables_protocol.py:70: error: Incompatible types in assignment (expression has type "Callable[[KwArg(str)], Any]", variable has type "Proto2") [assignment] -callables_protocol.py:70: note: "Proto2.__call__" has type "Callable[[VarArg(bytes), KwArg(str)], None]" +callables_protocol.py:35: error: Incompatible types in assignment (expression has type "def cb1_bad1(*vals: bytes, max_items: int | None) -> list[bytes]", variable has type "Proto1") [assignment] +callables_protocol.py:35: note: "Proto1.__call__" has type "def __call__(self, *vals: bytes, max_len: int | None = ...) -> list[bytes]" +callables_protocol.py:36: error: Incompatible types in assignment (expression has type "def cb1_bad2(*vals: bytes) -> list[bytes]", variable has type "Proto1") [assignment] +callables_protocol.py:36: note: "Proto1.__call__" has type "def __call__(self, *vals: bytes, max_len: int | None = ...) -> list[bytes]" +callables_protocol.py:37: error: Incompatible types in assignment (expression has type "def cb1_bad3(*vals: bytes, max_len: str | None) -> list[bytes]", variable has type "Proto1") [assignment] +callables_protocol.py:37: note: "Proto1.__call__" has type "def __call__(self, *vals: bytes, max_len: int | None = ...) -> list[bytes]" +callables_protocol.py:67: error: Incompatible types in assignment (expression has type "def cb2_bad1(*a: bytes) -> Any", variable has type "Proto2") [assignment] +callables_protocol.py:67: note: "Proto2.__call__" has type "def __call__(self, *vals: bytes, **kwargs: str) -> None" +callables_protocol.py:68: error: Incompatible types in assignment (expression has type "def cb2_bad2(*a: str, **b: str) -> Any", variable has type "Proto2") [assignment] +callables_protocol.py:68: note: "Proto2.__call__" has type "def __call__(self, *vals: bytes, **kwargs: str) -> None" +callables_protocol.py:69: error: Incompatible types in assignment (expression has type "def cb2_bad3(*a: bytes, **b: bytes) -> Any", variable has type "Proto2") [assignment] +callables_protocol.py:69: note: "Proto2.__call__" has type "def __call__(self, *vals: bytes, **kwargs: str) -> None" +callables_protocol.py:70: error: Incompatible types in assignment (expression has type "def cb2_bad4(**b: str) -> Any", variable has type "Proto2") [assignment] +callables_protocol.py:70: note: "Proto2.__call__" has type "def __call__(self, *vals: bytes, **kwargs: str) -> None" callables_protocol.py:97: error: Incompatible types in assignment (expression has type "Callable[[int], None]", variable has type "Proto4") [assignment] callables_protocol.py:97: note: "function" is missing following "Proto4" protocol member: callables_protocol.py:97: note: other_attribute -callables_protocol.py:121: error: Incompatible types in assignment (expression has type "Callable[[VarArg(bytes), DefaultNamedArg(int | None, 'max_len')], list[bytes]]", variable has type "NotProto6") [assignment] +callables_protocol.py:121: error: Incompatible types in assignment (expression has type "def cb6_bad1(*vals: bytes, max_len: int | None = ...) -> list[bytes]", variable has type "NotProto6") [assignment] callables_protocol.py:169: error: Incompatible types in assignment (expression has type "Callable[[int], Any]", variable has type "Proto8") [assignment] callables_protocol.py:169: note: "Proto8.__call__" has type overloaded function callables_protocol.py:186: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] callables_protocol.py:187: error: "Proto9[P, R]" has no attribute "xxx" [attr-defined] callables_protocol.py:197: error: "Proto9[[int], str]" has no attribute "other_attribute2"; maybe "other_attribute"? [attr-defined] callables_protocol.py:238: error: Incompatible types in assignment (expression has type "Callable[[int, str], Any]", variable has type "Proto11") [assignment] -callables_protocol.py:238: note: "Proto11.__call__" has type "Callable[[int, Arg(str, 'y')], Any]" -callables_protocol.py:260: error: Incompatible types in assignment (expression has type "Callable[[VarArg(Any), NamedArg(Any, 'kwarg0')], None]", variable has type "Proto12") [assignment] -callables_protocol.py:260: note: "Proto12.__call__" has type "Callable[[VarArg(Any), NamedArg(Any, 'kwarg0'), NamedArg(Any, 'kwarg1')], None]" +callables_protocol.py:238: note: "Proto11.__call__" has type "def __call__(self, int, /, y: str) -> Any" +callables_protocol.py:260: error: Incompatible types in assignment (expression has type "def cb12_bad1(*args: Any, kwarg0: Any) -> None", variable has type "Proto12") [assignment] +callables_protocol.py:260: note: "Proto12.__call__" has type "def __call__(self, *args: Any, kwarg0: Any, kwarg1: Any) -> None" callables_protocol.py:284: error: Incompatible types in assignment (expression has type "Callable[[str], str]", variable has type "Proto13_Default") [assignment] -callables_protocol.py:284: note: "Proto13_Default.__call__" has type "Callable[[DefaultArg(str, 'path')], str]" -callables_protocol.py:311: error: Incompatible types in assignment (expression has type "Callable[[NamedArg(str, 'path')], str]", variable has type "Proto14_Default") [assignment] -callables_protocol.py:311: note: "Proto14_Default.__call__" has type "Callable[[DefaultNamedArg(str, 'path')], str]" +callables_protocol.py:284: note: "Proto13_Default.__call__" has type "def __call__(self, path: str = ...) -> str" +callables_protocol.py:311: error: Incompatible types in assignment (expression has type "def cb14_no_default(*, path: str) -> str", variable has type "Proto14_Default") [assignment] +callables_protocol.py:311: note: "Proto14_Default.__call__" has type "def __call__(self, *, path: str = ...) -> str" """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/mypy/classes_classvar.toml b/conformance/results/mypy/classes_classvar.toml index fc940c040..238b36032 100644 --- a/conformance/results/mypy/classes_classvar.toml +++ b/conformance/results/mypy/classes_classvar.toml @@ -1,38 +1,39 @@ conformant = "Partial" notes = """ -Internal error if TypeVarTuple is used in ClassVar. -Does not reject use of ParamSpec in ClassVar. -Rejects ClassVar nested in Annotated. -Does not reject use of ClassVar in TypeAlias definition. -Does not infer type of ClassVar from assignment if no type is provided. +Internal error if `TypeVarTuple` is used in `ClassVar`. +Does not reject use of `ParamSpec` in `ClassVar`. +Rejects `ClassVar` nested in `Annotated`. +Does not reject use of `ClassVar` in `TypeAlias` definition. """ output = """ -classes_classvar.py:37: error: ClassVar[...] must have at most one type argument [valid-type] -classes_classvar.py:38: error: Invalid type: try using Literal[3] instead? [valid-type] -classes_classvar.py:39: error: Name "var" is not defined [name-defined] -classes_classvar.py:44: error: ClassVar cannot contain type variables [misc] -classes_classvar.py:45: error: ClassVar cannot contain type variables [misc] -classes_classvar.py:51: error: Incompatible types in assignment (expression has type "dict[Never, Never]", variable has type "list[str]") [assignment] -classes_classvar.py:53: error: Variable should not be annotated with both ClassVar and Final [misc] -classes_classvar.py:54: error: Invalid type: ClassVar nested inside other type [valid-type] -classes_classvar.py:60: error: Invalid type: ClassVar nested inside other type [valid-type] -classes_classvar.py:62: error: ClassVar can only be used for assignments in class body [misc] -classes_classvar.py:63: error: ClassVar can only be used for assignments in class body [misc] -classes_classvar.py:64: error: ClassVar can only be used for assignments in class body [misc] -classes_classvar.py:66: error: ClassVar can only be used for assignments in class body [misc] -classes_classvar.py:70: error: ClassVar can only be used for assignments in class body [misc] -classes_classvar.py:77: error: Expression is of type "Any", not "float" [assert-type] -classes_classvar.py:101: error: Cannot assign to class variable "stats" via instance [misc] -classes_classvar.py:130: error: Incompatible types in assignment (expression has type "ProtoAImpl", variable has type "ProtoA") [assignment] -classes_classvar.py:130: note: "ProtoAImpl" is missing following "ProtoA" protocol member: -classes_classvar.py:130: note: z -classes_classvar.py:130: note: Protocol member ProtoA.x expected class variable, got instance variable -classes_classvar.py:130: note: Protocol member ProtoA.y expected class variable, got instance variable +classes_classvar.py:40: error: ClassVar[...] must have at most one type argument [valid-type] +classes_classvar.py:41: error: Invalid type: try using Literal[3] instead? [valid-type] +classes_classvar.py:42: error: Name "var" is not defined; did you mean "var1" or "vars"? [name-defined] +classes_classvar.py:54: error: Incompatible types in assignment (expression has type "dict[Never, Never]", variable has type "list[str]") [assignment] +classes_classvar.py:56: error: Variable should not be annotated with both ClassVar and Final [misc] +classes_classvar.py:57: error: Invalid type: ClassVar nested inside other type [valid-type] +classes_classvar.py:69: error: Invalid type: ClassVar nested inside other type [valid-type] +classes_classvar.py:71: error: ClassVar can only be used for assignments in class body [misc] +classes_classvar.py:72: error: ClassVar can only be used for assignments in class body [misc] +classes_classvar.py:73: error: ClassVar can only be used for assignments in class body [misc] +classes_classvar.py:75: error: ClassVar can only be used for assignments in class body [misc] +classes_classvar.py:79: error: ClassVar can only be used for assignments in class body [misc] +classes_classvar.py:80: error: ClassVar[...] can't be used inside a type alias [valid-type] +classes_classvar.py:89: error: ClassVar[...] can't be used inside a TypedDict [valid-type] +classes_classvar.py:94: error: ClassVar[...] can't be used inside a NamedTuple [valid-type] +classes_classvar.py:127: error: Cannot assign to class variable "stats" via instance [misc] +classes_classvar.py:146: error: All protocol members must have explicitly declared types [misc] +classes_classvar.py:156: error: Incompatible types in assignment (expression has type "ProtoAImpl", variable has type "ProtoA") [assignment] +classes_classvar.py:156: note: "ProtoAImpl" is missing following "ProtoA" protocol member: +classes_classvar.py:156: note: z +classes_classvar.py:156: note: Protocol member ProtoA.x expected class variable, got instance variable +classes_classvar.py:156: note: Protocol member ProtoA.y expected class variable, got instance variable """ conformance_automated = "Fail" errors_diff = """ -Line 46: Expected 1 errors -Line 71: Expected 1 errors -Line 60: Unexpected errors ['classes_classvar.py:60: error: Invalid type: ClassVar nested inside other type [valid-type]'] -Line 77: Unexpected errors ['classes_classvar.py:77: error: Expression is of type "Any", not "float" [assert-type]'] +Line 47: Expected 1 errors +Line 48: Expected 1 errors +Line 49: Expected 1 errors +Line 69: Unexpected errors ['classes_classvar.py:69: error: Invalid type: ClassVar nested inside other type [valid-type]'] +Line 146: Unexpected errors ['classes_classvar.py:146: error: All protocol members must have explicitly declared types [misc]'] """ diff --git a/conformance/results/mypy/classes_override.toml b/conformance/results/mypy/classes_override.toml index bb72325de..860203f3b 100644 --- a/conformance/results/mypy/classes_override.toml +++ b/conformance/results/mypy/classes_override.toml @@ -1,6 +1,7 @@ conformant = "Partial" notes = """ -Does not handle case where parent class derives from Any. +Does not honor `@override` compatibility checks for `__init__` and `__new__`: +the incompatible constructor overrides in `ChildC2` are not flagged. """ output = """ classes_override.py:53: error: Method "method3" is marked as an override, but no base method was found with this name [misc] @@ -8,9 +9,9 @@ classes_override.py:56: error: Method "method4" is marked as an override, but no classes_override.py:79: error: Method "static_method1" is marked as an override, but no base method was found with this name [misc] classes_override.py:84: error: Method "class_method1" is marked as an override, but no base method was found with this name [misc] classes_override.py:89: error: Method "property1" is marked as an override, but no base method was found with this name [misc] -classes_override.py:101: error: Method "method1" is marked as an override, but no base method was found with this name [misc] """ conformance_automated = "Fail" errors_diff = """ -Line 101: Unexpected errors ['classes_override.py:101: error: Method "method1" is marked as an override, but no base method was found with this name [misc]'] +Lines 134, 135: Expected error (tag 'init') +Lines 137, 138: Expected error (tag 'new') """ diff --git a/conformance/results/mypy/constructors_call_init.toml b/conformance/results/mypy/constructors_call_init.toml index 3bf225988..f2d7df715 100644 --- a/conformance/results/mypy/constructors_call_init.toml +++ b/conformance/results/mypy/constructors_call_init.toml @@ -1,26 +1,17 @@ conformant = "Partial" notes = """ -Does not report errors during binding to self parameter of __init__ method. -Does not support function-scoped TypeVars in self annotation in __init__ method. -Does not reject use of class-scoped type variables in annotation of self parameter in __init__ method. +Does not report errors during binding to self parameter of `__init__` method. +Does not reject use of class-scoped type variables in annotation of self parameter in `__init__` method. """ conformance_automated = "Fail" errors_diff = """ Line 56: Expected 1 errors Line 107: Expected 1 errors Line 73: Unexpected errors ['constructors_call_init.py:73: error: Expression is of type "Class5[list[int]]", not "Class5[int]" [assert-type]'] -Line 91: Unexpected errors ['constructors_call_init.py:91: error: Expression is of type "Class6[V1, V2]", not "Class6[int, str]" [assert-type]'] -Line 92: Unexpected errors ['constructors_call_init.py:92: error: Expression is of type "Class6[V1, V2]", not "Class6[int, str]" [assert-type]'] -Line 99: Unexpected errors ['constructors_call_init.py:99: error: Expression is of type "Class7[V2, V1]", not "Class7[str, int]" [assert-type]'] -Line 100: Unexpected errors ['constructors_call_init.py:100: error: Expression is of type "Class7[V2, V1]", not "Class7[str, int]" [assert-type]'] """ output = """ constructors_call_init.py:21: error: Argument 1 to "Class1" has incompatible type "float"; expected "int" [arg-type] constructors_call_init.py:42: error: Argument 1 to "Class3" has incompatible type "Class2[Never]"; expected "Class3 | None" [arg-type] constructors_call_init.py:73: error: Expression is of type "Class5[list[int]]", not "Class5[int]" [assert-type] -constructors_call_init.py:91: error: Expression is of type "Class6[V1, V2]", not "Class6[int, str]" [assert-type] -constructors_call_init.py:92: error: Expression is of type "Class6[V1, V2]", not "Class6[int, str]" [assert-type] -constructors_call_init.py:99: error: Expression is of type "Class7[V2, V1]", not "Class7[str, int]" [assert-type] -constructors_call_init.py:100: error: Expression is of type "Class7[V2, V1]", not "Class7[str, int]" [assert-type] constructors_call_init.py:130: error: Too many arguments for "Class11" [call-arg] """ diff --git a/conformance/results/mypy/constructors_call_metaclass.toml b/conformance/results/mypy/constructors_call_metaclass.toml index 1ee25a8e1..a06679970 100644 --- a/conformance/results/mypy/constructors_call_metaclass.toml +++ b/conformance/results/mypy/constructors_call_metaclass.toml @@ -1,20 +1,18 @@ -conformant = "Unupported" +conformant = "Unsupported" notes = """ -Does not honor metaclass __call__ method when evaluating constructor call. -Does not skip evaluation of __new__ and __init__ if custom metaclass call returns non-class. +Does not honor metaclass `__call__` method when evaluating constructor call. +Does not skip evaluation of `__new__` and `__init__` if custom metaclass call returns non-class. """ conformance_automated = "Fail" errors_diff = """ -Line 23: Unexpected errors ['constructors_call_metaclass.py:23: error: Expression is of type "Class1", not "NoReturn" [assert-type]', 'constructors_call_metaclass.py:23: error: Missing positional argument "x" in call to "Class1" [call-arg]'] -Line 36: Unexpected errors ['constructors_call_metaclass.py:36: error: Expression is of type "Class2", not "int | Meta2" [assert-type]', 'constructors_call_metaclass.py:36: error: Missing positional argument "x" in call to "Class2" [call-arg]'] -Line 43: Unexpected errors ['constructors_call_metaclass.py:43: error: Argument 2 for "super" not an instance of argument 1 [misc]'] +Line 26: Unexpected errors ['constructors_call_metaclass.py:26: error: Expression is of type "Class1", not "Never" [assert-type]', 'constructors_call_metaclass.py:26: error: Missing positional argument "x" in call to "Class1" [call-arg]'] +Line 39: Unexpected errors ['constructors_call_metaclass.py:39: error: Expression is of type "Class2", not "int | Meta2" [assert-type]', 'constructors_call_metaclass.py:39: error: Missing positional argument "x" in call to "Class2" [call-arg]'] """ output = """ -constructors_call_metaclass.py:23: error: Expression is of type "Class1", not "NoReturn" [assert-type] -constructors_call_metaclass.py:23: error: Missing positional argument "x" in call to "Class1" [call-arg] -constructors_call_metaclass.py:36: error: Expression is of type "Class2", not "int | Meta2" [assert-type] -constructors_call_metaclass.py:36: error: Missing positional argument "x" in call to "Class2" [call-arg] -constructors_call_metaclass.py:43: error: Argument 2 for "super" not an instance of argument 1 [misc] -constructors_call_metaclass.py:51: error: Missing positional argument "x" in call to "Class3" [call-arg] -constructors_call_metaclass.py:65: error: Missing positional argument "x" in call to "Class4" [call-arg] +constructors_call_metaclass.py:26: error: Expression is of type "Class1", not "Never" [assert-type] +constructors_call_metaclass.py:26: error: Missing positional argument "x" in call to "Class1" [call-arg] +constructors_call_metaclass.py:39: error: Expression is of type "Class2", not "int | Meta2" [assert-type] +constructors_call_metaclass.py:39: error: Missing positional argument "x" in call to "Class2" [call-arg] +constructors_call_metaclass.py:54: error: Missing positional argument "x" in call to "Class3" [call-arg] +constructors_call_metaclass.py:68: error: Missing positional argument "x" in call to "Class4" [call-arg] """ diff --git a/conformance/results/mypy/constructors_call_new.toml b/conformance/results/mypy/constructors_call_new.toml index ce7ce82be..49860361e 100644 --- a/conformance/results/mypy/constructors_call_new.toml +++ b/conformance/results/mypy/constructors_call_new.toml @@ -1,17 +1,17 @@ conformant = "Partial" notes = """ -Does not support __new__ return type that is not a subclass of the class being constructed. -Does not skip evaluation of __init__ based on __new__ return type. -Does not report errors during binding to cls parameter of __new__ method. +Does not support `__new__` return type that is not a subclass of the class being constructed. +Does not skip evaluation of `__init__` based on `__new__` return type. +Does not report errors during binding to `cls` parameter of `__new__` method. """ conformance_automated = "Fail" errors_diff = """ -Line 145: Expected 1 errors +Line 148: Expected 1 errors Line 40: Unexpected errors ['constructors_call_new.py:40: error: Incompatible return type for "__new__" (returns "int", but must return a subtype of "Class3") [misc]'] Line 49: Unexpected errors ['constructors_call_new.py:49: error: Expression is of type "Class3", not "int" [assert-type]', 'constructors_call_new.py:49: error: Missing positional argument "x" in call to "Class3" [call-arg]'] Line 57: Unexpected errors ['constructors_call_new.py:57: error: "__new__" must return a class instance (got "Class4 | Any") [misc]'] Line 64: Unexpected errors ['constructors_call_new.py:64: error: Expression is of type "Class4", not "Class4 | Any" [assert-type]', 'constructors_call_new.py:64: error: Missing positional argument "x" in call to "Class4" [call-arg]'] -Line 76: Unexpected errors ['constructors_call_new.py:76: error: Expression is of type "Class5", not "NoReturn" [assert-type]', 'constructors_call_new.py:76: error: Missing positional argument "x" in call to "Class5" [call-arg]'] +Line 76: Unexpected errors ['constructors_call_new.py:76: error: Expression is of type "Class5", not "Never" [assert-type]', 'constructors_call_new.py:76: error: Missing positional argument "x" in call to "Class5" [call-arg]'] Line 82: Unexpected errors ['constructors_call_new.py:82: error: "__new__" must return a class instance (got "int | Class6") [misc]'] Line 89: Unexpected errors ['constructors_call_new.py:89: error: Expression is of type "Class6", not "int | Class6" [assert-type]', 'constructors_call_new.py:89: error: Missing positional argument "x" in call to "Class6" [call-arg]'] """ @@ -23,7 +23,7 @@ constructors_call_new.py:49: error: Missing positional argument "x" in call to " constructors_call_new.py:57: error: "__new__" must return a class instance (got "Class4 | Any") [misc] constructors_call_new.py:64: error: Expression is of type "Class4", not "Class4 | Any" [assert-type] constructors_call_new.py:64: error: Missing positional argument "x" in call to "Class4" [call-arg] -constructors_call_new.py:76: error: Expression is of type "Class5", not "NoReturn" [assert-type] +constructors_call_new.py:76: error: Expression is of type "Class5", not "Never" [assert-type] constructors_call_new.py:76: error: Missing positional argument "x" in call to "Class5" [call-arg] constructors_call_new.py:82: error: "__new__" must return a class instance (got "int | Class6") [misc] constructors_call_new.py:89: error: Expression is of type "Class6", not "int | Class6" [assert-type] diff --git a/conformance/results/mypy/constructors_call_type.toml b/conformance/results/mypy/constructors_call_type.toml index 7ba573760..c94564c53 100644 --- a/conformance/results/mypy/constructors_call_type.toml +++ b/conformance/results/mypy/constructors_call_type.toml @@ -1,6 +1,6 @@ conformant = "Partial" notes = """ -Does not validate call to custom metaclass __call__ method through type[T]. +Does not validate call to custom metaclass `__call__` method through `type[T]`. """ conformance_automated = "Fail" errors_diff = """ diff --git a/conformance/results/mypy/constructors_callable.toml b/conformance/results/mypy/constructors_callable.toml index 7f4f19e84..c477fd6b8 100644 --- a/conformance/results/mypy/constructors_callable.toml +++ b/conformance/results/mypy/constructors_callable.toml @@ -1,51 +1,49 @@ conformant = "Partial" notes = """ -Does not generate a union type for __new__ and __init__ when converting class to callable. -Does not ignore __init__ based on __new__ return type when converting class to callable. -Does not support __new__ return type that is different from class being constructed. +Does not generate a union type for `__new__` and `__init__` when converting class to callable. +Does not ignore `__init__` based on `__new__` return type when converting class to callable. +Does not support `__new__` return type that is different from class being constructed. """ conformance_automated = "Fail" errors_diff = """ -Line 127: Expected 1 errors -Line 144: Expected 1 errors -Line 73: Unexpected errors ['constructors_callable.py:73: error: Incompatible return type for "__new__" (returns "int", but must return a subtype of "Class4") [misc]'] -Line 78: Unexpected errors ['constructors_callable.py:78: error: Expression is of type "Class4", not "int" [assert-type]'] -Line 100: Unexpected errors ['constructors_callable.py:100: error: Expression is of type "Class5", not "NoReturn" [assert-type]'] -Line 105: Unexpected errors ['constructors_callable.py:105: error: Expression is of type "Class5", not "NoReturn" [assert-type]'] -Line 116: Unexpected errors ['constructors_callable.py:116: error: Incompatible return type for "__new__" (returns "Class6Proxy", but must return a subtype of "Class6") [misc]'] -Line 117: Unexpected errors ['constructors_callable.py:117: error: Incompatible return value type (got "Class6", expected "Class6Proxy") [return-value]'] -Line 126: Unexpected errors ['constructors_callable.py:126: error: Expression is of type "Class6", not "Class6Proxy" [assert-type]', 'constructors_callable.py:126: error: Too few arguments [call-arg]'] -Line 143: Unexpected errors ['constructors_callable.py:143: error: Expression is of type "Class6Any", not "Any" [assert-type]', 'constructors_callable.py:143: error: Too few arguments [call-arg]'] +Line 129: Expected 1 errors +Line 146: Expected 1 errors +Line 74: Unexpected errors ['constructors_callable.py:74: error: Incompatible return type for "__new__" (returns "int", but must return a subtype of "Class4") [misc]'] +Line 102: Unexpected errors ['constructors_callable.py:102: error: Expression is of type "Class5", not "Never" [assert-type]'] +Line 107: Unexpected errors ['constructors_callable.py:107: error: Expression is of type "Class5", not "Never" [assert-type]'] +Line 118: Unexpected errors ['constructors_callable.py:118: error: Incompatible return type for "__new__" (returns "Class6Proxy", but must return a subtype of "Class6") [misc]'] +Line 128: Unexpected errors ['constructors_callable.py:128: error: Expression is of type "Class6", not "Class6Proxy" [assert-type]', 'constructors_callable.py:128: error: Too few arguments [call-arg]'] +Line 145: Unexpected errors ['constructors_callable.py:145: error: Expression is of type "Class6Any", not "Any" [assert-type]', 'constructors_callable.py:145: error: Too few arguments [call-arg]'] """ output = """ -constructors_callable.py:36: note: Revealed type is "def (x: builtins.int) -> constructors_callable.Class1" +constructors_callable.py:36: note: Revealed type is "def (x: int) -> constructors_callable.Class1" constructors_callable.py:38: error: Too few arguments [call-arg] constructors_callable.py:39: error: Unexpected keyword argument "y" [call-arg] constructors_callable.py:49: note: Revealed type is "def () -> constructors_callable.Class2" constructors_callable.py:51: error: Too many arguments [call-arg] -constructors_callable.py:63: note: Revealed type is "def (x: builtins.int) -> constructors_callable.Class3" -constructors_callable.py:65: error: Too few arguments [call-arg] -constructors_callable.py:66: error: Unexpected keyword argument "y" [call-arg] -constructors_callable.py:67: error: Too many arguments [call-arg] -constructors_callable.py:73: error: Incompatible return type for "__new__" (returns "int", but must return a subtype of "Class4") [misc] -constructors_callable.py:77: note: Revealed type is "def (x: builtins.int) -> constructors_callable.Class4" -constructors_callable.py:78: error: Expression is of type "Class4", not "int" [assert-type] -constructors_callable.py:79: error: Too few arguments [call-arg] -constructors_callable.py:80: error: Unexpected keyword argument "y" [call-arg] -constructors_callable.py:97: note: Revealed type is "def (*args: Any, **kwargs: Any) -> constructors_callable.Class5" -constructors_callable.py:100: error: Expression is of type "Class5", not "NoReturn" [assert-type] -constructors_callable.py:105: error: Expression is of type "Class5", not "NoReturn" [assert-type] -constructors_callable.py:116: error: Incompatible return type for "__new__" (returns "Class6Proxy", but must return a subtype of "Class6") [misc] -constructors_callable.py:117: error: Incompatible return value type (got "Class6", expected "Class6Proxy") [return-value] -constructors_callable.py:125: note: Revealed type is "def (x: builtins.int) -> constructors_callable.Class6" -constructors_callable.py:126: error: Expression is of type "Class6", not "Class6Proxy" [assert-type] -constructors_callable.py:126: error: Too few arguments [call-arg] -constructors_callable.py:142: note: Revealed type is "def (x: builtins.int) -> constructors_callable.Class6Any" -constructors_callable.py:143: error: Expression is of type "Class6Any", not "Any" [assert-type] -constructors_callable.py:143: error: Too few arguments [call-arg] -constructors_callable.py:162: note: Revealed type is "Overload(def (x: builtins.int) -> constructors_callable.Class7[builtins.int], def (x: builtins.str) -> constructors_callable.Class7[builtins.str])" -constructors_callable.py:182: note: Revealed type is "def [T] (x: builtins.list[T`1], y: builtins.list[T`1]) -> constructors_callable.Class8[T`1]" -constructors_callable.py:184: error: Cannot infer function type argument [misc] -constructors_callable.py:193: note: Revealed type is "def [T] (x: builtins.list[T`-1], y: builtins.list[T`-1]) -> constructors_callable.Class9" -constructors_callable.py:195: error: Cannot infer function type argument [misc] +constructors_callable.py:64: note: Revealed type is "def (x: int) -> constructors_callable.Class3" +constructors_callable.py:66: error: Too few arguments [call-arg] +constructors_callable.py:67: error: Unexpected keyword argument "y" [call-arg] +constructors_callable.py:68: error: Too many arguments [call-arg] +constructors_callable.py:74: error: Incompatible return type for "__new__" (returns "int", but must return a subtype of "Class4") [misc] +constructors_callable.py:79: note: Revealed type is "def (x: int) -> int" +constructors_callable.py:81: error: Too few arguments [call-arg] +constructors_callable.py:82: error: Unexpected keyword argument "y" [call-arg] +constructors_callable.py:99: note: Revealed type is "def (*args: Any, **kwargs: Any) -> constructors_callable.Class5" +constructors_callable.py:102: error: Expression is of type "Class5", not "Never" [assert-type] +constructors_callable.py:107: error: Expression is of type "Class5", not "Never" [assert-type] +constructors_callable.py:118: error: Incompatible return type for "__new__" (returns "Class6Proxy", but must return a subtype of "Class6") [misc] +constructors_callable.py:127: note: Revealed type is "def (x: int) -> constructors_callable.Class6" +constructors_callable.py:128: error: Expression is of type "Class6", not "Class6Proxy" [assert-type] +constructors_callable.py:128: error: Too few arguments [call-arg] +constructors_callable.py:144: note: Revealed type is "def (x: int) -> constructors_callable.Class6Any" +constructors_callable.py:145: error: Expression is of type "Class6Any", not "Any" [assert-type] +constructors_callable.py:145: error: Too few arguments [call-arg] +constructors_callable.py:164: note: Revealed type is "Overload(def (x: int) -> constructors_callable.Class7[int], def (x: str) -> constructors_callable.Class7[str])" +constructors_callable.py:184: note: Revealed type is "def [T] (x: list[T], y: list[T]) -> constructors_callable.Class8[T]" +constructors_callable.py:185: error: Argument 2 has incompatible type "str"; expected "list[str]" [arg-type] +constructors_callable.py:187: error: Cannot infer function type argument [misc] +constructors_callable.py:196: note: Revealed type is "def [T] (x: list[T], y: list[T]) -> constructors_callable.Class9" +constructors_callable.py:197: error: Argument 2 has incompatible type "str"; expected "list[str]" [arg-type] +constructors_callable.py:199: error: Cannot infer function type argument [misc] """ diff --git a/conformance/results/mypy/constructors_consistency.toml b/conformance/results/mypy/constructors_consistency.toml index 225d7847a..5195baef1 100644 --- a/conformance/results/mypy/constructors_consistency.toml +++ b/conformance/results/mypy/constructors_consistency.toml @@ -1,4 +1,9 @@ conformant = "Pass" notes = """ -Does not report inconsistency between __new__ and __init__ (optional). +Does not report inconsistency between `__new__` and `__init__` (optional). +""" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ """ diff --git a/conformance/results/mypy/dataclasses_descriptors.toml b/conformance/results/mypy/dataclasses_descriptors.toml index 6e02a182d..e47310293 100644 --- a/conformance/results/mypy/dataclasses_descriptors.toml +++ b/conformance/results/mypy/dataclasses_descriptors.toml @@ -1,13 +1,18 @@ conformant = "Partial" notes = """ +Assumes descriptor behavior only when field is assigned in class body. Does not correctly evaluate type of descriptor access. """ output = """ +dataclasses_descriptors.py:61: error: Cannot access instance-only attribute "x" on class object [misc] +dataclasses_descriptors.py:62: error: Cannot access instance-only attribute "y" on class object [misc] dataclasses_descriptors.py:66: error: Expression is of type "Desc2[int]", not "int" [assert-type] dataclasses_descriptors.py:67: error: Expression is of type "Desc2[str]", not "str" [assert-type] """ conformance_automated = "Fail" errors_diff = """ +Line 61: Unexpected errors ['dataclasses_descriptors.py:61: error: Cannot access instance-only attribute "x" on class object [misc]'] +Line 62: Unexpected errors ['dataclasses_descriptors.py:62: error: Cannot access instance-only attribute "y" on class object [misc]'] Line 66: Unexpected errors ['dataclasses_descriptors.py:66: error: Expression is of type "Desc2[int]", not "int" [assert-type]'] Line 67: Unexpected errors ['dataclasses_descriptors.py:67: error: Expression is of type "Desc2[str]", not "str" [assert-type]'] """ diff --git a/conformance/results/mypy/dataclasses_final.toml b/conformance/results/mypy/dataclasses_final.toml index fdf86919a..ea61c82bc 100644 --- a/conformance/results/mypy/dataclasses_final.toml +++ b/conformance/results/mypy/dataclasses_final.toml @@ -1,17 +1,15 @@ conformant = "Partial" notes = """ -Wrongly requires a Final dataclass field to be initialized at class level. -Doesn't support Final nested inside ClassVar. +Wrongly requires a `Final` dataclass field to be initialized at class level. +Doesn't support `Final` nested inside `ClassVar`. """ conformance_automated = "Fail" errors_diff = """ Line 27: Expected 1 errors -Line 16: Unexpected errors ['dataclasses_final.py:16: error: Final name must be initialized with a value [misc]'] Line 18: Unexpected errors ['dataclasses_final.py:18: error: Final can be only used as an outermost qualifier in a variable annotation [valid-type]'] Line 24: Unexpected errors ['dataclasses_final.py:24: error: Expression is of type "Any", not "int" [assert-type]'] """ output = """ -dataclasses_final.py:16: error: Final name must be initialized with a value [misc] dataclasses_final.py:18: error: Final can be only used as an outermost qualifier in a variable annotation [valid-type] dataclasses_final.py:24: error: Expression is of type "Any", not "int" [assert-type] dataclasses_final.py:35: error: Cannot assign to final attribute "final_no_default" [misc] diff --git a/conformance/results/mypy/dataclasses_frozen.toml b/conformance/results/mypy/dataclasses_frozen.toml index 9ea054ded..465a17f6f 100644 --- a/conformance/results/mypy/dataclasses_frozen.toml +++ b/conformance/results/mypy/dataclasses_frozen.toml @@ -2,8 +2,8 @@ conformant = "Pass" output = """ dataclasses_frozen.py:16: error: Property "a" defined in "DC1" is read-only [misc] dataclasses_frozen.py:17: error: Property "b" defined in "DC1" is read-only [misc] -dataclasses_frozen.py:23: error: Cannot inherit non-frozen dataclass from a frozen one [misc] -dataclasses_frozen.py:33: error: Cannot inherit frozen dataclass from a non-frozen one [misc] +dataclasses_frozen.py:23: error: Non-frozen dataclass cannot inherit from a frozen dataclass [misc] +dataclasses_frozen.py:33: error: Frozen dataclass cannot inherit from a non-frozen dataclass [misc] """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/mypy/dataclasses_hash.toml b/conformance/results/mypy/dataclasses_hash.toml index 7af6dcbdc..e4c6a663f 100644 --- a/conformance/results/mypy/dataclasses_hash.toml +++ b/conformance/results/mypy/dataclasses_hash.toml @@ -1,11 +1,19 @@ -conformant = "Partial" +conformant = "Unsupported" notes = """ -Does not report when dataclass is not compatible with Hashable protocol. +Does not synthesize `__hash__ = None` as a class attribute for unhashable dataclasses. +Does not report when an unhashable dataclass has `__hash__` called directly on an instance. +Does not report when dataclass is not compatible with `Hashable` protocol. """ output = """ +dataclasses_hash.py:14: error: Expression is of type "Callable[[object], int]", not "None" [assert-type] +dataclasses_hash.py:36: error: Expression is of type "Callable[[object], int]", not "None" [assert-type] """ conformance_automated = "Fail" errors_diff = """ -Line 15: Expected 1 errors -Line 32: Expected 1 errors +Line 17: Expected 1 errors +Line 18: Expected 1 errors +Line 39: Expected 1 errors +Line 40: Expected 1 errors +Line 14: Unexpected errors ['dataclasses_hash.py:14: error: Expression is of type "Callable[[object], int]", not "None" [assert-type]'] +Line 36: Unexpected errors ['dataclasses_hash.py:36: error: Expression is of type "Callable[[object], int]", not "None" [assert-type]'] """ diff --git a/conformance/results/mypy/dataclasses_inheritance.toml b/conformance/results/mypy/dataclasses_inheritance.toml index 5f7dcc312..c90115220 100644 --- a/conformance/results/mypy/dataclasses_inheritance.toml +++ b/conformance/results/mypy/dataclasses_inheritance.toml @@ -1,7 +1,7 @@ conformant = "Pass" output = """ -dataclasses_inheritance.py:60: error: Cannot override instance variable (previously declared on base class "DC6") with class variable [misc] -dataclasses_inheritance.py:64: error: Cannot override class variable (previously declared on base class "DC6") with instance variable [misc] +dataclasses_inheritance.py:62: error: Cannot override instance variable (previously declared on base class "DC6") with class variable [misc] +dataclasses_inheritance.py:66: error: Cannot override class variable (previously declared on base class "DC6") with instance variable [misc] """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/mypy/dataclasses_kwonly.toml b/conformance/results/mypy/dataclasses_kwonly.toml index 118448df3..f0ac9ba4b 100644 --- a/conformance/results/mypy/dataclasses_kwonly.toml +++ b/conformance/results/mypy/dataclasses_kwonly.toml @@ -1,24 +1,9 @@ -conformant = "Partial" -notes = """ -Incorrectly rejects kw_only field with default before positional field. -""" +conformant = "Pass" output = """ -dataclasses_kwonly.py:23: error: Too many positional arguments for "DC1" [misc] -dataclasses_kwonly.py:29: error: Attributes without a default cannot follow attributes with one [misc] -dataclasses_kwonly.py:32: error: Too many positional arguments for "DC2" [misc] -dataclasses_kwonly.py:32: error: Too few arguments for "DC2" [call-arg] -dataclasses_kwonly.py:32: error: Argument 1 to "DC2" has incompatible type "str"; expected "int" [arg-type] -dataclasses_kwonly.py:35: error: "DC2" gets multiple values for keyword argument "b" [misc] -dataclasses_kwonly.py:35: error: Too few arguments for "DC2" [call-arg] -dataclasses_kwonly.py:35: error: Argument 1 to "DC2" has incompatible type "str"; expected "int" [arg-type] -dataclasses_kwonly.py:38: error: Too many positional arguments for "DC2" [misc] -dataclasses_kwonly.py:38: error: Argument 1 to "DC2" has incompatible type "str"; expected "int" [arg-type] -dataclasses_kwonly.py:38: error: Argument 2 to "DC2" has incompatible type "int"; expected "str" [arg-type] -dataclasses_kwonly.py:53: error: Too many positional arguments for "DC3" [misc] +dataclasses_kwonly.py:23: error: Too many positional arguments for "DC1" [call-arg] +dataclasses_kwonly.py:38: error: Too many positional arguments for "DC2" [call-arg] +dataclasses_kwonly.py:53: error: Too many positional arguments for "DC3" [call-arg] """ -conformance_automated = "Fail" +conformance_automated = "Pass" errors_diff = """ -Line 29: Unexpected errors ['dataclasses_kwonly.py:29: error: Attributes without a default cannot follow attributes with one [misc]'] -Line 32: Unexpected errors ['dataclasses_kwonly.py:32: error: Too many positional arguments for "DC2" [misc]', 'dataclasses_kwonly.py:32: error: Too few arguments for "DC2" [call-arg]', 'dataclasses_kwonly.py:32: error: Argument 1 to "DC2" has incompatible type "str"; expected "int" [arg-type]'] -Line 35: Unexpected errors ['dataclasses_kwonly.py:35: error: "DC2" gets multiple values for keyword argument "b" [misc]', 'dataclasses_kwonly.py:35: error: Too few arguments for "DC2" [call-arg]', 'dataclasses_kwonly.py:35: error: Argument 1 to "DC2" has incompatible type "str"; expected "int" [arg-type]'] """ diff --git a/conformance/results/mypy/dataclasses_match_args.toml b/conformance/results/mypy/dataclasses_match_args.toml new file mode 100644 index 000000000..1309854f5 --- /dev/null +++ b/conformance/results/mypy/dataclasses_match_args.toml @@ -0,0 +1,7 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_match_args.py:42: error: "type[DC4]" has no attribute "__match_args__" [attr-defined] +""" diff --git a/conformance/results/mypy/dataclasses_slots.toml b/conformance/results/mypy/dataclasses_slots.toml index 4a6d76337..7addfa5c1 100644 --- a/conformance/results/mypy/dataclasses_slots.toml +++ b/conformance/results/mypy/dataclasses_slots.toml @@ -1,6 +1,6 @@ conformant = "Partial" notes = """ -Does not reject write to instance variable that is not defined in __slots__. +Does not reject write to instance variable that is not defined in `__slots__`. """ output = """ dataclasses_slots.py:11: error: "DC1" both defines "__slots__" and is used with "slots=True" [misc] diff --git a/conformance/results/mypy/dataclasses_transform_class.toml b/conformance/results/mypy/dataclasses_transform_class.toml index 73d6f16ce..3c934ec91 100644 --- a/conformance/results/mypy/dataclasses_transform_class.toml +++ b/conformance/results/mypy/dataclasses_transform_class.toml @@ -1,11 +1,11 @@ conformant = "Pass" output = """ -dataclasses_transform_class.py:48: error: Cannot inherit non-frozen dataclass from a frozen one [misc] -dataclasses_transform_class.py:60: error: Property "id" defined in "Customer1" is read-only [misc] -dataclasses_transform_class.py:63: error: Too many positional arguments for "Customer1" [misc] -dataclasses_transform_class.py:69: error: Unsupported left operand type for < ("Customer1") [operator] -dataclasses_transform_class.py:79: error: Too many positional arguments for "Customer2" [misc] -dataclasses_transform_class.py:119: error: Property "id" defined in "Customer3" is read-only [misc] +dataclasses_transform_class.py:51: error: Non-frozen dataclass cannot inherit from a frozen dataclass [misc] +dataclasses_transform_class.py:63: error: Property "id" defined in "Customer1" is read-only [misc] +dataclasses_transform_class.py:66: error: Too many positional arguments for "Customer1" [call-arg] +dataclasses_transform_class.py:72: error: Unsupported left operand type for < ("Customer1") [operator] +dataclasses_transform_class.py:82: error: Too many positional arguments for "Customer2" [call-arg] +dataclasses_transform_class.py:122: error: Property "id" defined in "Customer3" is read-only [misc] """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/mypy/dataclasses_transform_converter.toml b/conformance/results/mypy/dataclasses_transform_converter.toml new file mode 100644 index 000000000..fc5633e50 --- /dev/null +++ b/conformance/results/mypy/dataclasses_transform_converter.toml @@ -0,0 +1,48 @@ +conformant = "Unsupported" +notes = """ +Converter parameter not yet supported. +""" +conformance_automated = "Fail" +errors_diff = """ +Line 118: Expected 1 errors +Line 112: Unexpected errors ['dataclasses_transform_converter.py:112: error: Argument 1 to "DC2" has incompatible type "str"; expected "int" [arg-type]', 'dataclasses_transform_converter.py:112: error: Argument 2 to "DC2" has incompatible type "str"; expected "int" [arg-type]', 'dataclasses_transform_converter.py:112: error: Argument 3 to "DC2" has incompatible type "str"; expected "int" [arg-type]', 'dataclasses_transform_converter.py:112: error: Argument 4 to "DC2" has incompatible type "bytes"; expected "ConverterClass" [arg-type]', 'dataclasses_transform_converter.py:112: error: Argument 5 to "DC2" has incompatible type "list[Never]"; expected "int" [arg-type]'] +Line 114: Unexpected errors ['dataclasses_transform_converter.py:114: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]'] +Line 115: Unexpected errors ['dataclasses_transform_converter.py:115: error: Incompatible types in assignment (expression has type "str", variable has type "ConverterClass") [assignment]'] +Line 116: Unexpected errors ['dataclasses_transform_converter.py:116: error: Incompatible types in assignment (expression has type "bytes", variable has type "ConverterClass") [assignment]'] +Line 121: Unexpected errors ['dataclasses_transform_converter.py:121: error: Argument 1 to "DC2" has incompatible type "str"; expected "int" [arg-type]', 'dataclasses_transform_converter.py:121: error: Argument 2 to "DC2" has incompatible type "str"; expected "int" [arg-type]', 'dataclasses_transform_converter.py:121: error: Argument 3 to "DC2" has incompatible type "str"; expected "int" [arg-type]', 'dataclasses_transform_converter.py:121: error: Argument 4 to "DC2" has incompatible type "str"; expected "ConverterClass" [arg-type]', 'dataclasses_transform_converter.py:121: error: Argument 5 to "DC2" has incompatible type "str"; expected "int" [arg-type]', 'dataclasses_transform_converter.py:121: error: Argument 6 to "DC2" has incompatible type "tuple[tuple[str, str], tuple[str, str]]"; expected "dict[str, str]" [arg-type]'] +""" +output = """ +dataclasses_transform_converter.py:48: error: Argument "converter" to "model_field" has incompatible type "Callable[[], int]"; expected "Callable[[Never], int]" [arg-type] +dataclasses_transform_converter.py:49: error: Argument "converter" to "model_field" has incompatible type "def bad_converter2(*, x: int) -> int"; expected "Callable[[Never], int]" [arg-type] +dataclasses_transform_converter.py:107: error: Argument 2 to "DC2" has incompatible type "str"; expected "int" [arg-type] +dataclasses_transform_converter.py:107: error: Argument 3 to "DC2" has incompatible type "str"; expected "int" [arg-type] +dataclasses_transform_converter.py:107: error: Argument 4 to "DC2" has incompatible type "bytes"; expected "ConverterClass" [arg-type] +dataclasses_transform_converter.py:107: error: Argument 5 to "DC2" has incompatible type "list[Never]"; expected "int" [arg-type] +dataclasses_transform_converter.py:108: error: Argument 1 to "DC2" has incompatible type "str"; expected "int" [arg-type] +dataclasses_transform_converter.py:108: error: Argument 2 to "DC2" has incompatible type "str"; expected "int" [arg-type] +dataclasses_transform_converter.py:108: error: Argument 3 to "DC2" has incompatible type "str"; expected "int" [arg-type] +dataclasses_transform_converter.py:108: error: Argument 4 to "DC2" has incompatible type "int"; expected "ConverterClass" [arg-type] +dataclasses_transform_converter.py:108: error: Argument 5 to "DC2" has incompatible type "list[Never]"; expected "int" [arg-type] +dataclasses_transform_converter.py:109: error: Argument 1 to "DC2" has incompatible type "str"; expected "int" [arg-type] +dataclasses_transform_converter.py:109: error: Argument 2 to "DC2" has incompatible type "str"; expected "int" [arg-type] +dataclasses_transform_converter.py:109: error: Argument 3 to "DC2" has incompatible type "str"; expected "int" [arg-type] +dataclasses_transform_converter.py:109: error: Argument 4 to "DC2" has incompatible type "str"; expected "ConverterClass" [arg-type] +dataclasses_transform_converter.py:109: error: Argument 5 to "DC2" has incompatible type "complex"; expected "int" [arg-type] +dataclasses_transform_converter.py:112: error: Argument 1 to "DC2" has incompatible type "str"; expected "int" [arg-type] +dataclasses_transform_converter.py:112: error: Argument 2 to "DC2" has incompatible type "str"; expected "int" [arg-type] +dataclasses_transform_converter.py:112: error: Argument 3 to "DC2" has incompatible type "str"; expected "int" [arg-type] +dataclasses_transform_converter.py:112: error: Argument 4 to "DC2" has incompatible type "bytes"; expected "ConverterClass" [arg-type] +dataclasses_transform_converter.py:112: error: Argument 5 to "DC2" has incompatible type "list[Never]"; expected "int" [arg-type] +dataclasses_transform_converter.py:114: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] +dataclasses_transform_converter.py:115: error: Incompatible types in assignment (expression has type "str", variable has type "ConverterClass") [assignment] +dataclasses_transform_converter.py:116: error: Incompatible types in assignment (expression has type "bytes", variable has type "ConverterClass") [assignment] +dataclasses_transform_converter.py:119: error: Incompatible types in assignment (expression has type "int", variable has type "ConverterClass") [assignment] +dataclasses_transform_converter.py:121: error: Argument 1 to "DC2" has incompatible type "str"; expected "int" [arg-type] +dataclasses_transform_converter.py:121: error: Argument 2 to "DC2" has incompatible type "str"; expected "int" [arg-type] +dataclasses_transform_converter.py:121: error: Argument 3 to "DC2" has incompatible type "str"; expected "int" [arg-type] +dataclasses_transform_converter.py:121: error: Argument 4 to "DC2" has incompatible type "str"; expected "ConverterClass" [arg-type] +dataclasses_transform_converter.py:121: error: Argument 5 to "DC2" has incompatible type "str"; expected "int" [arg-type] +dataclasses_transform_converter.py:121: error: Argument 6 to "DC2" has incompatible type "tuple[tuple[str, str], tuple[str, str]]"; expected "dict[str, str]" [arg-type] +dataclasses_transform_converter.py:130: error: Argument "converter" to "model_field" has incompatible type "Callable[[str], int]"; expected "Callable[[int], int]" [arg-type] +dataclasses_transform_converter.py:133: error: Cannot infer value of type parameter "S" of "model_field" [misc] +""" diff --git a/conformance/results/mypy/dataclasses_transform_field.toml b/conformance/results/mypy/dataclasses_transform_field.toml index bcc6b6069..6743d00f5 100644 --- a/conformance/results/mypy/dataclasses_transform_field.toml +++ b/conformance/results/mypy/dataclasses_transform_field.toml @@ -4,7 +4,7 @@ Does not properly handle field constructor that has default value for `kw_only` """ output = """ dataclasses_transform_field.py:64: error: Unexpected keyword argument "id" for "CustomerModel1" [call-arg] -dataclasses_transform_field.py:75: error: Too many positional arguments for "CustomerModel2" [misc] +dataclasses_transform_field.py:75: error: Too many positional arguments for "CustomerModel2" [call-arg] dataclasses_transform_field.py:75: error: Missing named argument "name" for "CustomerModel2" [call-arg] dataclasses_transform_field.py:77: error: Missing named argument "id" for "CustomerModel2" [call-arg] """ diff --git a/conformance/results/mypy/dataclasses_transform_func.toml b/conformance/results/mypy/dataclasses_transform_func.toml index c15824b79..46ba5c856 100644 --- a/conformance/results/mypy/dataclasses_transform_func.toml +++ b/conformance/results/mypy/dataclasses_transform_func.toml @@ -4,15 +4,15 @@ Does not handle `kw_only=False` override when `kw_only_default=True`. Does not report error when `order=False` and comparison operators are used. """ output = """ -dataclasses_transform_func.py:53: error: Too many positional arguments for "Customer1" [misc] -dataclasses_transform_func.py:57: error: Incompatible types in assignment (expression has type "int", variable has type "str") [assignment] -dataclasses_transform_func.py:65: error: Unexpected keyword argument "salary" for "Customer1" [call-arg] -dataclasses_transform_func.py:71: error: Too many positional arguments for "Customer2" [misc] -dataclasses_transform_func.py:90: error: Cannot inherit non-frozen dataclass from a frozen one [misc] -dataclasses_transform_func.py:97: error: Property "id" defined in "Customer3" is read-only [misc] +dataclasses_transform_func.py:52: error: Too many positional arguments for "Customer1" [call-arg] +dataclasses_transform_func.py:56: error: Incompatible types in assignment (expression has type "int", variable has type "str") [assignment] +dataclasses_transform_func.py:64: error: Unexpected keyword argument "salary" for "Customer1" [call-arg] +dataclasses_transform_func.py:70: error: Too many positional arguments for "Customer2" [call-arg] +dataclasses_transform_func.py:89: error: Non-frozen dataclass cannot inherit from a frozen dataclass [misc] +dataclasses_transform_func.py:96: error: Property "id" defined in "Customer3" is read-only [misc] """ conformance_automated = "Fail" errors_diff = """ -Line 61: Expected 1 errors -Line 53: Unexpected errors ['dataclasses_transform_func.py:53: error: Too many positional arguments for "Customer1" [misc]'] +Line 60: Expected 1 errors +Line 52: Unexpected errors ['dataclasses_transform_func.py:52: error: Too many positional arguments for "Customer1" [call-arg]'] """ diff --git a/conformance/results/mypy/dataclasses_transform_meta.toml b/conformance/results/mypy/dataclasses_transform_meta.toml index 27f979e0d..92bcd1a3d 100644 --- a/conformance/results/mypy/dataclasses_transform_meta.toml +++ b/conformance/results/mypy/dataclasses_transform_meta.toml @@ -1,11 +1,11 @@ conformant = "Pass" output = """ -dataclasses_transform_meta.py:48: error: Cannot inherit non-frozen dataclass from a frozen one [misc] -dataclasses_transform_meta.py:60: error: Property "id" defined in "Customer1" is read-only [misc] -dataclasses_transform_meta.py:63: error: Too many positional arguments for "Customer1" [misc] -dataclasses_transform_meta.py:70: error: Unsupported left operand type for < ("Customer1") [operator] -dataclasses_transform_meta.py:80: error: Too many positional arguments for "Customer2" [misc] -dataclasses_transform_meta.py:100: error: Property "id" defined in "Customer3" is read-only [misc] +dataclasses_transform_meta.py:51: error: Non-frozen dataclass cannot inherit from a frozen dataclass [misc] +dataclasses_transform_meta.py:63: error: Property "id" defined in "Customer1" is read-only [misc] +dataclasses_transform_meta.py:66: error: Too many positional arguments for "Customer1" [call-arg] +dataclasses_transform_meta.py:73: error: Unsupported left operand type for < ("Customer1") [operator] +dataclasses_transform_meta.py:83: error: Too many positional arguments for "Customer2" [call-arg] +dataclasses_transform_meta.py:103: error: Property "id" defined in "Customer3" is read-only [misc] """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/mypy/dataclasses_usage.toml b/conformance/results/mypy/dataclasses_usage.toml index 72bf10a7c..25f6f3026 100644 --- a/conformance/results/mypy/dataclasses_usage.toml +++ b/conformance/results/mypy/dataclasses_usage.toml @@ -3,18 +3,19 @@ notes = """ Does not detect unannotated usage of `dataclasses.field()`. """ output = """ -dataclasses_usage.py:35: error: Accessing "__init__" on an instance is unsound, since instance.__init__ could be from an incompatible subclass [misc] -dataclasses_usage.py:50: error: Missing positional argument "unit_price" in call to "InventoryItem" [call-arg] -dataclasses_usage.py:51: error: Argument 2 to "InventoryItem" has incompatible type "str"; expected "float" [arg-type] -dataclasses_usage.py:52: error: Too many arguments for "InventoryItem" [call-arg] -dataclasses_usage.py:61: error: Attributes without a default cannot follow attributes with one [misc] -dataclasses_usage.py:67: error: Attributes without a default cannot follow attributes with one [misc] -dataclasses_usage.py:73: error: Attributes without a default cannot follow attributes with one [misc] -dataclasses_usage.py:83: error: Too many arguments for "DC4" [call-arg] -dataclasses_usage.py:88: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] -dataclasses_usage.py:126: error: Too many arguments for "DC7" [call-arg] -dataclasses_usage.py:129: error: Missing positional argument "y" in call to "DC8" [call-arg] -dataclasses_usage.py:178: error: Too many arguments for "DC13" [call-arg] +dataclasses_usage.py:36: error: Accessing "__init__" on an instance is unsound, since instance.__init__ could be from an incompatible subclass [misc] +dataclasses_usage.py:51: error: Missing positional argument "unit_price" in call to "InventoryItem" [call-arg] +dataclasses_usage.py:52: error: Argument 2 to "InventoryItem" has incompatible type "str"; expected "float" [arg-type] +dataclasses_usage.py:53: error: Too many arguments for "InventoryItem" [call-arg] +dataclasses_usage.py:62: error: Attributes without a default cannot follow attributes with one [misc] +dataclasses_usage.py:68: error: Attributes without a default cannot follow attributes with one [misc] +dataclasses_usage.py:74: error: Attributes without a default cannot follow attributes with one [misc] +dataclasses_usage.py:84: error: Too many arguments for "DC4" [call-arg] +dataclasses_usage.py:89: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] +dataclasses_usage.py:128: error: Too many arguments for "DC7" [call-arg] +dataclasses_usage.py:131: error: Missing positional argument "y" in call to "DC8" [call-arg] +dataclasses_usage.py:180: error: Too many arguments for "DC13" [call-arg] +dataclasses_usage.py:246: error: Too many arguments for "DC19" [call-arg] """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/mypy/directives_assert_type.toml b/conformance/results/mypy/directives_assert_type.toml index a8feed5ee..61e4a8a27 100644 --- a/conformance/results/mypy/directives_assert_type.toml +++ b/conformance/results/mypy/directives_assert_type.toml @@ -1,13 +1,14 @@ conformant = "Pass" output = """ directives_assert_type.py:27: error: Expression is of type "int | str", not "int" [assert-type] -directives_assert_type.py:28: error: Expression is of type "Any", not "int" [assert-type] -directives_assert_type.py:29: error: Expression is of type "Literal[4]", not "int" [assert-type] -directives_assert_type.py:31: error: "assert_type" expects 2 arguments [misc] -directives_assert_type.py:31: error: Too few arguments for "assert_type" [call-arg] -directives_assert_type.py:32: error: Expression is of type "Literal['']", not "int" [assert-type] -directives_assert_type.py:33: error: "assert_type" expects 2 arguments [misc] -directives_assert_type.py:33: error: Too many arguments for "assert_type" [call-arg] +directives_assert_type.py:28: error: Expression is of type "int | str", not "Any" [assert-type] +directives_assert_type.py:29: error: Expression is of type "Any", not "int" [assert-type] +directives_assert_type.py:30: error: Expression is of type "Literal[4]", not "int" [assert-type] +directives_assert_type.py:32: error: "assert_type" expects 2 arguments [misc] +directives_assert_type.py:32: error: Too few arguments for "assert_type" [call-arg] +directives_assert_type.py:33: error: Expression is of type "Literal['']", not "int" [assert-type] +directives_assert_type.py:34: error: "assert_type" expects 2 arguments [misc] +directives_assert_type.py:34: error: Too many arguments for "assert_type" [call-arg] """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/mypy/directives_deprecated.toml b/conformance/results/mypy/directives_deprecated.toml new file mode 100644 index 000000000..e7bec6ab7 --- /dev/null +++ b/conformance/results/mypy/directives_deprecated.toml @@ -0,0 +1,18 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +directives_deprecated.py:18: error: class _directives_deprecated_library.Ham is deprecated: Use Spam instead [deprecated] +directives_deprecated.py:24: error: function _directives_deprecated_library.norwegian_blue is deprecated: It is pining for the fjords [deprecated] +directives_deprecated.py:25: error: function _directives_deprecated_library.norwegian_blue is deprecated: It is pining for the fjords [deprecated] +directives_deprecated.py:30: error: overload def (x: int) -> str of function _directives_deprecated_library.foo is deprecated: Only str will be allowed [deprecated] +directives_deprecated.py:41: error: function _directives_deprecated_library.Spam.__add__ is deprecated: There is enough spam in the world [deprecated] +directives_deprecated.py:42: error: function _directives_deprecated_library.Spam.__add__ is deprecated: There is enough spam in the world [deprecated] +directives_deprecated.py:44: error: function _directives_deprecated_library.Spam.greasy is deprecated: All spam will be equally greasy [deprecated] +directives_deprecated.py:47: error: function _directives_deprecated_library.Spam.shape is deprecated: Shapes are becoming immutable [deprecated] +directives_deprecated.py:48: error: function _directives_deprecated_library.Spam.shape is deprecated: Shapes are becoming immutable [deprecated] +directives_deprecated.py:58: error: function directives_deprecated.Invocable.__call__ is deprecated: Deprecated [deprecated] +directives_deprecated.py:69: error: function directives_deprecated.lorem is deprecated: Deprecated [deprecated] +directives_deprecated.py:98: error: function directives_deprecated.SupportsFoo1.foo is deprecated: Deprecated [deprecated] +""" diff --git a/conformance/results/mypy/directives_disjoint_base.toml b/conformance/results/mypy/directives_disjoint_base.toml new file mode 100644 index 000000000..77e4345df --- /dev/null +++ b/conformance/results/mypy/directives_disjoint_base.toml @@ -0,0 +1,14 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +directives_disjoint_base.py:69: error: Class "LeftAndRight" has incompatible disjoint bases [misc] +directives_disjoint_base.py:73: error: Class "LeftChildAndRight" has incompatible disjoint bases [misc] +directives_disjoint_base.py:77: error: Class "LeftAndRightViaChild" has incompatible disjoint bases [misc] +directives_disjoint_base.py:81: error: Class "LeftRecord" has incompatible disjoint bases [misc] +directives_disjoint_base.py:105: error: Class "IncompatibleSlots" has incompatible disjoint bases [misc] +directives_disjoint_base.py:113: error: Value of type variable "_TC" of "disjoint_base" cannot be "Callable[[], None]" [type-var] +directives_disjoint_base.py:118: error: @disjoint_base cannot be used with TypedDict [misc] +directives_disjoint_base.py:123: error: @disjoint_base cannot be used with protocol class [misc] +""" diff --git a/conformance/results/mypy/directives_reveal_type.toml b/conformance/results/mypy/directives_reveal_type.toml index 8621a0083..41a8c8720 100644 --- a/conformance/results/mypy/directives_reveal_type.toml +++ b/conformance/results/mypy/directives_reveal_type.toml @@ -1,7 +1,7 @@ conformant = "Pass" output = """ -directives_reveal_type.py:14: note: Revealed type is "Union[builtins.int, builtins.str]" -directives_reveal_type.py:15: note: Revealed type is "builtins.list[builtins.int]" +directives_reveal_type.py:14: note: Revealed type is "int | str" +directives_reveal_type.py:15: note: Revealed type is "list[int]" directives_reveal_type.py:16: note: Revealed type is "Any" directives_reveal_type.py:17: note: Revealed type is "directives_reveal_type.ForwardReference" directives_reveal_type.py:19: error: "reveal_type" expects 1 argument [misc] diff --git a/conformance/results/mypy/directives_type_ignore.toml b/conformance/results/mypy/directives_type_ignore.toml index 8dfefb377..1da66fa93 100644 --- a/conformance/results/mypy/directives_type_ignore.toml +++ b/conformance/results/mypy/directives_type_ignore.toml @@ -1,15 +1,14 @@ conformant = "Partial" notes = """ -Does not honor "# type: ignore" comment if comment includes additional text. +Does not honor `# type: ignore` comment if comment includes additional text. """ output = """ -directives_type_ignore.py:11: error: Invalid "type: ignore" comment [syntax] directives_type_ignore.py:11: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] -directives_type_ignore.py:14: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] -directives_type_ignore.py:14: note: Error code "assignment" not covered by "type: ignore" comment +directives_type_ignore.py:11: error: Invalid "type: ignore" comment [syntax] +directives_type_ignore.py:16: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] +directives_type_ignore.py:16: note: Error code "assignment" not covered by "type: ignore[an-empty-str-is-not-an-int]" comment """ conformance_automated = "Fail" errors_diff = """ -Line 11: Unexpected errors ['directives_type_ignore.py:11: error: Invalid "type: ignore" comment [syntax]', 'directives_type_ignore.py:11: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]'] -Line 14: Unexpected errors ['directives_type_ignore.py:14: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]'] +Line 11: Unexpected errors ['directives_type_ignore.py:11: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]', 'directives_type_ignore.py:11: error: Invalid "type: ignore" comment [syntax]'] """ diff --git a/conformance/results/mypy/directives_version_platform.toml b/conformance/results/mypy/directives_version_platform.toml index 7396a9dce..80c6eecff 100644 --- a/conformance/results/mypy/directives_version_platform.toml +++ b/conformance/results/mypy/directives_version_platform.toml @@ -1,13 +1,14 @@ conformant = "Pass" notes = """ -Does not understand three-element form of sys.version checks. -Does not understand os.name checks. +Does not understand three-element form of `sys.version` checks. +Does not understand `os.name` checks. """ output = """ -directives_version_platform.py:19: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] -directives_version_platform.py:27: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] -directives_version_platform.py:40: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] -directives_version_platform.py:45: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] +directives_version_platform.py:26: error: Expression is of type "int | str", not "int" [assert-type] +directives_version_platform.py:33: error: Name "val3" is not defined; did you mean "val13"? [name-defined] +directives_version_platform.py:42: error: Expression is of type "int | str", not "int" [assert-type] +directives_version_platform.py:50: error: Name "val6" is not defined [name-defined] +directives_version_platform.py:59: error: Name "val9" is not defined [name-defined] """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/mypy/enums_behaviors.toml b/conformance/results/mypy/enums_behaviors.toml new file mode 100644 index 000000000..a3193b611 --- /dev/null +++ b/conformance/results/mypy/enums_behaviors.toml @@ -0,0 +1,9 @@ +conformant = "Pass" +errors_diff = """ +""" +output = """ +enums_behaviors.py:28: error: Expression is of type "Color", not "Literal[Color.RED]" [assert-type] +enums_behaviors.py:32: error: Expression is of type "Color", not "Literal[Color.BLUE]" [assert-type] +enums_behaviors.py:44: error: Cannot extend enum with existing members: "Shape" [misc] +""" +conformance_automated = "Pass" diff --git a/conformance/results/mypy/enums_definition.toml b/conformance/results/mypy/enums_definition.toml new file mode 100644 index 000000000..06368c88e --- /dev/null +++ b/conformance/results/mypy/enums_definition.toml @@ -0,0 +1,7 @@ +conformant = "Pass" +errors_diff = """ +""" +output = """ +enums_definition.py:92: error: "type[Color12]" has no attribute "BLUE" [attr-defined] +""" +conformance_automated = "Pass" diff --git a/conformance/results/mypy/enums_expansion.toml b/conformance/results/mypy/enums_expansion.toml new file mode 100644 index 000000000..b14b1afd2 --- /dev/null +++ b/conformance/results/mypy/enums_expansion.toml @@ -0,0 +1,12 @@ +conformant = "Partial" +notes = """ +Improperly applies narrowing to `Flag` subclass. +""" +conformance_automated = "Fail" +errors_diff = """ +Line 56: Expected 1 errors +Line 55: Unexpected errors ['enums_expansion.py:55: error: Expression is of type "Literal[CustomFlags.FLAG3]", not "CustomFlags" [assert-type]'] +""" +output = """ +enums_expansion.py:55: error: Expression is of type "Literal[CustomFlags.FLAG3]", not "CustomFlags" [assert-type] +""" diff --git a/conformance/results/mypy/enums_member_names.toml b/conformance/results/mypy/enums_member_names.toml new file mode 100644 index 000000000..fc838dc78 --- /dev/null +++ b/conformance/results/mypy/enums_member_names.toml @@ -0,0 +1,11 @@ +conformant = "Pass" +notes = """ +Does not support special-cased handling of member name literal types in some cases (optional). +""" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +enums_member_names.py:26: error: Expression is of type "str", not "Literal['RED', 'BLUE']" [assert-type] +enums_member_names.py:30: error: Expression is of type "str", not "Literal['RED', 'BLUE', 'GREEN']" [assert-type] +""" diff --git a/conformance/results/mypy/enums_member_values.toml b/conformance/results/mypy/enums_member_values.toml new file mode 100644 index 000000000..f6ddcffe7 --- /dev/null +++ b/conformance/results/mypy/enums_member_values.toml @@ -0,0 +1,15 @@ +conformant = "Partial" +notes = """ +Does not enforce declared type of `_value_`. +Does not enforce assigned tuple types for enum members (optional). +""" +conformance_automated = "Fail" +errors_diff = """ +Line 78: Expected 1 errors +""" +output = """ +enums_member_values.py:26: error: Expression is of type "Any", not "Literal[1, 3]" [assert-type] +enums_member_values.py:54: error: Expression is of type "tuple[int, float, float]", not "Literal[1]" [assert-type] +enums_member_values.py:68: error: Expression is of type "int", not "Literal[1]" [assert-type] +enums_member_values.py:85: error: Incompatible types in assignment (expression has type "int", variable has type "str") [assignment] +""" diff --git a/conformance/results/mypy/enums_members.toml b/conformance/results/mypy/enums_members.toml new file mode 100644 index 000000000..e1b2b5349 --- /dev/null +++ b/conformance/results/mypy/enums_members.toml @@ -0,0 +1,31 @@ +conformant = "Partial" +notes = """ +Does not treat attribute with annotation and no assignment as non-member. +Does not treat callables as non-members. +Does not honor `enum.member` as method decorator. +Does not properly handle aliased enum members. +Does not support `_ignore_` mechanism (optional). +Does not treat attributes with private names as non-members. +""" +conformance_automated = "Fail" +errors_diff = """ +Line 86: Expected 1 errors +Line 87: Expected 1 errors +Line 133: Expected 1 errors +Line 104: Unexpected errors ['enums_members.py:104: error: Expression is of type "Literal[TrafficLight.AMBER]", not "Literal[TrafficLight.YELLOW]" [assert-type]'] +Line 121: Unexpected errors ['enums_members.py:121: error: Expression is of type "member[Callable[[Example], None]]", not "Any" [assert-type]', 'enums_members.py:121: error: Parameter 1 of Literal[...] is invalid [valid-type]'] +""" +output = """ +enums_members.py:54: error: Enum members must be left unannotated [misc] +enums_members.py:54: note: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members +enums_members.py:88: error: Parameter 1 of Literal[...] is invalid [valid-type] +enums_members.py:89: error: Parameter 1 of Literal[...] is invalid [valid-type] +enums_members.py:104: error: Expression is of type "Literal[TrafficLight.AMBER]", not "Literal[TrafficLight.YELLOW]" [assert-type] +enums_members.py:120: error: Expression is of type "int", not "Literal[Example.b]" [assert-type] +enums_members.py:121: error: Expression is of type "member[Callable[[Example], None]]", not "Any" [assert-type] +enums_members.py:121: error: Parameter 1 of Literal[...] is invalid [valid-type] +enums_members.py:132: note: Revealed type is "Any" +enums_members.py:132: note: 'reveal_type' always outputs 'Any' in unchecked functions +enums_members.py:150: error: Expression is of type "Literal[Pet5.DOG]", not "int" [assert-type] +enums_members.py:151: error: Expression is of type "Literal[Pet5.FISH]", not "int" [assert-type] +""" diff --git a/conformance/results/mypy/exceptions_context_managers.toml b/conformance/results/mypy/exceptions_context_managers.toml index cd630cbf5..513dbe853 100644 --- a/conformance/results/mypy/exceptions_context_managers.toml +++ b/conformance/results/mypy/exceptions_context_managers.toml @@ -3,3 +3,4 @@ errors_diff = """ """ output = """ """ +conformance_automated = "Pass" diff --git a/conformance/results/mypy/generics_base_class.toml b/conformance/results/mypy/generics_base_class.toml index 7d1dbad82..a0c547eeb 100644 --- a/conformance/results/mypy/generics_base_class.toml +++ b/conformance/results/mypy/generics_base_class.toml @@ -1,4 +1,7 @@ -conformant = "Pass" +conformant = "Partial" +notes = """ +Does not detect inconsistent type variable ordering. +""" output = """ generics_base_class.py:26: error: Argument 1 to "takes_dict_incorrect" has incompatible type "SymbolTable"; expected "dict[str, list[object]]" [arg-type] generics_base_class.py:29: error: Variable "typing.Generic" is not valid as a type [valid-type] @@ -9,6 +12,7 @@ generics_base_class.py:49: error: "LinkedList" expects 1 type argument, but 2 gi generics_base_class.py:61: error: "MyDict" expects 1 type argument, but 2 given [type-arg] generics_base_class.py:68: error: Duplicate type variables in Generic[...] or Protocol[...] [misc] """ -conformance_automated = "Pass" +conformance_automated = "Fail" errors_diff = """ +Line 98: Expected 1 errors """ diff --git a/conformance/results/mypy/generics_basic.toml b/conformance/results/mypy/generics_basic.toml index 024c77561..f850976ed 100644 --- a/conformance/results/mypy/generics_basic.toml +++ b/conformance/results/mypy/generics_basic.toml @@ -1,21 +1,29 @@ -conformant = "Partial" -notes = """ -Does not reject the use of a constraint parameterized by another type variable. -""" +conformant = "Pass" output = """ generics_basic.py:40: error: Value of type variable "AnyStr" of "concat" cannot be "Sequence[object]" [type-var] generics_basic.py:41: error: Value of type variable "AnyStr" of "concat" cannot be "Sequence[object]" [type-var] -generics_basic.py:49: error: TypeVar cannot have only a single constraint [misc] +generics_basic.py:49: error: Type variable must have at least two constrained types [misc] +generics_basic.py:55: error: TypeVar constraint type cannot be parametrized by type variables [misc] generics_basic.py:69: error: Value of type variable "AnyStr" of "concat" cannot be "Sequence[object]" [type-var] generics_basic.py:121: error: Duplicate type variables in Generic[...] or Protocol[...] [misc] generics_basic.py:157: error: Invalid index type "int" for "MyMap1[str, int]"; expected type "str" [index] generics_basic.py:158: error: Invalid index type "int" for "MyMap2[int, str]"; expected type "str" [index] -generics_basic.py:191: error: Dynamic metaclass not supported for "GenericMetaInstance" [misc] -generics_basic.py:191: error: Type variable "generics_basic.T" is unbound [valid-type] -generics_basic.py:191: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) -generics_basic.py:191: note: (Hint: Use "T" in function signature to bind "T" inside a function) +generics_basic.py:162: error: Free type variable expected in Generic[...] [misc] +generics_basic.py:163: error: Free type variable expected in Protocol[...] [misc] +generics_basic.py:171: error: If Generic[...] or Protocol[...] is present it should list all type variables [misc] +generics_basic.py:172: error: If Generic[...] or Protocol[...] is present it should list all type variables [misc] +generics_basic.py:208: error: Dynamic metaclass not supported for "GenericMetaInstance" [metaclass] +generics_basic.py:208: error: Type variable "generics_basic.T" is unbound [valid-type] +generics_basic.py:208: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) +generics_basic.py:208: note: (Hint: Use "T" in function signature to bind "T" inside a function) +generics_basic.py:223: error: Argument 2 to "takes_two_lists" has incompatible type "str"; expected "list[int]" [arg-type] +generics_basic.py:225: error: Cannot infer value of type parameter "T" of "takes_two_lists" [misc] +generics_basic.py:232: error: Cannot infer value of type parameter "T" of "takes_two_lists" [misc] +generics_basic.py:240: error: Argument 2 to "takes_two_int_lists" has incompatible type "str"; expected "list[int]" [arg-type] +generics_basic.py:241: error: Cannot infer value of type parameter "T_int" of "takes_two_int_lists" [misc] +generics_basic.py:244: error: Cannot infer value of type parameter "T_int" of "takes_two_int_lists" [misc] +generics_basic.py:251: error: Cannot infer value of type parameter "T_int" of "takes_two_int_lists" [misc] """ -conformance_automated = "Fail" +conformance_automated = "Pass" errors_diff = """ -Line 55: Expected 1 errors """ diff --git a/conformance/results/mypy/generics_defaults.toml b/conformance/results/mypy/generics_defaults.toml index 19633b6f5..d396b7545 100644 --- a/conformance/results/mypy/generics_defaults.toml +++ b/conformance/results/mypy/generics_defaults.toml @@ -1,11 +1,22 @@ -conformant = "Unsupported" +conformant = "Partial" +notes = """ +Does not detect a `TypeVar` with a default used after a `TypeVarTuple`. +Does not fully support defaults on `TypeVarTuple` and `ParamSpec`. +""" output = """ +generics_defaults.py:24: error: "T" cannot appear after "DefaultStrT" in type parameter list because it has no default type [misc] +generics_defaults.py:66: error: "AllTheDefaults" expects between 2 and 5 type arguments, but 1 given [type-arg] +generics_defaults.py:152: error: TypeVar default must be a subtype of the bound type [misc] +generics_defaults.py:159: error: TypeVar default must be one of the constraint types [misc] +generics_defaults.py:177: error: Expression is of type "int", not "Any" [assert-type] +generics_defaults.py:188: error: A type variable with default cannot follow TypeVarTuple [type-var] +generics_defaults.py:203: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "str" [valid-type] +generics_defaults.py:204: error: Expression is of type "tuple[Any, ...]", not "tuple[int, str]" [assert-type] +generics_defaults.py:205: error: Expression is of type "def (*Any, **Any) -> None", not "Callable[[float, bool], None]" [assert-type] """ conformance_automated = "Fail" errors_diff = """ -Line 24: Expected 1 errors -Line 50: Expected 1 errors -Line 104: Expected 1 errors -Line 111: Expected 1 errors -Line 138: Expected 1 errors +Line 203: Unexpected errors ['generics_defaults.py:203: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "str" [valid-type]'] +Line 204: Unexpected errors ['generics_defaults.py:204: error: Expression is of type "tuple[Any, ...]", not "tuple[int, str]" [assert-type]'] +Line 205: Unexpected errors ['generics_defaults.py:205: error: Expression is of type "def (*Any, **Any) -> None", not "Callable[[float, bool], None]" [assert-type]'] """ diff --git a/conformance/results/mypy/generics_defaults_referential.toml b/conformance/results/mypy/generics_defaults_referential.toml index bcf11e059..af8f6eb74 100644 --- a/conformance/results/mypy/generics_defaults_referential.toml +++ b/conformance/results/mypy/generics_defaults_referential.toml @@ -1,21 +1,18 @@ -conformant = "Unsupported" +conformant = "Partial" +notes = """ +Does not correctly handle defaults referencing other `TypeVar`s. +""" output = """ -generics_defaults_referential.py:23: error: Expression is of type "type[slice[Any, Any, Any]]", not "type[slice[int, int, int | None]]" [assert-type] +generics_defaults_referential.py:36: error: Argument 2 to "Foo" has incompatible type "str"; expected "int" [arg-type] generics_defaults_referential.py:37: error: Argument 1 to "Foo" has incompatible type "str"; expected "int" [arg-type] generics_defaults_referential.py:53: error: Type parameter "Start2T" has a default type that refers to one or more type variables that are out of scope [misc] -generics_defaults_referential.py:94: error: Expression is of type "type[Bar[Any, Any]]", not "type[Bar[Any, list[Any]]]" [assert-type] -generics_defaults_referential.py:95: error: Expression is of type "type[Bar[Any, Any]]", not "type[Bar[int, list[int]]]" [assert-type] -generics_defaults_referential.py:96: error: Expression is of type "Bar[int, list[Never]]", not "Bar[int, list[int]]" [assert-type] +generics_defaults_referential.py:60: error: Type parameter "S2" has a default type that refers to one or more type variables that are out of scope [misc] +generics_defaults_referential.py:74: error: TypeVar default must be one of the constraint types [misc] +generics_defaults_referential.py:77: error: TypeVar default must be one of the constraint types [misc] +generics_defaults_referential.py:78: error: TypeVar default must be one of the constraint types [misc] """ conformance_automated = "Fail" errors_diff = """ -Line 36: Expected 1 errors -Line 60: Expected 1 errors Line 68: Expected 1 errors -Line 74: Expected 1 errors -Line 78: Expected 1 errors -Line 23: Unexpected errors ['generics_defaults_referential.py:23: error: Expression is of type "type[slice[Any, Any, Any]]", not "type[slice[int, int, int | None]]" [assert-type]'] -Line 94: Unexpected errors ['generics_defaults_referential.py:94: error: Expression is of type "type[Bar[Any, Any]]", not "type[Bar[Any, list[Any]]]" [assert-type]'] -Line 95: Unexpected errors ['generics_defaults_referential.py:95: error: Expression is of type "type[Bar[Any, Any]]", not "type[Bar[int, list[int]]]" [assert-type]'] -Line 96: Unexpected errors ['generics_defaults_referential.py:96: error: Expression is of type "Bar[int, list[Never]]", not "Bar[int, list[int]]" [assert-type]'] +Line 77: Unexpected errors ['generics_defaults_referential.py:77: error: TypeVar default must be one of the constraint types [misc]'] """ diff --git a/conformance/results/mypy/generics_defaults_specialization.toml b/conformance/results/mypy/generics_defaults_specialization.toml index 95472edca..6515700dd 100644 --- a/conformance/results/mypy/generics_defaults_specialization.toml +++ b/conformance/results/mypy/generics_defaults_specialization.toml @@ -1,10 +1,8 @@ -conformant = "Unsupported" +conformant = "Pass" output = """ generics_defaults_specialization.py:30: error: Bad number of arguments for type alias, expected between 0 and 1, given 2 [type-arg] -generics_defaults_specialization.py:45: error: Expression is of type "type[Bar[Any]]", not "type[Bar[str]]" [assert-type] -generics_defaults_specialization.py:55: error: The type "type[Foo]" is not generic and not indexable [misc] +generics_defaults_specialization.py:58: error: The type "type[Foo]" is not generic and not indexable [misc] """ -conformance_automated = "Fail" +conformance_automated = "Pass" errors_diff = """ -Line 45: Unexpected errors ['generics_defaults_specialization.py:45: error: Expression is of type "type[Bar[Any]]", not "type[Bar[str]]" [assert-type]'] """ diff --git a/conformance/results/mypy/generics_mixed_variance_inference.toml b/conformance/results/mypy/generics_mixed_variance_inference.toml new file mode 100644 index 000000000..84f10eed9 --- /dev/null +++ b/conformance/results/mypy/generics_mixed_variance_inference.toml @@ -0,0 +1,9 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_mixed_variance_inference.py:13: error: Incompatible types in assignment (expression has type "Mixed[bool, []]", variable has type "Mixed[int, []]") [assignment] +generics_mixed_variance_inference.py:16: error: Incompatible types in assignment (expression has type "Mixed[int, object, []]", variable has type "Mixed[int, int, []]") [assignment] +generics_mixed_variance_inference.py:21: error: Incompatible types in assignment (expression has type "Mixed[int, [bool]]", variable has type "Mixed[int, [int]]") [assignment] +""" diff --git a/conformance/results/mypy/generics_paramspec_basic.toml b/conformance/results/mypy/generics_paramspec_basic.toml index 1ed2f81d5..538f6de4d 100644 --- a/conformance/results/mypy/generics_paramspec_basic.toml +++ b/conformance/results/mypy/generics_paramspec_basic.toml @@ -1,21 +1,19 @@ -conformant = "Partial" -notes = """ -Does not reject ParamSpec when used "bare" in type alias definition. -""" +conformant = "Pass" output = """ generics_paramspec_basic.py:10: error: String argument 1 "NotIt" to ParamSpec(...) does not match variable name "WrongName" [misc] +generics_paramspec_basic.py:15: error: Invalid location for ParamSpec "P" [valid-type] +generics_paramspec_basic.py:15: note: You can use ParamSpec as the first argument to Callable, e.g., "Callable[P, int]" generics_paramspec_basic.py:23: error: Invalid location for ParamSpec "P" [valid-type] -generics_paramspec_basic.py:23: note: You can use ParamSpec as the first argument to Callable, e.g., 'Callable[P, int]' +generics_paramspec_basic.py:23: note: You can use ParamSpec as the first argument to Callable, e.g., "Callable[P, int]" generics_paramspec_basic.py:27: error: Invalid location for Concatenate [valid-type] generics_paramspec_basic.py:27: note: You can use Concatenate as the first argument to Callable -generics_paramspec_basic.py:31: error: Invalid location for ParamSpec "P" [misc] -generics_paramspec_basic.py:31: note: You can use ParamSpec as the first argument to Callable, e.g., 'Callable[P, int]' +generics_paramspec_basic.py:31: error: Invalid location for ParamSpec "P" [valid-type] +generics_paramspec_basic.py:31: note: You can use ParamSpec as the first argument to Callable, e.g., "Callable[P, int]" generics_paramspec_basic.py:35: error: Invalid location for ParamSpec "P" [valid-type] -generics_paramspec_basic.py:35: note: You can use ParamSpec as the first argument to Callable, e.g., 'Callable[P, int]' +generics_paramspec_basic.py:35: note: You can use ParamSpec as the first argument to Callable, e.g., "Callable[P, int]" generics_paramspec_basic.py:39: error: Invalid location for ParamSpec "P" [valid-type] -generics_paramspec_basic.py:39: note: You can use ParamSpec as the first argument to Callable, e.g., 'Callable[P, int]' +generics_paramspec_basic.py:39: note: You can use ParamSpec as the first argument to Callable, e.g., "Callable[P, int]" """ -conformance_automated = "Fail" +conformance_automated = "Pass" errors_diff = """ -Line 15: Expected 1 errors """ diff --git a/conformance/results/mypy/generics_paramspec_components.toml b/conformance/results/mypy/generics_paramspec_components.toml index 0cfb13a94..bdc5f0b0f 100644 --- a/conformance/results/mypy/generics_paramspec_components.toml +++ b/conformance/results/mypy/generics_paramspec_components.toml @@ -1,35 +1,28 @@ -conformant = "Partial" -notes = """ -Does not report illegal use of "P.args" on normal parameter. -Does not report error when P.args is specified but P.kwargs is missing. -Does not report error when P is out of scope and P.args and P.kwargs is used. -Does not report error when keyword argument is specified between P.args and P.kwargs. -Does not report error when calling callable and argument is missing for concatenated parameters. -""" +conformant = "Pass" output = """ generics_paramspec_components.py:17: error: Use "P.args" for variadic "*" parameter [valid-type] generics_paramspec_components.py:17: error: Use "P.kwargs" for variadic "**" parameter [valid-type] +generics_paramspec_components.py:20: error: ParamSpec components are not allowed here [valid-type] generics_paramspec_components.py:23: error: Use "P.kwargs" for variadic "**" parameter [valid-type] +generics_paramspec_components.py:26: error: ParamSpec must have "*args" typed as "P.args" and "**kwargs" typed as "P.kwargs" [valid-type] +generics_paramspec_components.py:30: error: ParamSpec "P" is unbound [valid-type] +generics_paramspec_components.py:35: error: ParamSpec components are not allowed here [valid-type] +generics_paramspec_components.py:36: error: ParamSpec components are not allowed here [valid-type] +generics_paramspec_components.py:38: error: ParamSpec must have "*args" typed as "P.args" and "**kwargs" typed as "P.kwargs" [valid-type] +generics_paramspec_components.py:41: error: ParamSpec must have "*args" typed as "P.args" and "**kwargs" typed as "P.kwargs" [valid-type] generics_paramspec_components.py:49: error: Argument 1 has incompatible type "*P.kwargs"; expected "P.args" [arg-type] generics_paramspec_components.py:49: error: Argument 2 has incompatible type "**P.args"; expected "P.kwargs" [arg-type] generics_paramspec_components.py:51: error: Argument 1 has incompatible type "int"; expected "P.args" [arg-type] +generics_paramspec_components.py:60: error: Arguments not allowed after ParamSpec.args [valid-type] generics_paramspec_components.py:70: error: Argument 1 has incompatible type "*P.args"; expected "int" [arg-type] generics_paramspec_components.py:70: error: Argument 2 has incompatible type "int"; expected "P.args" [arg-type] +generics_paramspec_components.py:72: error: Argument 1 has incompatible type "*P.args"; expected "int" [arg-type] generics_paramspec_components.py:83: error: "foo" gets multiple values for keyword argument "x" [misc] generics_paramspec_components.py:83: error: Argument 1 to "foo" has incompatible type "*P.args"; expected "int" [arg-type] generics_paramspec_components.py:83: error: Argument 3 to "foo" has incompatible type "**P.kwargs"; expected "int" [arg-type] generics_paramspec_components.py:98: error: Argument 2 to "twice" has incompatible type "str"; expected "int" [arg-type] generics_paramspec_components.py:98: error: Argument 3 to "twice" has incompatible type "int"; expected "str" [arg-type] """ -conformance_automated = "Fail" +conformance_automated = "Pass" errors_diff = """ -Line 20: Expected 1 errors -Line 26: Expected 1 errors -Line 30: Expected 1 errors -Line 35: Expected 1 errors -Line 36: Expected 1 errors -Line 38: Expected 1 errors -Line 41: Expected 1 errors -Line 60: Expected 1 errors -Line 72: Expected 1 errors """ diff --git a/conformance/results/mypy/generics_paramspec_semantics.toml b/conformance/results/mypy/generics_paramspec_semantics.toml index e4f5aadaf..7dc429c76 100644 --- a/conformance/results/mypy/generics_paramspec_semantics.toml +++ b/conformance/results/mypy/generics_paramspec_semantics.toml @@ -3,14 +3,14 @@ output = """ generics_paramspec_semantics.py:26: error: Unexpected keyword argument "a" [call-arg] generics_paramspec_semantics.py:26: error: Unexpected keyword argument "b" [call-arg] generics_paramspec_semantics.py:27: error: Argument 2 has incompatible type "str"; expected "bool" [arg-type] -generics_paramspec_semantics.py:61: error: Argument 2 to "func1" has incompatible type "Callable[[NamedArg(int, 'y')], int]"; expected "Callable[[NamedArg(int, 'x')], int]" [arg-type] -generics_paramspec_semantics.py:97: error: Argument 1 has incompatible type "int"; expected "str" [arg-type] -generics_paramspec_semantics.py:107: error: Argument 1 has incompatible type "int"; expected "bool" [arg-type] -generics_paramspec_semantics.py:119: error: Argument 1 has incompatible type "int"; expected "str" [arg-type] -generics_paramspec_semantics.py:126: error: Argument 1 to "expects_int_first" has incompatible type "Callable[[str], int]"; expected "Callable[[int], int]" [arg-type] -generics_paramspec_semantics.py:126: note: This is likely because "one" has named arguments: "x". Consider marking them positional-only -generics_paramspec_semantics.py:131: error: Argument 1 to "expects_int_first" has incompatible type "Callable[[NamedArg(int, 'x')], int]"; expected "Callable[[int, NamedArg(int, 'x')], int]" [arg-type] -generics_paramspec_semantics.py:136: error: Argument 1 to "expects_int_first" has incompatible type "Callable[[KwArg(int)], int]"; expected "Callable[[int, KwArg(int)], int]" [arg-type] +generics_paramspec_semantics.py:61: error: Argument 2 to "func1" has incompatible type "def keyword_only_y(*, y: int) -> int"; expected "def (*, x: int) -> int" [arg-type] +generics_paramspec_semantics.py:98: error: Argument 1 has incompatible type "int"; expected "str" [arg-type] +generics_paramspec_semantics.py:108: error: Argument 1 has incompatible type "int"; expected "bool" [arg-type] +generics_paramspec_semantics.py:120: error: Argument 1 has incompatible type "int"; expected "str" [arg-type] +generics_paramspec_semantics.py:127: error: Argument 1 to "expects_int_first" has incompatible type "Callable[[str], int]"; expected "Callable[[int], int]" [arg-type] +generics_paramspec_semantics.py:127: note: This is likely because "one" has named arguments: "x". Consider marking them positional-only +generics_paramspec_semantics.py:132: error: Argument 1 to "expects_int_first" has incompatible type "def two(*, x: int) -> int"; expected "def (int, /, *, x: int) -> int" [arg-type] +generics_paramspec_semantics.py:137: error: Argument 1 to "expects_int_first" has incompatible type "def three(**kwargs: int) -> int"; expected "def (int, /, **kwargs: int) -> int" [arg-type] """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/mypy/generics_paramspec_specialization.toml b/conformance/results/mypy/generics_paramspec_specialization.toml index c705fbb80..c6d433147 100644 --- a/conformance/results/mypy/generics_paramspec_specialization.toml +++ b/conformance/results/mypy/generics_paramspec_specialization.toml @@ -1,10 +1,10 @@ conformant = "Pass" output = """ -generics_paramspec_specialization.py:45: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "int" [misc] -generics_paramspec_specialization.py:55: error: Argument 1 has incompatible type "str"; expected "int" [arg-type] -generics_paramspec_specialization.py:56: error: Argument 3 has incompatible type "str"; expected "bool" [arg-type] -generics_paramspec_specialization.py:61: error: Argument 1 has incompatible type "str"; expected "int" [arg-type] -generics_paramspec_specialization.py:62: error: Argument 3 has incompatible type "str"; expected "bool" [arg-type] +generics_paramspec_specialization.py:44: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "int" [valid-type] +generics_paramspec_specialization.py:54: error: Argument 1 has incompatible type "str"; expected "int" [arg-type] +generics_paramspec_specialization.py:55: error: Argument 3 has incompatible type "str"; expected "bool" [arg-type] +generics_paramspec_specialization.py:60: error: Argument 1 has incompatible type "str"; expected "int" [arg-type] +generics_paramspec_specialization.py:61: error: Argument 3 has incompatible type "str"; expected "bool" [arg-type] """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/mypy/generics_paramspec_variance.toml b/conformance/results/mypy/generics_paramspec_variance.toml new file mode 100644 index 000000000..3aa86da8f --- /dev/null +++ b/conformance/results/mypy/generics_paramspec_variance.toml @@ -0,0 +1,44 @@ +conformant = "Unsupported" +conformance_automated = "Fail" +errors_diff = """ +Line 15: Expected 1 errors +Line 30: Expected 1 errors +Line 90: Expected 1 errors +Line 111: Expected 1 errors +Line 117: Expected 1 errors +Line 126: Expected 1 errors +Line 132: Expected 1 errors +Line 151: Expected 1 errors +Line 31: Unexpected errors ['generics_paramspec_variance.py:31: error: Incompatible types in assignment (expression has type "CovariantParamSpec[[int]]", variable has type "CovariantParamSpec[[object]]") [assignment]'] +Line 84: Unexpected errors ['generics_paramspec_variance.py:84: error: Incompatible types in assignment (expression has type "OutitP[[NamedArg(int, \\'a\\')]]", variable has type "OutitP[[int]]") [assignment]'] +Line 86: Unexpected errors ['generics_paramspec_variance.py:86: error: Incompatible types in assignment (expression has type "OutitP[[int]]", variable has type "OutitP[[Arg(int, \\'a\\')]]") [assignment]'] +Line 97: Unexpected errors ['generics_paramspec_variance.py:97: error: The variance and bound arguments to ParamSpec do not have defined semantics yet [misc]'] +Line 98: Unexpected errors ['generics_paramspec_variance.py:98: error: The variance and bound arguments to ParamSpec do not have defined semantics yet [misc]'] +Line 99: Unexpected errors ['generics_paramspec_variance.py:99: error: The variance and bound arguments to ParamSpec do not have defined semantics yet [misc]'] +Line 133: Unexpected errors ['generics_paramspec_variance.py:133: error: Incompatible types in assignment (expression has type "CovariantParamSpecOld[[int]]", variable has type "CovariantParamSpecOld[[object]]") [assignment]'] +Line 152: Unexpected errors ['generics_paramspec_variance.py:152: error: Incompatible types in assignment (expression has type "InferredCovariantParamSpecOld[[int]]", variable has type "InferredCovariantParamSpecOld[[object]]") [assignment]'] +""" +output = """ +generics_paramspec_variance.py:14: error: Incompatible types in assignment (expression has type "InvariantParamSpec[[int]]", variable has type "InvariantParamSpec[[object]]") [assignment] +generics_paramspec_variance.py:21: error: Incompatible types in assignment (expression has type "ContravariantParamSpec[[int]]", variable has type "ContravariantParamSpec[[object]]") [assignment] +generics_paramspec_variance.py:31: error: Incompatible types in assignment (expression has type "CovariantParamSpec[[int]]", variable has type "CovariantParamSpec[[object]]") [assignment] +generics_paramspec_variance.py:61: error: Incompatible types in assignment (expression has type "InitP[[NamedArg(int, 'a')]]", variable has type "InitP[[int]]") [assignment] +generics_paramspec_variance.py:63: error: Incompatible types in assignment (expression has type "InitP[[int]]", variable has type "InitP[[Arg(int, 'a')]]") [assignment] +generics_paramspec_variance.py:65: error: Incompatible types in assignment (expression has type "InitP[[Arg(int, 'b')]]", variable has type "InitP[[Arg(int, 'a')]]") [assignment] +generics_paramspec_variance.py:69: error: Incompatible types in assignment (expression has type "InitP[[int, str]]", variable has type "InitP[[int]]") [assignment] +generics_paramspec_variance.py:84: error: Incompatible types in assignment (expression has type "OutitP[[NamedArg(int, 'a')]]", variable has type "OutitP[[int]]") [assignment] +generics_paramspec_variance.py:86: error: Incompatible types in assignment (expression has type "OutitP[[int]]", variable has type "OutitP[[Arg(int, 'a')]]") [assignment] +generics_paramspec_variance.py:88: error: Incompatible types in assignment (expression has type "OutitP[[Arg(int, 'b')]]", variable has type "OutitP[[Arg(int, 'a')]]") [assignment] +generics_paramspec_variance.py:92: error: Incompatible types in assignment (expression has type "OutitP[[int, str]]", variable has type "OutitP[[int]]") [assignment] +generics_paramspec_variance.py:97: error: The variance and bound arguments to ParamSpec do not have defined semantics yet [misc] +generics_paramspec_variance.py:98: error: The variance and bound arguments to ParamSpec do not have defined semantics yet [misc] +generics_paramspec_variance.py:99: error: The variance and bound arguments to ParamSpec do not have defined semantics yet [misc] +generics_paramspec_variance.py:100: error: The variance and bound arguments to ParamSpec do not have defined semantics yet [misc] +generics_paramspec_variance.py:101: error: The variance and bound arguments to ParamSpec do not have defined semantics yet [misc] +generics_paramspec_variance.py:102: error: The variance and bound arguments to ParamSpec do not have defined semantics yet [misc] +generics_paramspec_variance.py:110: error: Incompatible types in assignment (expression has type "InvariantParamSpecOld[[bool]]", variable has type "InvariantParamSpecOld[[int]]") [assignment] +generics_paramspec_variance.py:121: error: Incompatible types in assignment (expression has type "ContravariantParamSpecOld[[int]]", variable has type "ContravariantParamSpecOld[[object]]") [assignment] +generics_paramspec_variance.py:133: error: Incompatible types in assignment (expression has type "CovariantParamSpecOld[[int]]", variable has type "CovariantParamSpecOld[[object]]") [assignment] +generics_paramspec_variance.py:142: error: Incompatible types in assignment (expression has type "InferredContravariantParamSpecOld[[int]]", variable has type "InferredContravariantParamSpecOld[[object]]") [assignment] +generics_paramspec_variance.py:152: error: Incompatible types in assignment (expression has type "InferredCovariantParamSpecOld[[int]]", variable has type "InferredCovariantParamSpecOld[[object]]") [assignment] +""" diff --git a/conformance/results/mypy/generics_scoping.toml b/conformance/results/mypy/generics_scoping.toml index cffdc23b9..013baaa7c 100644 --- a/conformance/results/mypy/generics_scoping.toml +++ b/conformance/results/mypy/generics_scoping.toml @@ -1,31 +1,31 @@ -conformant = "Partial" -notes = """ -False negative on generic class nested within generic class with same type variable. -""" output = """ -generics_scoping.py:29: error: Argument 1 to "meth_2" of "MyClass" has incompatible type "str"; expected "int" [arg-type] -generics_scoping.py:50: error: Type variable "generics_scoping.S" is unbound [valid-type] -generics_scoping.py:50: note: (Hint: Use "Generic[S]" or "Protocol[S]" base class to bind "S" inside a class) -generics_scoping.py:50: note: (Hint: Use "S" in function signature to bind "S" inside a function) -generics_scoping.py:54: error: Type variable "generics_scoping.S" is unbound [valid-type] -generics_scoping.py:54: note: (Hint: Use "Generic[S]" or "Protocol[S]" base class to bind "S" inside a class) -generics_scoping.py:54: note: (Hint: Use "S" in function signature to bind "S" inside a function) -generics_scoping.py:65: error: Free type variable expected in Generic[...] [misc] -generics_scoping.py:78: error: Type variable "generics_scoping.T" is unbound [valid-type] -generics_scoping.py:78: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) -generics_scoping.py:78: note: (Hint: Use "T" in function signature to bind "T" inside a function) -generics_scoping.py:84: error: Can't use bound type variable "T" to define generic alias [valid-type] -generics_scoping.py:88: error: Type variable "generics_scoping.T" is unbound [valid-type] -generics_scoping.py:88: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) -generics_scoping.py:88: note: (Hint: Use "T" in function signature to bind "T" inside a function) +generics_scoping.py:16: error: Expression is of type "int", not "Literal[1]" [assert-type] +generics_scoping.py:20: error: Expression is of type "str", not "Literal['a']" [assert-type] +generics_scoping.py:34: error: Argument 1 to "meth_2" of "MyClass" has incompatible type "str"; expected "int" [arg-type] +generics_scoping.py:50: error: Expression is of type "str", not "Literal['abc']" [assert-type] +generics_scoping.py:54: error: Expression is of type "bytes", not "Literal[b'abc']" [assert-type] +generics_scoping.py:61: error: Type variable "generics_scoping.S" is unbound [valid-type] +generics_scoping.py:61: note: (Hint: Use "Generic[S]" or "Protocol[S]" base class to bind "S" inside a class) +generics_scoping.py:61: note: (Hint: Use "S" in function signature to bind "S" inside a function) +generics_scoping.py:65: error: Type variable "generics_scoping.S" is unbound [valid-type] +generics_scoping.py:65: note: (Hint: Use "Generic[S]" or "Protocol[S]" base class to bind "S" inside a class) +generics_scoping.py:65: note: (Hint: Use "S" in function signature to bind "S" inside a function) +generics_scoping.py:76: error: Free type variable expected in Generic[...] [misc] +generics_scoping.py:86: error: Type variable "T" is bound by an outer class [valid-type] generics_scoping.py:89: error: Type variable "generics_scoping.T" is unbound [valid-type] generics_scoping.py:89: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) generics_scoping.py:89: note: (Hint: Use "T" in function signature to bind "T" inside a function) -generics_scoping.py:90: error: Type variable "generics_scoping.T" is unbound [valid-type] -generics_scoping.py:90: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) -generics_scoping.py:90: note: (Hint: Use "T" in function signature to bind "T" inside a function) +generics_scoping.py:98: error: Can't use bound type variable "T" to define generic alias [valid-type] +generics_scoping.py:105: error: Type variable "generics_scoping.T" is unbound [valid-type] +generics_scoping.py:105: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) +generics_scoping.py:105: note: (Hint: Use "T" in function signature to bind "T" inside a function) +generics_scoping.py:106: error: Type variable "generics_scoping.T" is unbound [valid-type] +generics_scoping.py:106: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) +generics_scoping.py:106: note: (Hint: Use "T" in function signature to bind "T" inside a function) +generics_scoping.py:107: error: Type variable "generics_scoping.T" is unbound [valid-type] +generics_scoping.py:107: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) +generics_scoping.py:107: note: (Hint: Use "T" in function signature to bind "T" inside a function) """ -conformance_automated = "Fail" +conformance_automated = "Pass" errors_diff = """ -Line 75: Expected 1 errors """ diff --git a/conformance/results/mypy/generics_self_advanced.toml b/conformance/results/mypy/generics_self_advanced.toml index c6b3cd085..4581356b3 100644 --- a/conformance/results/mypy/generics_self_advanced.toml +++ b/conformance/results/mypy/generics_self_advanced.toml @@ -7,18 +7,14 @@ Does not retain `Self` when accessing attribute through `type[Self]`. """ output = """ generics_self_advanced.py:35: error: Expression is of type "ChildB", not "Self" [assert-type] -generics_self_advanced.py:38: error: Expression is of type "ChildB", not "Self" [assert-type] -generics_self_advanced.py:42: error: Expression is of type "type[ChildB]", not "type[Self]" [assert-type] -generics_self_advanced.py:43: error: Expression is of type "list[ChildB]", not "list[Self]" [assert-type] -generics_self_advanced.py:44: error: Expression is of type "ChildB", not "Self" [assert-type] -generics_self_advanced.py:45: error: Expression is of type "ChildB", not "Self" [assert-type] +generics_self_advanced.py:41: error: Expression is of type "ChildB", not "Self" [assert-type] +generics_self_advanced.py:45: error: Expression is of type "type[ChildB]", not "type[Self]" [assert-type] +generics_self_advanced.py:51: error: Expression is of type "ChildB", not "Self" [assert-type] """ conformance_automated = "Fail" errors_diff = """ Line 35: Unexpected errors ['generics_self_advanced.py:35: error: Expression is of type "ChildB", not "Self" [assert-type]'] -Line 38: Unexpected errors ['generics_self_advanced.py:38: error: Expression is of type "ChildB", not "Self" [assert-type]'] -Line 42: Unexpected errors ['generics_self_advanced.py:42: error: Expression is of type "type[ChildB]", not "type[Self]" [assert-type]'] -Line 43: Unexpected errors ['generics_self_advanced.py:43: error: Expression is of type "list[ChildB]", not "list[Self]" [assert-type]'] -Line 44: Unexpected errors ['generics_self_advanced.py:44: error: Expression is of type "ChildB", not "Self" [assert-type]'] -Line 45: Unexpected errors ['generics_self_advanced.py:45: error: Expression is of type "ChildB", not "Self" [assert-type]'] +Line 41: Unexpected errors ['generics_self_advanced.py:41: error: Expression is of type "ChildB", not "Self" [assert-type]'] +Line 45: Unexpected errors ['generics_self_advanced.py:45: error: Expression is of type "type[ChildB]", not "type[Self]" [assert-type]'] +Line 51: Unexpected errors ['generics_self_advanced.py:51: error: Expression is of type "ChildB", not "Self" [assert-type]'] """ diff --git a/conformance/results/mypy/generics_self_basic.toml b/conformance/results/mypy/generics_self_basic.toml index 1c3ea6402..2502d0de1 100644 --- a/conformance/results/mypy/generics_self_basic.toml +++ b/conformance/results/mypy/generics_self_basic.toml @@ -2,7 +2,7 @@ conformant = "Pass" output = """ generics_self_basic.py:20: error: Incompatible return value type (got "Shape", expected "Self") [return-value] generics_self_basic.py:33: error: Incompatible return value type (got "Shape", expected "Self") [return-value] -generics_self_basic.py:64: error: Self type cannot have type arguments [misc] +generics_self_basic.py:68: error: Self type cannot have type arguments [misc] """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/mypy/generics_self_usage.toml b/conformance/results/mypy/generics_self_usage.toml index 32b70b844..b13852536 100644 --- a/conformance/results/mypy/generics_self_usage.toml +++ b/conformance/results/mypy/generics_self_usage.toml @@ -5,17 +5,17 @@ generics_self_usage.py:76: error: Self type is only allowed in annotations withi generics_self_usage.py:82: error: Method cannot have explicit self annotation and Self type [misc] generics_self_usage.py:82: error: A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var] generics_self_usage.py:82: note: Consider using the upper bound "Foo2" instead -generics_self_usage.py:86: error: Incompatible return value type (got "Foo3", expected "Self") [return-value] -generics_self_usage.py:101: error: Self type is only allowed in annotations within class definition [misc] +generics_self_usage.py:87: error: Incompatible return value type (got "Foo3", expected "Self") [return-value] generics_self_usage.py:103: error: Self type is only allowed in annotations within class definition [misc] -generics_self_usage.py:106: error: Self type is only allowed in annotations within class definition [misc] -generics_self_usage.py:106: error: Self type cannot be used in type alias target [misc] -generics_self_usage.py:111: error: Static methods cannot use Self type [misc] -generics_self_usage.py:111: error: A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var] -generics_self_usage.py:111: note: Consider using the upper bound "Base" instead -generics_self_usage.py:116: error: Static methods cannot use Self type [misc] -generics_self_usage.py:121: error: Self type cannot be used in a metaclass [misc] -generics_self_usage.py:125: error: Self type cannot be used in a metaclass [misc] +generics_self_usage.py:105: error: Self type is only allowed in annotations within class definition [misc] +generics_self_usage.py:108: error: Self type is only allowed in annotations within class definition [misc] +generics_self_usage.py:108: error: Self type cannot be used in type alias target [misc] +generics_self_usage.py:113: error: Static methods cannot use Self type [misc] +generics_self_usage.py:113: error: A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var] +generics_self_usage.py:113: note: Consider using the upper bound "Base" instead +generics_self_usage.py:118: error: Static methods cannot use Self type [misc] +generics_self_usage.py:123: error: Self type cannot be used in a metaclass [misc] +generics_self_usage.py:127: error: Self type cannot be used in a metaclass [misc] """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/mypy/generics_syntax_compatibility.toml b/conformance/results/mypy/generics_syntax_compatibility.toml index 233f5e92c..d40eccb49 100644 --- a/conformance/results/mypy/generics_syntax_compatibility.toml +++ b/conformance/results/mypy/generics_syntax_compatibility.toml @@ -1,20 +1,8 @@ -conformant = "Unsupported" -notes = """ -Type parameter syntax not yet support. -""" +conformant = "Pass" output = """ -generics_syntax_compatibility.py:14: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_compatibility.py:14: error: Name "V" is not defined [name-defined] -generics_syntax_compatibility.py:18: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_compatibility.py:18: error: Name "V" is not defined [name-defined] -generics_syntax_compatibility.py:22: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_compatibility.py:23: error: Name "V" is not defined [name-defined] -generics_syntax_compatibility.py:26: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_compatibility.py:26: error: Name "M" is not defined [name-defined] +generics_syntax_compatibility.py:14: error: All type parameters should be declared ("K" not declared) [valid-type] +generics_syntax_compatibility.py:26: error: All type parameters should be declared ("K" not declared) [valid-type] """ -conformance_automated = "Fail" +conformance_automated = "Pass" errors_diff = """ -Line 18: Unexpected errors ['generics_syntax_compatibility.py:18: error: PEP 695 generics are not yet supported [valid-type]', 'generics_syntax_compatibility.py:18: error: Name "V" is not defined [name-defined]'] -Line 22: Unexpected errors ['generics_syntax_compatibility.py:22: error: PEP 695 generics are not yet supported [valid-type]'] -Line 23: Unexpected errors ['generics_syntax_compatibility.py:23: error: Name "V" is not defined [name-defined]'] """ diff --git a/conformance/results/mypy/generics_syntax_declarations.toml b/conformance/results/mypy/generics_syntax_declarations.toml index 229c387a1..d49de6a11 100644 --- a/conformance/results/mypy/generics_syntax_declarations.toml +++ b/conformance/results/mypy/generics_syntax_declarations.toml @@ -1,53 +1,20 @@ -conformant = "Unsupported" +conformant = "Partial" notes = """ -Type parameter syntax not yet support. +Doesn't flag TypeVar with empty constraints. """ output = """ -generics_syntax_declarations.py:13: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_declarations.py:14: error: Expression is of type "Any", not "TypeVar" [assert-type] -generics_syntax_declarations.py:14: error: Name "T" is not defined [name-defined] -generics_syntax_declarations.py:15: error: Expression is of type "Any", not "TypeVarTuple" [assert-type] -generics_syntax_declarations.py:15: error: Name "Ts" is not defined [name-defined] -generics_syntax_declarations.py:16: error: Expression is of type "Any", not "ParamSpec" [assert-type] -generics_syntax_declarations.py:16: error: Name "P" is not defined [name-defined] -generics_syntax_declarations.py:19: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_declarations.py:19: error: Free type variable expected in Generic[...] [misc] -generics_syntax_declarations.py:19: error: Name "T" is not defined [name-defined] -generics_syntax_declarations.py:23: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_declarations.py:27: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_declarations.py:27: error: Free type variable expected in Protocol[...] [misc] -generics_syntax_declarations.py:27: error: Name "S" is not defined [name-defined] -generics_syntax_declarations.py:27: error: Name "T" is not defined [name-defined] -generics_syntax_declarations.py:31: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_declarations.py:32: error: Name "T" is not defined [name-defined] -generics_syntax_declarations.py:37: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_declarations.py:41: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_declarations.py:45: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_declarations.py:46: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_declarations.py:50: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_declarations.py:54: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_declarations.py:58: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_declarations.py:62: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_declarations.py:66: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_declarations.py:73: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_declarations.py:77: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_declarations.py:81: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_declarations.py:85: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_declarations.py:17: error: Generic[...] base class is redundant [misc] +generics_syntax_declarations.py:25: error: No arguments expected for "Protocol" base class [misc] +generics_syntax_declarations.py:32: error: "T" has no attribute "is_integer" [attr-defined] +generics_syntax_declarations.py:44: error: Name "V" is not defined [name-defined] +generics_syntax_declarations.py:48: error: Bracketed expression "[...]" is not valid as a type [valid-type] +generics_syntax_declarations.py:64: error: Type variable must have at least two constrained types [misc] +generics_syntax_declarations.py:71: error: Variable "generics_syntax_declarations.t1" is not valid as a type [valid-type] +generics_syntax_declarations.py:71: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_declarations.py:75: error: Invalid type: try using Literal[3] instead? [valid-type] +generics_syntax_declarations.py:79: error: Name "S" is not defined [name-defined] """ conformance_automated = "Fail" errors_diff = """ -Line 34: Expected 1 errors -Line 13: Unexpected errors ['generics_syntax_declarations.py:13: error: PEP 695 generics are not yet supported [valid-type]'] -Line 14: Unexpected errors ['generics_syntax_declarations.py:14: error: Expression is of type "Any", not "TypeVar" [assert-type]', 'generics_syntax_declarations.py:14: error: Name "T" is not defined [name-defined]'] -Line 15: Unexpected errors ['generics_syntax_declarations.py:15: error: Expression is of type "Any", not "TypeVarTuple" [assert-type]', 'generics_syntax_declarations.py:15: error: Name "Ts" is not defined [name-defined]'] -Line 16: Unexpected errors ['generics_syntax_declarations.py:16: error: Expression is of type "Any", not "ParamSpec" [assert-type]', 'generics_syntax_declarations.py:16: error: Name "P" is not defined [name-defined]'] -Line 23: Unexpected errors ['generics_syntax_declarations.py:23: error: PEP 695 generics are not yet supported [valid-type]'] -Line 31: Unexpected errors ['generics_syntax_declarations.py:31: error: PEP 695 generics are not yet supported [valid-type]'] -Line 32: Unexpected errors ['generics_syntax_declarations.py:32: error: Name "T" is not defined [name-defined]'] -Line 37: Unexpected errors ['generics_syntax_declarations.py:37: error: PEP 695 generics are not yet supported [valid-type]'] -Line 41: Unexpected errors ['generics_syntax_declarations.py:41: error: PEP 695 generics are not yet supported [valid-type]'] -Line 45: Unexpected errors ['generics_syntax_declarations.py:45: error: PEP 695 generics are not yet supported [valid-type]'] -Line 54: Unexpected errors ['generics_syntax_declarations.py:54: error: PEP 695 generics are not yet supported [valid-type]'] -Line 58: Unexpected errors ['generics_syntax_declarations.py:58: error: PEP 695 generics are not yet supported [valid-type]'] -Line 85: Unexpected errors ['generics_syntax_declarations.py:85: error: PEP 695 generics are not yet supported [valid-type]'] +Line 60: Expected 1 errors """ diff --git a/conformance/results/mypy/generics_syntax_infer_variance.toml b/conformance/results/mypy/generics_syntax_infer_variance.toml index a780860aa..f664ea38e 100644 --- a/conformance/results/mypy/generics_syntax_infer_variance.toml +++ b/conformance/results/mypy/generics_syntax_infer_variance.toml @@ -1,6 +1,6 @@ conformant = "Unsupported" notes = """ -Type parameter syntax not yet support. +Type parameter syntax not yet supported. """ output = """ generics_syntax_infer_variance.py:11: error: Unexpected argument to "TypeVar()": "infer_variance" [misc] @@ -19,93 +19,89 @@ generics_syntax_infer_variance.py:29: error: "ShouldBeCovariant1" expects no typ generics_syntax_infer_variance.py:29: error: The type "type[ShouldBeCovariant1]" is not generic and not indexable [misc] generics_syntax_infer_variance.py:32: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] generics_syntax_infer_variance.py:32: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:36: error: "ShouldBeCovariant2" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:36: error: The type "type[ShouldBeCovariant2]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:37: error: "ShouldBeCovariant2" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:37: error: The type "type[ShouldBeCovariant2]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:40: error: Free type variable expected in Generic[...] [misc] -generics_syntax_infer_variance.py:41: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] -generics_syntax_infer_variance.py:41: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:41: error: "ShouldBeCovariant2" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:45: error: "ShouldBeCovariant3" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:45: error: The type "type[ShouldBeCovariant3]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:46: error: "ShouldBeCovariant3" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:46: error: The type "type[ShouldBeCovariant3]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:34: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:34: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:37: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:37: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:39: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:39: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:46: error: "ShouldBeCovariant2" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:46: error: The type "type[ShouldBeCovariant2]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:47: error: "ShouldBeCovariant2" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:47: error: The type "type[ShouldBeCovariant2]" is not generic and not indexable [misc] generics_syntax_infer_variance.py:50: error: Free type variable expected in Generic[...] [misc] generics_syntax_infer_variance.py:51: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] generics_syntax_infer_variance.py:51: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:54: error: "ShouldBeCovariant4" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:54: error: The type "type[ShouldBeCovariant4]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:55: error: "ShouldBeCovariant4" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:55: error: The type "type[ShouldBeCovariant4]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:58: error: Free type variable expected in Generic[...] [misc] -generics_syntax_infer_variance.py:59: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] -generics_syntax_infer_variance.py:59: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:63: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] -generics_syntax_infer_variance.py:63: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:67: error: "ShouldBeCovariant5" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:67: error: The type "type[ShouldBeCovariant5]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:68: error: "ShouldBeCovariant5" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:68: error: The type "type[ShouldBeCovariant5]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:71: error: Free type variable expected in Generic[...] [misc] -generics_syntax_infer_variance.py:72: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] -generics_syntax_infer_variance.py:72: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:74: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] -generics_syntax_infer_variance.py:74: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:78: error: "ShouldBeCovariant6" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:78: error: The type "type[ShouldBeCovariant6]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:79: error: "ShouldBeCovariant6" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:79: error: The type "type[ShouldBeCovariant6]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:82: error: Free type variable expected in Generic[...] [misc] -generics_syntax_infer_variance.py:83: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] -generics_syntax_infer_variance.py:83: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:51: error: "ShouldBeCovariant2" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:55: error: "ShouldBeCovariant3" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:55: error: The type "type[ShouldBeCovariant3]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:56: error: "ShouldBeCovariant3" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:56: error: The type "type[ShouldBeCovariant3]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:60: error: Free type variable expected in Generic[...] [misc] +generics_syntax_infer_variance.py:61: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:61: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:75: error: Free type variable expected in Generic[...] [misc] +generics_syntax_infer_variance.py:76: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:76: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:80: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:80: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:84: error: "ShouldBeCovariant5" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:84: error: The type "type[ShouldBeCovariant5]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:85: error: "ShouldBeCovariant5" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:85: error: The type "type[ShouldBeCovariant5]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:88: error: Free type variable expected in Generic[...] [misc] +generics_syntax_infer_variance.py:89: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:89: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases generics_syntax_infer_variance.py:91: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] generics_syntax_infer_variance.py:91: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:95: error: "ShouldBeInvariant1" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:95: error: The type "type[ShouldBeInvariant1]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:96: error: "ShouldBeInvariant1" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:96: error: The type "type[ShouldBeInvariant1]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:95: error: "ShouldBeCovariant6" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:95: error: The type "type[ShouldBeCovariant6]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:96: error: "ShouldBeCovariant6" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:96: error: The type "type[ShouldBeCovariant6]" is not generic and not indexable [misc] generics_syntax_infer_variance.py:99: error: Free type variable expected in Generic[...] [misc] generics_syntax_infer_variance.py:100: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] generics_syntax_infer_variance.py:100: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:103: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] -generics_syntax_infer_variance.py:103: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:106: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] -generics_syntax_infer_variance.py:106: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:110: error: "ShouldBeInvariant2" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:110: error: The type "type[ShouldBeInvariant2]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:111: error: "ShouldBeInvariant2" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:111: error: The type "type[ShouldBeInvariant2]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:114: error: Variable "generics_syntax_infer_variance.K" is not valid as a type [valid-type] -generics_syntax_infer_variance.py:114: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:114: error: Variable "generics_syntax_infer_variance.V" is not valid as a type [valid-type] -generics_syntax_infer_variance.py:118: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] -generics_syntax_infer_variance.py:118: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:119: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] -generics_syntax_infer_variance.py:119: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:120: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] -generics_syntax_infer_variance.py:120: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:121: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] -generics_syntax_infer_variance.py:121: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:125: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_infer_variance.py:126: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] -generics_syntax_infer_variance.py:126: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:129: error: "ShouldBeInvariant4" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:129: error: The type "type[ShouldBeInvariant4]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:132: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_infer_variance.py:133: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] -generics_syntax_infer_variance.py:133: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:137: error: "ShouldBeInvariant5" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:137: error: The type "type[ShouldBeInvariant5]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:140: error: Free type variable expected in Generic[...] [misc] -generics_syntax_infer_variance.py:141: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] -generics_syntax_infer_variance.py:141: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:144: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] -generics_syntax_infer_variance.py:144: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:148: error: "ShouldBeContravariant1" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:148: error: The type "type[ShouldBeContravariant1]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:149: error: "ShouldBeContravariant1" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:149: error: The type "type[ShouldBeContravariant1]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:104: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:104: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:108: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:108: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:112: error: "ShouldBeInvariant1" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:112: error: The type "type[ShouldBeInvariant1]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:113: error: "ShouldBeInvariant1" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:113: error: The type "type[ShouldBeInvariant1]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:116: error: Free type variable expected in Generic[...] [misc] +generics_syntax_infer_variance.py:117: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:117: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:120: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:120: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:123: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:123: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:127: error: "ShouldBeInvariant2" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:127: error: The type "type[ShouldBeInvariant2]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:128: error: "ShouldBeInvariant2" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:128: error: The type "type[ShouldBeInvariant2]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:131: error: Variable "generics_syntax_infer_variance.K" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:131: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:131: error: Variable "generics_syntax_infer_variance.V" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:135: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] +generics_syntax_infer_variance.py:135: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:136: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] +generics_syntax_infer_variance.py:136: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:137: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] +generics_syntax_infer_variance.py:137: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:138: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] +generics_syntax_infer_variance.py:138: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:146: error: Incompatible types in assignment (expression has type "ShouldBeInvariant4[int]", variable has type "ShouldBeInvariant4[float]") [assignment] +generics_syntax_infer_variance.py:154: error: Incompatible types in assignment (expression has type "ShouldBeInvariant5[int]", variable has type "ShouldBeInvariant5[float]") [assignment] +generics_syntax_infer_variance.py:157: error: Free type variable expected in Generic[...] [misc] +generics_syntax_infer_variance.py:158: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:158: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:161: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:161: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:165: error: "ShouldBeContravariant1" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:165: error: The type "type[ShouldBeContravariant1]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:166: error: "ShouldBeContravariant1" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:166: error: The type "type[ShouldBeContravariant1]" is not generic and not indexable [misc] """ conformance_automated = "Fail" errors_diff = """ @@ -117,35 +113,34 @@ Line 21: Unexpected errors ['generics_syntax_infer_variance.py:21: error: Variab Line 24: Unexpected errors ['generics_syntax_infer_variance.py:24: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] Line 28: Unexpected errors ['generics_syntax_infer_variance.py:28: error: "ShouldBeCovariant1" expects no type arguments, but 1 given [type-arg]', 'generics_syntax_infer_variance.py:28: error: The type "type[ShouldBeCovariant1]" is not generic and not indexable [misc]'] Line 32: Unexpected errors ['generics_syntax_infer_variance.py:32: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] -Line 36: Unexpected errors ['generics_syntax_infer_variance.py:36: error: "ShouldBeCovariant2" expects no type arguments, but 1 given [type-arg]', 'generics_syntax_infer_variance.py:36: error: The type "type[ShouldBeCovariant2]" is not generic and not indexable [misc]'] -Line 40: Unexpected errors ['generics_syntax_infer_variance.py:40: error: Free type variable expected in Generic[...] [misc]'] -Line 41: Unexpected errors ['generics_syntax_infer_variance.py:41: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]', 'generics_syntax_infer_variance.py:41: error: "ShouldBeCovariant2" expects no type arguments, but 1 given [type-arg]'] -Line 45: Unexpected errors ['generics_syntax_infer_variance.py:45: error: "ShouldBeCovariant3" expects no type arguments, but 1 given [type-arg]', 'generics_syntax_infer_variance.py:45: error: The type "type[ShouldBeCovariant3]" is not generic and not indexable [misc]'] +Line 34: Unexpected errors ['generics_syntax_infer_variance.py:34: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] +Line 37: Unexpected errors ['generics_syntax_infer_variance.py:37: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] +Line 39: Unexpected errors ['generics_syntax_infer_variance.py:39: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] +Line 46: Unexpected errors ['generics_syntax_infer_variance.py:46: error: "ShouldBeCovariant2" expects no type arguments, but 1 given [type-arg]', 'generics_syntax_infer_variance.py:46: error: The type "type[ShouldBeCovariant2]" is not generic and not indexable [misc]'] Line 50: Unexpected errors ['generics_syntax_infer_variance.py:50: error: Free type variable expected in Generic[...] [misc]'] -Line 51: Unexpected errors ['generics_syntax_infer_variance.py:51: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] -Line 54: Unexpected errors ['generics_syntax_infer_variance.py:54: error: "ShouldBeCovariant4" expects no type arguments, but 1 given [type-arg]', 'generics_syntax_infer_variance.py:54: error: The type "type[ShouldBeCovariant4]" is not generic and not indexable [misc]'] -Line 58: Unexpected errors ['generics_syntax_infer_variance.py:58: error: Free type variable expected in Generic[...] [misc]'] -Line 59: Unexpected errors ['generics_syntax_infer_variance.py:59: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] -Line 63: Unexpected errors ['generics_syntax_infer_variance.py:63: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] -Line 67: Unexpected errors ['generics_syntax_infer_variance.py:67: error: "ShouldBeCovariant5" expects no type arguments, but 1 given [type-arg]', 'generics_syntax_infer_variance.py:67: error: The type "type[ShouldBeCovariant5]" is not generic and not indexable [misc]'] -Line 71: Unexpected errors ['generics_syntax_infer_variance.py:71: error: Free type variable expected in Generic[...] [misc]'] -Line 72: Unexpected errors ['generics_syntax_infer_variance.py:72: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] -Line 74: Unexpected errors ['generics_syntax_infer_variance.py:74: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] -Line 78: Unexpected errors ['generics_syntax_infer_variance.py:78: error: "ShouldBeCovariant6" expects no type arguments, but 1 given [type-arg]', 'generics_syntax_infer_variance.py:78: error: The type "type[ShouldBeCovariant6]" is not generic and not indexable [misc]'] -Line 82: Unexpected errors ['generics_syntax_infer_variance.py:82: error: Free type variable expected in Generic[...] [misc]'] -Line 83: Unexpected errors ['generics_syntax_infer_variance.py:83: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] +Line 51: Unexpected errors ['generics_syntax_infer_variance.py:51: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]', 'generics_syntax_infer_variance.py:51: error: "ShouldBeCovariant2" expects no type arguments, but 1 given [type-arg]'] +Line 55: Unexpected errors ['generics_syntax_infer_variance.py:55: error: "ShouldBeCovariant3" expects no type arguments, but 1 given [type-arg]', 'generics_syntax_infer_variance.py:55: error: The type "type[ShouldBeCovariant3]" is not generic and not indexable [misc]'] +Line 60: Unexpected errors ['generics_syntax_infer_variance.py:60: error: Free type variable expected in Generic[...] [misc]'] +Line 61: Unexpected errors ['generics_syntax_infer_variance.py:61: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] +Line 75: Unexpected errors ['generics_syntax_infer_variance.py:75: error: Free type variable expected in Generic[...] [misc]'] +Line 76: Unexpected errors ['generics_syntax_infer_variance.py:76: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] +Line 80: Unexpected errors ['generics_syntax_infer_variance.py:80: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] +Line 84: Unexpected errors ['generics_syntax_infer_variance.py:84: error: "ShouldBeCovariant5" expects no type arguments, but 1 given [type-arg]', 'generics_syntax_infer_variance.py:84: error: The type "type[ShouldBeCovariant5]" is not generic and not indexable [misc]'] +Line 88: Unexpected errors ['generics_syntax_infer_variance.py:88: error: Free type variable expected in Generic[...] [misc]'] +Line 89: Unexpected errors ['generics_syntax_infer_variance.py:89: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] Line 91: Unexpected errors ['generics_syntax_infer_variance.py:91: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] +Line 95: Unexpected errors ['generics_syntax_infer_variance.py:95: error: "ShouldBeCovariant6" expects no type arguments, but 1 given [type-arg]', 'generics_syntax_infer_variance.py:95: error: The type "type[ShouldBeCovariant6]" is not generic and not indexable [misc]'] Line 99: Unexpected errors ['generics_syntax_infer_variance.py:99: error: Free type variable expected in Generic[...] [misc]'] Line 100: Unexpected errors ['generics_syntax_infer_variance.py:100: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] -Line 103: Unexpected errors ['generics_syntax_infer_variance.py:103: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] -Line 106: Unexpected errors ['generics_syntax_infer_variance.py:106: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] -Line 114: Unexpected errors ['generics_syntax_infer_variance.py:114: error: Variable "generics_syntax_infer_variance.K" is not valid as a type [valid-type]', 'generics_syntax_infer_variance.py:114: error: Variable "generics_syntax_infer_variance.V" is not valid as a type [valid-type]'] -Line 125: Unexpected errors ['generics_syntax_infer_variance.py:125: error: PEP 695 generics are not yet supported [valid-type]'] -Line 126: Unexpected errors ['generics_syntax_infer_variance.py:126: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] -Line 132: Unexpected errors ['generics_syntax_infer_variance.py:132: error: PEP 695 generics are not yet supported [valid-type]'] -Line 133: Unexpected errors ['generics_syntax_infer_variance.py:133: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] -Line 140: Unexpected errors ['generics_syntax_infer_variance.py:140: error: Free type variable expected in Generic[...] [misc]'] -Line 141: Unexpected errors ['generics_syntax_infer_variance.py:141: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] -Line 144: Unexpected errors ['generics_syntax_infer_variance.py:144: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] -Line 149: Unexpected errors ['generics_syntax_infer_variance.py:149: error: "ShouldBeContravariant1" expects no type arguments, but 1 given [type-arg]', 'generics_syntax_infer_variance.py:149: error: The type "type[ShouldBeContravariant1]" is not generic and not indexable [misc]'] +Line 104: Unexpected errors ['generics_syntax_infer_variance.py:104: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] +Line 108: Unexpected errors ['generics_syntax_infer_variance.py:108: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] +Line 116: Unexpected errors ['generics_syntax_infer_variance.py:116: error: Free type variable expected in Generic[...] [misc]'] +Line 117: Unexpected errors ['generics_syntax_infer_variance.py:117: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] +Line 120: Unexpected errors ['generics_syntax_infer_variance.py:120: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] +Line 123: Unexpected errors ['generics_syntax_infer_variance.py:123: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] +Line 131: Unexpected errors ['generics_syntax_infer_variance.py:131: error: Variable "generics_syntax_infer_variance.K" is not valid as a type [valid-type]', 'generics_syntax_infer_variance.py:131: error: Variable "generics_syntax_infer_variance.V" is not valid as a type [valid-type]'] +Line 157: Unexpected errors ['generics_syntax_infer_variance.py:157: error: Free type variable expected in Generic[...] [misc]'] +Line 158: Unexpected errors ['generics_syntax_infer_variance.py:158: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] +Line 161: Unexpected errors ['generics_syntax_infer_variance.py:161: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type]'] +Line 166: Unexpected errors ['generics_syntax_infer_variance.py:166: error: "ShouldBeContravariant1" expects no type arguments, but 1 given [type-arg]', 'generics_syntax_infer_variance.py:166: error: The type "type[ShouldBeContravariant1]" is not generic and not indexable [misc]'] """ diff --git a/conformance/results/mypy/generics_syntax_scoping.toml b/conformance/results/mypy/generics_syntax_scoping.toml index 5e961fdcb..433b9c67b 100644 --- a/conformance/results/mypy/generics_syntax_scoping.toml +++ b/conformance/results/mypy/generics_syntax_scoping.toml @@ -1,91 +1,36 @@ -conformant = "Unsupported" +conformant = "Partial" notes = """ -Type parameter syntax not yet support. +Does not following runtime scoping rules for type parameters in all cases. """ output = """ -generics_syntax_scoping.py:14: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_scoping.py:18: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_scoping.py:22: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_scoping.py:26: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_scoping.py:27: error: "Foo" expects no type arguments, but 1 given [type-arg] -generics_syntax_scoping.py:27: error: Variable "generics_syntax_scoping.T" is not valid as a type [valid-type] -generics_syntax_scoping.py:27: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_scoping.py:31: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_scoping.py:31: error: "BaseClassC" expects no type arguments, but 1 given [type-arg] -generics_syntax_scoping.py:31: error: Variable "generics_syntax_scoping.T" is not valid as a type [valid-type] -generics_syntax_scoping.py:31: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_scoping.py:31: error: The type "type[Foo]" is not generic and not indexable [misc] -generics_syntax_scoping.py:31: error: Cannot determine type of "T" [has-type] -generics_syntax_scoping.py:35: error: Cannot determine type of "T" [has-type] -generics_syntax_scoping.py:35: error: Name "T" is used before definition [used-before-def] -generics_syntax_scoping.py:39: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_scoping.py:40: error: "Foo" expects no type arguments, but 1 given [type-arg] -generics_syntax_scoping.py:40: error: Variable "generics_syntax_scoping.T" is not valid as a type [valid-type] -generics_syntax_scoping.py:40: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_scoping.py:40: error: The first argument to Callable must be a list of types, parameter specification, or "..." [valid-type] -generics_syntax_scoping.py:40: note: See https://mypy.readthedocs.io/en/stable/kinds_of_types.html#callable-types-and-lambdas -generics_syntax_scoping.py:40: error: Name "P" is not defined [name-defined] -generics_syntax_scoping.py:40: error: Name "R" is not defined [name-defined] -generics_syntax_scoping.py:44: error: The type "type[Foo]" is not generic and not indexable [misc] -generics_syntax_scoping.py:44: error: Cannot determine type of "T" [has-type] -generics_syntax_scoping.py:45: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_scoping.py:49: error: PEP 695 type aliases are not yet supported [valid-type] -generics_syntax_scoping.py:49: error: Name "K" is not defined [name-defined] -generics_syntax_scoping.py:49: error: Name "V" is not defined [name-defined] -generics_syntax_scoping.py:55: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_scoping.py:59: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_scoping.py:62: error: Expression is of type "Any", not "str" [assert-type] -generics_syntax_scoping.py:62: note: "assert_type" expects everything to be "Any" in unchecked functions -generics_syntax_scoping.py:67: error: Expression is of type "Any", not "int" [assert-type] -generics_syntax_scoping.py:67: note: "assert_type" expects everything to be "Any" in unchecked functions -generics_syntax_scoping.py:74: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_scoping.py:74: error: Variable "generics_syntax_scoping.T" is not valid as a type [valid-type] -generics_syntax_scoping.py:74: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_scoping.py:77: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_scoping.py:77: error: "Inner" expects no type arguments, but 1 given [type-arg] -generics_syntax_scoping.py:77: error: Variable "generics_syntax_scoping.T" is not valid as a type [valid-type] -generics_syntax_scoping.py:77: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_scoping.py:81: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_scoping.py:81: error: The first argument to Callable must be a list of types, parameter specification, or "..." [valid-type] -generics_syntax_scoping.py:81: note: See https://mypy.readthedocs.io/en/stable/kinds_of_types.html#callable-types-and-lambdas -generics_syntax_scoping.py:81: error: Name "P" is not defined [name-defined] -generics_syntax_scoping.py:81: error: Name "R" is not defined [name-defined] -generics_syntax_scoping.py:89: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_scoping.py:89: error: Variable "generics_syntax_scoping.T" is not valid as a type [valid-type] +generics_syntax_scoping.py:14: error: Name "S" is not defined [name-defined] +generics_syntax_scoping.py:18: error: Variable "generics_syntax_scoping.T" is not valid as a type [valid-type] +generics_syntax_scoping.py:18: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_scoping.py:26: error: Cannot determine type of "T" [has-type] +generics_syntax_scoping.py:26: error: Name "T" is used before definition [used-before-def] +generics_syntax_scoping.py:35: error: Variable "generics_syntax_scoping.T" is not valid as a type [valid-type] +generics_syntax_scoping.py:35: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_scoping.py:53: error: Expression is of type "Any", not "str" [assert-type] +generics_syntax_scoping.py:53: note: "assert_type" expects everything to be "Any" in unchecked functions +generics_syntax_scoping.py:58: error: Expression is of type "Any", not "int" [assert-type] +generics_syntax_scoping.py:58: note: "assert_type" expects everything to be "Any" in unchecked functions +generics_syntax_scoping.py:83: error: "T" already defined as a type parameter [misc] +generics_syntax_scoping.py:86: error: "T" already defined as a type parameter [misc] +generics_syntax_scoping.py:89: error: "T" already defined as a type parameter [misc] +generics_syntax_scoping.py:89: error: Variable "generics_syntax_scoping.ClassE.T" is not valid as a type [valid-type] generics_syntax_scoping.py:89: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_scoping.py:92: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_scoping.py:95: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_scoping.py:98: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_scoping.py:98: error: Variable "generics_syntax_scoping.ClassE.T" is not valid as a type [valid-type] -generics_syntax_scoping.py:98: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_scoping.py:105: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_scoping.py:116: error: Expression is of type "Any", not "TypeVar" [assert-type] +generics_syntax_scoping.py:108: error: Expression is of type "Any", not "TypeVar" [assert-type] +generics_syntax_scoping.py:108: note: "assert_type" expects everything to be "Any" in unchecked functions +generics_syntax_scoping.py:113: error: Expression is of type "Any", not "complex" [assert-type] +generics_syntax_scoping.py:113: note: "assert_type" expects everything to be "Any" in unchecked functions +generics_syntax_scoping.py:116: error: Expression is of type "Any", not "complex" [assert-type] generics_syntax_scoping.py:116: note: "assert_type" expects everything to be "Any" in unchecked functions -generics_syntax_scoping.py:121: error: Expression is of type "Any", not "complex" [assert-type] -generics_syntax_scoping.py:121: note: "assert_type" expects everything to be "Any" in unchecked functions -generics_syntax_scoping.py:124: error: Expression is of type "Any", not "complex" [assert-type] -generics_syntax_scoping.py:124: note: "assert_type" expects everything to be "Any" in unchecked functions """ conformance_automated = "Fail" errors_diff = """ -Line 22: Unexpected errors ['generics_syntax_scoping.py:22: error: PEP 695 generics are not yet supported [valid-type]'] -Line 26: Unexpected errors ['generics_syntax_scoping.py:26: error: PEP 695 generics are not yet supported [valid-type]'] -Line 27: Unexpected errors ['generics_syntax_scoping.py:27: error: "Foo" expects no type arguments, but 1 given [type-arg]', 'generics_syntax_scoping.py:27: error: Variable "generics_syntax_scoping.T" is not valid as a type [valid-type]'] -Line 31: Unexpected errors ['generics_syntax_scoping.py:31: error: PEP 695 generics are not yet supported [valid-type]', 'generics_syntax_scoping.py:31: error: "BaseClassC" expects no type arguments, but 1 given [type-arg]', 'generics_syntax_scoping.py:31: error: Variable "generics_syntax_scoping.T" is not valid as a type [valid-type]', 'generics_syntax_scoping.py:31: error: The type "type[Foo]" is not generic and not indexable [misc]', 'generics_syntax_scoping.py:31: error: Cannot determine type of "T" [has-type]'] -Line 39: Unexpected errors ['generics_syntax_scoping.py:39: error: PEP 695 generics are not yet supported [valid-type]'] -Line 40: Unexpected errors ['generics_syntax_scoping.py:40: error: "Foo" expects no type arguments, but 1 given [type-arg]', 'generics_syntax_scoping.py:40: error: Variable "generics_syntax_scoping.T" is not valid as a type [valid-type]', 'generics_syntax_scoping.py:40: error: The first argument to Callable must be a list of types, parameter specification, or "..." [valid-type]', 'generics_syntax_scoping.py:40: error: Name "P" is not defined [name-defined]', 'generics_syntax_scoping.py:40: error: Name "R" is not defined [name-defined]'] -Line 45: Unexpected errors ['generics_syntax_scoping.py:45: error: PEP 695 generics are not yet supported [valid-type]'] -Line 49: Unexpected errors ['generics_syntax_scoping.py:49: error: PEP 695 type aliases are not yet supported [valid-type]', 'generics_syntax_scoping.py:49: error: Name "K" is not defined [name-defined]', 'generics_syntax_scoping.py:49: error: Name "V" is not defined [name-defined]'] -Line 55: Unexpected errors ['generics_syntax_scoping.py:55: error: PEP 695 generics are not yet supported [valid-type]'] -Line 59: Unexpected errors ['generics_syntax_scoping.py:59: error: PEP 695 generics are not yet supported [valid-type]'] -Line 62: Unexpected errors ['generics_syntax_scoping.py:62: error: Expression is of type "Any", not "str" [assert-type]'] -Line 67: Unexpected errors ['generics_syntax_scoping.py:67: error: Expression is of type "Any", not "int" [assert-type]'] -Line 74: Unexpected errors ['generics_syntax_scoping.py:74: error: PEP 695 generics are not yet supported [valid-type]', 'generics_syntax_scoping.py:74: error: Variable "generics_syntax_scoping.T" is not valid as a type [valid-type]'] -Line 77: Unexpected errors ['generics_syntax_scoping.py:77: error: PEP 695 generics are not yet supported [valid-type]', 'generics_syntax_scoping.py:77: error: "Inner" expects no type arguments, but 1 given [type-arg]', 'generics_syntax_scoping.py:77: error: Variable "generics_syntax_scoping.T" is not valid as a type [valid-type]'] -Line 81: Unexpected errors ['generics_syntax_scoping.py:81: error: PEP 695 generics are not yet supported [valid-type]', 'generics_syntax_scoping.py:81: error: The first argument to Callable must be a list of types, parameter specification, or "..." [valid-type]', 'generics_syntax_scoping.py:81: error: Name "P" is not defined [name-defined]', 'generics_syntax_scoping.py:81: error: Name "R" is not defined [name-defined]'] -Line 89: Unexpected errors ['generics_syntax_scoping.py:89: error: PEP 695 generics are not yet supported [valid-type]', 'generics_syntax_scoping.py:89: error: Variable "generics_syntax_scoping.T" is not valid as a type [valid-type]'] -Line 105: Unexpected errors ['generics_syntax_scoping.py:105: error: PEP 695 generics are not yet supported [valid-type]'] -Line 116: Unexpected errors ['generics_syntax_scoping.py:116: error: Expression is of type "Any", not "TypeVar" [assert-type]'] -Line 121: Unexpected errors ['generics_syntax_scoping.py:121: error: Expression is of type "Any", not "complex" [assert-type]'] -Line 124: Unexpected errors ['generics_syntax_scoping.py:124: error: Expression is of type "Any", not "complex" [assert-type]'] +Line 53: Unexpected errors ['generics_syntax_scoping.py:53: error: Expression is of type "Any", not "str" [assert-type]'] +Line 58: Unexpected errors ['generics_syntax_scoping.py:58: error: Expression is of type "Any", not "int" [assert-type]'] +Line 108: Unexpected errors ['generics_syntax_scoping.py:108: error: Expression is of type "Any", not "TypeVar" [assert-type]'] +Line 113: Unexpected errors ['generics_syntax_scoping.py:113: error: Expression is of type "Any", not "complex" [assert-type]'] +Line 116: Unexpected errors ['generics_syntax_scoping.py:116: error: Expression is of type "Any", not "complex" [assert-type]'] """ diff --git a/conformance/results/mypy/generics_type_erasure.toml b/conformance/results/mypy/generics_type_erasure.toml index 86e3cf0ae..a37b9c98a 100644 --- a/conformance/results/mypy/generics_type_erasure.toml +++ b/conformance/results/mypy/generics_type_erasure.toml @@ -1,21 +1,19 @@ conformant = "Partial" notes = """ -Infers Node[Never] instead of Node[Any] when argument is not provided. -False negative on instance attribute access on type(node). +Infers `Node[Never]` instead of `Node[Any]` when argument is not provided. """ output = """ -generics_type_erasure.py:17: error: Expression is of type "Node[Never]", not "Node[Any]" [assert-type] -generics_type_erasure.py:20: error: Expression is of type Never, not "Any" [assert-type] -generics_type_erasure.py:36: error: Argument 1 to "Node" has incompatible type "str"; expected "int | None" [arg-type] -generics_type_erasure.py:38: error: Argument 1 to "Node" has incompatible type "int"; expected "str | None" [arg-type] -generics_type_erasure.py:40: error: Access to generic instance variables via class is ambiguous [misc] -generics_type_erasure.py:41: error: Access to generic instance variables via class is ambiguous [misc] +generics_type_erasure.py:19: error: Expression is of type "Node[Never]", not "Node[Any]" [assert-type] +generics_type_erasure.py:22: error: Expression is of type "Never", not "Any" [assert-type] +generics_type_erasure.py:38: error: Argument 1 to "Node" has incompatible type "str"; expected "int | None" [arg-type] +generics_type_erasure.py:40: error: Argument 1 to "Node" has incompatible type "int"; expected "str | None" [arg-type] generics_type_erasure.py:42: error: Access to generic instance variables via class is ambiguous [misc] generics_type_erasure.py:43: error: Access to generic instance variables via class is ambiguous [misc] +generics_type_erasure.py:44: error: Access to generic instance variables via class is ambiguous [misc] +generics_type_erasure.py:45: error: Access to generic instance variables via class is ambiguous [misc] """ conformance_automated = "Fail" errors_diff = """ -Line 44: Expected 1 errors -Line 17: Unexpected errors ['generics_type_erasure.py:17: error: Expression is of type "Node[Never]", not "Node[Any]" [assert-type]'] -Line 20: Unexpected errors ['generics_type_erasure.py:20: error: Expression is of type Never, not "Any" [assert-type]'] +Line 19: Unexpected errors ['generics_type_erasure.py:19: error: Expression is of type "Node[Never]", not "Node[Any]" [assert-type]'] +Line 22: Unexpected errors ['generics_type_erasure.py:22: error: Expression is of type "Never", not "Any" [assert-type]'] """ diff --git a/conformance/results/mypy/generics_typevartuple_args.toml b/conformance/results/mypy/generics_typevartuple_args.toml index a6fae99fd..5920b7325 100644 --- a/conformance/results/mypy/generics_typevartuple_args.toml +++ b/conformance/results/mypy/generics_typevartuple_args.toml @@ -1,6 +1,6 @@ conformant = "Partial" notes = """ -Does not enforce that tuples captured by TypeVarTuple are same type. +Does not enforce that tuples captured by `TypeVarTuple` are of the same length. """ output = """ generics_typevartuple_args.py:33: error: Argument 3 to "exec_le" has incompatible type "str"; expected "Env" [arg-type] @@ -15,5 +15,4 @@ generics_typevartuple_args.py:67: error: Too few arguments for "func3" [call-ar conformance_automated = "Fail" errors_diff = """ Line 75: Expected 1 errors -Line 76: Expected 1 errors """ diff --git a/conformance/results/mypy/generics_typevartuple_basic.toml b/conformance/results/mypy/generics_typevartuple_basic.toml index 7319c34cd..5bf562c64 100644 --- a/conformance/results/mypy/generics_typevartuple_basic.toml +++ b/conformance/results/mypy/generics_typevartuple_basic.toml @@ -1,29 +1,23 @@ conformant = "Partial" notes = """ -Does not enforce that tuples captured by TypeVarTuple are same length. -Does not enforce that tuples captured by TypeVarTuple are same type. +Does not enforce that tuples captured by `TypeVarTuple` are same length. """ output = """ -generics_typevartuple_basic.py:42: error: Argument 1 to "Array" has incompatible type "Height"; expected "tuple[Height, Width]" [arg-type] -generics_typevartuple_basic.py:43: error: Argument 1 to "Array" has incompatible type "tuple[Batch, Width]"; expected "tuple[Batch, Height, Width]" [arg-type] -generics_typevartuple_basic.py:45: error: Argument 1 to "Array" has incompatible type "tuple[Time, Batch, Width, Height]"; expected "tuple[Time, Batch, Height, Width]" [arg-type] -generics_typevartuple_basic.py:52: error: Free type variable expected in Generic[...] [misc] -generics_typevartuple_basic.py:53: error: TypeVarTuple "Shape" is only valid with an unpack [valid-type] -generics_typevartuple_basic.py:56: error: TypeVarTuple "Shape" is only valid with an unpack [valid-type] -generics_typevartuple_basic.py:57: error: Incompatible return value type (got "tuple[*Shape]", expected "tuple[Any]") [return-value] -generics_typevartuple_basic.py:59: error: TypeVarTuple "Shape" is only valid with an unpack [valid-type] -generics_typevartuple_basic.py:65: error: Unexpected keyword argument "covariant" for "TypeVarTuple" [misc] +generics_typevartuple_basic.py:43: error: Argument 1 to "Array" has incompatible type "Height"; expected "tuple[Height, Width]" [arg-type] +generics_typevartuple_basic.py:44: error: Argument 1 to "Array" has incompatible type "tuple[Batch, Width]"; expected "tuple[Batch, Height, Width]" [arg-type] +generics_typevartuple_basic.py:46: error: Argument 1 to "Array" has incompatible type "tuple[Time, Batch, Width, Height]"; expected "tuple[Time, Batch, Height, Width]" [arg-type] +generics_typevartuple_basic.py:53: error: Free type variable expected in Generic[...] [misc] +generics_typevartuple_basic.py:54: error: TypeVarTuple "Shape" is only valid with an unpack [valid-type] +generics_typevartuple_basic.py:57: error: TypeVarTuple "Shape" is only valid with an unpack [valid-type] +generics_typevartuple_basic.py:60: error: TypeVarTuple "Shape" is only valid with an unpack [valid-type] generics_typevartuple_basic.py:66: error: Too many positional arguments for "TypeVarTuple" [misc] generics_typevartuple_basic.py:67: error: Unexpected keyword argument "bound" for "TypeVarTuple" [misc] -generics_typevartuple_basic.py:99: error: Cannot infer type argument 1 of "multiply" [misc] -generics_typevartuple_basic.py:100: error: Cannot infer type argument 1 of "multiply" [misc] -generics_typevartuple_basic.py:106: error: Can only use one type var tuple in a class def [misc] +generics_typevartuple_basic.py:100: error: Cannot infer value of type parameter "Shape" of "multiply" [misc] +generics_typevartuple_basic.py:101: error: Cannot infer value of type parameter "Shape" of "multiply" [misc] +generics_typevartuple_basic.py:107: error: Can only use one type var tuple in a class def [misc] +generics_typevartuple_basic.py:111: error: Can only use one type var tuple in a class def [misc] """ conformance_automated = "Fail" errors_diff = """ -Line 44: Expected 1 errors -Line 89: Expected 1 errors -Line 90: Expected 1 errors -Line 45: Unexpected errors ['generics_typevartuple_basic.py:45: error: Argument 1 to "Array" has incompatible type "tuple[Time, Batch, Width, Height]"; expected "tuple[Time, Batch, Height, Width]" [arg-type]'] -Line 57: Unexpected errors ['generics_typevartuple_basic.py:57: error: Incompatible return value type (got "tuple[*Shape]", expected "tuple[Any]") [return-value]'] +Line 91: Expected 1 errors """ diff --git a/conformance/results/mypy/generics_typevartuple_specialization.toml b/conformance/results/mypy/generics_typevartuple_specialization.toml index 00f8c44e6..dacfd5951 100644 --- a/conformance/results/mypy/generics_typevartuple_specialization.toml +++ b/conformance/results/mypy/generics_typevartuple_specialization.toml @@ -1,24 +1,20 @@ conformant = "Partial" notes = """ -Incorrectly specializes generic alias that includes a TypeVar and TypeVarTuple if no type arguments are provided. -Rejects specialization of generic type alias defined as a tuple containing a TypeVar. -"More than one Unpack" error message has no line number. +Incorrectly specializes generic alias that includes a `TypeVar` and `TypeVarTuple` if no type arguments are provided. +Rejects specialization of generic type alias defined as a tuple containing a `TypeVar`. """ output = """ -generics_typevartuple_specialization.py: error: More than one Unpack in a type is not allowed [misc] -generics_typevartuple_specialization.py:85: error: Argument 1 to "takes_float_array_with_specific_shape" has incompatible type "Array2[float, *tuple[Any, ...]]"; expected "Array2[float, Height, Width]" [arg-type] generics_typevartuple_specialization.py:108: error: Type application is only supported for generic classes [misc] generics_typevartuple_specialization.py:109: error: Type application is only supported for generic classes [misc] generics_typevartuple_specialization.py:109: error: Unpack is only valid in a variadic position [valid-type] generics_typevartuple_specialization.py:110: error: Type application is only supported for generic classes [misc] generics_typevartuple_specialization.py:110: error: Unpack is only valid in a variadic position [valid-type] +generics_typevartuple_specialization.py:121: error: More than one variadic Unpack in a type is not allowed [misc] +generics_typevartuple_specialization.py:122: error: More than one variadic Unpack in a type is not allowed [misc] generics_typevartuple_specialization.py:127: error: Bad number of arguments for type alias, expected at least 2, given 1 [type-arg] generics_typevartuple_specialization.py:163: error: TypeVarTuple cannot be split [type-arg] """ conformance_automated = "Fail" errors_diff = """ -Line 121: Expected 1 errors -Line 122: Expected 1 errors -Line 85: Unexpected errors ['generics_typevartuple_specialization.py:85: error: Argument 1 to "takes_float_array_with_specific_shape" has incompatible type "Array2[float, *tuple[Any, ...]]"; expected "Array2[float, Height, Width]" [arg-type]'] Line 108: Unexpected errors ['generics_typevartuple_specialization.py:108: error: Type application is only supported for generic classes [misc]'] """ diff --git a/conformance/results/mypy/generics_typevartuple_variance.toml b/conformance/results/mypy/generics_typevartuple_variance.toml new file mode 100644 index 000000000..35d157ef1 --- /dev/null +++ b/conformance/results/mypy/generics_typevartuple_variance.toml @@ -0,0 +1,51 @@ +conformant = "Unsupported" +conformance_automated = "Fail" +errors_diff = """ +Line 14: Expected 1 errors +Line 18: Expected 1 errors +Line 21: Expected 1 errors +Line 28: Expected 1 errors +Line 31: Expected 1 errors +Line 34: Expected 1 errors +Line 68: Expected 1 errors +Line 79: Expected 1 errors +Line 83: Expected 1 errors +Line 90: Expected 1 errors +Line 107: Expected 1 errors +Line 29: Unexpected errors ['generics_typevartuple_variance.py:29: error: Incompatible types in assignment (expression has type "ContravariantTypeVarTuple[object]", variable has type "ContravariantTypeVarTuple[int]") [assignment]'] +Line 30: Unexpected errors ['generics_typevartuple_variance.py:30: error: Incompatible types in assignment (expression has type "ContravariantTypeVarTuple[*tuple[object, ...]]", variable has type "ContravariantTypeVarTuple[*tuple[int, ...]]") [assignment]'] +Line 33: Unexpected errors ['generics_typevartuple_variance.py:33: error: Incompatible types in assignment (expression has type "ContravariantTypeVarTuple[*tuple[int, ...]]", variable has type "ContravariantTypeVarTuple[int]") [assignment]'] +Line 55: Unexpected errors ['generics_typevartuple_variance.py:55: error: Unexpected keyword argument "infer_variance" for "TypeVarTuple" [misc]'] +Line 73: Unexpected errors ['generics_typevartuple_variance.py:73: error: Unexpected keyword argument "contravariant" for "TypeVarTuple" [misc]'] +Line 84: Unexpected errors ['generics_typevartuple_variance.py:84: error: Incompatible types in assignment (expression has type "ContravariantTypeVarTupleOld[object]", variable has type "ContravariantTypeVarTupleOld[int]") [assignment]'] +Line 87: Unexpected errors ['generics_typevartuple_variance.py:87: error: Unexpected keyword argument "covariant" for "TypeVarTuple" [misc]'] +Line 108: Unexpected errors ['generics_typevartuple_variance.py:108: error: Incompatible types in assignment (expression has type "InferredContravariantTypeVarTupleOld[object]", variable has type "InferredContravariantTypeVarTupleOld[int]") [assignment]'] +""" +output = """ +generics_typevartuple_variance.py:15: error: Incompatible types in assignment (expression has type "InvariantTypeVarTuple[object]", variable has type "InvariantTypeVarTuple[int]") [assignment] +generics_typevartuple_variance.py:17: error: Incompatible types in assignment (expression has type "InvariantTypeVarTuple[*tuple[object, ...]]", variable has type "InvariantTypeVarTuple[*tuple[int, ...]]") [assignment] +generics_typevartuple_variance.py:20: error: Incompatible types in assignment (expression has type "InvariantTypeVarTuple[*tuple[int, ...]]", variable has type "InvariantTypeVarTuple[int]") [assignment] +generics_typevartuple_variance.py:29: error: Incompatible types in assignment (expression has type "ContravariantTypeVarTuple[object]", variable has type "ContravariantTypeVarTuple[int]") [assignment] +generics_typevartuple_variance.py:30: error: Incompatible types in assignment (expression has type "ContravariantTypeVarTuple[*tuple[object, ...]]", variable has type "ContravariantTypeVarTuple[*tuple[int, ...]]") [assignment] +generics_typevartuple_variance.py:33: error: Incompatible types in assignment (expression has type "ContravariantTypeVarTuple[*tuple[int, ...]]", variable has type "ContravariantTypeVarTuple[int]") [assignment] +generics_typevartuple_variance.py:42: error: Incompatible types in assignment (expression has type "CovariantTypeVarTuple[object]", variable has type "CovariantTypeVarTuple[int]") [assignment] +generics_typevartuple_variance.py:45: error: Incompatible types in assignment (expression has type "CovariantTypeVarTuple[bool, object]", variable has type "CovariantTypeVarTuple[int, int]") [assignment] +generics_typevartuple_variance.py:46: error: Incompatible types in assignment (expression has type "CovariantTypeVarTuple[object, bool]", variable has type "CovariantTypeVarTuple[int, int]") [assignment] +generics_typevartuple_variance.py:47: error: Incompatible types in assignment (expression has type "CovariantTypeVarTuple[object, object]", variable has type "CovariantTypeVarTuple[int, int]") [assignment] +generics_typevartuple_variance.py:48: error: Incompatible types in assignment (expression has type "CovariantTypeVarTuple[*tuple[object, ...]]", variable has type "CovariantTypeVarTuple[*tuple[int, ...]]") [assignment] +generics_typevartuple_variance.py:51: error: Incompatible types in assignment (expression has type "CovariantTypeVarTuple[*tuple[int, ...]]", variable has type "CovariantTypeVarTuple[int]") [assignment] +generics_typevartuple_variance.py:55: error: Unexpected keyword argument "infer_variance" for "TypeVarTuple" [misc] +generics_typevartuple_variance.py:56: error: Unexpected keyword argument "covariant" for "TypeVarTuple" [misc] +generics_typevartuple_variance.py:56: error: Unexpected keyword argument "contravariant" for "TypeVarTuple" [misc] +generics_typevartuple_variance.py:57: error: Unexpected keyword argument "covariant" for "TypeVarTuple" [misc] +generics_typevartuple_variance.py:57: error: Unexpected keyword argument "infer_variance" for "TypeVarTuple" [misc] +generics_typevartuple_variance.py:58: error: Unexpected keyword argument "contravariant" for "TypeVarTuple" [misc] +generics_typevartuple_variance.py:58: error: Unexpected keyword argument "infer_variance" for "TypeVarTuple" [misc] +generics_typevartuple_variance.py:69: error: Incompatible types in assignment (expression has type "InvariantTypeVarTupleOld[object]", variable has type "InvariantTypeVarTupleOld[int]") [assignment] +generics_typevartuple_variance.py:73: error: Unexpected keyword argument "contravariant" for "TypeVarTuple" [misc] +generics_typevartuple_variance.py:84: error: Incompatible types in assignment (expression has type "ContravariantTypeVarTupleOld[object]", variable has type "ContravariantTypeVarTupleOld[int]") [assignment] +generics_typevartuple_variance.py:87: error: Unexpected keyword argument "covariant" for "TypeVarTuple" [misc] +generics_typevartuple_variance.py:97: error: Incompatible types in assignment (expression has type "CovariantTypeVarTupleOld[object]", variable has type "CovariantTypeVarTupleOld[int]") [assignment] +generics_typevartuple_variance.py:108: error: Incompatible types in assignment (expression has type "InferredContravariantTypeVarTupleOld[object]", variable has type "InferredContravariantTypeVarTupleOld[int]") [assignment] +generics_typevartuple_variance.py:116: error: Incompatible types in assignment (expression has type "InferredCovariantTypeVarTupleOld[object]", variable has type "InferredCovariantTypeVarTupleOld[int]") [assignment] +""" diff --git a/conformance/results/mypy/generics_upper_bound.toml b/conformance/results/mypy/generics_upper_bound.toml index 4cf18a8f0..9aad1c5cf 100644 --- a/conformance/results/mypy/generics_upper_bound.toml +++ b/conformance/results/mypy/generics_upper_bound.toml @@ -4,8 +4,8 @@ Does not reject use of type variable within an upper bound. """ output = """ generics_upper_bound.py:43: error: Expression is of type "Collection[int]", not "list[int] | set[int]" [assert-type] -generics_upper_bound.py:51: error: Value of type variable "ST" of "longer" cannot be "int" [type-var] -generics_upper_bound.py:56: error: TypeVar cannot have both values and an upper bound [misc] +generics_upper_bound.py:52: error: Value of type variable "ST" of "longer" cannot be "int" [type-var] +generics_upper_bound.py:57: error: TypeVar cannot have both values and an upper bound [misc] """ conformance_automated = "Fail" errors_diff = """ diff --git a/conformance/results/mypy/generics_variance.toml b/conformance/results/mypy/generics_variance.toml index 531a60fcc..2dff34a72 100644 --- a/conformance/results/mypy/generics_variance.toml +++ b/conformance/results/mypy/generics_variance.toml @@ -1,6 +1,6 @@ conformant = "Partial" notes = """ -Does not reject use of class-scoped TypeVar used in a base class when variance is incompatible. +Does not reject use of class-scoped `TypeVar` used in a base class when variance is incompatible. """ output = """ generics_variance.py:14: error: TypeVar cannot be both covariant and contravariant [misc] @@ -14,13 +14,9 @@ generics_variance.py:131: error: Variance of TypeVar "T_contra" incompatible wit conformance_automated = "Fail" errors_diff = """ Line 113: Expected 1 errors -Line 126: Expected 1 errors -Line 132: Expected 1 errors -Line 142: Expected 1 errors Line 163: Expected 1 errors Line 167: Expected 1 errors Line 191: Expected 1 errors -Line 196: Expected 1 errors -Line 125: Unexpected errors ['generics_variance.py:125: error: Variance of TypeVar "T_co" incompatible with variance in parent type [type-var]'] -Line 131: Unexpected errors ['generics_variance.py:131: error: Variance of TypeVar "T_contra" incompatible with variance in parent type [type-var]'] +Lines 141, 142: Expected error (tag 'CoContra_Child5') +Lines 195, 196: Expected error (tag 'ContraToContraToContra_WithTA') """ diff --git a/conformance/results/mypy/generics_variance_inference.toml b/conformance/results/mypy/generics_variance_inference.toml index ecc8609cb..761c10490 100644 --- a/conformance/results/mypy/generics_variance_inference.toml +++ b/conformance/results/mypy/generics_variance_inference.toml @@ -1,127 +1,37 @@ -conformant = "Unsupported" +conformant = "Partial" notes = """ -Type parameter syntax not yet support. +polymorphic functions with bound self type influence variance inference, +which is not part of the variance inference algorithm as described in the spec. +See gh-2281 for details. """ output = """ -generics_variance_inference.py:15: error: PEP 695 generics are not yet supported [valid-type] -generics_variance_inference.py:15: error: Name "T1" is not defined [name-defined] -generics_variance_inference.py:16: error: Name "T2" is not defined [name-defined] -generics_variance_inference.py:19: error: Name "T3" is not defined [name-defined] -generics_variance_inference.py:23: error: "ClassA" expects no type arguments, but 3 given [type-arg] -generics_variance_inference.py:24: error: "ClassA" expects no type arguments, but 3 given [type-arg] -generics_variance_inference.py:25: error: "ClassA" expects no type arguments, but 3 given [type-arg] -generics_variance_inference.py:26: error: "ClassA" expects no type arguments, but 3 given [type-arg] -generics_variance_inference.py:28: error: "ClassA" expects no type arguments, but 3 given [type-arg] -generics_variance_inference.py:29: error: "ClassA" expects no type arguments, but 3 given [type-arg] -generics_variance_inference.py:32: error: PEP 695 generics are not yet supported [valid-type] -generics_variance_inference.py:33: error: A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var] -generics_variance_inference.py:40: error: "ShouldBeCovariant1" expects no type arguments, but 1 given [type-arg] -generics_variance_inference.py:40: error: The type "type[ShouldBeCovariant1]" is not generic and not indexable [misc] -generics_variance_inference.py:41: error: "ShouldBeCovariant1" expects no type arguments, but 1 given [type-arg] -generics_variance_inference.py:41: error: The type "type[ShouldBeCovariant1]" is not generic and not indexable [misc] -generics_variance_inference.py:44: error: PEP 695 generics are not yet supported [valid-type] -generics_variance_inference.py:48: error: Cannot instantiate abstract class "ShouldBeCovariant2" with abstract attributes "__getitem__" and "__len__" [abstract] -generics_variance_inference.py:48: error: Incompatible types in assignment (expression has type "ShouldBeCovariant2[int]", variable has type "ShouldBeCovariant2[float]") [assignment] -generics_variance_inference.py:49: error: Cannot instantiate abstract class "ShouldBeCovariant2" with abstract attributes "__getitem__" and "__len__" [abstract] +generics_variance_inference.py:24: error: Incompatible types in assignment (expression has type "ClassA[float, int, int]", variable has type "ClassA[int, int, int]") [assignment] +generics_variance_inference.py:25: error: Incompatible types in assignment (expression has type "ClassA[float, int, int]", variable has type "ClassA[float, float, int]") [assignment] +generics_variance_inference.py:28: error: Incompatible types in assignment (expression has type "ClassA[int, float, float]", variable has type "ClassA[int, int, int]") [assignment] +generics_variance_inference.py:41: error: Incompatible types in assignment (expression has type "ShouldBeCovariant1[float]", variable has type "ShouldBeCovariant1[int]") [assignment] generics_variance_inference.py:49: error: Incompatible types in assignment (expression has type "ShouldBeCovariant2[float]", variable has type "ShouldBeCovariant2[int]") [assignment] -generics_variance_inference.py:52: error: PEP 695 generics are not yet supported [valid-type] -generics_variance_inference.py:57: error: "ShouldBeCovariant3" expects no type arguments, but 1 given [type-arg] -generics_variance_inference.py:57: error: The type "type[ShouldBeCovariant3]" is not generic and not indexable [misc] -generics_variance_inference.py:58: error: "ShouldBeCovariant3" expects no type arguments, but 1 given [type-arg] -generics_variance_inference.py:58: error: The type "type[ShouldBeCovariant3]" is not generic and not indexable [misc] -generics_variance_inference.py:62: error: PEP 695 generics are not yet supported [valid-type] -generics_variance_inference.py:63: error: Type variable "generics_variance_inference.T" is unbound [valid-type] -generics_variance_inference.py:63: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) -generics_variance_inference.py:63: note: (Hint: Use "T" in function signature to bind "T" inside a function) -generics_variance_inference.py:66: error: "ShouldBeCovariant4" expects no type arguments, but 1 given [type-arg] -generics_variance_inference.py:66: error: The type "type[ShouldBeCovariant4]" is not generic and not indexable [misc] -generics_variance_inference.py:67: error: "ShouldBeCovariant4" expects no type arguments, but 1 given [type-arg] -generics_variance_inference.py:67: error: The type "type[ShouldBeCovariant4]" is not generic and not indexable [misc] -generics_variance_inference.py:70: error: PEP 695 generics are not yet supported [valid-type] -generics_variance_inference.py:75: error: A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var] -generics_variance_inference.py:79: error: "ShouldBeCovariant5" expects no type arguments, but 1 given [type-arg] -generics_variance_inference.py:79: error: The type "type[ShouldBeCovariant5]" is not generic and not indexable [misc] -generics_variance_inference.py:80: error: "ShouldBeCovariant5" expects no type arguments, but 1 given [type-arg] -generics_variance_inference.py:80: error: The type "type[ShouldBeCovariant5]" is not generic and not indexable [misc] -generics_variance_inference.py:83: error: PEP 695 generics are not yet supported [valid-type] -generics_variance_inference.py:96: error: "ShouldBeInvariant1" expects no type arguments, but 1 given [type-arg] -generics_variance_inference.py:96: error: The type "type[ShouldBeInvariant1]" is not generic and not indexable [misc] -generics_variance_inference.py:97: error: "ShouldBeInvariant1" expects no type arguments, but 1 given [type-arg] -generics_variance_inference.py:97: error: The type "type[ShouldBeInvariant1]" is not generic and not indexable [misc] -generics_variance_inference.py:100: error: PEP 695 generics are not yet supported [valid-type] -generics_variance_inference.py:104: error: A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var] -generics_variance_inference.py:111: error: "ShouldBeInvariant2" expects no type arguments, but 1 given [type-arg] -generics_variance_inference.py:111: error: The type "type[ShouldBeInvariant2]" is not generic and not indexable [misc] -generics_variance_inference.py:112: error: "ShouldBeInvariant2" expects no type arguments, but 1 given [type-arg] -generics_variance_inference.py:112: error: The type "type[ShouldBeInvariant2]" is not generic and not indexable [misc] -generics_variance_inference.py:115: error: PEP 695 generics are not yet supported [valid-type] -generics_variance_inference.py:115: error: Name "K" is not defined [name-defined] -generics_variance_inference.py:115: error: Name "V" is not defined [name-defined] -generics_variance_inference.py:119: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] -generics_variance_inference.py:119: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] -generics_variance_inference.py:120: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] -generics_variance_inference.py:120: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] -generics_variance_inference.py:121: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] -generics_variance_inference.py:121: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] -generics_variance_inference.py:122: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] -generics_variance_inference.py:122: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] -generics_variance_inference.py:126: error: PEP 695 generics are not yet supported [valid-type] -generics_variance_inference.py:127: error: Type variable "generics_variance_inference.T" is unbound [valid-type] -generics_variance_inference.py:127: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) -generics_variance_inference.py:127: note: (Hint: Use "T" in function signature to bind "T" inside a function) -generics_variance_inference.py:130: error: "ShouldBeInvariant4" expects no type arguments, but 1 given [type-arg] -generics_variance_inference.py:130: error: The type "type[ShouldBeInvariant4]" is not generic and not indexable [misc] -generics_variance_inference.py:133: error: PEP 695 generics are not yet supported [valid-type] -generics_variance_inference.py:138: error: "ShouldBeInvariant5" expects no type arguments, but 1 given [type-arg] -generics_variance_inference.py:138: error: The type "type[ShouldBeInvariant5]" is not generic and not indexable [misc] -generics_variance_inference.py:141: error: PEP 695 generics are not yet supported [valid-type] -generics_variance_inference.py:149: error: "ShouldBeContravariant1" expects no type arguments, but 1 given [type-arg] -generics_variance_inference.py:149: error: The type "type[ShouldBeContravariant1]" is not generic and not indexable [misc] -generics_variance_inference.py:150: error: "ShouldBeContravariant1" expects no type arguments, but 1 given [type-arg] -generics_variance_inference.py:150: error: The type "type[ShouldBeContravariant1]" is not generic and not indexable [misc] -generics_variance_inference.py:165: error: PEP 695 generics are not yet supported [valid-type] +generics_variance_inference.py:58: error: Incompatible types in assignment (expression has type "ShouldBeCovariant3[float]", variable has type "ShouldBeCovariant3[int]") [assignment] +generics_variance_inference.py:67: error: Incompatible types in assignment (expression has type "ShouldBeCovariant4[float]", variable has type "ShouldBeCovariant4[int]") [assignment] +generics_variance_inference.py:80: error: Incompatible types in assignment (expression has type "ShouldBeCovariant5[float]", variable has type "ShouldBeCovariant5[int]") [assignment] +generics_variance_inference.py:96: error: Incompatible types in assignment (expression has type "ShouldBeInvariant1[int]", variable has type "ShouldBeInvariant1[float]") [assignment] +generics_variance_inference.py:97: error: Incompatible types in assignment (expression has type "ShouldBeInvariant1[float]", variable has type "ShouldBeInvariant1[int]") [assignment] +generics_variance_inference.py:111: error: Incompatible types in assignment (expression has type "ShouldBeInvariant2[int]", variable has type "ShouldBeInvariant2[float]") [assignment] +generics_variance_inference.py:112: error: Incompatible types in assignment (expression has type "ShouldBeInvariant2[float]", variable has type "ShouldBeInvariant2[int]") [assignment] +generics_variance_inference.py:119: error: Incompatible types in assignment (expression has type "ShouldBeInvariant3[int, str]", variable has type "ShouldBeInvariant3[float, str]") [assignment] +generics_variance_inference.py:120: error: Incompatible types in assignment (expression has type "ShouldBeInvariant3[float, str]", variable has type "ShouldBeInvariant3[int, str]") [assignment] +generics_variance_inference.py:121: error: Incompatible types in assignment (expression has type "ShouldBeInvariant3[str, int]", variable has type "ShouldBeInvariant3[str, float]") [assignment] +generics_variance_inference.py:122: error: Incompatible types in assignment (expression has type "ShouldBeInvariant3[str, float]", variable has type "ShouldBeInvariant3[str, int]") [assignment] +generics_variance_inference.py:130: error: Incompatible types in assignment (expression has type "ShouldBeInvariant4[int]", variable has type "ShouldBeInvariant4[float]") [assignment] +generics_variance_inference.py:138: error: Incompatible types in assignment (expression has type "ShouldBeInvariant5[int]", variable has type "ShouldBeInvariant5[float]") [assignment] +generics_variance_inference.py:149: error: Incompatible types in assignment (expression has type "ShouldBeContravariant1[int]", variable has type "ShouldBeContravariant1[float]") [assignment] generics_variance_inference.py:169: error: Incompatible types in assignment (expression has type "ShouldBeInvariant6[float]", variable has type "ShouldBeInvariant6[int]") [assignment] generics_variance_inference.py:170: error: Incompatible types in assignment (expression has type "ShouldBeInvariant6[int]", variable has type "ShouldBeInvariant6[float]") [assignment] -generics_variance_inference.py:177: error: PEP 695 generics are not yet supported [valid-type] generics_variance_inference.py:181: error: Incompatible types in assignment (expression has type "ShouldBeCovariant6[float]", variable has type "ShouldBeCovariant6[int]") [assignment] -generics_variance_inference.py:182: error: Incompatible types in assignment (expression has type "ShouldBeCovariant6[int]", variable has type "ShouldBeCovariant6[float]") [assignment] -generics_variance_inference.py:189: error: PEP 695 generics are not yet supported [valid-type] -generics_variance_inference.py:193: error: Incompatible types in assignment (expression has type "ShouldBeContravariant2[float]", variable has type "ShouldBeContravariant2[int]") [assignment] generics_variance_inference.py:194: error: Incompatible types in assignment (expression has type "ShouldBeContravariant2[int]", variable has type "ShouldBeContravariant2[float]") [assignment] +generics_variance_inference.py:204: error: Incompatible types in assignment (expression has type "ShouldBeCovariant7[int]", variable has type "ShouldBeCovariant7[object]") [assignment] +generics_variance_inference.py:205: error: Incompatible types in assignment (expression has type "ShouldBeCovariant7[object]", variable has type "ShouldBeCovariant7[int]") [assignment] """ conformance_automated = "Fail" errors_diff = """ -Line 15: Unexpected errors ['generics_variance_inference.py:15: error: PEP 695 generics are not yet supported [valid-type]', 'generics_variance_inference.py:15: error: Name "T1" is not defined [name-defined]'] -Line 16: Unexpected errors ['generics_variance_inference.py:16: error: Name "T2" is not defined [name-defined]'] -Line 19: Unexpected errors ['generics_variance_inference.py:19: error: Name "T3" is not defined [name-defined]'] -Line 23: Unexpected errors ['generics_variance_inference.py:23: error: "ClassA" expects no type arguments, but 3 given [type-arg]'] -Line 26: Unexpected errors ['generics_variance_inference.py:26: error: "ClassA" expects no type arguments, but 3 given [type-arg]'] -Line 29: Unexpected errors ['generics_variance_inference.py:29: error: "ClassA" expects no type arguments, but 3 given [type-arg]'] -Line 32: Unexpected errors ['generics_variance_inference.py:32: error: PEP 695 generics are not yet supported [valid-type]'] -Line 33: Unexpected errors ['generics_variance_inference.py:33: error: A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var]'] -Line 40: Unexpected errors ['generics_variance_inference.py:40: error: "ShouldBeCovariant1" expects no type arguments, but 1 given [type-arg]', 'generics_variance_inference.py:40: error: The type "type[ShouldBeCovariant1]" is not generic and not indexable [misc]'] -Line 44: Unexpected errors ['generics_variance_inference.py:44: error: PEP 695 generics are not yet supported [valid-type]'] -Line 48: Unexpected errors ['generics_variance_inference.py:48: error: Cannot instantiate abstract class "ShouldBeCovariant2" with abstract attributes "__getitem__" and "__len__" [abstract]', 'generics_variance_inference.py:48: error: Incompatible types in assignment (expression has type "ShouldBeCovariant2[int]", variable has type "ShouldBeCovariant2[float]") [assignment]'] -Line 52: Unexpected errors ['generics_variance_inference.py:52: error: PEP 695 generics are not yet supported [valid-type]'] -Line 57: Unexpected errors ['generics_variance_inference.py:57: error: "ShouldBeCovariant3" expects no type arguments, but 1 given [type-arg]', 'generics_variance_inference.py:57: error: The type "type[ShouldBeCovariant3]" is not generic and not indexable [misc]'] -Line 62: Unexpected errors ['generics_variance_inference.py:62: error: PEP 695 generics are not yet supported [valid-type]'] -Line 63: Unexpected errors ['generics_variance_inference.py:63: error: Type variable "generics_variance_inference.T" is unbound [valid-type]'] -Line 66: Unexpected errors ['generics_variance_inference.py:66: error: "ShouldBeCovariant4" expects no type arguments, but 1 given [type-arg]', 'generics_variance_inference.py:66: error: The type "type[ShouldBeCovariant4]" is not generic and not indexable [misc]'] -Line 70: Unexpected errors ['generics_variance_inference.py:70: error: PEP 695 generics are not yet supported [valid-type]'] -Line 75: Unexpected errors ['generics_variance_inference.py:75: error: A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var]'] -Line 79: Unexpected errors ['generics_variance_inference.py:79: error: "ShouldBeCovariant5" expects no type arguments, but 1 given [type-arg]', 'generics_variance_inference.py:79: error: The type "type[ShouldBeCovariant5]" is not generic and not indexable [misc]'] -Line 83: Unexpected errors ['generics_variance_inference.py:83: error: PEP 695 generics are not yet supported [valid-type]'] -Line 100: Unexpected errors ['generics_variance_inference.py:100: error: PEP 695 generics are not yet supported [valid-type]'] -Line 104: Unexpected errors ['generics_variance_inference.py:104: error: A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var]'] -Line 115: Unexpected errors ['generics_variance_inference.py:115: error: PEP 695 generics are not yet supported [valid-type]', 'generics_variance_inference.py:115: error: Name "K" is not defined [name-defined]', 'generics_variance_inference.py:115: error: Name "V" is not defined [name-defined]'] -Line 126: Unexpected errors ['generics_variance_inference.py:126: error: PEP 695 generics are not yet supported [valid-type]'] -Line 127: Unexpected errors ['generics_variance_inference.py:127: error: Type variable "generics_variance_inference.T" is unbound [valid-type]'] -Line 133: Unexpected errors ['generics_variance_inference.py:133: error: PEP 695 generics are not yet supported [valid-type]'] -Line 141: Unexpected errors ['generics_variance_inference.py:141: error: PEP 695 generics are not yet supported [valid-type]'] -Line 150: Unexpected errors ['generics_variance_inference.py:150: error: "ShouldBeContravariant1" expects no type arguments, but 1 given [type-arg]', 'generics_variance_inference.py:150: error: The type "type[ShouldBeContravariant1]" is not generic and not indexable [misc]'] -Line 165: Unexpected errors ['generics_variance_inference.py:165: error: PEP 695 generics are not yet supported [valid-type]'] -Line 177: Unexpected errors ['generics_variance_inference.py:177: error: PEP 695 generics are not yet supported [valid-type]'] -Line 182: Unexpected errors ['generics_variance_inference.py:182: error: Incompatible types in assignment (expression has type "ShouldBeCovariant6[int]", variable has type "ShouldBeCovariant6[float]") [assignment]'] -Line 189: Unexpected errors ['generics_variance_inference.py:189: error: PEP 695 generics are not yet supported [valid-type]'] -Line 193: Unexpected errors ['generics_variance_inference.py:193: error: Incompatible types in assignment (expression has type "ShouldBeContravariant2[float]", variable has type "ShouldBeContravariant2[int]") [assignment]'] +Line 204: Unexpected errors ['generics_variance_inference.py:204: error: Incompatible types in assignment (expression has type "ShouldBeCovariant7[int]", variable has type "ShouldBeCovariant7[object]") [assignment]'] """ diff --git a/conformance/results/mypy/historical_positional.toml b/conformance/results/mypy/historical_positional.toml index c8cf6eafb..7bd5cc052 100644 --- a/conformance/results/mypy/historical_positional.toml +++ b/conformance/results/mypy/historical_positional.toml @@ -5,19 +5,13 @@ Treats keyword-only parameter as positional-only. Applies legacy positional-only rules when PEP 570 syntax is used. """ output = """ -historical_positional.py:13: note: "f1" defined here historical_positional.py:18: error: Unexpected keyword argument "__x" for "f1" [call-arg] -historical_positional.py:29: note: "f3" defined here -historical_positional.py:32: error: Unexpected keyword argument "__y" for "f3" [call-arg] -historical_positional.py:36: note: "m1" of "A" defined here -historical_positional.py:43: error: Unexpected keyword argument "__x" for "m1" of "A" [call-arg] -historical_positional.py:50: note: "f4" defined here -historical_positional.py:53: error: Unexpected keyword argument "__y" for "f4" [call-arg] +historical_positional.py:59: error: Unexpected keyword argument "__x" for "m1" of "A" [call-arg] +historical_positional.py:69: error: Unexpected keyword argument "__y" for "f4" [call-arg] """ conformance_automated = "Fail" errors_diff = """ Line 26: Expected 1 errors -Line 38: Expected 1 errors -Line 32: Unexpected errors ['historical_positional.py:32: error: Unexpected keyword argument "__y" for "f3" [call-arg]'] -Line 53: Unexpected errors ['historical_positional.py:53: error: Unexpected keyword argument "__y" for "f4" [call-arg]'] +Line 54: Expected 1 errors +Line 69: Unexpected errors ['historical_positional.py:69: error: Unexpected keyword argument "__y" for "f4" [call-arg]'] """ diff --git a/conformance/results/mypy/literals_interactions.toml b/conformance/results/mypy/literals_interactions.toml index c7b835880..a9f03f046 100644 --- a/conformance/results/mypy/literals_interactions.toml +++ b/conformance/results/mypy/literals_interactions.toml @@ -1,17 +1,20 @@ -conformant = "Partial" notes = """ -Does not narrow type of `x` with `x in Literal` type guard pattern. +Does not narrow `str` or `LiteralString` types to `Literal` string types via equality or containment checks. """ output = """ +literals_interactions.py:14: error: Tuple index out of range [misc] literals_interactions.py:15: error: Tuple index out of range [misc] literals_interactions.py:16: error: Tuple index out of range [misc] literals_interactions.py:17: error: Tuple index out of range [misc] -literals_interactions.py:18: error: Tuple index out of range [misc] -literals_interactions.py:106: error: Argument 1 to "expects_bad_status" has incompatible type "str"; expected "Literal['MALFORMED', 'ABORTED']" [arg-type] -literals_interactions.py:109: error: Argument 1 to "expects_pending_status" has incompatible type "str"; expected "Literal['PENDING']" [arg-type] +literals_interactions.py:111: error: Argument 1 to "expects_bad_status" has incompatible type "str"; expected "Literal['MALFORMED', 'ABORTED']" [arg-type] +literals_interactions.py:113: error: Argument 1 to "expects_bad_status" has incompatible type "str"; expected "Literal['MALFORMED', 'ABORTED']" [arg-type] +literals_interactions.py:116: error: Argument 1 to "expects_bad_status" has incompatible type "str"; expected "Literal['MALFORMED', 'ABORTED']" [arg-type] +literals_interactions.py:119: error: Argument 1 to "expects_pending_status" has incompatible type "str"; expected "Literal['PENDING']" [arg-type] +literals_interactions.py:128: error: Argument 1 to "expects_bad_status" has incompatible type "str"; expected "Literal['MALFORMED', 'ABORTED']" [arg-type] +literals_interactions.py:130: error: Argument 1 to "expects_bad_status" has incompatible type "str"; expected "Literal['MALFORMED', 'ABORTED']" [arg-type] +literals_interactions.py:133: error: Argument 1 to "expects_bad_status" has incompatible type "str"; expected "Literal['MALFORMED', 'ABORTED']" [arg-type] +literals_interactions.py:136: error: Argument 1 to "expects_pending_status" has incompatible type "str"; expected "Literal['PENDING']" [arg-type] """ -conformance_automated = "Fail" +conformance_automated = "Pass" errors_diff = """ -Line 106: Unexpected errors ['literals_interactions.py:106: error: Argument 1 to "expects_bad_status" has incompatible type "str"; expected "Literal[\\'MALFORMED\\', \\'ABORTED\\']" [arg-type]'] -Line 109: Unexpected errors ['literals_interactions.py:109: error: Argument 1 to "expects_pending_status" has incompatible type "str"; expected "Literal[\\'PENDING\\']" [arg-type]'] """ diff --git a/conformance/results/mypy/literals_literalstring.toml b/conformance/results/mypy/literals_literalstring.toml index b6554e3f6..dc1470fc2 100644 --- a/conformance/results/mypy/literals_literalstring.toml +++ b/conformance/results/mypy/literals_literalstring.toml @@ -6,17 +6,17 @@ output = """ literals_literalstring.py:36: error: Parameter 2 of Literal[...] is invalid [valid-type] literals_literalstring.py:37: error: Parameter 1 of Literal[...] is invalid [valid-type] literals_literalstring.py:43: error: Incompatible types in assignment (expression has type "Literal['two']", variable has type "Literal['']") [assignment] -literals_literalstring.py:74: error: Incompatible types in assignment (expression has type "int", variable has type "str") [assignment] -literals_literalstring.py:75: error: Incompatible types in assignment (expression has type "bytes", variable has type "str") [assignment] -literals_literalstring.py:157: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader [misc] +literals_literalstring.py:73: error: Incompatible types in assignment (expression has type "int", variable has type "str") [assignment] +literals_literalstring.py:74: error: Incompatible types in assignment (expression has type "bytes", variable has type "str") [assignment] +literals_literalstring.py:156: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader [overload-cannot-match] literals_literalstring.py:167: error: Expression is of type "B", not "A" [assert-type] """ conformance_automated = "Fail" errors_diff = """ -Line 66: Expected 1 errors -Line 120: Expected 1 errors -Line 134: Expected 1 errors +Line 65: Expected 1 errors +Line 119: Expected 1 errors +Line 133: Expected 1 errors Line 171: Expected 1 errors -Line 157: Unexpected errors ["literals_literalstring.py:157: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader [misc]"] +Line 156: Unexpected errors ["literals_literalstring.py:156: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader [overload-cannot-match]"] Line 167: Unexpected errors ['literals_literalstring.py:167: error: Expression is of type "B", not "A" [assert-type]'] """ diff --git a/conformance/results/mypy/literals_parameterizations.toml b/conformance/results/mypy/literals_parameterizations.toml index b5a992641..3dfc58304 100644 --- a/conformance/results/mypy/literals_parameterizations.toml +++ b/conformance/results/mypy/literals_parameterizations.toml @@ -1,6 +1,6 @@ conformant = "Partial" notes = """ -Does not reject tuple within Literal. +Does not reject tuple within `Literal`. """ output = """ literals_parameterizations.py:41: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type] @@ -8,11 +8,11 @@ literals_parameterizations.py:42: error: Invalid type: Literal[...] cannot conta literals_parameterizations.py:43: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type] literals_parameterizations.py:44: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type] literals_parameterizations.py:45: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type] -literals_parameterizations.py:47: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type] +literals_parameterizations.py:47: error: Parameter 1 of Literal[...] is invalid [valid-type] literals_parameterizations.py:48: error: Parameter 1 of Literal[...] is invalid [valid-type] literals_parameterizations.py:49: error: Parameter 1 of Literal[...] is invalid [valid-type] literals_parameterizations.py:50: error: Parameter 1 of Literal[...] is invalid [valid-type] -literals_parameterizations.py:51: error: Parameter 1 of Literal[...] cannot be of type "float" [valid-type] +literals_parameterizations.py:51: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type] literals_parameterizations.py:52: error: Parameter 1 of Literal[...] cannot be of type "Any" [valid-type] literals_parameterizations.py:53: error: Parameter 1 of Literal[...] is invalid [valid-type] literals_parameterizations.py:56: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type] diff --git a/conformance/results/mypy/namedtuples_define_class.toml b/conformance/results/mypy/namedtuples_define_class.toml index adf590b48..12c4dc552 100644 --- a/conformance/results/mypy/namedtuples_define_class.toml +++ b/conformance/results/mypy/namedtuples_define_class.toml @@ -1,21 +1,37 @@ conformant = "Partial" notes = """ Does not reject override of named tuple attribute in child class. +Does not support version-conditional fields. """ output = """ -namedtuples_define_class.py:32: error: Tuple index out of range [misc] namedtuples_define_class.py:33: error: Tuple index out of range [misc] -namedtuples_define_class.py:44: error: Missing positional argument "y" in call to "Point" [call-arg] +namedtuples_define_class.py:34: error: Tuple index out of range [misc] namedtuples_define_class.py:45: error: Missing positional argument "y" in call to "Point" [call-arg] -namedtuples_define_class.py:46: error: Argument 2 to "Point" has incompatible type "str"; expected "int" [arg-type] -namedtuples_define_class.py:47: error: Argument "units" to "Point" has incompatible type "int"; expected "str" [arg-type] -namedtuples_define_class.py:48: error: Too many arguments for "Point" [call-arg] -namedtuples_define_class.py:49: error: Unexpected keyword argument "other" for "Point" [call-arg] -namedtuples_define_class.py:59: error: Non-default NamedTuple fields cannot follow default fields [misc] -namedtuples_define_class.py:98: error: Argument 2 to "Property" has incompatible type "float"; expected "str" [arg-type] -namedtuples_define_class.py:105: error: NamedTuple should be a single base [misc] +namedtuples_define_class.py:46: error: Missing positional argument "y" in call to "Point" [call-arg] +namedtuples_define_class.py:47: error: Argument 2 to "Point" has incompatible type "str"; expected "int" [arg-type] +namedtuples_define_class.py:48: error: Argument "units" to "Point" has incompatible type "int"; expected "str" [arg-type] +namedtuples_define_class.py:49: error: Too many arguments for "Point" [call-arg] +namedtuples_define_class.py:50: error: Unexpected keyword argument "other" for "Point" [call-arg] +namedtuples_define_class.py:60: error: Invalid statement in NamedTuple definition; expected "field_name: field_type [= default]" [misc] +namedtuples_define_class.py:66: error: Missing positional argument "units" in call to "Point2" [call-arg] +namedtuples_define_class.py:68: error: Too many values to unpack (2 expected, 3 provided) [misc] +namedtuples_define_class.py:77: error: NamedTuple field name cannot start with an underscore: _y [misc] +namedtuples_define_class.py:87: error: Non-default NamedTuple fields cannot follow default fields [misc] +namedtuples_define_class.py:114: error: Invalid statement in NamedTuple definition; expected "field_name: field_type [= default]" [misc] +namedtuples_define_class.py:116: error: Invalid statement in NamedTuple definition; expected "field_name: field_type [= default]" [misc] +namedtuples_define_class.py:120: error: Too many arguments for "ConditionalField" [call-arg] +namedtuples_define_class.py:121: error: Too many arguments for "ConditionalField" [call-arg] +namedtuples_define_class.py:140: error: Argument 2 to "Property" has incompatible type "float"; expected "str" [arg-type] +namedtuples_define_class.py:147: error: NamedTuple should be a single base [misc] """ conformance_automated = "Fail" errors_diff = """ -Line 79: Expected 1 errors +Line 70: Expected 1 errors +Line 107: Expected 1 errors +Line 60: Unexpected errors ['namedtuples_define_class.py:60: error: Invalid statement in NamedTuple definition; expected "field_name: field_type [= default]" [misc]'] +Line 66: Unexpected errors ['namedtuples_define_class.py:66: error: Missing positional argument "units" in call to "Point2" [call-arg]'] +Line 68: Unexpected errors ['namedtuples_define_class.py:68: error: Too many values to unpack (2 expected, 3 provided) [misc]'] +Line 114: Unexpected errors ['namedtuples_define_class.py:114: error: Invalid statement in NamedTuple definition; expected "field_name: field_type [= default]" [misc]'] +Line 116: Unexpected errors ['namedtuples_define_class.py:116: error: Invalid statement in NamedTuple definition; expected "field_name: field_type [= default]" [misc]'] +Line 120: Unexpected errors ['namedtuples_define_class.py:120: error: Too many arguments for "ConditionalField" [call-arg]'] """ diff --git a/conformance/results/mypy/namedtuples_define_functional.toml b/conformance/results/mypy/namedtuples_define_functional.toml index 7601d5252..6356dc8c5 100644 --- a/conformance/results/mypy/namedtuples_define_functional.toml +++ b/conformance/results/mypy/namedtuples_define_functional.toml @@ -1,7 +1,4 @@ conformant = "Pass" -notes = """ -Does not handle illegal named tuple names the same as runtime. -""" output = """ namedtuples_define_functional.py:16: error: Missing positional argument "y" in call to "Point1" [call-arg] namedtuples_define_functional.py:21: error: Missing positional arguments "x", "y" in call to "Point2" [call-arg] @@ -11,11 +8,12 @@ namedtuples_define_functional.py:36: error: Argument 2 to "Point5" has incompati namedtuples_define_functional.py:37: error: Too many arguments for "Point5" [call-arg] namedtuples_define_functional.py:42: error: Argument 2 to "Point6" has incompatible type "str"; expected "int" [arg-type] namedtuples_define_functional.py:43: error: Argument "x" to "Point6" has incompatible type "float"; expected "int" [arg-type] -namedtuples_define_functional.py:52: error: Name "a" already defined (possibly by an import) [no-redef] -namedtuples_define_functional.py:57: error: Unexpected keyword argument "_1" for "NT4" [call-arg] -namedtuples_define_functional.py:66: error: Missing positional argument "a" in call to "NT5" [call-arg] +namedtuples_define_functional.py:52: error: "namedtuple()" has duplicate field name "a" [misc] +namedtuples_define_functional.py:53: error: "namedtuple()" field name "def" is a keyword [misc] +namedtuples_define_functional.py:54: error: "namedtuple()" field name "def" is a keyword [misc] +namedtuples_define_functional.py:55: error: "namedtuple()" field name "_d" starts with an underscore [misc] +namedtuples_define_functional.py:69: error: Missing positional argument "a" in call to "NT7" [call-arg] """ -conformance_automated = "Fail" +conformance_automated = "Pass" errors_diff = """ -Line 57: Unexpected errors ['namedtuples_define_functional.py:57: error: Unexpected keyword argument "_1" for "NT4" [call-arg]'] """ diff --git a/conformance/results/mypy/narrowing_typeguard.toml b/conformance/results/mypy/narrowing_typeguard.toml index f4a9a666d..4c4f09522 100644 --- a/conformance/results/mypy/narrowing_typeguard.toml +++ b/conformance/results/mypy/narrowing_typeguard.toml @@ -4,6 +4,7 @@ narrowing_typeguard.py:102: error: TypeGuard functions must have a positional ar narrowing_typeguard.py:107: error: TypeGuard functions must have a positional argument [valid-type] narrowing_typeguard.py:128: error: Argument 1 to "takes_callable_str" has incompatible type "Callable[[object], TypeGuard[int]]"; expected "Callable[[object], str]" [arg-type] narrowing_typeguard.py:148: error: Argument 1 to "takes_callable_str_proto" has incompatible type "Callable[[object], TypeGuard[int]]"; expected "CallableStrProto" [arg-type] +narrowing_typeguard.py:148: note: "CallableStrProto.__call__" has type "def __call__(self, val: object) -> str" """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/mypy/narrowing_typeis.toml b/conformance/results/mypy/narrowing_typeis.toml index f16730029..cdb53c5eb 100644 --- a/conformance/results/mypy/narrowing_typeis.toml +++ b/conformance/results/mypy/narrowing_typeis.toml @@ -1,14 +1,15 @@ conformant = "Pass" output = """ -narrowing_typeis.py:105: error: "TypeIs" functions must have a positional argument [valid-type] narrowing_typeis.py:110: error: "TypeIs" functions must have a positional argument [valid-type] -narrowing_typeis.py:132: error: Argument 1 to "takes_callable_str" has incompatible type "Callable[[object], TypeIs[int]]"; expected "Callable[[object], str]" [arg-type] -narrowing_typeis.py:152: error: Argument 1 to "takes_callable_str_proto" has incompatible type "Callable[[object], TypeIs[int]]"; expected "CallableStrProto" [arg-type] -narrowing_typeis.py:169: error: Argument 1 to "takes_typeguard" has incompatible type "Callable[[object], TypeIs[int]]"; expected "Callable[[object], TypeGuard[int]]" [arg-type] -narrowing_typeis.py:170: error: Argument 1 to "takes_typeis" has incompatible type "Callable[[object], TypeGuard[int]]"; expected "Callable[[object], TypeIs[int]]" [arg-type] -narrowing_typeis.py:191: error: Argument 1 to "takes_int_typeis" has incompatible type "Callable[[object], TypeIs[bool]]"; expected "Callable[[object], TypeIs[int]]" [arg-type] -narrowing_typeis.py:195: error: Narrowed type "str" is not a subtype of input type "int" [narrowed-type-not-subtype] -narrowing_typeis.py:199: error: Narrowed type "list[int]" is not a subtype of input type "list[object]" [narrowed-type-not-subtype] +narrowing_typeis.py:115: error: "TypeIs" functions must have a positional argument [valid-type] +narrowing_typeis.py:137: error: Argument 1 to "takes_callable_str" has incompatible type "Callable[[object], TypeIs[int]]"; expected "Callable[[object], str]" [arg-type] +narrowing_typeis.py:157: error: Argument 1 to "takes_callable_str_proto" has incompatible type "Callable[[object], TypeIs[int]]"; expected "CallableStrProto" [arg-type] +narrowing_typeis.py:157: note: "CallableStrProto.__call__" has type "def __call__(self, val: object) -> str" +narrowing_typeis.py:174: error: Argument 1 to "takes_typeguard" has incompatible type "Callable[[object], TypeIs[int]]"; expected "Callable[[object], TypeGuard[int]]" [arg-type] +narrowing_typeis.py:175: error: Argument 1 to "takes_typeis" has incompatible type "Callable[[object], TypeGuard[int]]"; expected "Callable[[object], TypeIs[int]]" [arg-type] +narrowing_typeis.py:196: error: Argument 1 to "takes_int_typeis" has incompatible type "Callable[[object], TypeIs[bool]]"; expected "Callable[[object], TypeIs[int]]" [arg-type] +narrowing_typeis.py:200: error: Narrowed type "str" is not a subtype of input type "int" [narrowed-type-not-subtype] +narrowing_typeis.py:204: error: Narrowed type "list[int]" is not a subtype of input type "list[object]" [narrowed-type-not-subtype] """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/mypy/overloads_basic.toml b/conformance/results/mypy/overloads_basic.toml index 6a7966962..f592ea606 100644 --- a/conformance/results/mypy/overloads_basic.toml +++ b/conformance/results/mypy/overloads_basic.toml @@ -1,11 +1,9 @@ conformant = "Pass" output = """ -overloads_basic.py:37: error: No overload variant of "__getitem__" of "Bytes" matches argument type "str" [call-overload] -overloads_basic.py:37: note: Possible overload variants: -overloads_basic.py:37: note: def __getitem__(self, int, /) -> int -overloads_basic.py:37: note: def __getitem__(self, slice, /) -> bytes -overloads_basic.py:62: error: Single overload definition, multiple required [misc] -overloads_basic.py:74: error: An overloaded function outside a stub file must have an implementation [no-overload-impl] +overloads_basic.py:39: error: No overload variant of "__getitem__" of "Bytes" matches argument type "str" [call-overload] +overloads_basic.py:39: note: Possible overload variants: +overloads_basic.py:39: note: def __getitem__(self, int, /) -> int +overloads_basic.py:39: note: def __getitem__(self, slice[Any, Any, Any], /) -> bytes """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/mypy/overloads_consistency.toml b/conformance/results/mypy/overloads_consistency.toml new file mode 100644 index 000000000..1010582c5 --- /dev/null +++ b/conformance/results/mypy/overloads_consistency.toml @@ -0,0 +1,8 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +overloads_consistency.py:28: error: Overloaded function implementation cannot produce return type of signature 2 [misc] +overloads_consistency.py:44: error: Overloaded function implementation does not accept all possible parameters of signature 2 [misc] +""" diff --git a/conformance/results/mypy/overloads_definitions.toml b/conformance/results/mypy/overloads_definitions.toml new file mode 100644 index 000000000..e653284f3 --- /dev/null +++ b/conformance/results/mypy/overloads_definitions.toml @@ -0,0 +1,19 @@ +conformant = "Partial" +conformance_automated = "Fail" +notes = """ +Allows `@override` to be on all overloads and implementation, instead of just implementation. +""" +errors_diff = """ +Lines 226, 227, 228, 231, 232: Expected error (tag 'override_impl') +""" +output = """ +overloads_definitions.py:15: error: Single overload definition, multiple required [misc] +overloads_definitions.py:27: error: An overloaded function outside a stub file must have an implementation [no-overload-impl] +overloads_definitions.py:58: error: An overloaded function outside a stub file must have an implementation [no-overload-impl] +overloads_definitions.py:71: error: Overload does not consistently use the "@staticmethod" decorator on all function signatures. [misc] +overloads_definitions.py:84: error: Overload does not consistently use the "@classmethod" decorator on all function signatures. [misc] +overloads_definitions.py:122: error: @final should be applied only to overload implementation [misc] +overloads_definitions.py:137: error: @final should be applied only to overload implementation [misc] +overloads_definitions.py:180: error: Cannot override final attribute "final_method" (previously declared in base class "Base") [misc] +overloads_definitions.py:195: error: Method "bad_override" is marked as an override, but no base method was found with this name [misc] +""" diff --git a/conformance/results/mypy/overloads_definitions_stub.toml b/conformance/results/mypy/overloads_definitions_stub.toml new file mode 100644 index 000000000..1a4dc4fa7 --- /dev/null +++ b/conformance/results/mypy/overloads_definitions_stub.toml @@ -0,0 +1,17 @@ +conformant = "Partial" +notes = """ +Allows `@override` to appear in a stub file not on the first overload. +""" +conformance_automated = "Fail" +errors_diff = """ +Lines 143, 146, 147, 149: Expected error (tag 'override_impl') +""" +output = """ +overloads_definitions_stub.pyi:13: error: Single overload definition, multiple required [misc] +overloads_definitions_stub.pyi:32: error: Overload does not consistently use the "@staticmethod" decorator on all function signatures. [misc] +overloads_definitions_stub.pyi:39: error: Overload does not consistently use the "@classmethod" decorator on all function signatures. [misc] +overloads_definitions_stub.pyi:71: error: In a stub file @final must be applied only to the first overload [misc] +overloads_definitions_stub.pyi:84: error: In a stub file @final must be applied only to the first overload [misc] +overloads_definitions_stub.pyi:107: error: Cannot override final attribute "final_method" (previously declared in base class "Base") [misc] +overloads_definitions_stub.pyi:120: error: Method "bad_override" is marked as an override, but no base method was found with this name [misc] +""" diff --git a/conformance/results/mypy/overloads_evaluation.toml b/conformance/results/mypy/overloads_evaluation.toml new file mode 100644 index 000000000..2c9c60487 --- /dev/null +++ b/conformance/results/mypy/overloads_evaluation.toml @@ -0,0 +1,46 @@ +conformant = "Partial" +notes = """ +Does not expand boolean arguments to `Literal[True]` and `Literal[False]`. +Does not expand enum arguments to literal variants. +Does not expand tuple arguments to possible combinations. +Evaluates `Any` in some cases where overload is not ambiguous. +""" +conformance_automated = "Fail" +errors_diff = """ +Line 135: Unexpected errors ['overloads_evaluation.py:135: error: No overload variant of "expand_bool" matches argument type "bool" [call-overload]'] +Line 136: Unexpected errors ['overloads_evaluation.py:136: error: Expression is of type "Any", not "Literal[0, 1]" [assert-type]'] +Line 161: Unexpected errors ['overloads_evaluation.py:161: error: No overload variant of "expand_enum" matches argument type "Color" [call-overload]'] +Line 162: Unexpected errors ['overloads_evaluation.py:162: error: Expression is of type "Any", not "Literal[0, 1]" [assert-type]'] +Line 205: Unexpected errors ['overloads_evaluation.py:205: error: Argument 1 to "expand_tuple" has incompatible type "tuple[int, int | str]"; expected "tuple[int, int]" [arg-type]'] +Line 206: Unexpected errors ['overloads_evaluation.py:206: error: Expression is of type "int", not "int | str" [assert-type]'] +Line 312: Unexpected errors ['overloads_evaluation.py:312: error: Expression is of type "Any", not "float" [assert-type]'] +""" +output = """ +overloads_evaluation.py:38: error: All overload variants of "example1_1" require at least one argument [call-overload] +overloads_evaluation.py:38: note: Possible overload variants: +overloads_evaluation.py:38: note: def example1_1(x: int, y: str) -> int +overloads_evaluation.py:38: note: def example1_1(x: str) -> str +overloads_evaluation.py:46: error: No overload variant of "example1_1" matches argument types "int", "int" [call-overload] +overloads_evaluation.py:46: note: Possible overload variants: +overloads_evaluation.py:46: note: def example1_1(x: int, y: str) -> int +overloads_evaluation.py:46: note: def example1_1(x: str) -> str +overloads_evaluation.py:51: error: No overload variant of "example1_1" matches argument type "int" [call-overload] +overloads_evaluation.py:51: note: Possible overload variants: +overloads_evaluation.py:51: note: def example1_1(x: int, y: str) -> int +overloads_evaluation.py:51: note: def example1_1(x: str) -> str +overloads_evaluation.py:116: error: Argument 1 to "example2" has incompatible type "int | str"; expected "int" [arg-type] +overloads_evaluation.py:116: error: Argument 2 to "example2" has incompatible type "int | str"; expected "str" [arg-type] +overloads_evaluation.py:135: error: No overload variant of "expand_bool" matches argument type "bool" [call-overload] +overloads_evaluation.py:135: note: Possible overload variants: +overloads_evaluation.py:135: note: def expand_bool(x: Literal[False]) -> Literal[0] +overloads_evaluation.py:135: note: def expand_bool(x: Literal[True]) -> Literal[1] +overloads_evaluation.py:136: error: Expression is of type "Any", not "Literal[0, 1]" [assert-type] +overloads_evaluation.py:161: error: No overload variant of "expand_enum" matches argument type "Color" [call-overload] +overloads_evaluation.py:161: note: Possible overload variants: +overloads_evaluation.py:161: note: def expand_enum(x: Literal[Color.RED]) -> Literal[0] +overloads_evaluation.py:161: note: def expand_enum(x: Literal[Color.BLUE]) -> Literal[1] +overloads_evaluation.py:162: error: Expression is of type "Any", not "Literal[0, 1]" [assert-type] +overloads_evaluation.py:205: error: Argument 1 to "expand_tuple" has incompatible type "tuple[int, int | str]"; expected "tuple[int, int]" [arg-type] +overloads_evaluation.py:206: error: Expression is of type "int", not "int | str" [assert-type] +overloads_evaluation.py:312: error: Expression is of type "Any", not "float" [assert-type] +""" diff --git a/conformance/results/mypy/protocols_class_objects.toml b/conformance/results/mypy/protocols_class_objects.toml index 48cccc872..c2fae510f 100644 --- a/conformance/results/mypy/protocols_class_objects.toml +++ b/conformance/results/mypy/protocols_class_objects.toml @@ -12,14 +12,14 @@ protocols_class_objects.py:74: error: Incompatible types in assignment (expressi protocols_class_objects.py:74: note: Following member(s) of "ConcreteB" have conflicts: protocols_class_objects.py:74: note: prop1: expected "int", got "Callable[[ConcreteB], int]" protocols_class_objects.py:74: note: Only class variables allowed for class object access on protocols, prop1 is an instance variable of "ConcreteB" -protocols_class_objects.py:101: error: Incompatible types in assignment (expression has type "type[ConcreteC1]", variable has type "ProtoC1") [assignment] -protocols_class_objects.py:101: note: ClassVar protocol member ProtoC1.attr1 can never be matched by a class object -protocols_class_objects.py:103: error: Incompatible types in assignment (expression has type "type[ConcreteC2]", variable has type "ProtoC1") [assignment] -protocols_class_objects.py:103: note: Only class variables allowed for class object access on protocols, attr1 is an instance variable of "ConcreteC2" -protocols_class_objects.py:103: note: ClassVar protocol member ProtoC1.attr1 can never be matched by a class object -protocols_class_objects.py:104: error: Incompatible types in assignment (expression has type "type[ConcreteC2]", variable has type "ProtoC2") [assignment] -protocols_class_objects.py:104: note: Only class variables allowed for class object access on protocols, attr1 is an instance variable of "ConcreteC2" -protocols_class_objects.py:105: error: Incompatible types in assignment (expression has type "type[ConcreteC3]", variable has type "ProtoC1") [assignment] +protocols_class_objects.py:104: error: Incompatible types in assignment (expression has type "type[ConcreteC1]", variable has type "ProtoC1") [assignment] +protocols_class_objects.py:104: note: ClassVar protocol member ProtoC1.attr1 can never be matched by a class object +protocols_class_objects.py:106: error: Incompatible types in assignment (expression has type "type[ConcreteC2]", variable has type "ProtoC1") [assignment] +protocols_class_objects.py:106: note: Only class variables allowed for class object access on protocols, attr1 is an instance variable of "ConcreteC2" +protocols_class_objects.py:106: note: ClassVar protocol member ProtoC1.attr1 can never be matched by a class object +protocols_class_objects.py:107: error: Incompatible types in assignment (expression has type "type[ConcreteC2]", variable has type "ProtoC2") [assignment] +protocols_class_objects.py:107: note: Only class variables allowed for class object access on protocols, attr1 is an instance variable of "ConcreteC2" +protocols_class_objects.py:108: error: Incompatible types in assignment (expression has type "type[ConcreteC3]", variable has type "ProtoC1") [assignment] """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/mypy/protocols_definition.toml b/conformance/results/mypy/protocols_definition.toml index 717b8cad5..e34a5fbba 100644 --- a/conformance/results/mypy/protocols_definition.toml +++ b/conformance/results/mypy/protocols_definition.toml @@ -51,6 +51,9 @@ protocols_definition.py:340: error: Incompatible types in assignment (expression protocols_definition.py:340: note: Protocol member Template6.val1 expected settable variable, got read-only attribute protocols_definition.py:341: error: Incompatible types in assignment (expression has type "Concrete6_Bad3", variable has type "Template6") [assignment] protocols_definition.py:341: note: Protocol member Template6.val1 expected settable variable, got read-only attribute +protocols_definition.py:369: error: Incompatible types in assignment (expression has type "Concrete7_Bad1", variable has type "Template7") [assignment] +protocols_definition.py:369: note: Protocol member Template7.val1 expected class variable, got instance variable +protocols_definition.py:370: error: Incompatible types in assignment (expression has type "Concrete7_Bad2", variable has type "Template7") [assignment] """ conformance_automated = "Fail" errors_diff = """ diff --git a/conformance/results/mypy/protocols_explicit.toml b/conformance/results/mypy/protocols_explicit.toml index 46491e4d9..80ef20393 100644 --- a/conformance/results/mypy/protocols_explicit.toml +++ b/conformance/results/mypy/protocols_explicit.toml @@ -5,11 +5,10 @@ Does not report unimplemented attributes for class that explicitly derives from output = """ protocols_explicit.py:27: error: Call to abstract method "draw" of "PColor" with trivial body via super() is unsafe [safe-super] protocols_explicit.py:56: error: Incompatible types in assignment (expression has type "tuple[int, int, str]", base class "RGB" defined the type as "tuple[int, int, int]") [assignment] -protocols_explicit.py:59: error: Cannot instantiate abstract class "Point" with abstract attributes "intensity", "other" and "transparency" [abstract] -protocols_explicit.py:86: error: Cannot instantiate abstract class "Concrete1" with abstract attributes "cm1" and "im1" [abstract] -protocols_explicit.py:104: error: Cannot instantiate abstract class "Concrete3" with abstract attributes "cm10", "cm11" and "im1" [abstract] -protocols_explicit.py:129: error: Cannot instantiate abstract class "Concrete5" with abstract attribute "method1" [abstract] -protocols_explicit.py:159: error: Cannot instantiate abstract class "Concrete7A" with abstract attribute "method1" [abstract] +protocols_explicit.py:60: error: Cannot instantiate abstract class "Point" with abstract attributes "intensity" and "transparency" [abstract] +protocols_explicit.py:89: error: Cannot instantiate abstract class "Concrete1" with abstract attribute "cm1" [abstract] +protocols_explicit.py:134: error: Cannot instantiate abstract class "Concrete5" with abstract attribute "method1" [abstract] +protocols_explicit.py:164: error: Cannot instantiate abstract class "Concrete7A" with abstract attribute "method1" [abstract] """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/mypy/protocols_generic.toml b/conformance/results/mypy/protocols_generic.toml index 68b145e39..655434e55 100644 --- a/conformance/results/mypy/protocols_generic.toml +++ b/conformance/results/mypy/protocols_generic.toml @@ -1,7 +1,4 @@ -conformant = "Partial" -notes = """ -Fails protocol matching when method-scoped TypeVar is used in protocol. -""" +conformant = "Pass" output = """ protocols_generic.py:40: error: Incompatible types in assignment (expression has type "Concrete1", variable has type "Proto1[int, str]") [assignment] protocols_generic.py:40: note: Following member(s) of "Concrete1" have conflicts: @@ -19,27 +16,22 @@ protocols_generic.py:56: error: Incompatible types in assignment (expression has protocols_generic.py:66: error: Incompatible types in assignment (expression has type "Sender[int]", variable has type "Sender[float]") [assignment] protocols_generic.py:74: error: Incompatible types in assignment (expression has type "AttrProto[int]", variable has type "AttrProto[float]") [assignment] protocols_generic.py:75: error: Incompatible types in assignment (expression has type "AttrProto[float]", variable has type "AttrProto[int]") [assignment] -protocols_generic.py:145: error: Incompatible types in assignment (expression has type "ConcreteHasProperty2", variable has type "HasPropertyProto") [assignment] -protocols_generic.py:145: note: Following member(s) of "ConcreteHasProperty2" have conflicts: -protocols_generic.py:145: note: Expected: -protocols_generic.py:145: note: def [T] m(self, item: T, callback: Callable[[T], str]) -> str -protocols_generic.py:145: note: Got: -protocols_generic.py:145: note: def m(self, item: int, callback: Callable[[int], str]) -> str -protocols_generic.py:146: error: Incompatible types in assignment (expression has type "ConcreteHasProperty3", variable has type "HasPropertyProto") [assignment] -protocols_generic.py:146: note: Following member(s) of "ConcreteHasProperty3" have conflicts: -protocols_generic.py:146: note: f: expected "ConcreteHasProperty3", got "int" -protocols_generic.py:146: note: Expected: -protocols_generic.py:146: note: def [T] m(self, item: T, callback: Callable[[T], str]) -> str -protocols_generic.py:146: note: Got: -protocols_generic.py:146: note: def m(self, item: int, callback: Callable[[int], str]) -> str -protocols_generic.py:147: error: Incompatible types in assignment (expression has type "ConcreteHasProperty4", variable has type "HasPropertyProto") [assignment] -protocols_generic.py:147: note: Following member(s) of "ConcreteHasProperty4" have conflicts: -protocols_generic.py:147: note: Expected: -protocols_generic.py:147: note: def [T] m(self, item: T, callback: Callable[[T], str]) -> str -protocols_generic.py:147: note: Got: -protocols_generic.py:147: note: def m(self, item: str, callback: Callable[[int], str]) -> str +protocols_generic.py:133: error: Incompatible types in assignment (expression has type "InvalidParentProperty", variable has type "HasParentProperty") [assignment] +protocols_generic.py:133: note: Following member(s) of "InvalidParentProperty" have conflicts: +protocols_generic.py:133: note: parent: expected "InvalidParentProperty", got "HasParentProperty" +protocols_generic.py:153: error: Incompatible types in assignment (expression has type "InvalidHasMethod", variable has type "HasMethod") [assignment] +protocols_generic.py:153: note: Following member(s) of "InvalidHasMethod" have conflicts: +protocols_generic.py:153: note: Expected: +protocols_generic.py:153: note: def [T] m(self, item: T, callback: Callable[[T], str]) -> str +protocols_generic.py:153: note: Got: +protocols_generic.py:153: note: def m(self, item: int, callback: Callable[[int], str]) -> str +protocols_generic.py:185: error: Incompatible types in assignment (expression has type "InvalidGreaterThan", variable has type "HasGreaterThan") [assignment] +protocols_generic.py:185: note: Following member(s) of "InvalidGreaterThan" have conflicts: +protocols_generic.py:185: note: Expected: +protocols_generic.py:185: note: def __gt__(self, InvalidGreaterThan, /) -> bool +protocols_generic.py:185: note: Got: +protocols_generic.py:185: note: def __gt__(self, int, /) -> bool """ -conformance_automated = "Fail" +conformance_automated = "Pass" errors_diff = """ -Line 145: Unexpected errors ['protocols_generic.py:145: error: Incompatible types in assignment (expression has type "ConcreteHasProperty2", variable has type "HasPropertyProto") [assignment]'] """ diff --git a/conformance/results/mypy/protocols_runtime_checkable.toml b/conformance/results/mypy/protocols_runtime_checkable.toml index 8e39d8b64..859ffd725 100644 --- a/conformance/results/mypy/protocols_runtime_checkable.toml +++ b/conformance/results/mypy/protocols_runtime_checkable.toml @@ -1,6 +1,6 @@ conformant = "Partial" notes = """ -Does not report unsafe overlap for runtime_checkable protocol. +Does not report unsafe overlap for `runtime_checkable` protocol. """ output = """ protocols_runtime_checkable.py:23: error: Only @runtime_checkable protocols can be used with instance and class checks [misc] @@ -12,6 +12,6 @@ protocols_runtime_checkable.py:61: note: Protocol "DataProtocol" has non-method conformance_automated = "Fail" errors_diff = """ Line 88: Expected 1 errors -Line 92: Expected 1 errors -Line 96: Expected 1 errors +Line 91: Expected 1 errors +Line 94: Expected 1 errors """ diff --git a/conformance/results/mypy/protocols_variance.toml b/conformance/results/mypy/protocols_variance.toml index e434501cf..58d213901 100644 --- a/conformance/results/mypy/protocols_variance.toml +++ b/conformance/results/mypy/protocols_variance.toml @@ -1,15 +1,20 @@ -conformant = "Pass" +conformant = "Partial" +notes = """ +False report of ParamSpec variance keywords. +""" output = """ -protocols_variance.py:21: error: Invariant type variable "T1" used in protocol where covariant one is expected [misc] -protocols_variance.py:40: error: Invariant type variable "T3" used in protocol where contravariant one is expected [misc] -protocols_variance.py:56: error: Invariant type variable "T1" used in protocol where contravariant one is expected [misc] -protocols_variance.py:61: error: Covariant type variable "T1_co" used in protocol where contravariant one is expected [misc] -protocols_variance.py:62: error: Cannot use a covariant type variable as a parameter [misc] -protocols_variance.py:66: error: Invariant type variable "T1" used in protocol where covariant one is expected [misc] -protocols_variance.py:71: error: Contravariant type variable "T1_contra" used in protocol where covariant one is expected [misc] -protocols_variance.py:72: error: Cannot use a contravariant type variable as return type [misc] -protocols_variance.py:104: error: Invariant type variable "T1" used in protocol where covariant one is expected [misc] +protocols_variance.py:15: error: The variance and bound arguments to ParamSpec do not have defined semantics yet [misc] +protocols_variance.py:22: error: Invariant type variable "T1" used in protocol where covariant one is expected [misc] +protocols_variance.py:41: error: Invariant type variable "T3" used in protocol where contravariant one is expected [misc] +protocols_variance.py:57: error: Invariant type variable "T1" used in protocol where contravariant one is expected [misc] +protocols_variance.py:62: error: Covariant type variable "T1_co" used in protocol where contravariant one is expected [misc] +protocols_variance.py:63: error: Cannot use a covariant type variable as a parameter [misc] +protocols_variance.py:67: error: Invariant type variable "T1" used in protocol where covariant one is expected [misc] +protocols_variance.py:72: error: Contravariant type variable "T1_contra" used in protocol where covariant one is expected [misc] +protocols_variance.py:73: error: Cannot use a contravariant type variable as return type [misc] +protocols_variance.py:105: error: Invariant type variable "T1" used in protocol where covariant one is expected [misc] """ -conformance_automated = "Pass" +conformance_automated = "Fail" errors_diff = """ +Line 15: Unexpected errors ['protocols_variance.py:15: error: The variance and bound arguments to ParamSpec do not have defined semantics yet [misc]'] """ diff --git a/conformance/results/mypy/qualifiers_annotated.toml b/conformance/results/mypy/qualifiers_annotated.toml index 999b512ba..e3cfd8ab9 100644 --- a/conformance/results/mypy/qualifiers_annotated.toml +++ b/conformance/results/mypy/qualifiers_annotated.toml @@ -1,45 +1,39 @@ conformant = "Partial" notes = """ -Does not allow ClassVar to be nested within Annotated. -Does not allow Final to be nested within Annotated. -Does not allow Required and NotRequired to be nested within Annotated. -Does not reject type[T] compatibility for type alias defined with Annotated. -Does not reject call of type alias defined with Annotated. +Does not allow `ClassVar` to be nested within `Annotated`. +Does not allow `Final` to be nested within `Annotated`. +Does not allow `Required` and `NotRequired` to be nested within `Annotated`. +Does not reject `type[T]` compatibility for type alias defined with `Annotated`. +Does not reject call of type alias defined with `Annotated`. """ output = """ -qualifiers_annotated.py:43: error: Bracketed expression "[...]" is not valid as a type [valid-type] -qualifiers_annotated.py:44: error: Syntax error in type annotation [syntax] -qualifiers_annotated.py:44: note: Suggestion: Is there a spurious trailing comma? -qualifiers_annotated.py:45: error: Invalid type comment or annotation [valid-type] -qualifiers_annotated.py:46: error: Invalid type comment or annotation [valid-type] -qualifiers_annotated.py:47: error: Invalid type comment or annotation [valid-type] +qualifiers_annotated.py:38: error: Bracketed expression "[...]" is not valid as a type [valid-type] +qualifiers_annotated.py:39: error: Syntax error in type annotation [syntax] +qualifiers_annotated.py:39: note: Suggestion: Is there a spurious trailing comma? +qualifiers_annotated.py:40: error: Invalid type comment or annotation [valid-type] +qualifiers_annotated.py:41: error: Inline TypedDict is experimental, must be enabled with --enable-incomplete-feature=InlineTypedDict [misc] +qualifiers_annotated.py:41: error: Name "b" is not defined [name-defined] +qualifiers_annotated.py:42: error: Invalid type comment or annotation [valid-type] +qualifiers_annotated.py:43: error: Invalid type comment or annotation [valid-type] +qualifiers_annotated.py:44: error: Invalid type comment or annotation [valid-type] +qualifiers_annotated.py:45: error: Name "var1" is not defined [name-defined] +qualifiers_annotated.py:46: error: Invalid type: try using Literal[True] instead? [valid-type] +qualifiers_annotated.py:47: error: Invalid type: try using Literal[1] instead? [valid-type] qualifiers_annotated.py:48: error: Invalid type comment or annotation [valid-type] qualifiers_annotated.py:49: error: Invalid type comment or annotation [valid-type] -qualifiers_annotated.py:50: error: Name "var1" is not defined [name-defined] -qualifiers_annotated.py:51: error: Invalid type: try using Literal[True] instead? [valid-type] -qualifiers_annotated.py:52: error: Invalid type: try using Literal[1] instead? [valid-type] -qualifiers_annotated.py:53: error: Invalid type comment or annotation [valid-type] -qualifiers_annotated.py:54: error: Invalid type comment or annotation [valid-type] -qualifiers_annotated.py:64: error: Annotated[...] must have exactly one type argument and at least one annotation [valid-type] -qualifiers_annotated.py:76: error: Incompatible types in assignment (expression has type "object", variable has type "type[Any]") [assignment] -qualifiers_annotated.py:84: error: Argument 1 to "func4" has incompatible type "object"; expected "type[Never]" [arg-type] -qualifiers_annotated.py:91: error: "" not callable [operator] -qualifiers_annotated.py:92: error: "object" not callable [operator] -qualifiers_annotated.py:98: error: Invalid type: ClassVar nested inside other type [valid-type] -qualifiers_annotated.py:100: error: Final can be only used as an outermost qualifier in a variable annotation [valid-type] -qualifiers_annotated.py:110: error: Required[] can be only used in a TypedDict definition [valid-type] -qualifiers_annotated.py:112: error: NotRequired[] can be only used in a TypedDict definition [valid-type] -qualifiers_annotated.py:119: error: Cannot redefine "T" as a type variable [misc] -qualifiers_annotated.py:119: error: Invalid assignment target [misc] +qualifiers_annotated.py:59: error: Annotated[...] must have exactly one type argument and at least one annotation [valid-type] +qualifiers_annotated.py:71: error: Incompatible types in assignment (expression has type "", variable has type "type[Any]") [assignment] +qualifiers_annotated.py:79: error: Argument 1 to "func4" has incompatible type ""; expected "type[Never]" [arg-type] +qualifiers_annotated.py:86: error: "" not callable [operator] +qualifiers_annotated.py:87: error: "" not callable [operator] +qualifiers_annotated.py:93: error: Invalid type: ClassVar nested inside other type [valid-type] +qualifiers_annotated.py:95: error: Final can be only used as an outermost qualifier in a variable annotation [valid-type] """ conformance_automated = "Fail" errors_diff = """ -Line 77: Expected 1 errors -Line 85: Expected 1 errors -Line 93: Expected 1 errors -Line 98: Unexpected errors ['qualifiers_annotated.py:98: error: Invalid type: ClassVar nested inside other type [valid-type]'] -Line 100: Unexpected errors ['qualifiers_annotated.py:100: error: Final can be only used as an outermost qualifier in a variable annotation [valid-type]'] -Line 110: Unexpected errors ['qualifiers_annotated.py:110: error: Required[] can be only used in a TypedDict definition [valid-type]'] -Line 112: Unexpected errors ['qualifiers_annotated.py:112: error: NotRequired[] can be only used in a TypedDict definition [valid-type]'] -Line 119: Unexpected errors ['qualifiers_annotated.py:119: error: Cannot redefine "T" as a type variable [misc]', 'qualifiers_annotated.py:119: error: Invalid assignment target [misc]'] +Line 72: Expected 1 errors +Line 80: Expected 1 errors +Line 88: Expected 1 errors +Line 93: Unexpected errors ['qualifiers_annotated.py:93: error: Invalid type: ClassVar nested inside other type [valid-type]'] +Line 95: Unexpected errors ['qualifiers_annotated.py:95: error: Final can be only used as an outermost qualifier in a variable annotation [valid-type]'] """ diff --git a/conformance/results/mypy/qualifiers_final_annotation.toml b/conformance/results/mypy/qualifiers_final_annotation.toml index eecb8fd05..099d55b0c 100644 --- a/conformance/results/mypy/qualifiers_final_annotation.toml +++ b/conformance/results/mypy/qualifiers_final_annotation.toml @@ -1,9 +1,9 @@ conformant = "Partial" notes = """ -Does not treat use of Final name as if it was replaced by the literal in NamedTuple definition. -Does not allow conditional assignment of Final instance variable in __init__ method. -Does not allow redefinition of private class variable that is marked Final in parent class. -Does not report modification of local Final variable via "for" statement. +Does not treat use of `Final` name as if it was replaced by the literal in `NamedTuple` definition. +Does not allow conditional assignment of `Final` instance variable in `__init__` method. +Does not allow redefinition of private class variable that is marked `Final` in parent class. +Does not report modification of local `Final` variable via `for` statement. """ output = """ qualifiers_final_annotation.py:16: error: Type in Final[...] can only be omitted if there is an initializer [misc] @@ -24,23 +24,27 @@ qualifiers_final_annotation.py:107: error: Final can be only used as an outermos qualifiers_final_annotation.py:108: error: Variable should not be annotated with both ClassVar and Final [misc] qualifiers_final_annotation.py:118: error: Final can be only used as an outermost qualifier in a variable annotation [valid-type] qualifiers_final_annotation.py:121: error: Final can be only used as an outermost qualifier in a variable annotation [valid-type] -qualifiers_final_annotation.py:131: error: Invalid "NamedTuple()" field name [misc] -qualifiers_final_annotation.py:133: error: Unexpected keyword argument "x" for "N" [call-arg] -qualifiers_final_annotation.py:133: error: Unexpected keyword argument "y" for "N" [call-arg] -qualifiers_final_annotation.py:134: error: Unexpected keyword argument "a" for "N" [call-arg] -qualifiers_final_annotation.py:135: error: Unexpected keyword argument "x" for "N" [call-arg] -qualifiers_final_annotation.py:135: error: Unexpected keyword argument "y" for "N" [call-arg] -qualifiers_final_annotation.py:141: error: Cannot assign to final name "ID1" [misc] -qualifiers_final_annotation.py:145: error: Cannot assign to final name "x" [misc] -qualifiers_final_annotation.py:147: error: Cannot assign to final name "x" [misc] -qualifiers_final_annotation.py:152: error: Incompatible types in assignment (expression has type "TextIOWrapper", variable has type "int") [assignment] -qualifiers_final_annotation.py:155: error: Cannot assign to final name "x" [misc] +qualifiers_final_annotation.py:131: error: Final[...] can't be used inside a TypedDict [valid-type] +qualifiers_final_annotation.py:136: error: Final[...] can't be used inside a NamedTuple [valid-type] +qualifiers_final_annotation.py:145: error: Invalid "NamedTuple()" field name [misc] +qualifiers_final_annotation.py:147: error: Unexpected keyword argument "x" for "N" [call-arg] +qualifiers_final_annotation.py:147: error: Unexpected keyword argument "y" for "N" [call-arg] +qualifiers_final_annotation.py:148: error: Unexpected keyword argument "a" for "N" [call-arg] +qualifiers_final_annotation.py:149: error: Unexpected keyword argument "x" for "N" [call-arg] +qualifiers_final_annotation.py:149: error: Unexpected keyword argument "y" for "N" [call-arg] +qualifiers_final_annotation.py:155: error: Cannot assign to final name "ID1" [misc] +qualifiers_final_annotation.py:159: error: Cannot assign to final name "x" [misc] +qualifiers_final_annotation.py:161: error: Cannot assign to final name "x" [misc] +qualifiers_final_annotation.py:166: error: Incompatible types in assignment (expression has type "TextIOWrapper[_WrappedBuffer]", variable has type "int") [assignment] +qualifiers_final_annotation.py:169: error: Cannot assign to final name "x" [misc] +qualifiers_final_annotation.py:180: error: Cannot assign to final name "TEN" [misc] +qualifiers_final_annotation.py:184: error: Cannot assign to final name "PI" [misc] """ conformance_automated = "Fail" errors_diff = """ -Line 149: Expected 1 errors +Line 163: Expected 1 errors Line 59: Unexpected errors ['qualifiers_final_annotation.py:59: error: Cannot assign to final attribute "ID6" [misc]'] Line 96: Unexpected errors ['qualifiers_final_annotation.py:96: error: Cannot assign to final name "__private" [misc]'] -Line 131: Unexpected errors ['qualifiers_final_annotation.py:131: error: Invalid "NamedTuple()" field name [misc]'] -Line 133: Unexpected errors ['qualifiers_final_annotation.py:133: error: Unexpected keyword argument "x" for "N" [call-arg]', 'qualifiers_final_annotation.py:133: error: Unexpected keyword argument "y" for "N" [call-arg]'] +Line 145: Unexpected errors ['qualifiers_final_annotation.py:145: error: Invalid "NamedTuple()" field name [misc]'] +Line 147: Unexpected errors ['qualifiers_final_annotation.py:147: error: Unexpected keyword argument "x" for "N" [call-arg]', 'qualifiers_final_annotation.py:147: error: Unexpected keyword argument "y" for "N" [call-arg]'] """ diff --git a/conformance/results/mypy/specialtypes_never.toml b/conformance/results/mypy/specialtypes_never.toml index 04e942227..d4640eb57 100644 --- a/conformance/results/mypy/specialtypes_never.toml +++ b/conformance/results/mypy/specialtypes_never.toml @@ -1,10 +1,10 @@ conformant = "Pass" output = """ specialtypes_never.py:19: error: Implicit return in function which does not return [misc] -specialtypes_never.py:82: error: Incompatible types in assignment (expression has type "list[NoReturn]", variable has type "list[int]") [assignment] -specialtypes_never.py:82: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance -specialtypes_never.py:82: note: Consider using "Sequence" instead, which is covariant -specialtypes_never.py:101: error: Incompatible return value type (got "ClassC[NoReturn]", expected "ClassC[U]") [return-value] +specialtypes_never.py:85: error: Incompatible types in assignment (expression has type "list[Never]", variable has type "list[int]") [assignment] +specialtypes_never.py:85: note: "list" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance +specialtypes_never.py:85: note: Consider using "Sequence" instead, which is covariant +specialtypes_never.py:104: error: Incompatible return value type (got "ClassC[Never]", expected "ClassC[U]") [return-value] """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/mypy/specialtypes_sentinels.toml b/conformance/results/mypy/specialtypes_sentinels.toml new file mode 100644 index 000000000..ef78a42a8 --- /dev/null +++ b/conformance/results/mypy/specialtypes_sentinels.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +specialtypes_sentinels.py:14: error: Incompatible default for parameter "x" (default has type "MISSING", parameter has type "int") [assignment] +specialtypes_sentinels.py:36: error: Argument 1 to "func2" has incompatible type "Cls.IN_CLASS"; expected "int | MISSING | SPECIAL" [arg-type] +specialtypes_sentinels.py:39: error: Argument 1 to "func3" has incompatible type "MISSING"; expected "int | Cls.IN_CLASS" [arg-type] +""" diff --git a/conformance/results/mypy/specialtypes_type.toml b/conformance/results/mypy/specialtypes_type.toml index ea8d59f2a..d83279230 100644 --- a/conformance/results/mypy/specialtypes_type.toml +++ b/conformance/results/mypy/specialtypes_type.toml @@ -1,6 +1,6 @@ conformant = "Partial" notes = """ -Does not treat `type` same as `type[Any]` for assert_type. +Does not treat `type` same as `type[Any]` for `assert_type`. Does not allow access to unknown attributes from object of type `type[Any]`. """ output = """ diff --git a/conformance/results/mypy/tuples_type_compat.toml b/conformance/results/mypy/tuples_type_compat.toml index 55d7bf4de..a63d5f961 100644 --- a/conformance/results/mypy/tuples_type_compat.toml +++ b/conformance/results/mypy/tuples_type_compat.toml @@ -1,7 +1,7 @@ conformant = "Partial" notes = """ Does not support tuple narrowing based on `len()` type guard (optional). -Incorrectly narrows tuple based on sequence patterns. +Incorrectly marks a match case as unreachable. """ output = """ tuples_type_compat.py:15: error: Incompatible types in assignment (expression has type "tuple[float, complex]", variable has type "tuple[int, int]") [assignment] @@ -10,29 +10,29 @@ tuples_type_compat.py:32: error: Incompatible types in assignment (expression ha tuples_type_compat.py:33: error: Incompatible types in assignment (expression has type "tuple[int, ...]", variable has type "tuple[int]") [assignment] tuples_type_compat.py:43: error: Incompatible types in assignment (expression has type "tuple[int, ...]", variable has type "tuple[int]") [assignment] tuples_type_compat.py:62: error: Incompatible types in assignment (expression has type "tuple[int, ...]", variable has type "tuple[int, int]") [assignment] -tuples_type_compat.py:95: error: Expression is of type "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]", not "tuple[int]" [assert-type] -tuples_type_compat.py:99: error: Expression is of type "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]", not "tuple[str, str] | tuple[int, int]" [assert-type] -tuples_type_compat.py:103: error: Expression is of type "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]", not "tuple[int, str, int]" [assert-type] -tuples_type_compat.py:117: error: Expression is of type "tuple[Never, int]", not "tuple[int | str, int]" [assert-type] -tuples_type_compat.py:136: error: Expression is of type "Sequence[object]", not "Sequence[complex | list[int]]" [assert-type] -tuples_type_compat.py:139: error: Expression is of type "Sequence[object]", not "Sequence[int | str]" [assert-type] -tuples_type_compat.py:144: error: Incompatible types in assignment (expression has type "tuple[int, str, str]", variable has type "tuple[int, str]") [assignment] -tuples_type_compat.py:149: error: Incompatible types in assignment (expression has type "tuple[int, int, str]", variable has type "tuple[int, *tuple[str, ...]]") [assignment] -tuples_type_compat.py:150: error: Incompatible types in assignment (expression has type "tuple[int, str, int]", variable has type "tuple[int, *tuple[str, ...]]") [assignment] -tuples_type_compat.py:156: error: Incompatible types in assignment (expression has type "tuple[int, str, str]", variable has type "tuple[int, *tuple[str, ...], int]") [assignment] -tuples_type_compat.py:157: error: Incompatible types in assignment (expression has type "tuple[int, str, str, float]", variable has type "tuple[int, *tuple[str, ...], int]") [assignment] -tuples_type_compat.py:162: error: Incompatible types in assignment (expression has type "tuple[int, str, int]", variable has type "tuple[*tuple[str, ...], int]") [assignment] -tuples_type_compat.py:163: error: Incompatible types in assignment (expression has type "tuple[str, str, float]", variable has type "tuple[*tuple[str, ...], int]") [assignment] -tuples_type_compat.py:168: error: Incompatible types in assignment (expression has type "tuple[str, str]", variable has type "tuple[str, str, int]") [assignment] -tuples_type_compat.py:171: error: Incompatible types in assignment (expression has type "tuple[str, str]", variable has type "tuple[str, str, str, *tuple[str, ...]]") [assignment] -tuples_type_compat.py:175: error: Incompatible types in assignment (expression has type "tuple[str, str]", variable has type "tuple[*tuple[str, ...], str, str, str]") [assignment] +tuples_type_compat.py:76: error: Expression is of type "tuple[int]", not "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]" [assert-type] +tuples_type_compat.py:81: error: Expression is of type "tuple[str, str] | tuple[int, int]", not "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]" [assert-type] +tuples_type_compat.py:86: error: Expression is of type "tuple[int, str, int]", not "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]" [assert-type] +tuples_type_compat.py:102: error: Expression is of type "tuple[int]", not "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]" [assert-type] +tuples_type_compat.py:107: error: Expression is of type "tuple[str, str] | tuple[int, int]", not "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]" [assert-type] +tuples_type_compat.py:112: error: Expression is of type "tuple[int, str, int]", not "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]" [assert-type] +tuples_type_compat.py:127: error: Expression is of type "tuple[int | str, str]", not "tuple[int | str, int | str]" [assert-type] +tuples_type_compat.py:130: error: Expression is of type "tuple[int | str, int]", not "tuple[int | str, int | str]" [assert-type] +tuples_type_compat.py:149: error: Expression is of type "Sequence[object]", not "Sequence[complex | list[int]]" [assert-type] +tuples_type_compat.py:152: error: Expression is of type "Sequence[object]", not "Sequence[int | str]" [assert-type] +tuples_type_compat.py:157: error: Incompatible types in assignment (expression has type "tuple[int, str, str]", variable has type "tuple[int, str]") [assignment] +tuples_type_compat.py:162: error: Incompatible types in assignment (expression has type "tuple[int, int, str]", variable has type "tuple[int, *tuple[str, ...]]") [assignment] +tuples_type_compat.py:163: error: Incompatible types in assignment (expression has type "tuple[int, str, int]", variable has type "tuple[int, *tuple[str, ...]]") [assignment] +tuples_type_compat.py:169: error: Incompatible types in assignment (expression has type "tuple[int, str, str]", variable has type "tuple[int, *tuple[str, ...], int]") [assignment] +tuples_type_compat.py:170: error: Incompatible types in assignment (expression has type "tuple[int, str, str, float]", variable has type "tuple[int, *tuple[str, ...], int]") [assignment] +tuples_type_compat.py:175: error: Incompatible types in assignment (expression has type "tuple[int, str, int]", variable has type "tuple[*tuple[str, ...], int]") [assignment] +tuples_type_compat.py:176: error: Incompatible types in assignment (expression has type "tuple[str, str, float]", variable has type "tuple[*tuple[str, ...], int]") [assignment] +tuples_type_compat.py:181: error: Incompatible types in assignment (expression has type "tuple[str, str]", variable has type "tuple[str, str, int]") [assignment] +tuples_type_compat.py:184: error: Incompatible types in assignment (expression has type "tuple[str, str]", variable has type "tuple[str, str, str, *tuple[str, ...]]") [assignment] +tuples_type_compat.py:188: error: Incompatible types in assignment (expression has type "tuple[str, str]", variable has type "tuple[*tuple[str, ...], str, str, str]") [assignment] """ conformance_automated = "Fail" errors_diff = """ -Line 95: Unexpected errors ['tuples_type_compat.py:95: error: Expression is of type "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]", not "tuple[int]" [assert-type]'] -Line 99: Unexpected errors ['tuples_type_compat.py:99: error: Expression is of type "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]", not "tuple[str, str] | tuple[int, int]" [assert-type]'] -Line 103: Unexpected errors ['tuples_type_compat.py:103: error: Expression is of type "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]", not "tuple[int, str, int]" [assert-type]'] -Line 117: Unexpected errors ['tuples_type_compat.py:117: error: Expression is of type "tuple[Never, int]", not "tuple[int | str, int]" [assert-type]'] -Line 136: Unexpected errors ['tuples_type_compat.py:136: error: Expression is of type "Sequence[object]", not "Sequence[complex | list[int]]" [assert-type]'] -Line 139: Unexpected errors ['tuples_type_compat.py:139: error: Expression is of type "Sequence[object]", not "Sequence[int | str]" [assert-type]'] +Line 149: Unexpected errors ['tuples_type_compat.py:149: error: Expression is of type "Sequence[object]", not "Sequence[complex | list[int]]" [assert-type]'] +Line 152: Unexpected errors ['tuples_type_compat.py:152: error: Expression is of type "Sequence[object]", not "Sequence[int | str]" [assert-type]'] """ diff --git a/conformance/results/mypy/tuples_unpacked.toml b/conformance/results/mypy/tuples_unpacked.toml index ad33667a3..12dee95c6 100644 --- a/conformance/results/mypy/tuples_unpacked.toml +++ b/conformance/results/mypy/tuples_unpacked.toml @@ -1,15 +1,14 @@ conformant = "Partial" notes = """ -"More than one unpack" error is missing a line number. +"More than one unpack" error is missing in some cases. """ output = """ -tuples_unpacked.py: error: More than one Unpack in a type is not allowed [misc] -tuples_unpacked.py:59: error: More than one Unpack in a type is not allowed [misc] +tuples_unpacked.py:40: error: More than one variadic Unpack in a type is not allowed [misc] +tuples_unpacked.py:51: error: More than one variadic Unpack in a type is not allowed [misc] +tuples_unpacked.py:59: error: More than one variadic Unpack in a type is not allowed [misc] """ conformance_automated = "Fail" errors_diff = """ -Line 40: Expected 1 errors Line 41: Expected 1 errors -Line 51: Expected 1 errors -Line 61: Expected 1 errors +Lines 60, 61: Expected error (tag 't14') """ diff --git a/conformance/results/mypy/typeddicts_alt_syntax.toml b/conformance/results/mypy/typeddicts_alt_syntax.toml index 2d1177efa..197eba532 100644 --- a/conformance/results/mypy/typeddicts_alt_syntax.toml +++ b/conformance/results/mypy/typeddicts_alt_syntax.toml @@ -6,7 +6,7 @@ output = """ typeddicts_alt_syntax.py:23: error: TypedDict() expects a dictionary literal as the second argument [misc] typeddicts_alt_syntax.py:27: error: Invalid TypedDict() field name [misc] typeddicts_alt_syntax.py:31: error: First argument "WrongName" to TypedDict() does not match variable name "BadTypedDict3" [name-match] -typeddicts_alt_syntax.py:35: error: Too many arguments for TypedDict() [misc] +typeddicts_alt_syntax.py:35: error: Unexpected keyword argument "other" for "TypedDict" [misc] typeddicts_alt_syntax.py:41: error: Unexpected arguments to TypedDict() [misc] typeddicts_alt_syntax.py:44: error: Extra keys ("name", "year") for TypedDict "Movie2" [typeddict-unknown-key] typeddicts_alt_syntax.py:45: error: Extra keys ("name", "year") for TypedDict "Movie2" [typeddict-unknown-key] diff --git a/conformance/results/mypy/typeddicts_class_syntax.toml b/conformance/results/mypy/typeddicts_class_syntax.toml index 76e44ef9b..d15df036b 100644 --- a/conformance/results/mypy/typeddicts_class_syntax.toml +++ b/conformance/results/mypy/typeddicts_class_syntax.toml @@ -1,11 +1,21 @@ -conformant = "Pass" +conformant = "Partial" +notes = """ +Does not support version-conditional items in `TypedDict` definitions. +""" output = """ -typeddicts_class_syntax.py:29: error: Invalid statement in TypedDict definition; expected "field_name: field_type" [misc] -typeddicts_class_syntax.py:33: error: Invalid statement in TypedDict definition; expected "field_name: field_type" [misc] -typeddicts_class_syntax.py:38: error: Invalid statement in TypedDict definition; expected "field_name: field_type" [misc] -typeddicts_class_syntax.py:44: error: Unexpected keyword argument "metaclass" for "__init_subclass__" of "TypedDict" [call-arg] -typeddicts_class_syntax.py:49: error: Unexpected keyword argument "other" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_class_syntax.py:30: error: Invalid statement in TypedDict definition; expected "field_name: field_type" [misc] +typeddicts_class_syntax.py:34: error: Invalid statement in TypedDict definition; expected "field_name: field_type" [misc] +typeddicts_class_syntax.py:39: error: Invalid statement in TypedDict definition; expected "field_name: field_type" [misc] +typeddicts_class_syntax.py:49: error: Unexpected keyword argument "metaclass" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_class_syntax.py:54: error: Unexpected keyword argument "other" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_class_syntax.py:62: error: Invalid statement in TypedDict definition; expected "field_name: field_type" [misc] +typeddicts_class_syntax.py:64: error: Invalid statement in TypedDict definition; expected "field_name: field_type" [misc] +typeddicts_class_syntax.py:68: error: Extra key "y" for TypedDict "ConditionalField" [typeddict-unknown-key] +typeddicts_class_syntax.py:69: error: Extra keys ("y", "z") for TypedDict "ConditionalField" [typeddict-unknown-key] """ -conformance_automated = "Pass" +conformance_automated = "Fail" errors_diff = """ +Line 62: Unexpected errors ['typeddicts_class_syntax.py:62: error: Invalid statement in TypedDict definition; expected "field_name: field_type" [misc]'] +Line 64: Unexpected errors ['typeddicts_class_syntax.py:64: error: Invalid statement in TypedDict definition; expected "field_name: field_type" [misc]'] +Line 68: Unexpected errors ['typeddicts_class_syntax.py:68: error: Extra key "y" for TypedDict "ConditionalField" [typeddict-unknown-key]'] """ diff --git a/conformance/results/mypy/typeddicts_extra_items.toml b/conformance/results/mypy/typeddicts_extra_items.toml new file mode 100644 index 000000000..3853be1bd --- /dev/null +++ b/conformance/results/mypy/typeddicts_extra_items.toml @@ -0,0 +1,130 @@ +conformant = "Unsupported" +conformance_automated = "Fail" +errors_diff = """ +Line 73: Expected 1 errors +Line 109: Expected 1 errors +Line 215: Expected 1 errors +Line 222: Expected 1 errors +Line 242: Expected 1 errors +Line 256: Expected 1 errors +Line 257: Expected 1 errors +Line 268: Expected 1 errors +Lines 184, 185: Expected error (tag 'MovieRequiredYear') +Lines 187, 188: Expected error (tag 'MovieNotRequiredYear') +Lines 196, 197: Expected error (tag 'BookWithPublisher') +Line 11: Unexpected errors ['typeddicts_extra_items.py:11: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]'] +Line 14: Unexpected errors ['typeddicts_extra_items.py:14: error: Extra key "novel_adaptation" for TypedDict "Movie" [typeddict-unknown-key]'] +Line 19: Unexpected errors ['typeddicts_extra_items.py:19: error: Unexpected keyword argument "extra_items" for "TypedDict" [misc]'] +Line 21: Unexpected errors ['typeddicts_extra_items.py:21: error: Extra keys ("name", "novel_adaptation") for TypedDict "MovieFunctional" [typeddict-unknown-key]'] +Line 29: Unexpected errors ['typeddicts_extra_items.py:29: error: Expression is of type "Any", not "bool" [assert-type]', 'typeddicts_extra_items.py:29: error: TypedDict "Movie" has no key "novel_adaptation" [typeddict-item]'] +Line 33: Unexpected errors ['typeddicts_extra_items.py:33: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]'] +Line 40: Unexpected errors ['typeddicts_extra_items.py:40: error: Extra key "other_extra_key" for TypedDict "InheritedMovie" [typeddict-unknown-key]'] +Line 70: Unexpected errors ['typeddicts_extra_items.py:70: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]'] +Line 100: Unexpected errors ['typeddicts_extra_items.py:100: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]'] +Line 106: Unexpected errors ['typeddicts_extra_items.py:106: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]'] +Line 124: Unexpected errors ['typeddicts_extra_items.py:124: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]'] +Line 129: Unexpected errors ['typeddicts_extra_items.py:129: error: TypedDict "MovieEI" has no key "year" [typeddict-item]'] +Line 137: Unexpected errors ['typeddicts_extra_items.py:137: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]'] +Line 144: Unexpected errors ['typeddicts_extra_items.py:144: error: Unexpected keyword argument "year" for "unpack_extra" [call-arg]'] +Line 149: Unexpected errors ['typeddicts_extra_items.py:149: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]'] +Line 152: Unexpected errors ['typeddicts_extra_items.py:152: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]'] +Line 155: Unexpected errors ['typeddicts_extra_items.py:155: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]'] +Line 165: Unexpected errors ['typeddicts_extra_items.py:165: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]'] +Line 171: Unexpected errors ['typeddicts_extra_items.py:171: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]'] +Line 181: Unexpected errors ['typeddicts_extra_items.py:181: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]'] +Line 193: Unexpected errors ['typeddicts_extra_items.py:193: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]'] +Line 210: Unexpected errors ['typeddicts_extra_items.py:210: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]'] +Line 217: Unexpected errors ['typeddicts_extra_items.py:217: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]'] +Line 228: Unexpected errors ['typeddicts_extra_items.py:228: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]'] +Line 231: Unexpected errors ['typeddicts_extra_items.py:231: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]'] +Line 235: Unexpected errors ['typeddicts_extra_items.py:235: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]'] +Line 248: Unexpected errors ['typeddicts_extra_items.py:248: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]'] +Line 251: Unexpected errors ['typeddicts_extra_items.py:251: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]'] +Line 254: Unexpected errors ['typeddicts_extra_items.py:254: error: Extra key "year" for TypedDict "MovieExtraInt" [typeddict-unknown-key]'] +Line 255: Unexpected errors ['typeddicts_extra_items.py:255: error: Extra key "description" for TypedDict "MovieExtraStr" [typeddict-unknown-key]'] +Line 266: Unexpected errors ['typeddicts_extra_items.py:266: error: Extra key "year" for TypedDict "MovieExtraInt" [typeddict-unknown-key]'] +Line 280: Unexpected errors ['typeddicts_extra_items.py:280: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]'] +Line 284: Unexpected errors ['typeddicts_extra_items.py:284: error: Extra key "year" for TypedDict "ExtraMovie" [typeddict-unknown-key]'] +Line 299: Unexpected errors ['typeddicts_extra_items.py:299: error: Extra key "summary" for TypedDict "MovieExtraStr" [typeddict-unknown-key]'] +Line 300: Unexpected errors ['typeddicts_extra_items.py:300: error: Incompatible types in assignment (expression has type "MovieExtraStr", variable has type "Mapping[str, str]") [assignment]'] +Line 302: Unexpected errors ['typeddicts_extra_items.py:302: error: Extra key "year" for TypedDict "MovieExtraInt" [typeddict-unknown-key]'] +Line 304: Unexpected errors ['typeddicts_extra_items.py:304: error: Incompatible types in assignment (expression has type "MovieExtraInt", variable has type "Mapping[str, int | str]") [assignment]'] +Line 310: Unexpected errors ['typeddicts_extra_items.py:310: error: Expression is of type "list[tuple[str, object]]", not "list[tuple[str, int | str]]" [assert-type]'] +Line 311: Unexpected errors ['typeddicts_extra_items.py:311: error: Expression is of type "list[object]", not "list[int | str]" [assert-type]'] +Line 319: Unexpected errors ['typeddicts_extra_items.py:319: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]'] +Line 326: Unexpected errors ['typeddicts_extra_items.py:326: error: Incompatible types in assignment (expression has type "IntDict", variable has type "dict[str, int]") [assignment]'] +Line 329: Unexpected errors ['typeddicts_extra_items.py:329: error: Extra key "bar" for TypedDict "IntDictWithNum" [typeddict-unknown-key]'] +Line 330: Unexpected errors ['typeddicts_extra_items.py:330: error: Incompatible types in assignment (expression has type "IntDictWithNum", variable has type "dict[str, int]") [assignment]'] +Line 337: Unexpected errors ['typeddicts_extra_items.py:337: error: "IntDictWithNum" has no attribute "clear" [attr-defined]'] +Line 339: Unexpected errors ['typeddicts_extra_items.py:339: error: Expression is of type "Any", not "tuple[str, int]" [assert-type]', 'typeddicts_extra_items.py:339: error: "IntDictWithNum" has no attribute "popitem" [attr-defined]'] +Line 342: Unexpected errors ['typeddicts_extra_items.py:342: error: TypedDict key must be a string literal; expected one of ("num") [literal-required]'] +Line 343: Unexpected errors ['typeddicts_extra_items.py:343: error: Expected TypedDict key to be string literal [misc]'] +""" +output = """ +typeddicts_extra_items.py:11: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:14: error: Extra key "novel_adaptation" for TypedDict "Movie" [typeddict-unknown-key] +typeddicts_extra_items.py:15: error: Extra key "year" for TypedDict "Movie" [typeddict-unknown-key] +typeddicts_extra_items.py:19: error: Unexpected keyword argument "extra_items" for "TypedDict" [misc] +typeddicts_extra_items.py:21: error: Extra keys ("name", "novel_adaptation") for TypedDict "MovieFunctional" [typeddict-unknown-key] +typeddicts_extra_items.py:22: error: Extra keys ("name", "year") for TypedDict "MovieFunctional" [typeddict-unknown-key] +typeddicts_extra_items.py:29: error: Expression is of type "Any", not "bool" [assert-type] +typeddicts_extra_items.py:29: error: TypedDict "Movie" has no key "novel_adaptation" [typeddict-item] +typeddicts_extra_items.py:33: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:39: error: Incompatible types (expression has type "None", TypedDict item "year" has type "int") [typeddict-item] +typeddicts_extra_items.py:40: error: Extra key "other_extra_key" for TypedDict "InheritedMovie" [typeddict-unknown-key] +typeddicts_extra_items.py:49: error: "closed" argument must be a True or False literal [literal-required] +typeddicts_extra_items.py:67: error: Open TypedDict class cannot subclass closed TypedDict class "ClosedBase" [misc] +typeddicts_extra_items.py:70: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:92: error: Cannot extend closed base class "MovieA" with new field "age" [misc] +typeddicts_extra_items.py:95: error: Cannot extend closed base class "MovieB" with new field "age" [misc] +typeddicts_extra_items.py:100: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:106: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:114: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:117: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:124: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:128: error: Key "name" of TypedDict "MovieEI" cannot be deleted [misc] +typeddicts_extra_items.py:129: error: TypedDict "MovieEI" has no key "year" [typeddict-item] +typeddicts_extra_items.py:137: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:143: error: Unexpected keyword argument "year" for "unpack_no_extra" [call-arg] +typeddicts_extra_items.py:144: error: Unexpected keyword argument "year" for "unpack_extra" [call-arg] +typeddicts_extra_items.py:149: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:152: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:155: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:165: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:171: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:174: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:181: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:193: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:210: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:217: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:228: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:231: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:235: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:248: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:251: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:254: error: Extra key "year" for TypedDict "MovieExtraInt" [typeddict-unknown-key] +typeddicts_extra_items.py:255: error: Extra key "description" for TypedDict "MovieExtraStr" [typeddict-unknown-key] +typeddicts_extra_items.py:266: error: Extra key "year" for TypedDict "MovieExtraInt" [typeddict-unknown-key] +typeddicts_extra_items.py:278: error: Extra key "year" for TypedDict "NonClosedMovie" [typeddict-unknown-key] +typeddicts_extra_items.py:280: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:284: error: Extra key "year" for TypedDict "ExtraMovie" [typeddict-unknown-key] +typeddicts_extra_items.py:285: error: Extra key "language" for TypedDict "ExtraMovie" [typeddict-unknown-key] +typeddicts_extra_items.py:293: error: Extra key "year" for TypedDict "ClosedMovie" [typeddict-unknown-key] +typeddicts_extra_items.py:299: error: Extra key "summary" for TypedDict "MovieExtraStr" [typeddict-unknown-key] +typeddicts_extra_items.py:300: error: Incompatible types in assignment (expression has type "MovieExtraStr", variable has type "Mapping[str, str]") [assignment] +typeddicts_extra_items.py:302: error: Extra key "year" for TypedDict "MovieExtraInt" [typeddict-unknown-key] +typeddicts_extra_items.py:303: error: Incompatible types in assignment (expression has type "MovieExtraInt", variable has type "Mapping[str, int]") [assignment] +typeddicts_extra_items.py:304: error: Incompatible types in assignment (expression has type "MovieExtraInt", variable has type "Mapping[str, int | str]") [assignment] +typeddicts_extra_items.py:310: error: Expression is of type "list[tuple[str, object]]", not "list[tuple[str, int | str]]" [assert-type] +typeddicts_extra_items.py:311: error: Expression is of type "list[object]", not "list[int | str]" [assert-type] +typeddicts_extra_items.py:319: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg] +typeddicts_extra_items.py:326: error: Incompatible types in assignment (expression has type "IntDict", variable has type "dict[str, int]") [assignment] +typeddicts_extra_items.py:329: error: Extra key "bar" for TypedDict "IntDictWithNum" [typeddict-unknown-key] +typeddicts_extra_items.py:330: error: Incompatible types in assignment (expression has type "IntDictWithNum", variable has type "dict[str, int]") [assignment] +typeddicts_extra_items.py:337: error: "IntDictWithNum" has no attribute "clear" [attr-defined] +typeddicts_extra_items.py:339: error: Expression is of type "Any", not "tuple[str, int]" [assert-type] +typeddicts_extra_items.py:339: error: "IntDictWithNum" has no attribute "popitem" [attr-defined] +typeddicts_extra_items.py:342: error: TypedDict key must be a string literal; expected one of ("num") [literal-required] +typeddicts_extra_items.py:343: error: Expected TypedDict key to be string literal [misc] +typeddicts_extra_items.py:352: error: Incompatible types in assignment (expression has type "dict[str, int]", variable has type "IntDict") [assignment] +""" diff --git a/conformance/results/mypy/typeddicts_inheritance.toml b/conformance/results/mypy/typeddicts_inheritance.toml index 6679cb131..5f89a8c40 100644 --- a/conformance/results/mypy/typeddicts_inheritance.toml +++ b/conformance/results/mypy/typeddicts_inheritance.toml @@ -1,8 +1,8 @@ conformant = "Pass" output = """ typeddicts_inheritance.py:44: error: All bases of a new TypedDict must be TypedDict types [misc] -typeddicts_inheritance.py:55: error: Overwriting TypedDict field "x" while extending [misc] -typeddicts_inheritance.py:65: error: Overwriting TypedDict field "x" while merging [misc] +typeddicts_inheritance.py:55: error: Definition of field "x" incompatible with base class "X1" [misc] +typeddicts_inheritance.py:65: error: Incompatible definitions of field "x" in base classes "Y2" and "X2" [misc] """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/mypy/typeddicts_readonly.toml b/conformance/results/mypy/typeddicts_readonly.toml index 8af1a3a9c..882ee1b87 100644 --- a/conformance/results/mypy/typeddicts_readonly.toml +++ b/conformance/results/mypy/typeddicts_readonly.toml @@ -1,35 +1,12 @@ -conformant = "Unsupported" +conformant = "Pass" output = """ -typeddicts_readonly.py:18: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly.py:18: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly.py:25: error: "ReadOnly?[builtins.list[builtins.str]]" has no attribute "append" [attr-defined] -typeddicts_readonly.py:31: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly.py:31: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly.py:37: error: "ReadOnly?[builtins.list[builtins.str]]" has no attribute "append" [attr-defined] -typeddicts_readonly.py:45: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly.py:45: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly.py:45: error: Required[] can be only used in a TypedDict definition [valid-type] -typeddicts_readonly.py:46: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly.py:46: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly.py:46: error: NotRequired[] can be only used in a TypedDict definition [valid-type] -typeddicts_readonly.py:55: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly.py:55: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly.py:56: error: NotRequired[] can be only used in a TypedDict definition [valid-type] +typeddicts_readonly.py:24: error: ReadOnly TypedDict key "members" TypedDict is mutated [typeddict-readonly-mutated] +typeddicts_readonly.py:36: error: ReadOnly TypedDict key "members" TypedDict is mutated [typeddict-readonly-mutated] +typeddicts_readonly.py:50: error: ReadOnly TypedDict key "title" TypedDict is mutated [typeddict-readonly-mutated] +typeddicts_readonly.py:51: error: ReadOnly TypedDict key "year" TypedDict is mutated [typeddict-readonly-mutated] +typeddicts_readonly.py:60: error: ReadOnly TypedDict key "title" TypedDict is mutated [typeddict-readonly-mutated] +typeddicts_readonly.py:61: error: ReadOnly TypedDict key "year" TypedDict is mutated [typeddict-readonly-mutated] """ -conformance_automated = "Fail" +conformance_automated = "Pass" errors_diff = """ -Line 24: Expected 1 errors -Line 36: Expected 1 errors -Line 50: Expected 1 errors -Line 51: Expected 1 errors -Line 60: Expected 1 errors -Line 61: Expected 1 errors -Line 18: Unexpected errors ['typeddicts_readonly.py:18: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]'] -Line 25: Unexpected errors ['typeddicts_readonly.py:25: error: "ReadOnly?[builtins.list[builtins.str]]" has no attribute "append" [attr-defined]'] -Line 31: Unexpected errors ['typeddicts_readonly.py:31: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]'] -Line 37: Unexpected errors ['typeddicts_readonly.py:37: error: "ReadOnly?[builtins.list[builtins.str]]" has no attribute "append" [attr-defined]'] -Line 45: Unexpected errors ['typeddicts_readonly.py:45: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]', 'typeddicts_readonly.py:45: error: Required[] can be only used in a TypedDict definition [valid-type]'] -Line 46: Unexpected errors ['typeddicts_readonly.py:46: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]', 'typeddicts_readonly.py:46: error: NotRequired[] can be only used in a TypedDict definition [valid-type]'] -Line 55: Unexpected errors ['typeddicts_readonly.py:55: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]'] -Line 56: Unexpected errors ['typeddicts_readonly.py:56: error: NotRequired[] can be only used in a TypedDict definition [valid-type]'] """ diff --git a/conformance/results/mypy/typeddicts_readonly_consistency.toml b/conformance/results/mypy/typeddicts_readonly_consistency.toml index 9228d1630..803f1bbd2 100644 --- a/conformance/results/mypy/typeddicts_readonly_consistency.toml +++ b/conformance/results/mypy/typeddicts_readonly_consistency.toml @@ -1,24 +1,13 @@ -conformant = "Unsupported" +conformant = "Pass" output = """ -typeddicts_readonly_consistency.py:30: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_consistency.py:30: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly_consistency.py:30: error: NotRequired[] can be only used in a TypedDict definition [valid-type] typeddicts_readonly_consistency.py:37: error: Incompatible types in assignment (expression has type "A1", variable has type "B1") [assignment] typeddicts_readonly_consistency.py:38: error: Incompatible types in assignment (expression has type "C1", variable has type "B1") [assignment] typeddicts_readonly_consistency.py:40: error: Incompatible types in assignment (expression has type "A1", variable has type "C1") [assignment] -typeddicts_readonly_consistency.py:41: error: Incompatible types in assignment (expression has type "B1", variable has type "C1") [assignment] -typeddicts_readonly_consistency.py:66: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_consistency.py:66: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly_consistency.py:79: error: Incompatible types in assignment (expression has type "C2", variable has type "A2") [assignment] +typeddicts_readonly_consistency.py:81: error: Incompatible types in assignment (expression has type "A2", variable has type "B2") [assignment] typeddicts_readonly_consistency.py:82: error: Incompatible types in assignment (expression has type "C2", variable has type "B2") [assignment] typeddicts_readonly_consistency.py:84: error: Incompatible types in assignment (expression has type "A2", variable has type "C2") [assignment] typeddicts_readonly_consistency.py:85: error: Incompatible types in assignment (expression has type "B2", variable has type "C2") [assignment] """ -conformance_automated = "Fail" +conformance_automated = "Pass" errors_diff = """ -Line 81: Expected 1 errors -Line 30: Unexpected errors ['typeddicts_readonly_consistency.py:30: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]', 'typeddicts_readonly_consistency.py:30: error: NotRequired[] can be only used in a TypedDict definition [valid-type]'] -Line 41: Unexpected errors ['typeddicts_readonly_consistency.py:41: error: Incompatible types in assignment (expression has type "B1", variable has type "C1") [assignment]'] -Line 66: Unexpected errors ['typeddicts_readonly_consistency.py:66: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]'] -Line 79: Unexpected errors ['typeddicts_readonly_consistency.py:79: error: Incompatible types in assignment (expression has type "C2", variable has type "A2") [assignment]'] """ diff --git a/conformance/results/mypy/typeddicts_readonly_inheritance.toml b/conformance/results/mypy/typeddicts_readonly_inheritance.toml index 609c0abf9..4db3223e6 100644 --- a/conformance/results/mypy/typeddicts_readonly_inheritance.toml +++ b/conformance/results/mypy/typeddicts_readonly_inheritance.toml @@ -1,91 +1,22 @@ -conformant = "Unsupported" +conformant = "Partial" +notes = """ +Incorrectly rejects non-`ReadOnly` override of `ReadOnly` item. +Incorrectly rejects override of `ReadOnly` item with another `ReadOnly` item with narrower type. +Incorrectly rejects override of `NotRequired ReadOnly` item with a `Required ReadOnly` item. +""" output = """ -typeddicts_readonly_inheritance.py:15: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_inheritance.py:15: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly_inheritance.py:19: error: Overwriting TypedDict field "name" while extending [misc] -typeddicts_readonly_inheritance.py:43: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_inheritance.py:43: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly_inheritance.py:44: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_inheritance.py:44: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly_inheritance.py:49: error: Overwriting TypedDict field "albums" while extending [misc] -typeddicts_readonly_inheritance.py:49: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_inheritance.py:49: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly_inheritance.py:50: error: Overwriting TypedDict field "alt" while extending [misc] -typeddicts_readonly_inheritance.py:50: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_inheritance.py:50: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly_inheritance.py:58: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_inheritance.py:58: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly_inheritance.py:58: error: NotRequired[] can be only used in a TypedDict definition [valid-type] -typeddicts_readonly_inheritance.py:62: error: Overwriting TypedDict field "name" while extending [misc] -typeddicts_readonly_inheritance.py:62: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_inheritance.py:62: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly_inheritance.py:62: error: Required[] can be only used in a TypedDict definition [valid-type] +typeddicts_readonly_inheritance.py:36: error: ReadOnly TypedDict key "name" TypedDict is mutated [typeddict-readonly-mutated] +typeddicts_readonly_inheritance.py:50: error: Definition of field "alt" incompatible with base class "AlbumCollection" [misc] typeddicts_readonly_inheritance.py:65: error: Missing key "name" for TypedDict "RequiredName" [typeddict-item] -typeddicts_readonly_inheritance.py:72: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_inheritance.py:72: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly_inheritance.py:72: error: NotRequired[] can be only used in a TypedDict definition [valid-type] -typeddicts_readonly_inheritance.py:76: error: Overwriting TypedDict field "ident" while extending [misc] typeddicts_readonly_inheritance.py:82: error: Value of "ident" has incompatible type "int"; expected "str" [typeddict-item] typeddicts_readonly_inheritance.py:83: error: Incompatible types (expression has type "int", TypedDict item "ident" has type "str") [typeddict-item] typeddicts_readonly_inheritance.py:84: error: Missing key "ident" for TypedDict "User" [typeddict-item] -typeddicts_readonly_inheritance.py:89: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_inheritance.py:89: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly_inheritance.py:89: error: NotRequired[] can be only used in a TypedDict definition [valid-type] -typeddicts_readonly_inheritance.py:90: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_inheritance.py:90: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly_inheritance.py:90: error: Required[] can be only used in a TypedDict definition [valid-type] -typeddicts_readonly_inheritance.py:94: error: Overwriting TypedDict field "a" while extending [misc] -typeddicts_readonly_inheritance.py:94: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_inheritance.py:94: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly_inheritance.py:98: error: Overwriting TypedDict field "a" while extending [misc] -typeddicts_readonly_inheritance.py:102: error: Overwriting TypedDict field "b" while extending [misc] -typeddicts_readonly_inheritance.py:102: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_inheritance.py:102: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly_inheritance.py:102: error: Required[] can be only used in a TypedDict definition [valid-type] -typeddicts_readonly_inheritance.py:106: error: Overwriting TypedDict field "c" while extending [misc] -typeddicts_readonly_inheritance.py:106: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_inheritance.py:106: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly_inheritance.py:106: error: NotRequired[] can be only used in a TypedDict definition [valid-type] -typeddicts_readonly_inheritance.py:111: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_inheritance.py:111: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly_inheritance.py:116: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_inheritance.py:116: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly_inheritance.py:119: error: Overwriting TypedDict field "x" while merging [misc] -typeddicts_readonly_inheritance.py:119: error: Overwriting TypedDict field "y" while merging [misc] -typeddicts_readonly_inheritance.py:123: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_inheritance.py:123: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly_inheritance.py:123: error: NotRequired[] can be only used in a TypedDict definition [valid-type] -typeddicts_readonly_inheritance.py:124: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_inheritance.py:124: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly_inheritance.py:124: error: Required[] can be only used in a TypedDict definition [valid-type] -typeddicts_readonly_inheritance.py:128: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_inheritance.py:128: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly_inheritance.py:128: error: Required[] can be only used in a TypedDict definition [valid-type] -typeddicts_readonly_inheritance.py:129: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_inheritance.py:129: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly_inheritance.py:129: error: NotRequired[] can be only used in a TypedDict definition [valid-type] -typeddicts_readonly_inheritance.py:132: error: Overwriting TypedDict field "x" while merging [misc] -typeddicts_readonly_inheritance.py:132: error: Overwriting TypedDict field "y" while merging [misc] +typeddicts_readonly_inheritance.py:98: error: Field "a" is required in base class "F1" [misc] +typeddicts_readonly_inheritance.py:119: error: Incompatible definitions of field "x" in base classes "TD_A2" and "TD_A1" [misc] """ conformance_automated = "Fail" errors_diff = """ -Line 36: Expected 1 errors -Line 15: Unexpected errors ['typeddicts_readonly_inheritance.py:15: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]'] -Line 19: Unexpected errors ['typeddicts_readonly_inheritance.py:19: error: Overwriting TypedDict field "name" while extending [misc]'] -Line 43: Unexpected errors ['typeddicts_readonly_inheritance.py:43: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]'] -Line 44: Unexpected errors ['typeddicts_readonly_inheritance.py:44: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]'] -Line 49: Unexpected errors ['typeddicts_readonly_inheritance.py:49: error: Overwriting TypedDict field "albums" while extending [misc]', 'typeddicts_readonly_inheritance.py:49: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]'] -Line 58: Unexpected errors ['typeddicts_readonly_inheritance.py:58: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]', 'typeddicts_readonly_inheritance.py:58: error: NotRequired[] can be only used in a TypedDict definition [valid-type]'] -Line 62: Unexpected errors ['typeddicts_readonly_inheritance.py:62: error: Overwriting TypedDict field "name" while extending [misc]', 'typeddicts_readonly_inheritance.py:62: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]', 'typeddicts_readonly_inheritance.py:62: error: Required[] can be only used in a TypedDict definition [valid-type]'] -Line 72: Unexpected errors ['typeddicts_readonly_inheritance.py:72: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]', 'typeddicts_readonly_inheritance.py:72: error: NotRequired[] can be only used in a TypedDict definition [valid-type]'] -Line 76: Unexpected errors ['typeddicts_readonly_inheritance.py:76: error: Overwriting TypedDict field "ident" while extending [misc]'] -Line 89: Unexpected errors ['typeddicts_readonly_inheritance.py:89: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]', 'typeddicts_readonly_inheritance.py:89: error: NotRequired[] can be only used in a TypedDict definition [valid-type]'] -Line 90: Unexpected errors ['typeddicts_readonly_inheritance.py:90: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]', 'typeddicts_readonly_inheritance.py:90: error: Required[] can be only used in a TypedDict definition [valid-type]'] -Line 102: Unexpected errors ['typeddicts_readonly_inheritance.py:102: error: Overwriting TypedDict field "b" while extending [misc]', 'typeddicts_readonly_inheritance.py:102: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]', 'typeddicts_readonly_inheritance.py:102: error: Required[] can be only used in a TypedDict definition [valid-type]'] -Line 111: Unexpected errors ['typeddicts_readonly_inheritance.py:111: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]'] -Line 116: Unexpected errors ['typeddicts_readonly_inheritance.py:116: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]'] -Line 123: Unexpected errors ['typeddicts_readonly_inheritance.py:123: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]', 'typeddicts_readonly_inheritance.py:123: error: NotRequired[] can be only used in a TypedDict definition [valid-type]'] -Line 124: Unexpected errors ['typeddicts_readonly_inheritance.py:124: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]', 'typeddicts_readonly_inheritance.py:124: error: Required[] can be only used in a TypedDict definition [valid-type]'] -Line 128: Unexpected errors ['typeddicts_readonly_inheritance.py:128: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]', 'typeddicts_readonly_inheritance.py:128: error: Required[] can be only used in a TypedDict definition [valid-type]'] -Line 129: Unexpected errors ['typeddicts_readonly_inheritance.py:129: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]', 'typeddicts_readonly_inheritance.py:129: error: NotRequired[] can be only used in a TypedDict definition [valid-type]'] +Line 94: Expected 1 errors +Line 106: Expected 1 errors +Line 132: Expected 1 errors """ diff --git a/conformance/results/mypy/typeddicts_readonly_kwargs.toml b/conformance/results/mypy/typeddicts_readonly_kwargs.toml index cc8dcd749..a90e015f1 100644 --- a/conformance/results/mypy/typeddicts_readonly_kwargs.toml +++ b/conformance/results/mypy/typeddicts_readonly_kwargs.toml @@ -1,13 +1,7 @@ -conformant = "Unsupported" +conformant = "Pass" output = """ -typeddicts_readonly_kwargs.py:24: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_kwargs.py:24: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly_kwargs.py:25: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_kwargs.py:25: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +typeddicts_readonly_kwargs.py:33: error: ReadOnly TypedDict key "key1" TypedDict is mutated [typeddict-readonly-mutated] """ -conformance_automated = "Fail" +conformance_automated = "Pass" errors_diff = """ -Line 33: Expected 1 errors -Line 24: Unexpected errors ['typeddicts_readonly_kwargs.py:24: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]'] -Line 25: Unexpected errors ['typeddicts_readonly_kwargs.py:25: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]'] """ diff --git a/conformance/results/mypy/typeddicts_readonly_update.toml b/conformance/results/mypy/typeddicts_readonly_update.toml index dfb56389c..aa147b3ee 100644 --- a/conformance/results/mypy/typeddicts_readonly_update.toml +++ b/conformance/results/mypy/typeddicts_readonly_update.toml @@ -1,13 +1,13 @@ -conformant = "Unsupported" +conformant = "Partial" +notes = """ +Incorrectly allows update of `ReadOnly` item. +Incorrectly rejects update involving an item with `Never` type. +""" output = """ -typeddicts_readonly_update.py:17: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_update.py:17: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -typeddicts_readonly_update.py:30: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type] -typeddicts_readonly_update.py:30: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +typeddicts_readonly_update.py:34: error: Argument 1 to "update" of "TypedDict" has incompatible type "B"; expected "TypedDict({'x'?=: int, 'y': int})" [typeddict-item] """ conformance_automated = "Fail" errors_diff = """ Line 23: Expected 1 errors -Line 17: Unexpected errors ['typeddicts_readonly_update.py:17: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]'] -Line 30: Unexpected errors ['typeddicts_readonly_update.py:30: error: Variable "typing_extensions.ReadOnly" is not valid as a type [valid-type]'] +Line 34: Unexpected errors ['typeddicts_readonly_update.py:34: error: Argument 1 to "update" of "TypedDict" has incompatible type "B"; expected "TypedDict({\\'x\\'?=: int, \\'y\\': int})" [typeddict-item]'] """ diff --git a/conformance/results/mypy/typeddicts_required.toml b/conformance/results/mypy/typeddicts_required.toml index e4e89e9bf..bbd8da92a 100644 --- a/conformance/results/mypy/typeddicts_required.toml +++ b/conformance/results/mypy/typeddicts_required.toml @@ -1,17 +1,10 @@ -conformant = "Partial" -notes = """ -Does not support nesting of `Annotated` and `Required` or `NotRequired`. -""" +conformant = "Pass" output = """ typeddicts_required.py:12: error: Required[] can be only used in a TypedDict definition [valid-type] typeddicts_required.py:16: error: NotRequired[] can be only used in a TypedDict definition [valid-type] -typeddicts_required.py:59: error: Required[] can be only used in a TypedDict definition [valid-type] -typeddicts_required.py:60: error: NotRequired[] can be only used in a TypedDict definition [valid-type] -typeddicts_required.py:65: error: Required[] can be only used in a TypedDict definition [valid-type] -typeddicts_required.py:67: error: Required[] can be only used in a TypedDict definition [valid-type] +typeddicts_required.py:60: error: "Required[]" type cannot be nested [valid-type] +typeddicts_required.py:61: error: "NotRequired[]" type cannot be nested [valid-type] """ -conformance_automated = "Fail" +conformance_automated = "Pass" errors_diff = """ -Line 65: Unexpected errors ['typeddicts_required.py:65: error: Required[] can be only used in a TypedDict definition [valid-type]'] -Line 67: Unexpected errors ['typeddicts_required.py:67: error: Required[] can be only used in a TypedDict definition [valid-type]'] """ diff --git a/conformance/results/mypy/typeddicts_type_consistency.toml b/conformance/results/mypy/typeddicts_type_consistency.toml index e0e0ba7f2..3ddab2c9c 100644 --- a/conformance/results/mypy/typeddicts_type_consistency.toml +++ b/conformance/results/mypy/typeddicts_type_consistency.toml @@ -8,8 +8,6 @@ typeddicts_type_consistency.py:76: error: Incompatible types in assignment (expr typeddicts_type_consistency.py:77: error: Incompatible types in assignment (expression has type "B3", variable has type "dict[str, object]") [assignment] typeddicts_type_consistency.py:78: error: Incompatible types in assignment (expression has type "B3", variable has type "dict[Any, Any]") [assignment] typeddicts_type_consistency.py:82: error: Incompatible types in assignment (expression has type "B3", variable has type "Mapping[str, int]") [assignment] -typeddicts_type_consistency.py:101: error: Incompatible types in assignment (expression has type "str | None", variable has type "str") [assignment] -typeddicts_type_consistency.py:107: error: Incompatible types in assignment (expression has type "int | str", variable has type "int") [assignment] typeddicts_type_consistency.py:126: error: Incompatible types (expression has type "int", TypedDict item "inner_key" has type "str") [typeddict-item] """ conformance_automated = "Pass" diff --git a/conformance/results/mypy/typeforms_typeform.toml b/conformance/results/mypy/typeforms_typeform.toml new file mode 100644 index 000000000..ce105569d --- /dev/null +++ b/conformance/results/mypy/typeforms_typeform.toml @@ -0,0 +1,29 @@ +conformant = "Partial" +notes = """ +Does not support assigning `Union` and `GenericAlias` objects to their runtime types. +""" +conformance_automated = "Fail" +errors_diff = """ +Line 71: Expected 1 errors +Line 46: Unexpected errors ['typeforms_typeform.py:46: error: Incompatible types in assignment (expression has type "UnionType | type[str]", variable has type "UnionType") [assignment]'] +Line 49: Unexpected errors ['typeforms_typeform.py:49: error: Incompatible types in assignment (expression has type "type[list[int]]", variable has type "GenericAlias") [assignment]'] +""" +output = """ +typeforms_typeform.py:23: error: Incompatible types in assignment (expression has type "TypeForm[str | int]", variable has type "TypeForm[str | None]") [assignment] +typeforms_typeform.py:24: error: Incompatible types in assignment (expression has type "TypeForm[list[str | None]]", variable has type "TypeForm[str | None]") [assignment] +typeforms_typeform.py:46: error: Incompatible types in assignment (expression has type "UnionType | type[str]", variable has type "UnionType") [assignment] +typeforms_typeform.py:49: error: Incompatible types in assignment (expression has type "type[list[int]]", variable has type "GenericAlias") [assignment] +typeforms_typeform.py:59: error: Argument 1 to "func1" has incompatible type "str"; expected "TypeForm[Any]" [arg-type] +typeforms_typeform.py:67: error: Incompatible types in assignment (expression has type "tuple[Never, ...]", variable has type "TypeForm[Any]") [assignment] +typeforms_typeform.py:68: error: Incompatible types in assignment (expression has type "tuple[int, int]", variable has type "TypeForm[Any]") [assignment] +typeforms_typeform.py:69: error: Incompatible types in assignment (expression has type "int", variable has type "TypeForm[Any]") [assignment] +typeforms_typeform.py:70: error: Incompatible types in assignment (expression has type "", variable has type "TypeForm[Any]") [assignment] +typeforms_typeform.py:72: error: Incompatible types in assignment (expression has type "", variable has type "TypeForm[Any]") [assignment] +typeforms_typeform.py:73: error: Incompatible types in assignment (expression has type "", variable has type "TypeForm[Any]") [assignment] +typeforms_typeform.py:74: error: Incompatible types in assignment (expression has type "", variable has type "TypeForm[Any]") [assignment] +typeforms_typeform.py:75: error: Incompatible types in assignment (expression has type "str", variable has type "TypeForm[Any]") [assignment] +typeforms_typeform.py:86: error: Invalid type comment or annotation [valid-type] +typeforms_typeform.py:88: error: TypeForm argument is not a type [misc] +typeforms_typeform.py:98: error: Incompatible types in assignment (expression has type "TypeForm[int]", variable has type "TypeForm[str]") [assignment] +typeforms_typeform.py:108: error: Incompatible types in assignment (expression has type "type[int]", variable has type "TypeForm[str]") [assignment] +""" diff --git a/conformance/results/mypy/version.toml b/conformance/results/mypy/version.toml index 268bd31ac..46d35802d 100644 --- a/conformance/results/mypy/version.toml +++ b/conformance/results/mypy/version.toml @@ -1,2 +1 @@ -version = "mypy 1.10.0" -test_duration = 1.4 +version = "mypy 2.4.0" diff --git a/conformance/results/pycroscope/aliases_explicit.toml b/conformance/results/pycroscope/aliases_explicit.toml new file mode 100644 index 000000000..61a47bec4 --- /dev/null +++ b/conformance/results/pycroscope/aliases_explicit.toml @@ -0,0 +1,26 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./aliases_explicit.py:67:8: Expected 0 type arguments for type alias, got 1 [invalid_specialization] +./aliases_explicit.py:68:8: Expected 0 type arguments for type alias, got 1 [invalid_specialization] +./aliases_explicit.py:69:8: Expected 1 type arguments for type alias, got 2 [invalid_specialization] +./aliases_explicit.py:70:8: Expected 1 type arguments for type alias, got 2 [invalid_specialization] +./aliases_explicit.py:71:8: ParamSpec specialization must use list form, Concatenate[..., P], P, or ... [invalid_annotation] +./aliases_explicit.py:79:20: Invalid type annotation [invalid_annotation] +./aliases_explicit.py:80:20: Unrecognized annotation [invalid_annotation] +./aliases_explicit.py:81:20: Unrecognized annotation tuple[tuple[type 'int', type 'str']] [invalid_annotation] +./aliases_explicit.py:82:20: Invalid type annotation [invalid_annotation] +./aliases_explicit.py:83:20: Unrecognized annotation [invalid_annotation] +./aliases_explicit.py:84:20: Invalid type annotation [invalid_annotation] +./aliases_explicit.py:85:20: Cannot resolve subscripted annotation: [invalid_annotation] +./aliases_explicit.py:86:20: Invalid type annotation [invalid_annotation] +./aliases_explicit.py:87:20: Invalid type annotation 3 [invalid_annotation] +./aliases_explicit.py:88:21: Invalid type annotation True [invalid_annotation] +./aliases_explicit.py:89:21: Invalid type annotation 1 [invalid_annotation] +./aliases_explicit.py:90:21: Invalid type annotation [invalid_annotation] +./aliases_explicit.py:91:21: Invalid type annotation [invalid_annotation] +./aliases_explicit.py:100:4: Expected 0 type arguments for type alias, got 1 [invalid_specialization] +./aliases_explicit.py:101:5: TypeForm[.ListOrSetAlias] (synthetic from Literal[list | set]) is not callable [not_callable] +./aliases_explicit.py:102:4: Expected 0 type arguments for type alias, got 1 [invalid_specialization] +""" diff --git a/conformance/results/pycroscope/aliases_implicit.toml b/conformance/results/pycroscope/aliases_implicit.toml new file mode 100644 index 000000000..9bdc116fc --- /dev/null +++ b/conformance/results/pycroscope/aliases_implicit.toml @@ -0,0 +1,38 @@ +conformant = "Partial" +notes = """ +Fails to handle various weird annotations. +Various bugs with resolving generic aliases. +""" +conformance_automated = "Fail" +errors_diff = """ +Line 76: Expected 1 errors +Line 106: Expected 1 errors +Line 111: Expected 1 errors +Line 112: Expected 1 errors +Line 113: Expected 1 errors +Line 117: Expected 1 errors +Line 118: Expected 1 errors +Line 119: Expected 1 errors +Line 70: Unexpected errors ['./aliases_implicit.py:70:16: Any[from_another] is not equivalent to int | str | list[list[int]] | None'] +Line 95: Unexpected errors ["./aliases_implicit.py:95:16: Cannot resolve subscripted annotation: [invalid_annotation]"] +Line 100: Unexpected errors ["./aliases_implicit.py:100:17: Annotated[type 'list', (<+list is_truthy None> == NullConstraint())] is always True because it does not provide __bool__ [type_always_true]"] +""" +output = """ +./aliases_implicit.py:70:16: Any[from_another] is not equivalent to int | str | list[list[int]] | None +./aliases_implicit.py:77:8: Unrecognized annotation types.GenericAlias [invalid_annotation] +./aliases_implicit.py:78:8: Expected 1 type arguments for type alias, got 2 [invalid_specialization] +./aliases_implicit.py:79:8: Expected 1 type arguments for type alias, got 2 [invalid_specialization] +./aliases_implicit.py:80:8: ParamSpec specialization must use list form, Concatenate[..., P], P, or ... [invalid_annotation] +./aliases_implicit.py:81:8: Type argument str is not compatible with ~TFloat@./aliases_implicit.py.GoodTypeAlias12 [invalid_specialization] +./aliases_implicit.py:95:16: Cannot resolve subscripted annotation: [invalid_annotation] +./aliases_implicit.py:100:17: Annotated[type 'list', (<+list is_truthy None> == NullConstraint())] is always True because it does not provide __bool__ [type_always_true] +./aliases_implicit.py:107:8: Invalid type annotation [, ] [invalid_annotation] +./aliases_implicit.py:108:8: Invalid type annotation ((, ),) [invalid_annotation] +./aliases_implicit.py:109:8: Unrecognized annotation [invalid_annotation] +./aliases_implicit.py:110:8: Invalid type annotation {'a': 'b'} [invalid_annotation] +./aliases_implicit.py:114:8: Invalid type annotation 3 [invalid_annotation] +./aliases_implicit.py:115:9: Invalid type annotation True [invalid_annotation] +./aliases_implicit.py:116:9: Invalid type annotation 1 [invalid_annotation] +./aliases_implicit.py:133:5: Literal[list | set] is not callable [not_callable] +./aliases_implicit.py:135:4: Unrecognized annotation object [invalid_annotation] +""" diff --git a/conformance/results/pycroscope/aliases_newtype.toml b/conformance/results/pycroscope/aliases_newtype.toml new file mode 100644 index 000000000..c0ce676a5 --- /dev/null +++ b/conformance/results/pycroscope/aliases_newtype.toml @@ -0,0 +1,19 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./aliases_newtype.py:11:7: Incompatible argument type for x: expected int but got Literal['user'] [incompatible_argument] +./aliases_newtype.py:12:0: Incompatible assignment: expected NewType('UserId', int), got Literal[42] [incompatible_assignment] +./aliases_newtype.py:18:0: Incompatible assignment: expected type, got Literal[pycroscope.implementation.UserId] [incompatible_assignment] +./aliases_newtype.py:23:15: Second argument to "isinstance" must be a type, union, or tuple of types, not "pycroscope.implementation.UserId" [incompatible_argument] +./aliases_newtype.py:26:20: NewType cannot be used as a base class [invalid_base] +./aliases_newtype.py:35:19: NewType named 'BadName' must be assigned to a variable with the same name [must_have_same_name] +./aliases_newtype.py:41:5: Object Literal[pycroscope.implementation.GoodNewType1] does not support subscripting [unsupported_operation] +./aliases_newtype.py:47:37: NewType base type cannot be generic [incompatible_call] +./aliases_newtype.py:50:37: NewType base type cannot be generic [incompatible_call] +./aliases_newtype.py:52:37: NewType base type cannot be a protocol [incompatible_call] +./aliases_newtype.py:54:37: NewType base type cannot be a literal type [incompatible_call] +./aliases_newtype.py:61:37: NewType base type cannot be a TypedDict [incompatible_call] +./aliases_newtype.py:63:14: In call to typing.NewType: Takes 2 positional arguments but 3 were given [incompatible_call] +./aliases_newtype.py:65:37: NewType base type cannot be Any [incompatible_call] +""" diff --git a/conformance/results/pycroscope/aliases_recursive.toml b/conformance/results/pycroscope/aliases_recursive.toml new file mode 100644 index 000000000..471c9bead --- /dev/null +++ b/conformance/results/pycroscope/aliases_recursive.toml @@ -0,0 +1,17 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./aliases_recursive.py:19:0: Incompatible assignment: expected int | str | float | list[int | str | float | list[.Json = int | str | float | list[int | str | float | list[.Json] | dict[str, .Json] | None] | dict[str, int | str | float | list[.Json] | dict[str, .Json] | None] | None] | dict[str, .Json = int | str | float | list[int | str | float | list[.Json] | dict[str, .Json] | None] | dict[str, int | str | float | list[.Json] | dict[str, .Json] | None] | None] | None] | dict[str, int | str | float | list[.Json = int | str | float | list[int | str | float | list[.Json] | dict[str, .Json] | None] | dict[str, int | str | float | list[.Json] | dict[str, .Json] | None] | None] | dict[str, .Json = int | str | float | list[int | str | float | list[.Json] | dict[str, .Json] | None] | dict[str, int | str | float | list[.Json] | dict[str, .Json] | None] | None] | None] | None, got Literal[{'a': 1, 'b': 3j}] [incompatible_assignment] +./aliases_recursive.py:20:0: Incompatible assignment: expected int | str | float | list[int | str | float | list[.Json = int | str | float | list[int | str | float | list[.Json] | dict[str, .Json] | None] | dict[str, int | str | float | list[.Json] | dict[str, .Json] | None] | None] | dict[str, .Json = int | str | float | list[int | str | float | list[.Json] | dict[str, .Json] | None] | dict[str, int | str | float | list[.Json] | dict[str, .Json] | None] | None] | None] | dict[str, int | str | float | list[.Json = int | str | float | list[int | str | float | list[.Json] | dict[str, .Json] | None] | dict[str, int | str | float | list[.Json] | dict[str, .Json] | None] | None] | dict[str, .Json = int | str | float | list[int | str | float | list[.Json] | dict[str, .Json] | None] | dict[str, int | str | float | list[.Json] | dict[str, .Json] | None] | None] | None] | None, got Literal[[2, 3j]] [incompatible_assignment] +./aliases_recursive.py:38:0: Incompatible assignment: expected str | int | tuple[str | int | tuple[.RecursiveTuple = str | int | tuple[str | int | tuple[.RecursiveTuple, ...], ...], ...], ...], got Literal[(1, ('1', 1), (1, (1, [2])))] [incompatible_assignment] +./aliases_recursive.py:39:0: Incompatible assignment: expected str | int | tuple[str | int | tuple[.RecursiveTuple = str | int | tuple[str | int | tuple[.RecursiveTuple, ...], ...], ...], ...], got Literal[(1, [1])] [incompatible_assignment] +./aliases_recursive.py:50:0: Incompatible assignment: expected str | int | collections.abc.Mapping[str, str | int | collections.abc.Mapping[str, None.RecursiveMapping = str | int | collections.abc.Mapping[str, str | int | collections.abc.Mapping[str, None.RecursiveMapping]]]], got Literal[{'1': [1]}] [incompatible_assignment] +./aliases_recursive.py:51:0: Incompatible assignment: expected str | int | collections.abc.Mapping[str, str | int | collections.abc.Mapping[str, None.RecursiveMapping = str | int | collections.abc.Mapping[str, str | int | collections.abc.Mapping[str, None.RecursiveMapping]]]], got Literal[{'1': '1', '2': 1, '3': [1, 2]}] [incompatible_assignment] +./aliases_recursive.py:52:0: Incompatible assignment: expected str | int | collections.abc.Mapping[str, str | int | collections.abc.Mapping[str, None.RecursiveMapping = str | int | collections.abc.Mapping[str, str | int | collections.abc.Mapping[str, None.RecursiveMapping]]]], got Literal[{'1': '1', '2': 1, '3': {'0': '0', '1': 1, '2': [1, 2, 3]}}] [incompatible_assignment] +./aliases_recursive.py:63:0: Incompatible assignment: expected aliases_recursive.GenericTypeAlias1[str] = list[aliases_recursive.GenericTypeAlias1[~T1] = list[aliases_recursive.GenericTypeAlias1[~T1] | ~T1] | ~T1], got Literal[['hi', [2.4]]] [incompatible_assignment] +./aliases_recursive.py:69:0: Incompatible assignment: expected aliases_recursive.GenericTypeAlias2[str, int] = list[aliases_recursive.GenericTypeAlias2[~T1, ~T2] = list[aliases_recursive.GenericTypeAlias2[~T1, ~T2] | ~T1 | ~T2] | ~T1 | ~T2], got Literal[[[3, ['hi', 3, [3.4]]], 'hi']] [incompatible_assignment] +./aliases_recursive.py:72:0: Type alias RecursiveUnion has a circular definition [invalid_type_alias] +./aliases_recursive.py:75:0: Type alias MutualReference1 has a circular definition [invalid_type_alias] +./aliases_recursive.py:75:62: Type alias MutualReference2 has a circular definition [invalid_type_alias] +""" diff --git a/conformance/results/pycroscope/aliases_type_statement.toml b/conformance/results/pycroscope/aliases_type_statement.toml new file mode 100644 index 000000000..d22c1deb9 --- /dev/null +++ b/conformance/results/pycroscope/aliases_type_statement.toml @@ -0,0 +1,38 @@ +conformant = "Partial" +notes = """ +Fails to reject various weird annotations. +Rejects a valid recursive generic type alias. +""" +conformance_automated = "Fail" +errors_diff = """ +Line 37: Expected 1 errors +Line 38: Expected 1 errors +Line 39: Expected 1 errors +Line 40: Expected 1 errors +Line 41: Expected 1 errors +Line 42: Expected 1 errors +Line 43: Expected 1 errors +Line 44: Expected 1 errors +Line 45: Expected 1 errors +Line 46: Expected 1 errors +Line 47: Expected 1 errors +Line 49: Expected 1 errors +Line 61: Unexpected errors ['./aliases_type_statement.py:61:0: Unrecognized annotation typing._SpecialForm [invalid_annotation]'] +""" +output = """ +./aliases_type_statement.py:17:0: typing.TypeAliasType has no attribute 'bit_count' [undefined_attribute] +./aliases_type_statement.py:19:0: TypeForm[.GoodAlias1] (synthetic from typing.TypeAliasType) is not callable [not_callable] +./aliases_type_statement.py:23:6: typing.TypeAliasType has no attribute 'other_attrib' [undefined_attribute] +./aliases_type_statement.py:26:17: Type alias cannot be used as a base class [invalid_base] +./aliases_type_statement.py:31:21: Second argument to "isinstance" cannot be a type alias [incompatible_argument] +./aliases_type_statement.py:48:22: Annotated[type 'list', (<+list is_truthy None> == NullConstraint())] is always True because it does not provide __bool__ [type_always_true] +./aliases_type_statement.py:53:22: Type alias cannot combine old-style TypeVar declarations with type statement parameters [invalid_type_alias] +./aliases_type_statement.py:58:16: Type alias must declare type parameters in the type statement [invalid_type_alias] +./aliases_type_statement.py:61:0: Unrecognized annotation typing._SpecialForm [invalid_annotation] +./aliases_type_statement.py:68:6: Type argument str is not compatible with ~S@./aliases_type_statement.py.RecursiveTypeAlias2 [invalid_specialization] +./aliases_type_statement.py:70:6: Type argument int is not compatible with ~T@./aliases_type_statement.py.RecursiveTypeAlias2 [invalid_specialization] +./aliases_type_statement.py:73:0: Type alias RecursiveTypeAlias3 has a circular definition [invalid_type_alias] +./aliases_type_statement.py:75:0: Type alias RecursiveTypeAlias4 has a circular definition [invalid_type_alias] +./aliases_type_statement.py:79:0: Type alias RecursiveTypeAlias6 has a circular definition [invalid_type_alias] +./aliases_type_statement.py:80:0: Type alias RecursiveTypeAlias7 has a circular definition [invalid_type_alias] +""" diff --git a/conformance/results/pycroscope/aliases_typealiastype.toml b/conformance/results/pycroscope/aliases_typealiastype.toml new file mode 100644 index 000000000..9aae0a048 --- /dev/null +++ b/conformance/results/pycroscope/aliases_typealiastype.toml @@ -0,0 +1,28 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./aliases_typealiastype.py:32:6: typing.TypeAliasType has no attribute 'other_attrib' [undefined_attribute] +./aliases_typealiastype.py:40:4: Type argument int is not compatible with ~TStr@./aliases_typealiastype.py.GoodAlias5 [invalid_specialization] +./aliases_typealiastype.py:43:44: Type alias cannot combine old-style TypeVar declarations with type statement parameters [invalid_type_alias] +./aliases_typealiastype.py:44:44: Type alias must declare type parameters in the type statement [invalid_type_alias] +./aliases_typealiastype.py:45:56: type_params argument to TypeAliasType must be a literal tuple [invalid_type_alias] +./aliases_typealiastype.py:46:0: Type alias BadAlias4 has a circular definition [invalid_type_alias] +./aliases_typealiastype.py:47:0: Type alias BadAlias5 has a circular definition [invalid_type_alias] +./aliases_typealiastype.py:48:0: Type alias BadAlias6 has a circular definition [invalid_type_alias] +./aliases_typealiastype.py:49:0: Type alias BadAlias7 has a circular definition [invalid_type_alias] +./aliases_typealiastype.py:52:39: Invalid type annotation [invalid_annotation] +./aliases_typealiastype.py:53:39: Unrecognized annotation [invalid_annotation] +./aliases_typealiastype.py:54:41: Unrecognized annotation tuple[tuple[type 'int', type 'str']] [invalid_annotation] +./aliases_typealiastype.py:55:41: Invalid type annotation [invalid_annotation] +./aliases_typealiastype.py:56:41: Unrecognized annotation [invalid_annotation] +./aliases_typealiastype.py:57:41: Invalid type annotation [invalid_annotation] +./aliases_typealiastype.py:58:41: Cannot resolve subscripted annotation: [invalid_annotation] +./aliases_typealiastype.py:59:41: Invalid type annotation [invalid_annotation] +./aliases_typealiastype.py:60:41: Invalid type annotation 3 [invalid_annotation] +./aliases_typealiastype.py:61:41: Invalid type annotation True [invalid_annotation] +./aliases_typealiastype.py:62:41: Invalid type annotation 1 [invalid_annotation] +./aliases_typealiastype.py:63:41: Invalid type annotation [invalid_annotation] +./aliases_typealiastype.py:64:41: Invalid type annotation [invalid_annotation] +./aliases_typealiastype.py:66:0: Type alias BadAlias21 has a circular definition [invalid_type_alias] +""" diff --git a/conformance/results/pycroscope/aliases_variance.toml b/conformance/results/pycroscope/aliases_variance.toml new file mode 100644 index 000000000..9b84c03ca --- /dev/null +++ b/conformance/results/pycroscope/aliases_variance.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./aliases_variance.py:24:15: T_co has incompatible variance in base class [invalid_base] +./aliases_variance.py:28:15: T_co has incompatible variance in base class [invalid_base] +./aliases_variance.py:32:15: T_co has incompatible variance in base class [invalid_base] +./aliases_variance.py:44:15: T_contra has incompatible variance in base class [invalid_base] +""" diff --git a/conformance/results/pycroscope/annotations_coroutines.toml b/conformance/results/pycroscope/annotations_coroutines.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/pycroscope/annotations_coroutines.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pycroscope/annotations_forward_refs.toml b/conformance/results/pycroscope/annotations_forward_refs.toml new file mode 100644 index 000000000..f1bdcad94 --- /dev/null +++ b/conformance/results/pycroscope/annotations_forward_refs.toml @@ -0,0 +1,54 @@ +conformant = "Partial" +notes = """ +Fails to reject `"x" | int` annotations that fail at runtime. +Resolves forward references in type annotations in classes at the point of definition instead of end-of-scope +Rejects some valid quoted annotations. +""" +conformance_automated = "Fail" +errors_diff = """ +Line 24: Expected 1 errors +Line 25: Expected 1 errors +Line 94: Expected 1 errors +Line 96: Expected 1 errors +Line 14: Unexpected errors ['./annotations_forward_refs.py:14:8: Undefined name: ClassA [undefined_name]', './annotations_forward_refs.py:14:22: Undefined name: ClassA [undefined_name]', './annotations_forward_refs.py:14:42: Undefined name: ClassA [undefined_name]', './annotations_forward_refs.py:14:62: Undefined name: ClassA [undefined_name]'] +Line 16: Unexpected errors ['./annotations_forward_refs.py:16:16: Any[error] is not equivalent to ./annotations_forward_refs.py.ClassA'] +Line 17: Unexpected errors ['./annotations_forward_refs.py:17:16: list[Any[error]] is not equivalent to list[./annotations_forward_refs.py.ClassA]'] +Line 18: Unexpected errors ['./annotations_forward_refs.py:18:16: list[Any[error]] is not equivalent to list[./annotations_forward_refs.py.ClassA]'] +Line 19: Unexpected errors ['./annotations_forward_refs.py:19:16: list[int | Any[error]] is not equivalent to list[./annotations_forward_refs.py.ClassA | int]'] +Line 84: Unexpected errors ['./annotations_forward_refs.py:84:12: Undefined name: ClassInner [undefined_name]'] +Line 112: Unexpected errors ['./annotations_forward_refs.py:112:16: Any[error] is not equivalent to ./annotations_forward_refs.py.ClassD.ClassInner'] +""" +output = """ +./annotations_forward_refs.py:14:8: Undefined name: ClassA [undefined_name] +./annotations_forward_refs.py:14:22: Undefined name: ClassA [undefined_name] +./annotations_forward_refs.py:14:42: Undefined name: ClassA [undefined_name] +./annotations_forward_refs.py:14:62: Undefined name: ClassA [undefined_name] +./annotations_forward_refs.py:16:16: Any[error] is not equivalent to ./annotations_forward_refs.py.ClassA +./annotations_forward_refs.py:17:16: list[Any[error]] is not equivalent to list[./annotations_forward_refs.py.ClassA] +./annotations_forward_refs.py:18:16: list[Any[error]] is not equivalent to list[./annotations_forward_refs.py.ClassA] +./annotations_forward_refs.py:19:16: list[int | Any[error]] is not equivalent to list[./annotations_forward_refs.py.ClassA | int] +./annotations_forward_refs.py:22:6: Undefined name: ClassA [undefined_name] +./annotations_forward_refs.py:23:11: Undefined name: ClassA [undefined_name] +./annotations_forward_refs.py:41:0: Invalid type annotation [invalid_annotation] +./annotations_forward_refs.py:42:8: Unrecognized annotation [invalid_annotation] +./annotations_forward_refs.py:43:8: Unrecognized annotation tuple[type 'int', type 'str'] [invalid_annotation] +./annotations_forward_refs.py:44:0: Invalid type annotation [invalid_annotation] +./annotations_forward_refs.py:45:8: Unrecognized annotation [invalid_annotation] +./annotations_forward_refs.py:46:0: Invalid type annotation [invalid_annotation] +./annotations_forward_refs.py:47:8: Cannot resolve subscripted annotation: [invalid_annotation] +./annotations_forward_refs.py:48:0: Invalid type annotation [invalid_annotation] +./annotations_forward_refs.py:49:8: Invalid type annotation 1 [invalid_annotation] +./annotations_forward_refs.py:50:9: Invalid type annotation True [invalid_annotation] +./annotations_forward_refs.py:51:9: Invalid type annotation 1 [invalid_annotation] +./annotations_forward_refs.py:52:9: Invalid type annotation -1 [invalid_annotation] +./annotations_forward_refs.py:53:0: Invalid type annotation [invalid_annotation] +./annotations_forward_refs.py:54:0: Invalid type annotation [invalid_annotation] +./annotations_forward_refs.py:55:9: Invalid type annotation [invalid_annotation] +./annotations_forward_refs.py:83:12: Undefined name: ClassInner [undefined_name] +./annotations_forward_refs.py:84:12: Undefined name: ClassInner [undefined_name] +./annotations_forward_refs.py:92:12: Undefined name: ClassF [undefined_name] +./annotations_forward_refs.py:101:7: Unrecognized annotation (self: ./annotations_forward_refs.py.ClassD) -> None [invalid_annotation] +./annotations_forward_refs.py:103:7: Unrecognized annotation (self: ./annotations_forward_refs.py.ClassD) -> None [invalid_annotation] +./annotations_forward_refs.py:111:16: Any[error] is not equivalent to ./annotations_forward_refs.py.ClassD.ClassInner +./annotations_forward_refs.py:112:16: Any[error] is not equivalent to ./annotations_forward_refs.py.ClassD.ClassInner +""" diff --git a/conformance/results/pycroscope/annotations_future_import.toml b/conformance/results/pycroscope/annotations_future_import.toml new file mode 100644 index 000000000..7576dc678 --- /dev/null +++ b/conformance/results/pycroscope/annotations_future_import.toml @@ -0,0 +1,27 @@ +conformant = "Partial" +notes = """ +Forward references to nested classes are not resolved +Nested classes are resolved, but its type is Any +Resolves some class annotations to outer names instead of shadowing class bindings +""" +conformance_automated = "Fail" +errors_diff = """ +Line 37: Expected 1 errors +Line 39: Expected 1 errors +Line 26: Unexpected errors ['./annotations_future_import.py:26:12: Undefined name: ClassInner [undefined_name]'] +Line 27: Unexpected errors ['./annotations_future_import.py:27:12: Undefined name: ClassInner [undefined_name]'] +Line 55: Unexpected errors ['./annotations_future_import.py:55:16: Any[inference] is not equivalent to annotations_future_import.ClassB.ClassInner'] +Line 56: Unexpected errors ['./annotations_future_import.py:56:16: Any[inference] is not equivalent to annotations_future_import.ClassB.ClassInner'] +Line 57: Unexpected errors ['./annotations_future_import.py:57:16: Any[inference] is not equivalent to annotations_future_import.ClassB.ClassInner'] +Line 58: Unexpected errors ['./annotations_future_import.py:58:16: Any[inference] is not equivalent to annotations_future_import.ClassB.ClassInner'] +""" +output = """ +./annotations_future_import.py:26:12: Undefined name: ClassInner [undefined_name] +./annotations_future_import.py:27:12: Undefined name: ClassInner [undefined_name] +./annotations_future_import.py:44:7: Invalid type annotation [invalid_annotation] +./annotations_future_import.py:46:7: Invalid type annotation [invalid_annotation] +./annotations_future_import.py:55:16: Any[inference] is not equivalent to annotations_future_import.ClassB.ClassInner +./annotations_future_import.py:56:16: Any[inference] is not equivalent to annotations_future_import.ClassB.ClassInner +./annotations_future_import.py:57:16: Any[inference] is not equivalent to annotations_future_import.ClassB.ClassInner +./annotations_future_import.py:58:16: Any[inference] is not equivalent to annotations_future_import.ClassB.ClassInner +""" diff --git a/conformance/results/pycroscope/annotations_generators.toml b/conformance/results/pycroscope/annotations_generators.toml new file mode 100644 index 000000000..44a1909d4 --- /dev/null +++ b/conformance/results/pycroscope/annotations_generators.toml @@ -0,0 +1,16 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./annotations_generators.py:51:0: Function may exit without returning a value [missing_return] +./annotations_generators.py:54:8: Incompatible return type: expected annotations_generators.C, got Literal[False] [incompatible_return_value] +./annotations_generators.py:57:8: Cannot assign value of type Literal[3] to yield expression of type annotations_generators.A [incompatible_yield] +./annotations_generators.py:66:8: Cannot assign value of type Literal[3] to yield expression of type annotations_generators.A [incompatible_yield] +./annotations_generators.py:71:4: Incompatible return type: expected None, got Literal[True] [incompatible_return_value] +./annotations_generators.py:75:4: Cannot assign value of type annotations_generators.B to yield expression of type annotations_generators.A [incompatible_yield] +./annotations_generators.py:86:20: Generator function must return an iterable [generator_return] +./annotations_generators.py:91:26: Async generator function must return an async iterable [generator_return] +./annotations_generators.py:118:4: Cannot yield from collections.abc.Iterator[annotations_generators.A] (expected annotations_generators.B) [incompatible_yield] +./annotations_generators.py:119:4: Cannot yield from Literal[[1]] (expected annotations_generators.B) [incompatible_yield] +./annotations_generators.py:135:4: Cannot send int to a generator (expected str) [incompatible_yield] +""" diff --git a/conformance/results/pycroscope/annotations_methods.toml b/conformance/results/pycroscope/annotations_methods.toml new file mode 100644 index 000000000..abfcc72e8 --- /dev/null +++ b/conformance/results/pycroscope/annotations_methods.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./annotations_methods.py:42:12: annotations_methods.B is not equivalent to annotations_methods.A +""" diff --git a/conformance/results/pycroscope/annotations_typeexpr.toml b/conformance/results/pycroscope/annotations_typeexpr.toml new file mode 100644 index 000000000..d323d5697 --- /dev/null +++ b/conformance/results/pycroscope/annotations_typeexpr.toml @@ -0,0 +1,24 @@ +conformant = "Partial" +notes = """ +Fails to reject various weird annotations +""" +conformance_automated = "Fail" +errors_diff = """ +Line 88: Expected 1 errors +Line 93: Expected 1 errors +Line 94: Expected 1 errors +Line 95: Expected 1 errors +Line 100: Expected 1 errors +Line 101: Expected 1 errors +""" +output = """ +./annotations_typeexpr.py:89:8: Invalid type annotation [, ] [invalid_annotation] +./annotations_typeexpr.py:90:8: Invalid type annotation (, ) [invalid_annotation] +./annotations_typeexpr.py:91:8: Unrecognized annotation [invalid_annotation] +./annotations_typeexpr.py:92:8: Invalid type annotation {} [invalid_annotation] +./annotations_typeexpr.py:96:8: Invalid type annotation 3 [invalid_annotation] +./annotations_typeexpr.py:97:9: Invalid type annotation True [invalid_annotation] +./annotations_typeexpr.py:98:9: Invalid type annotation 1 [invalid_annotation] +./annotations_typeexpr.py:99:9: Invalid type annotation -1 [invalid_annotation] +./annotations_typeexpr.py:102:9: Invalid type annotation [invalid_annotation] +""" diff --git a/conformance/results/pycroscope/callables_annotation.toml b/conformance/results/pycroscope/callables_annotation.toml new file mode 100644 index 000000000..d74b67611 --- /dev/null +++ b/conformance/results/pycroscope/callables_annotation.toml @@ -0,0 +1,21 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./callables_annotation.py:25:4: Missing required positional argument at position 1 [incompatible_call] +./callables_annotation.py:26:10: Incompatible argument type for @1: expected str but got Literal[2] [incompatible_argument] +./callables_annotation.py:27:4: Takes 2 positional arguments but 3 were given [incompatible_call] +./callables_annotation.py:29:4: Missing required positional argument at position 0 [incompatible_call] +./callables_annotation.py:35:4: Takes 0 positional arguments but 1 were given [incompatible_call] +./callables_annotation.py:55:4: Callable[] requires exactly two arguments [invalid_annotation] +./callables_annotation.py:56:4: Invalid arguments to Callable: [invalid_annotation] +./callables_annotation.py:57:4: Invalid type annotation [] [invalid_annotation] +./callables_annotation.py:58:4: Callable[] requires exactly two arguments [invalid_annotation] +./callables_annotation.py:59:4: Ellipsis must be used directly in Callable[..., T], not in Callable[[...], T] [invalid_annotation] +./callables_annotation.py:91:0: Incompatible assignment: expected (int, /, **Any[explicit]) -> str, got () -> str [incompatible_assignment] +./callables_annotation.py:93:0: Incompatible assignment: expected (int, /, **Any[explicit]) -> str, got (*, a: int) -> str [incompatible_assignment] +./callables_annotation.py:159:4: Incompatible assignment: expected ./callables_annotation.py.Proto5[Any[explicit]], got ./callables_annotation.py.Proto8 [incompatible_assignment] +./callables_annotation.py:172:4: Incompatible assignment: expected .Callback2[AnySig()] = (int, /, ****P) -> str, got () -> str [incompatible_assignment] +./callables_annotation.py:187:4: Incompatible assignment: expected (str, /, **Any[explicit]) -> str, got (int, str, /) -> str [incompatible_assignment] +./callables_annotation.py:189:4: Incompatible assignment: expected .CallbackWithStr[AnySig()] = (str, /, ****P) -> str, got (int, str, /) -> str [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/callables_kwargs.toml b/conformance/results/pycroscope/callables_kwargs.toml new file mode 100644 index 000000000..492f041f5 --- /dev/null +++ b/conformance/results/pycroscope/callables_kwargs.toml @@ -0,0 +1,19 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./callables_kwargs.py:46:4: In call to callables_kwargs.func1: Missing required argument 'v1' [incompatible_call] +./callables_kwargs.py:51:4: In call to callables_kwargs.func1: Got an unexpected keyword argument 'v4' [incompatible_call] +./callables_kwargs.py:52:4: In call to callables_kwargs.func1: Missing required argument 'v1' [incompatible_call] +./callables_kwargs.py:58:4: Incompatible argument type for v1: expected int but got str [incompatible_argument] +./callables_kwargs.py:61:4: In call to callables_kwargs.func1: Got an unexpected keyword argument 'v4' [incompatible_call] +./callables_kwargs.py:63:4: Multiple values provided for argument 'v1' [incompatible_call] +./callables_kwargs.py:64:4: In call to callables_kwargs.func2: Parameter 'v3' provided as both a positional and a keyword argument [incompatible_call] +./callables_kwargs.py:65:4: Multiple values provided for argument 'v1' [incompatible_call] +./callables_kwargs.py:101:0: Incompatible assignment: expected callables_kwargs.TDProtocol3, got function 'callables_kwargs.func1' [incompatible_assignment] +./callables_kwargs.py:102:0: Incompatible assignment: expected callables_kwargs.TDProtocol4, got function 'callables_kwargs.func1' [incompatible_assignment] +./callables_kwargs.py:103:0: Incompatible assignment: expected callables_kwargs.TDProtocol5, got function 'callables_kwargs.func1' [incompatible_assignment] +./callables_kwargs.py:111:21: Parameter v1 overlaps with TypedDict key in **kwargs [invalid_annotation] +./callables_kwargs.py:122:12: Expected TypedDict type inside Unpack[] for **kwargs [invalid_annotation] +./callables_kwargs.py:134:0: Incompatible assignment: expected callables_kwargs.TDProtocol6, got function 'callables_kwargs.func7' [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/callables_protocol.toml b/conformance/results/pycroscope/callables_protocol.toml new file mode 100644 index 000000000..658e045ad --- /dev/null +++ b/conformance/results/pycroscope/callables_protocol.toml @@ -0,0 +1,22 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./callables_protocol.py:35:0: Incompatible assignment: expected ./callables_protocol.py.Proto1, got (*vals: tuple[bytes, ...], max_items: int | None) -> list[bytes] [incompatible_assignment] +./callables_protocol.py:36:0: Incompatible assignment: expected ./callables_protocol.py.Proto1, got (*vals: tuple[bytes, ...]) -> list[bytes] [incompatible_assignment] +./callables_protocol.py:37:0: Incompatible assignment: expected ./callables_protocol.py.Proto1, got (*vals: tuple[bytes, ...], max_len: str | None) -> list[bytes] [incompatible_assignment] +./callables_protocol.py:67:0: Incompatible assignment: expected ./callables_protocol.py.Proto2, got (*a: tuple[bytes, ...]) -> Any[unannotated] [incompatible_assignment] +./callables_protocol.py:68:0: Incompatible assignment: expected ./callables_protocol.py.Proto2, got (*a: tuple[str, ...], **b: dict[str, str]) -> Any[unannotated] [incompatible_assignment] +./callables_protocol.py:69:0: Incompatible assignment: expected ./callables_protocol.py.Proto2, got (*a: tuple[bytes, ...], **b: dict[str, bytes]) -> Any[unannotated] [incompatible_assignment] +./callables_protocol.py:70:0: Incompatible assignment: expected ./callables_protocol.py.Proto2, got (**b: dict[str, str]) -> Any[unannotated] [incompatible_assignment] +./callables_protocol.py:97:0: Incompatible assignment: expected ./callables_protocol.py.Proto4, got (x: int) -> None [incompatible_assignment] +./callables_protocol.py:121:0: Incompatible assignment: expected ./callables_protocol.py.NotProto6, got (*vals: tuple[bytes, ...], max_len: int | None = None) -> list[bytes] [incompatible_assignment] +./callables_protocol.py:169:0: Incompatible assignment: expected ./callables_protocol.py.Proto8, got (x: int) -> Any[explicit] [incompatible_assignment] +./callables_protocol.py:186:4: Incompatible types in assignment to attribute 'other_attribute': expected int, got Literal['str'] [incompatible_assignment] +./callables_protocol.py:187:4: ./callables_protocol.py.Proto9[**P@./callables_protocol.py.decorator1..decorator1, +R@./callables_protocol.py.decorator1..decorator1] has no attribute 'xxx' [undefined_attribute] +./callables_protocol.py:197:6: ./callables_protocol.py.Proto9[(x: int) -> Any[unannotated], str] has no attribute 'other_attribute2' [undefined_attribute] +./callables_protocol.py:238:0: Incompatible assignment: expected ./callables_protocol.py.Proto11, got (x: int, y: str, /) -> Any[explicit] [incompatible_assignment] +./callables_protocol.py:260:0: Incompatible assignment: expected ./callables_protocol.py.Proto12, got (*args: tuple[Any[explicit], ...], kwarg0: Any[explicit]) -> None [incompatible_assignment] +./callables_protocol.py:284:0: Incompatible assignment: expected ./callables_protocol.py.Proto13_Default, got (path: str) -> str [incompatible_assignment] +./callables_protocol.py:311:0: Incompatible assignment: expected ./callables_protocol.py.Proto14_Default, got (*, path: str) -> str [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/callables_subtyping.toml b/conformance/results/pycroscope/callables_subtyping.toml new file mode 100644 index 000000000..548cae50e --- /dev/null +++ b/conformance/results/pycroscope/callables_subtyping.toml @@ -0,0 +1,37 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./callables_subtyping.py:26:4: Incompatible assignment: expected (float | int, /) -> float | int, got (int, /) -> int [incompatible_assignment] +./callables_subtyping.py:29:4: Incompatible assignment: expected (int, /) -> int, got (float | int, /) -> float | int [incompatible_assignment] +./callables_subtyping.py:51:4: Incompatible assignment: expected callables_subtyping.Standard2, got callables_subtyping.PosOnly2 [incompatible_assignment] +./callables_subtyping.py:52:4: Incompatible assignment: expected callables_subtyping.Standard2, got callables_subtyping.KwOnly2 [incompatible_assignment] +./callables_subtyping.py:55:4: Incompatible assignment: expected callables_subtyping.PosOnly2, got callables_subtyping.KwOnly2 [incompatible_assignment] +./callables_subtyping.py:58:4: Incompatible assignment: expected callables_subtyping.KwOnly2, got callables_subtyping.PosOnly2 [incompatible_assignment] +./callables_subtyping.py:82:4: Incompatible assignment: expected callables_subtyping.IntArgs3, got callables_subtyping.NoArgs3 [incompatible_assignment] +./callables_subtyping.py:85:4: Incompatible assignment: expected callables_subtyping.FloatArgs3, got callables_subtyping.NoArgs3 [incompatible_assignment] +./callables_subtyping.py:86:4: Incompatible assignment: expected callables_subtyping.FloatArgs3, got callables_subtyping.IntArgs3 [incompatible_assignment] +./callables_subtyping.py:116:4: Incompatible assignment: expected callables_subtyping.PosOnly4, got callables_subtyping.IntArgs4 [incompatible_assignment] +./callables_subtyping.py:119:4: Incompatible assignment: expected callables_subtyping.IntStrArgs4, got callables_subtyping.StrArgs4 [incompatible_assignment] +./callables_subtyping.py:120:4: Incompatible assignment: expected callables_subtyping.IntStrArgs4, got callables_subtyping.IntArgs4 [incompatible_assignment] +./callables_subtyping.py:122:4: Incompatible assignment: expected callables_subtyping.StrArgs4, got callables_subtyping.IntArgs4 [incompatible_assignment] +./callables_subtyping.py:124:4: Incompatible assignment: expected callables_subtyping.IntArgs4, got callables_subtyping.StrArgs4 [incompatible_assignment] +./callables_subtyping.py:125:4: Incompatible assignment: expected callables_subtyping.Standard4, got callables_subtyping.IntStrArgs4 [incompatible_assignment] +./callables_subtyping.py:126:4: Incompatible assignment: expected callables_subtyping.Standard4, got callables_subtyping.StrArgs4 [incompatible_assignment] +./callables_subtyping.py:151:4: Incompatible assignment: expected callables_subtyping.IntKwargs5, got callables_subtyping.NoKwargs5 [incompatible_assignment] +./callables_subtyping.py:154:4: Incompatible assignment: expected callables_subtyping.FloatKwargs5, got callables_subtyping.NoKwargs5 [incompatible_assignment] +./callables_subtyping.py:155:4: Incompatible assignment: expected callables_subtyping.FloatKwargs5, got callables_subtyping.IntKwargs5 [incompatible_assignment] +./callables_subtyping.py:187:4: Incompatible assignment: expected callables_subtyping.KwOnly6, got callables_subtyping.IntKwargs6 [incompatible_assignment] +./callables_subtyping.py:190:4: Incompatible assignment: expected callables_subtyping.IntStrKwargs6, got callables_subtyping.StrKwargs6 [incompatible_assignment] +./callables_subtyping.py:191:4: Incompatible assignment: expected callables_subtyping.IntStrKwargs6, got callables_subtyping.IntKwargs6 [incompatible_assignment] +./callables_subtyping.py:193:4: Incompatible assignment: expected callables_subtyping.StrKwargs6, got callables_subtyping.IntKwargs6 [incompatible_assignment] +./callables_subtyping.py:195:4: Incompatible assignment: expected callables_subtyping.IntKwargs6, got callables_subtyping.StrKwargs6 [incompatible_assignment] +./callables_subtyping.py:196:4: Incompatible assignment: expected callables_subtyping.Standard6, got callables_subtyping.IntStrKwargs6 [incompatible_assignment] +./callables_subtyping.py:197:4: Incompatible assignment: expected callables_subtyping.Standard6, got callables_subtyping.StrKwargs6 [incompatible_assignment] +./callables_subtyping.py:236:4: Incompatible assignment: expected callables_subtyping.DefaultArg8, got callables_subtyping.NoDefaultArg8 [incompatible_assignment] +./callables_subtyping.py:237:4: Incompatible assignment: expected callables_subtyping.DefaultArg8, got callables_subtyping.NoX8 [incompatible_assignment] +./callables_subtyping.py:240:4: Incompatible assignment: expected callables_subtyping.NoDefaultArg8, got callables_subtyping.NoX8 [incompatible_assignment] +./callables_subtyping.py:243:4: Incompatible assignment: expected callables_subtyping.NoX8, got callables_subtyping.NoDefaultArg8 [incompatible_assignment] +./callables_subtyping.py:273:4: Incompatible assignment: expected callables_subtyping.FloatArg9, got callables_subtyping.Overloaded9 [incompatible_assignment] +./callables_subtyping.py:297:4: Incompatible assignment: expected callables_subtyping.Overloaded10, got callables_subtyping.StrArg10 [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/classes_classvar.toml b/conformance/results/pycroscope/classes_classvar.toml new file mode 100644 index 000000000..4d3f0e1dd --- /dev/null +++ b/conformance/results/pycroscope/classes_classvar.toml @@ -0,0 +1,24 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./classes_classvar.py:40:10: Invalid type annotation (, ) [invalid_annotation] +./classes_classvar.py:41:10: Invalid type annotation 3 [invalid_annotation] +./classes_classvar.py:42:13: Undefined name: var [undefined_name] +./classes_classvar.py:47:10: ClassVar type cannot include type parameters [classvar_type_parameters] +./classes_classvar.py:48:10: ClassVar type cannot include type parameters [classvar_type_parameters] +./classes_classvar.py:49:10: ClassVar type cannot include type parameters [classvar_type_parameters] +./classes_classvar.py:54:4: Incompatible assignment: expected list[str], got Literal[{}] [incompatible_assignment] +./classes_classvar.py:56:10: Final cannot be combined with ClassVar [invalid_qualifier] +./classes_classvar.py:57:11: Unrecognized annotation typing.ClassVar[] [invalid_annotation] +./classes_classvar.py:71:25: Unexpected ClassVar annotation [invalid_qualifier] +./classes_classvar.py:72:11: ClassVar can only be used for assignments in class body [invalid_qualifier] +./classes_classvar.py:73:17: ClassVar can only be used for assignments in class body [invalid_qualifier] +./classes_classvar.py:75:25: Unexpected ClassVar annotation [invalid_qualifier] +./classes_classvar.py:79:7: ClassVar can only be used for assignments in class body [invalid_qualifier] +./classes_classvar.py:80:19: ClassVar cannot be used in type aliases [invalid_qualifier] +./classes_classvar.py:89:7: Unexpected ClassVar annotation [invalid_qualifier] +./classes_classvar.py:94:7: ClassVar cannot be used for NamedTuple fields [invalid_qualifier] +./classes_classvar.py:127:0: Cannot assign to class variable 'stats' via instance [incompatible_assignment] +./classes_classvar.py:156:0: Incompatible assignment: expected ./classes_classvar.py.ProtoA, got ./classes_classvar.py.ProtoAImpl [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/classes_override.toml b/conformance/results/pycroscope/classes_override.toml new file mode 100644 index 000000000..b140ec840 --- /dev/null +++ b/conformance/results/pycroscope/classes_override.toml @@ -0,0 +1,12 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./classes_override.py:53:4: Method does not override any base method [override_does_not_override] +./classes_override.py:65:4: Method does not override any base method [override_does_not_override] +./classes_override.py:79:4: Method does not override any base method [override_does_not_override] +./classes_override.py:84:4: Method does not override any base method [override_does_not_override] +./classes_override.py:89:4: Method does not override any base method [override_does_not_override] +./classes_override.py:135:4: Value of __init__ incompatible with base class classes_override.ParentC [incompatible_override] +./classes_override.py:138:4: Value of __new__ incompatible with base class classes_override.ParentC [incompatible_override] +""" diff --git a/conformance/results/pycroscope/constructors_call_init.toml b/conformance/results/pycroscope/constructors_call_init.toml new file mode 100644 index 000000000..da605980b --- /dev/null +++ b/conformance/results/pycroscope/constructors_call_init.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./constructors_call_init.py:21:12: Incompatible argument type for x: expected int but got Literal[1.0] [incompatible_argument] +./constructors_call_init.py:42:7: Incompatible argument type for x: expected ./constructors_call_init.py.Class3 | None but got ./constructors_call_init.py.Class2 [incompatible_argument] +./constructors_call_init.py:56:0: Missing required positional argument '%self' [incompatible_call] +./constructors_call_init.py:107:17: Class-scoped type variables are not allowed in __init__ self annotation [invalid_self_usage] +./constructors_call_init.py:130:0: Takes 0 positional arguments but 1 were given [incompatible_call] +""" diff --git a/conformance/results/pycroscope/constructors_call_metaclass.toml b/conformance/results/pycroscope/constructors_call_metaclass.toml new file mode 100644 index 000000000..2ec970e16 --- /dev/null +++ b/conformance/results/pycroscope/constructors_call_metaclass.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./constructors_call_metaclass.py:54:0: Missing required argument 'x' [incompatible_call] +./constructors_call_metaclass.py:68:0: Missing required argument 'x' [incompatible_call] +""" diff --git a/conformance/results/pycroscope/constructors_call_new.toml b/conformance/results/pycroscope/constructors_call_new.toml new file mode 100644 index 000000000..b747f222c --- /dev/null +++ b/conformance/results/pycroscope/constructors_call_new.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./constructors_call_new.py:21:12: Incompatible argument type for x: expected int but got Literal[1.0] [incompatible_argument] +./constructors_call_new.py:148:0: Missing required positional argument '%self' [incompatible_call] +""" diff --git a/conformance/results/pycroscope/constructors_call_type.toml b/conformance/results/pycroscope/constructors_call_type.toml new file mode 100644 index 000000000..1391f7471 --- /dev/null +++ b/conformance/results/pycroscope/constructors_call_type.toml @@ -0,0 +1,13 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./constructors_call_type.py:30:4: In call to constructors_call_type.Meta1.__call__: Missing required argument 'x' [incompatible_call] +./constructors_call_type.py:40:4: In call to constructors_call_type.Class2: Missing required argument 'x' [incompatible_call] +./constructors_call_type.py:50:4: In call to constructors_call_type.Class3: Missing required argument 'x' [incompatible_call] +./constructors_call_type.py:59:4: In call to constructors_call_type.Class4: Takes 0 positional arguments but 1 were given [incompatible_call] +./constructors_call_type.py:64:4: Takes 0 positional arguments but 1 were given [incompatible_call] +./constructors_call_type.py:72:4: In call to constructors_call_type.Meta1.__call__: Missing required argument 'x' [incompatible_call] +./constructors_call_type.py:81:4: In call to constructors_call_type.Class2: Missing required argument 'y' [incompatible_call] +./constructors_call_type.py:82:11: Incompatible argument type for y: expected str but got Literal[2] [incompatible_argument] +""" diff --git a/conformance/results/pycroscope/constructors_callable.toml b/conformance/results/pycroscope/constructors_callable.toml new file mode 100644 index 000000000..c9dbd4a39 --- /dev/null +++ b/conformance/results/pycroscope/constructors_callable.toml @@ -0,0 +1,29 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./constructors_callable.py:36:12: Revealed type is '(x: int) -> ./constructors_callable.py.Class1' [reveal_type] +./constructors_callable.py:38:0: Missing required argument 'x' [incompatible_call] +./constructors_callable.py:39:0: Missing required argument 'x' [incompatible_call] +./constructors_callable.py:49:12: Revealed type is '() -> ./constructors_callable.py.Class2' [reveal_type] +./constructors_callable.py:51:0: Takes 0 positional arguments but 1 were given [incompatible_call] +./constructors_callable.py:64:12: Revealed type is '(x: int) -> ./constructors_callable.py.Class3' [reveal_type] +./constructors_callable.py:66:0: Missing required argument 'x' [incompatible_call] +./constructors_callable.py:67:0: Missing required argument 'x' [incompatible_call] +./constructors_callable.py:68:0: Takes 1 positional arguments but 2 were given [incompatible_call] +./constructors_callable.py:79:12: Revealed type is '(x: int) -> int' [reveal_type] +./constructors_callable.py:81:0: Missing required argument 'x' [incompatible_call] +./constructors_callable.py:82:0: Missing required argument 'x' [incompatible_call] +./constructors_callable.py:99:12: Revealed type is '(*args: tuple[Any[ellipsis_callable], ...], **kwargs: dict[str, Any[ellipsis_callable]]) -> Never' [reveal_type] +./constructors_callable.py:127:12: Revealed type is '() -> ./constructors_callable.py.Class6Proxy' [reveal_type] +./constructors_callable.py:129:0: Takes 0 positional arguments but 1 were given [incompatible_call] +./constructors_callable.py:144:12: Revealed type is '() -> Any[explicit]' [reveal_type] +./constructors_callable.py:146:0: Takes 0 positional arguments but 1 were given [incompatible_call] +./constructors_callable.py:164:4: Revealed type is '(x: ~_Ctor_Class7_T) -> ./constructors_callable.py.Class7[~_Ctor_Class7_T]' [reveal_type] +./constructors_callable.py:184:12: Revealed type is '(x: list[~T@./constructors_callable.py.Class8], y: list[~T@./constructors_callable.py.Class8]) -> ./constructors_callable.py.Class8[~T@./constructors_callable.py.Class8]' [reveal_type] +./constructors_callable.py:185:9: Incompatible argument type for y: expected list[~T@./constructors_callable.py.Class8] but got Literal['not a list'] [incompatible_argument] +./constructors_callable.py:187:0: Cannot resolve type variables [incompatible_call] +./constructors_callable.py:196:12: Revealed type is '(x: list[~T@./constructors_callable.py.Class9.__init__..__init__], y: list[~T@./constructors_callable.py.Class9.__init__..__init__]) -> ./constructors_callable.py.Class9' [reveal_type] +./constructors_callable.py:197:9: Incompatible argument type for y: expected list[~T@./constructors_callable.py.Class9.__init__..__init__] but got Literal['not a list'] [incompatible_argument] +./constructors_callable.py:199:0: Cannot resolve type variables [incompatible_call] +""" diff --git a/conformance/results/pycroscope/constructors_consistency.toml b/conformance/results/pycroscope/constructors_consistency.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/pycroscope/constructors_consistency.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pycroscope/dataclasses_descriptors.toml b/conformance/results/pycroscope/dataclasses_descriptors.toml new file mode 100644 index 000000000..5b89c7ef9 --- /dev/null +++ b/conformance/results/pycroscope/dataclasses_descriptors.toml @@ -0,0 +1,23 @@ +conformant = "Partial" +notes = """ +Conformance suite is questionable; see +""" +conformance_automated = "Fail" +errors_diff = """ +Line 61: Unexpected errors ['./dataclasses_descriptors.py:61:12: Any[error] is not equivalent to list[int]', "./dataclasses_descriptors.py:61:12: has no attribute 'x' [undefined_attribute]"] +Line 62: Unexpected errors ['./dataclasses_descriptors.py:62:12: Any[error] is not equivalent to list[str]', "./dataclasses_descriptors.py:62:12: has no attribute 'y' [undefined_attribute]"] +Line 63: Unexpected errors ['./dataclasses_descriptors.py:63:12: list[Any[generic_argument]] is not equivalent to list[str]'] +Line 66: Unexpected errors ['./dataclasses_descriptors.py:66:12: ./dataclasses_descriptors.py.Desc2[int] is not equivalent to int'] +Line 67: Unexpected errors ['./dataclasses_descriptors.py:67:12: ./dataclasses_descriptors.py.Desc2[str] is not equivalent to str'] +Line 68: Unexpected errors ['./dataclasses_descriptors.py:68:12: Any[generic_argument] is not equivalent to str'] +""" +output = """ +./dataclasses_descriptors.py:61:12: Any[error] is not equivalent to list[int] +./dataclasses_descriptors.py:61:12: has no attribute 'x' [undefined_attribute] +./dataclasses_descriptors.py:62:12: Any[error] is not equivalent to list[str] +./dataclasses_descriptors.py:62:12: has no attribute 'y' [undefined_attribute] +./dataclasses_descriptors.py:63:12: list[Any[generic_argument]] is not equivalent to list[str] +./dataclasses_descriptors.py:66:12: ./dataclasses_descriptors.py.Desc2[int] is not equivalent to int +./dataclasses_descriptors.py:67:12: ./dataclasses_descriptors.py.Desc2[str] is not equivalent to str +./dataclasses_descriptors.py:68:12: Any[generic_argument] is not equivalent to str +""" diff --git a/conformance/results/pycroscope/dataclasses_final.toml b/conformance/results/pycroscope/dataclasses_final.toml new file mode 100644 index 000000000..07f248420 --- /dev/null +++ b/conformance/results/pycroscope/dataclasses_final.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./dataclasses_final.py:27:0: Cannot assign to final name final_classvar [incompatible_assignment] +./dataclasses_final.py:35:0: Cannot assign to final name final_no_default [incompatible_assignment] +./dataclasses_final.py:36:0: Cannot assign to final name final_with_default [incompatible_assignment] +./dataclasses_final.py:37:0: Cannot assign to instance attribute 'final_no_default' via class object [incompatible_assignment] +./dataclasses_final.py:38:0: Cannot assign to final name final_with_default [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/dataclasses_frozen.toml b/conformance/results/pycroscope/dataclasses_frozen.toml new file mode 100644 index 000000000..c64b3d316 --- /dev/null +++ b/conformance/results/pycroscope/dataclasses_frozen.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./dataclasses_frozen.py:16:0: Cannot assign to attribute a of frozen dataclass ./dataclasses_frozen.py.DC1 [incompatible_assignment] +./dataclasses_frozen.py:17:0: Cannot assign to attribute b of frozen dataclass ./dataclasses_frozen.py.DC1 [incompatible_assignment] +./dataclasses_frozen.py:23:0: Non-frozen dataclass cannot inherit from a frozen dataclass [invalid_base] +./dataclasses_frozen.py:33:0: Frozen dataclass cannot inherit from a non-frozen dataclass [invalid_base] +""" diff --git a/conformance/results/pycroscope/dataclasses_hash.toml b/conformance/results/pycroscope/dataclasses_hash.toml new file mode 100644 index 000000000..ebe2bbf79 --- /dev/null +++ b/conformance/results/pycroscope/dataclasses_hash.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./dataclasses_hash.py:17:0: None is not callable [not_callable] +./dataclasses_hash.py:18:0: Incompatible assignment: expected pycroscope.relations.HashableProto, got ./dataclasses_hash.py.DC1 [incompatible_assignment] +./dataclasses_hash.py:39:0: None is not callable [not_callable] +./dataclasses_hash.py:40:0: Incompatible assignment: expected pycroscope.relations.HashableProto, got ./dataclasses_hash.py.DC3 [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/dataclasses_inheritance.toml b/conformance/results/pycroscope/dataclasses_inheritance.toml new file mode 100644 index 000000000..5c74e15a1 --- /dev/null +++ b/conformance/results/pycroscope/dataclasses_inheritance.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./dataclasses_inheritance.py:62:4: Value of x incompatible with base class ./dataclasses_inheritance.py.DC6 [incompatible_override] +./dataclasses_inheritance.py:66:4: Value of y incompatible with base class ./dataclasses_inheritance.py.DC6 [incompatible_override] +""" diff --git a/conformance/results/pycroscope/dataclasses_kwonly.toml b/conformance/results/pycroscope/dataclasses_kwonly.toml new file mode 100644 index 000000000..55ead395f --- /dev/null +++ b/conformance/results/pycroscope/dataclasses_kwonly.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./dataclasses_kwonly.py:23:0: Takes 1 positional arguments but 2 were given [incompatible_call] +./dataclasses_kwonly.py:38:0: Takes 1 positional arguments but 2 were given [incompatible_call] +./dataclasses_kwonly.py:53:0: Takes 1 positional arguments but 2 were given [incompatible_call] +""" diff --git a/conformance/results/pycroscope/dataclasses_match_args.toml b/conformance/results/pycroscope/dataclasses_match_args.toml new file mode 100644 index 000000000..6b3009b7e --- /dev/null +++ b/conformance/results/pycroscope/dataclasses_match_args.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./dataclasses_match_args.py:42:0: has no attribute '__match_args__' [undefined_attribute] +""" diff --git a/conformance/results/pycroscope/dataclasses_order.toml b/conformance/results/pycroscope/dataclasses_order.toml new file mode 100644 index 000000000..69aaa4a36 --- /dev/null +++ b/conformance/results/pycroscope/dataclasses_order.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./dataclasses_order.py:50:3: Unsupported operands for less than: ./dataclasses_order.py.DC1 and ./dataclasses_order.py.DC2 [unsupported_operation] +""" diff --git a/conformance/results/pycroscope/dataclasses_postinit.toml b/conformance/results/pycroscope/dataclasses_postinit.toml new file mode 100644 index 000000000..225afffc6 --- /dev/null +++ b/conformance/results/pycroscope/dataclasses_postinit.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./dataclasses_postinit.py:19:4: Dataclass __post_init__ is incompatible with InitVar fields [incompatible_override] +./dataclasses_postinit.py:28:6: ./dataclasses_postinit.py.DC1 has no attribute 'x' [undefined_attribute] +./dataclasses_postinit.py:29:6: ./dataclasses_postinit.py.DC1 has no attribute 'y' [undefined_attribute] +./dataclasses_postinit.py:36:4: Dataclass __post_init__ is incompatible with InitVar fields [incompatible_override] +""" diff --git a/conformance/results/pycroscope/dataclasses_slots.toml b/conformance/results/pycroscope/dataclasses_slots.toml new file mode 100644 index 000000000..d89f94045 --- /dev/null +++ b/conformance/results/pycroscope/dataclasses_slots.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./dataclasses_slots.py:11:0: Class cannot define __slots__ when dataclass slots=True [invalid_dataclass] +./dataclasses_slots.py:25:8: Cannot assign to attribute 'y'; it is not in __slots__ for ./dataclasses_slots.py.DC2 [incompatible_assignment] +./dataclasses_slots.py:38:8: Cannot assign to attribute 'y'; it is not in __slots__ for ./dataclasses_slots.py.DC3 [incompatible_assignment] +./dataclasses_slots.py:66:0: has no attribute '__slots__' [undefined_attribute] +./dataclasses_slots.py:69:0: ./dataclasses_slots.py.DC6 has no attribute '__slots__' [undefined_attribute] +""" diff --git a/conformance/results/pycroscope/dataclasses_transform_class.toml b/conformance/results/pycroscope/dataclasses_transform_class.toml new file mode 100644 index 000000000..1eab06434 --- /dev/null +++ b/conformance/results/pycroscope/dataclasses_transform_class.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./dataclasses_transform_class.py:51:0: Non-frozen dataclass cannot inherit from a frozen dataclass [invalid_base] +./dataclasses_transform_class.py:63:0: Cannot assign to attribute id of frozen dataclass ./dataclasses_transform_class.py.Customer1 [incompatible_assignment] +./dataclasses_transform_class.py:66:7: Missing required argument 'id' [incompatible_call] +./dataclasses_transform_class.py:72:5: Unsupported operands for less than: ./dataclasses_transform_class.py.Customer1 and ./dataclasses_transform_class.py.Customer1 [unsupported_operation] +./dataclasses_transform_class.py:82:7: Missing required argument 'id' [incompatible_call] +./dataclasses_transform_class.py:122:0: Cannot assign to attribute id of frozen dataclass ./dataclasses_transform_class.py.Customer3 [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/dataclasses_transform_converter.toml b/conformance/results/pycroscope/dataclasses_transform_converter.toml new file mode 100644 index 000000000..7db3d21eb --- /dev/null +++ b/conformance/results/pycroscope/dataclasses_transform_converter.toml @@ -0,0 +1,14 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./dataclasses_transform_converter.py:48:40: Incompatible argument type for converter: expected (~S, /) -> ~T but got () -> int [incompatible_argument] +./dataclasses_transform_converter.py:49:40: Incompatible argument type for converter: expected (~S, /) -> ~T but got (*, x: int) -> int [incompatible_argument] +./dataclasses_transform_converter.py:107:4: Incompatible argument type for field0: expected str but got Literal[1] [incompatible_argument] +./dataclasses_transform_converter.py:108:22: Incompatible argument type for field3: expected str | bytes but got Literal[1] [incompatible_argument] +./dataclasses_transform_converter.py:109:28: Incompatible argument type for field4: expected str | list[str] but got Literal[3j] [incompatible_argument] +./dataclasses_transform_converter.py:118:0: Incompatible types in assignment to attribute 'field0': expected str, got Literal[1] [incompatible_assignment] +./dataclasses_transform_converter.py:119:0: Incompatible types in assignment to attribute 'field3': expected str | bytes, got Literal[1] [incompatible_assignment] +./dataclasses_transform_converter.py:130:18: Cannot resolve type variables [incompatible_call] +./dataclasses_transform_converter.py:133:18: Cannot resolve type variables [incompatible_call] +""" diff --git a/conformance/results/pycroscope/dataclasses_transform_field.toml b/conformance/results/pycroscope/dataclasses_transform_field.toml new file mode 100644 index 000000000..527ade972 --- /dev/null +++ b/conformance/results/pycroscope/dataclasses_transform_field.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./dataclasses_transform_field.py:64:0: Got an unexpected keyword argument 'id' [incompatible_call] +./dataclasses_transform_field.py:75:0: Missing required argument 'name' [incompatible_call] +""" diff --git a/conformance/results/pycroscope/dataclasses_transform_func.toml b/conformance/results/pycroscope/dataclasses_transform_func.toml new file mode 100644 index 000000000..42b222af7 --- /dev/null +++ b/conformance/results/pycroscope/dataclasses_transform_func.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./dataclasses_transform_func.py:56:0: Incompatible types in assignment to attribute 'name': expected str, got Literal[3] [incompatible_assignment] +./dataclasses_transform_func.py:60:5: Unsupported operands for less than: ./dataclasses_transform_func.py.Customer1 and ./dataclasses_transform_func.py.Customer1 [unsupported_operation] +./dataclasses_transform_func.py:64:7: Got an unexpected keyword argument 'salary' [incompatible_call] +./dataclasses_transform_func.py:70:7: Missing required argument 'id' [incompatible_call] +./dataclasses_transform_func.py:89:0: Non-frozen dataclass cannot inherit from a frozen dataclass [invalid_base] +./dataclasses_transform_func.py:96:0: Cannot assign to attribute id of frozen dataclass ./dataclasses_transform_func.py.Customer3 [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/dataclasses_transform_meta.toml b/conformance/results/pycroscope/dataclasses_transform_meta.toml new file mode 100644 index 000000000..4aff98937 --- /dev/null +++ b/conformance/results/pycroscope/dataclasses_transform_meta.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./dataclasses_transform_meta.py:51:0: Non-frozen dataclass cannot inherit from a frozen dataclass [invalid_base] +./dataclasses_transform_meta.py:63:0: Cannot assign to attribute id of frozen dataclass ./dataclasses_transform_meta.py.Customer1 [incompatible_assignment] +./dataclasses_transform_meta.py:66:7: Missing required argument 'id' [incompatible_call] +./dataclasses_transform_meta.py:73:5: Unsupported operands for less than: ./dataclasses_transform_meta.py.Customer1 and ./dataclasses_transform_meta.py.Customer1 [unsupported_operation] +./dataclasses_transform_meta.py:83:7: Missing required argument 'id' [incompatible_call] +./dataclasses_transform_meta.py:103:0: Cannot assign to attribute id of frozen dataclass ./dataclasses_transform_meta.py.Customer3 [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/dataclasses_usage.toml b/conformance/results/pycroscope/dataclasses_usage.toml new file mode 100644 index 000000000..1bd968622 --- /dev/null +++ b/conformance/results/pycroscope/dataclasses_usage.toml @@ -0,0 +1,17 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./dataclasses_usage.py:51:5: Missing required argument 'unit_price' [incompatible_call] +./dataclasses_usage.py:52:27: Incompatible argument type for unit_price: expected float | int but got Literal['price'] [incompatible_argument] +./dataclasses_usage.py:53:5: Takes 3 positional arguments but 4 were given [incompatible_call] +./dataclasses_usage.py:59:1: Dataclass fields without defaults cannot follow fields with defaults [invalid_dataclass] +./dataclasses_usage.py:65:1: Dataclass fields without defaults cannot follow fields with defaults [invalid_dataclass] +./dataclasses_usage.py:71:1: Dataclass fields without defaults cannot follow fields with defaults [invalid_dataclass] +./dataclasses_usage.py:84:5: Takes 1 positional arguments but 2 were given [incompatible_call] +./dataclasses_usage.py:89:4: Dataclass default_factory return type is incompatible with field type int [incompatible_assignment] +./dataclasses_usage.py:128:0: Takes 1 positional arguments but 2 were given [incompatible_call] +./dataclasses_usage.py:131:0: Missing required argument 'y' [incompatible_call] +./dataclasses_usage.py:180:0: Takes 0 positional arguments but 1 were given [incompatible_call] +./dataclasses_usage.py:246:0: Takes 2 positional arguments but 3 were given [incompatible_call] +""" diff --git a/conformance/results/pycroscope/directives_assert_type.toml b/conformance/results/pycroscope/directives_assert_type.toml new file mode 100644 index 000000000..a1506a6ff --- /dev/null +++ b/conformance/results/pycroscope/directives_assert_type.toml @@ -0,0 +1,12 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./directives_assert_type.py:27:16: int | str is not equivalent to int +./directives_assert_type.py:28:16: int | str is not equivalent to Any[explicit] +./directives_assert_type.py:29:16: Any[explicit] is not equivalent to int +./directives_assert_type.py:30:16: Literal[4] is not equivalent to int +./directives_assert_type.py:32:4: In call to typing.assert_type: Missing required positional argument 'val' [incompatible_call] +./directives_assert_type.py:33:16: Literal[''] is not equivalent to int +./directives_assert_type.py:34:4: In call to typing.assert_type: Takes 2 positional arguments but 3 were given [incompatible_call] +""" diff --git a/conformance/results/pycroscope/directives_cast.toml b/conformance/results/pycroscope/directives_cast.toml new file mode 100644 index 000000000..9429a6b9c --- /dev/null +++ b/conformance/results/pycroscope/directives_cast.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./directives_cast.py:15:7: In call to typing.cast: Missing required positional argument 'typ' [incompatible_call] +./directives_cast.py:16:7: Invalid type annotation 1 [invalid_annotation] +./directives_cast.py:17:7: In call to typing.cast: Takes 2 positional arguments but 3 were given [incompatible_call] +""" diff --git a/conformance/results/pycroscope/directives_deprecated.toml b/conformance/results/pycroscope/directives_deprecated.toml new file mode 100644 index 000000000..0aa05c021 --- /dev/null +++ b/conformance/results/pycroscope/directives_deprecated.toml @@ -0,0 +1,17 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./directives_deprecated.py:18:43: type '_directives_deprecated_library.Ham' is deprecated: Use Spam instead [deprecated] +./directives_deprecated.py:24:0: function '_directives_deprecated_library.norwegian_blue' is deprecated: It is pining for the fjords [deprecated] +./directives_deprecated.py:25:4: function '_directives_deprecated_library.norwegian_blue' is deprecated: It is pining for the fjords [deprecated] +./directives_deprecated.py:30:0: Use of deprecated overload (x: int) -> str: Only str will be allowed [deprecated] +./directives_deprecated.py:41:4: function '_directives_deprecated_library.Spam.__add__' with typevars TypeVarMap(typevars={~SelfT@_directives_deprecated_library.Spam=_directives_deprecated_library.Spam}) is deprecated: There is enough spam in the world [deprecated] +./directives_deprecated.py:42:0: function '_directives_deprecated_library.Spam.__add__' with typevars TypeVarMap(typevars={~SelfT@_directives_deprecated_library.Spam=_directives_deprecated_library.Spam}) is deprecated: There is enough spam in the world [deprecated] +./directives_deprecated.py:44:0: Property getter 'greasy' is deprecated: All spam will be equally greasy [deprecated] +./directives_deprecated.py:47:0: Property setter 'shape' is deprecated: Shapes are becoming immutable [deprecated] +./directives_deprecated.py:48:0: Property setter 'shape' is deprecated: Shapes are becoming immutable [deprecated] +./directives_deprecated.py:58:0: Method __call__ is deprecated: Deprecated [deprecated] +./directives_deprecated.py:69:0: () -> None is deprecated: Deprecated [deprecated] +./directives_deprecated.py:98:4: () -> None is deprecated: Deprecated [deprecated] +""" diff --git a/conformance/results/pycroscope/directives_disjoint_base.toml b/conformance/results/pycroscope/directives_disjoint_base.toml new file mode 100644 index 000000000..f58404656 --- /dev/null +++ b/conformance/results/pycroscope/directives_disjoint_base.toml @@ -0,0 +1,13 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./directives_disjoint_base.py:69:0: Class has incompatible disjoint bases [invalid_base] +./directives_disjoint_base.py:73:0: Class has incompatible disjoint bases [invalid_base] +./directives_disjoint_base.py:77:0: Class has incompatible disjoint bases [invalid_base] +./directives_disjoint_base.py:81:0: Class has incompatible disjoint bases [invalid_base] +./directives_disjoint_base.py:105:0: Class has incompatible disjoint bases [invalid_base] +./directives_disjoint_base.py:113:1: disjoint_base cannot be applied to a function [invalid_disjoint_base] +./directives_disjoint_base.py:118:1: disjoint_base cannot be applied to a TypedDict [invalid_disjoint_base] +./directives_disjoint_base.py:123:1: disjoint_base cannot be applied to a Protocol [invalid_disjoint_base] +""" diff --git a/conformance/results/pycroscope/directives_no_type_check.toml b/conformance/results/pycroscope/directives_no_type_check.toml new file mode 100644 index 000000000..869c59892 --- /dev/null +++ b/conformance/results/pycroscope/directives_no_type_check.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./directives_no_type_check.py:15:4: Incompatible assignment: expected int, got Literal[''] [incompatible_assignment] +./directives_no_type_check.py:25:8: Unsupported operands for addition: int and str [unsupported_operation] +./directives_no_type_check.py:26:4: Incompatible return type: expected None, got Literal[1] [incompatible_return_value] +./directives_no_type_check.py:29:6: Incompatible argument type for a: expected int but got Literal[b'invalid'] [incompatible_argument] +./directives_no_type_check.py:29:18: Incompatible argument type for b: expected str but got Literal[b'arguments'] [incompatible_argument] +./directives_no_type_check.py:32:0: Missing required argument 'a' [incompatible_call] +""" diff --git a/conformance/results/pycroscope/directives_reveal_type.toml b/conformance/results/pycroscope/directives_reveal_type.toml new file mode 100644 index 000000000..4af147aab --- /dev/null +++ b/conformance/results/pycroscope/directives_reveal_type.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./directives_reveal_type.py:14:16: Revealed type is 'int | str' [reveal_type] +./directives_reveal_type.py:15:16: Revealed type is 'list[int]' [reveal_type] +./directives_reveal_type.py:16:16: Revealed type is 'Any[explicit]' [reveal_type] +./directives_reveal_type.py:17:16: Revealed type is 'directives_reveal_type.ForwardReference' [reveal_type] +./directives_reveal_type.py:19:4: In call to typing.reveal_type: Missing required positional argument 'value' [incompatible_call] +./directives_reveal_type.py:20:4: In call to typing.reveal_type: Takes 1 positional arguments but 2 were given [incompatible_call] +""" diff --git a/conformance/results/pycroscope/directives_type_checking.toml b/conformance/results/pycroscope/directives_type_checking.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/pycroscope/directives_type_checking.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pycroscope/directives_type_ignore.toml b/conformance/results/pycroscope/directives_type_ignore.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/pycroscope/directives_type_ignore.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pycroscope/directives_type_ignore_file1.toml b/conformance/results/pycroscope/directives_type_ignore_file1.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/pycroscope/directives_type_ignore_file1.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pycroscope/directives_type_ignore_file2.toml b/conformance/results/pycroscope/directives_type_ignore_file2.toml new file mode 100644 index 000000000..b1f55aca0 --- /dev/null +++ b/conformance/results/pycroscope/directives_type_ignore_file2.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./directives_type_ignore_file2.py:14:0: Incompatible assignment: expected int, got Literal[''] [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/directives_version_platform.toml b/conformance/results/pycroscope/directives_version_platform.toml new file mode 100644 index 000000000..a6ce7215d --- /dev/null +++ b/conformance/results/pycroscope/directives_version_platform.toml @@ -0,0 +1,12 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./directives_version_platform.py:33:18: Undefined name: val3 [undefined_name] +./directives_version_platform.py:50:18: Undefined name: val6 [undefined_name] +./directives_version_platform.py:59:18: Undefined name: val9 [undefined_name] +./directives_version_platform.py:66:18: val10 may be used uninitialized [possibly_undefined_name] +./directives_version_platform.py:67:21: val11 may be used uninitialized [possibly_undefined_name] +./directives_version_platform.py:74:21: val12 may be used uninitialized [possibly_undefined_name] +./directives_version_platform.py:75:18: val13 may be used uninitialized [possibly_undefined_name] +""" diff --git a/conformance/results/pycroscope/enums_behaviors.toml b/conformance/results/pycroscope/enums_behaviors.toml new file mode 100644 index 000000000..abe030442 --- /dev/null +++ b/conformance/results/pycroscope/enums_behaviors.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./enums_behaviors.py:28:12: ./enums_behaviors.py.Color is not equivalent to Literal[] +./enums_behaviors.py:32:12: ./enums_behaviors.py.Color is not equivalent to Literal[] +./enums_behaviors.py:44:20: Cannot inherit from final class [invalid_base] +""" diff --git a/conformance/results/pycroscope/enums_definition.toml b/conformance/results/pycroscope/enums_definition.toml new file mode 100644 index 000000000..622573cae --- /dev/null +++ b/conformance/results/pycroscope/enums_definition.toml @@ -0,0 +1,22 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./enums_definition.py:34:12: enum.Enum has no attribute 'RED' [undefined_attribute] +./enums_definition.py:34:32: enum.Enum has no attribute 'RED' [undefined_attribute] +./enums_definition.py:35:12: type[enum.Enum] has no attribute 'RED' [undefined_attribute] +./enums_definition.py:35:32: type[enum.Enum] has no attribute 'RED' [undefined_attribute] +./enums_definition.py:36:12: type[enum.Enum] has no attribute 'RED' [undefined_attribute] +./enums_definition.py:36:32: type[enum.Enum] has no attribute 'RED' [undefined_attribute] +./enums_definition.py:37:12: type[enum.Enum] has no attribute 'RED' [undefined_attribute] +./enums_definition.py:37:32: type[enum.Enum] has no attribute 'RED' [undefined_attribute] +./enums_definition.py:38:12: type[enum.Enum] has no attribute 'RED' [undefined_attribute] +./enums_definition.py:38:32: type[enum.Enum] has no attribute 'RED' [undefined_attribute] +./enums_definition.py:39:12: type[enum.Enum] has no attribute 'RED' [undefined_attribute] +./enums_definition.py:39:32: type[enum.Enum] has no attribute 'RED' [undefined_attribute] +./enums_definition.py:40:12: type[enum.Enum] has no attribute 'RED' [undefined_attribute] +./enums_definition.py:40:32: type[enum.Enum] has no attribute 'RED' [undefined_attribute] +./enums_definition.py:41:12: type[enum.Enum] has no attribute 'RED' [undefined_attribute] +./enums_definition.py:41:32: type[enum.Enum] has no attribute 'RED' [undefined_attribute] +./enums_definition.py:92:0: has no attribute 'BLUE' [undefined_attribute] +""" diff --git a/conformance/results/pycroscope/enums_expansion.toml b/conformance/results/pycroscope/enums_expansion.toml new file mode 100644 index 000000000..529ddb5b1 --- /dev/null +++ b/conformance/results/pycroscope/enums_expansion.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./enums_expansion.py:56:20: enums_expansion.CustomFlags is not equivalent to Literal[] +""" diff --git a/conformance/results/pycroscope/enums_member_names.toml b/conformance/results/pycroscope/enums_member_names.toml new file mode 100644 index 000000000..3a96dcafc --- /dev/null +++ b/conformance/results/pycroscope/enums_member_names.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./enums_member_names.py:21:12: str is not equivalent to Literal['RED'] +./enums_member_names.py:30:16: Annotated[str, EnumName(enum_cls=)] is not equivalent to Literal['RED', 'BLUE', 'GREEN'] +""" diff --git a/conformance/results/pycroscope/enums_member_values.toml b/conformance/results/pycroscope/enums_member_values.toml new file mode 100644 index 000000000..ca9b47ee4 --- /dev/null +++ b/conformance/results/pycroscope/enums_member_values.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./enums_member_values.py:21:12: Any[explicit] is not equivalent to Literal[1] +./enums_member_values.py:54:12: Literal[(1, 3.303e+23, 2439700.0)] is not equivalent to Literal[1] +./enums_member_values.py:68:12: Literal[] is not equivalent to Literal[1] +./enums_member_values.py:78:4: Enum member value must be assignable to int [invalid_annotation] +./enums_member_values.py:85:8: Enum member value must be assignable to str [invalid_annotation] +./enums_member_values.py:96:12: Literal[Ellipsis] is not equivalent to int +""" diff --git a/conformance/results/pycroscope/enums_members.toml b/conformance/results/pycroscope/enums_members.toml new file mode 100644 index 000000000..a7edb501a --- /dev/null +++ b/conformance/results/pycroscope/enums_members.toml @@ -0,0 +1,15 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./enums_members.py:54:4: Enum members should not be explicitly annotated [invalid_annotation] +./enums_members.py:86:11: Arguments to Literal[] must be literals, not (AnyValue(source=),) [invalid_literal] +./enums_members.py:87:11: Arguments to Literal[] must be literals, not (CallableValue(typ=, literal_only=False, signature=Signature(parameters={'x': SigParameter(name='x', kind=, default=None, annotation=TypedValue(typ=, literal_only=False))}, return_value=TypedValue(typ=, literal_only=False), impl=None, callable=None, is_asynq=False, has_return_annotation=True, allow_call=False, allow_partial_call=False, evaluator=None, deprecated=None)),) [invalid_literal] +./enums_members.py:88:9: Arguments to Literal[] must be literals, not (TypedValue(typ=, literal_only=False),) [invalid_literal] +./enums_members.py:89:7: Arguments to Literal[] must be literals, not (CallableValue(typ=, literal_only=False, signature=Signature(parameters={'self': SigParameter(name='self', kind=, default=None, annotation=TypedValue(typ=ClassOwner(module='./enums_members.py', qualname='Pet4', identity='./enums_members.py.Pet4'), literal_only=False))}, return_value=KnownValue(val=None), impl=None, callable=None, is_asynq=False, has_return_annotation=True, allow_call=False, allow_partial_call=False, evaluator=None, deprecated=None)),) [invalid_literal] +./enums_members.py:120:12: int is not equivalent to Any[unannotated] +./enums_members.py:132:20: Revealed type is 'int' [reveal_type] +./enums_members.py:133:20: int is not equivalent to Any[unannotated] +./enums_members.py:150:12: ./enums_members.py.Pet5 is not equivalent to int +./enums_members.py:151:12: ./enums_members.py.Pet5 is not equivalent to int +""" diff --git a/conformance/results/pycroscope/exceptions_context_managers.toml b/conformance/results/pycroscope/exceptions_context_managers.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/pycroscope/exceptions_context_managers.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pycroscope/generics_base_class.toml b/conformance/results/pycroscope/generics_base_class.toml new file mode 100644 index 000000000..4f03dbec0 --- /dev/null +++ b/conformance/results/pycroscope/generics_base_class.toml @@ -0,0 +1,12 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_base_class.py:26:25: Incompatible argument type for x: expected dict[str, list[object]] but got ./generics_base_class.py.SymbolTable [incompatible_argument] +./generics_base_class.py:29:10: Generic[...] is valid only as a base class [invalid_annotation] +./generics_base_class.py:30:7: Generic[...] is valid only as a base class [invalid_annotation] +./generics_base_class.py:49:21: Expected 1 type arguments for ./generics_base_class.py.LinkedList [invalid_specialization] +./generics_base_class.py:61:17: Expected 1 type arguments for ./generics_base_class.py.MyDict [invalid_specialization] +./generics_base_class.py:68:24: Type parameter list cannot contain duplicate type variables [invalid_base] +./generics_base_class.py:98:31: Inconsistent type variable order in base classes [invalid_base] +""" diff --git a/conformance/results/pycroscope/generics_basic.toml b/conformance/results/pycroscope/generics_basic.toml new file mode 100644 index 000000000..2cabd73cf --- /dev/null +++ b/conformance/results/pycroscope/generics_basic.toml @@ -0,0 +1,24 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_basic.py:40:4: Cannot resolve type variables [incompatible_call] +./generics_basic.py:41:4: Cannot resolve type variables [incompatible_call] +./generics_basic.py:49:17: TypeVar must have at least two constraints [incompatible_call] +./generics_basic.py:55:52: TypeVar bounds and constraints cannot contain type parameters [invalid_annotation] +./generics_basic.py:69:4: Cannot resolve type variables [incompatible_call] +./generics_basic.py:121:20: Type parameter list cannot contain duplicate type variables [invalid_base] +./generics_basic.py:157:7: Incompatible argument type for key: expected str but got Literal[0] [incompatible_argument] +./generics_basic.py:158:7: Incompatible argument type for key: expected str but got Literal[0] [incompatible_argument] +./generics_basic.py:162:19: All arguments to Generic or Protocol must be type variables [invalid_base] +./generics_basic.py:163:20: All arguments to Generic or Protocol must be type variables [invalid_base] +./generics_basic.py:171:27: All type parameters for the class must appear within Generic or Protocol [invalid_base] +./generics_basic.py:172:27: All type parameters for the class must appear within Generic or Protocol [invalid_base] +./generics_basic.py:208:36: Cannot determine metaclass [invalid_metaclass] +./generics_basic.py:223:21: Incompatible argument type for y: expected list[~T@./generics_basic.py.takes_two_lists..takes_two_lists] but got Literal['not a list'] [incompatible_argument] +./generics_basic.py:225:0: Cannot resolve type variables [incompatible_call] +./generics_basic.py:232:4: Cannot resolve type variables [incompatible_call] +./generics_basic.py:240:25: Incompatible argument type for y: expected list[~T_int@./generics_basic.py.takes_two_int_lists..takes_two_int_lists] but got Literal['not a list'] [incompatible_argument] +./generics_basic.py:241:25: Incompatible argument type for y: expected list[~T_int@./generics_basic.py.takes_two_int_lists..takes_two_int_lists] but got Literal[['']] [incompatible_argument] +./generics_basic.py:251:4: Cannot resolve type variables [incompatible_call] +""" diff --git a/conformance/results/pycroscope/generics_defaults.toml b/conformance/results/pycroscope/generics_defaults.toml new file mode 100644 index 000000000..70c20747d --- /dev/null +++ b/conformance/results/pycroscope/generics_defaults.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_defaults.py:24:0: non-default TypeVars cannot follow ones with defaults [invalid_type_parameter_default] +./generics_defaults.py:66:7: Expected at least 2 type arguments for ./generics_defaults.py.AllTheDefaults [invalid_specialization] +./generics_defaults.py:152:50: TypeVar default must be assignable to its bound [invalid_type_parameter_default] +./generics_defaults.py:159:51: TypeVar default must be one of its constraints [invalid_type_parameter_default] +./generics_defaults.py:176:12: Any[generic_argument] is not equivalent to int +./generics_defaults.py:188:0: TypeVars with defaults cannot follow TypeVarTuples [invalid_type_parameter_default] +""" diff --git a/conformance/results/pycroscope/generics_defaults_referential.toml b/conformance/results/pycroscope/generics_defaults_referential.toml new file mode 100644 index 000000000..d6d2e1b4e --- /dev/null +++ b/conformance/results/pycroscope/generics_defaults_referential.toml @@ -0,0 +1,12 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_defaults_referential.py:36:16: Incompatible argument type for b: expected int but got str [incompatible_argument] +./generics_defaults_referential.py:37:13: Incompatible argument type for a: expected int but got str [incompatible_argument] +./generics_defaults_referential.py:53:0: Type parameter defaults can reference only earlier type parameters from the same class [invalid_type_parameter_default] +./generics_defaults_referential.py:60:4: Type parameter defaults can reference only earlier type parameters from the same class [invalid_type_parameter_default] +./generics_defaults_referential.py:68:39: TypeVar default must be assignable to its bound [invalid_type_parameter_default] +./generics_defaults_referential.py:74:51: TypeVar default must be one of its constraints [invalid_type_parameter_default] +./generics_defaults_referential.py:78:62: TypeVar default must be one of its constraints [invalid_type_parameter_default] +""" diff --git a/conformance/results/pycroscope/generics_defaults_specialization.toml b/conformance/results/pycroscope/generics_defaults_specialization.toml new file mode 100644 index 000000000..4aab1f309 --- /dev/null +++ b/conformance/results/pycroscope/generics_defaults_specialization.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_defaults_specialization.py:30:0: Expected 1 type arguments for type alias, got 2 [invalid_specialization] +./generics_defaults_specialization.py:48:0: Incompatible assignment: expected type[./generics_defaults_specialization.py.Bar[int]], got [incompatible_assignment] +./generics_defaults_specialization.py:58:0: ./generics_defaults_specialization.py.Foo cannot be further subscripted [invalid_specialization] +""" diff --git a/conformance/results/pycroscope/generics_mixed_variance_inference.toml b/conformance/results/pycroscope/generics_mixed_variance_inference.toml new file mode 100644 index 000000000..679f6f667 --- /dev/null +++ b/conformance/results/pycroscope/generics_mixed_variance_inference.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_mixed_variance_inference.py:13:0: Incompatible assignment: expected generics_mixed_variance_inference.Mixed[int, tuple[()], () -> Any[generic_argument]], got generics_mixed_variance_inference.Mixed[bool, () -> Any[generic_argument]] [incompatible_assignment] +./generics_mixed_variance_inference.py:16:0: Incompatible assignment: expected generics_mixed_variance_inference.Mixed[int, int, () -> Any[generic_argument]], got generics_mixed_variance_inference.Mixed[int, object, () -> Any[generic_argument]] [incompatible_assignment] +./generics_mixed_variance_inference.py:21:0: Incompatible assignment: expected generics_mixed_variance_inference.Mixed[int, tuple[()], (int, /) -> Any[generic_argument]], got generics_mixed_variance_inference.Mixed[int, (bool, /) -> Any[generic_argument]] [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/generics_paramspec_basic.toml b/conformance/results/pycroscope/generics_paramspec_basic.toml new file mode 100644 index 000000000..5a5c534f6 --- /dev/null +++ b/conformance/results/pycroscope/generics_paramspec_basic.toml @@ -0,0 +1,14 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_paramspec_basic.py:10:22: ParamSpec named 'NotIt' must be assigned to a variable with the same name [must_have_same_name] +./generics_paramspec_basic.py:15:17: ParamSpec cannot be used in this annotation context [invalid_paramspec_usage] +./generics_paramspec_basic.py:23:10: ParamSpec cannot be used in this annotation context [invalid_paramspec_usage] +./generics_paramspec_basic.py:23:19: ParamSpec cannot be used in this annotation context [invalid_paramspec_usage] +./generics_paramspec_basic.py:27:13: Unrecognized annotation typing.Concatenate[, ~P] [invalid_annotation] +./generics_paramspec_basic.py:31:10: ParamSpec cannot be used in this annotation context [invalid_paramspec_usage] +./generics_paramspec_basic.py:35:10: ParamSpec cannot be used in this annotation context [invalid_paramspec_usage] +./generics_paramspec_basic.py:39:11: ParamSpec cannot be used in this annotation context [invalid_paramspec_usage] +./generics_paramspec_basic.py:39:22: ParamSpec cannot be used in this annotation context [invalid_paramspec_usage] +""" diff --git a/conformance/results/pycroscope/generics_paramspec_components.toml b/conformance/results/pycroscope/generics_paramspec_components.toml new file mode 100644 index 000000000..80e8cbccf --- /dev/null +++ b/conformance/results/pycroscope/generics_paramspec_components.toml @@ -0,0 +1,23 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_paramspec_components.py:17:18: ParamSpec cannot be used in this annotation context [invalid_paramspec_usage] +./generics_paramspec_components.py:17:36: ParamSpec cannot be used in this annotation context [invalid_paramspec_usage] +./generics_paramspec_components.py:20:19: ParamSpec cannot be used in this annotation context [invalid_paramspec_usage] +./generics_paramspec_components.py:23:37: ParamSpec cannot be used in this annotation context [invalid_paramspec_usage] +./generics_paramspec_components.py:26:37: ParamSpec.args must be used together with ParamSpec.kwargs [invalid_paramspec_usage] +./generics_paramspec_components.py:30:18: ParamSpec cannot be used in this annotation context [invalid_paramspec_usage] +./generics_paramspec_components.py:30:34: ParamSpec cannot be used in this annotation context [invalid_paramspec_usage] +./generics_paramspec_components.py:35:17: ParamSpec cannot be used in this annotation context [invalid_paramspec_usage] +./generics_paramspec_components.py:36:19: ParamSpec cannot be used in this annotation context [invalid_paramspec_usage] +./generics_paramspec_components.py:38:19: ParamSpec.args must be used together with ParamSpec.kwargs [invalid_paramspec_usage] +./generics_paramspec_components.py:41:22: ParamSpec.kwargs must be used together with ParamSpec.args [invalid_paramspec_usage] +./generics_paramspec_components.py:49:8: tuple[object, ...] is not a mapping [incompatible_call] +./generics_paramspec_components.py:51:8: Takes 0 positional arguments but 1 were given [incompatible_call] +./generics_paramspec_components.py:60:37: ParamSpec.args and ParamSpec.kwargs must be adjacent [invalid_paramspec_usage] +./generics_paramspec_components.py:70:17: Arguments cannot follow ParamSpec.args [incompatible_call] +./generics_paramspec_components.py:72:8: Missing required positional argument at position 0 [incompatible_call] +./generics_paramspec_components.py:83:14: Arguments cannot follow ParamSpec.args [incompatible_call] +./generics_paramspec_components.py:98:0: In call to generics_paramspec_components.twice: Cannot resolve type variables [incompatible_call] +""" diff --git a/conformance/results/pycroscope/generics_paramspec_semantics.toml b/conformance/results/pycroscope/generics_paramspec_semantics.toml new file mode 100644 index 000000000..c332d805f --- /dev/null +++ b/conformance/results/pycroscope/generics_paramspec_semantics.toml @@ -0,0 +1,15 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_paramspec_semantics.py:26:0: Missing required positional argument 'a' [incompatible_call] +./generics_paramspec_semantics.py:27:8: Incompatible argument type for b: expected bool but got Literal['A'] [incompatible_argument] +./generics_paramspec_semantics.py:46:5: Cannot resolve type variables [incompatible_call] +./generics_paramspec_semantics.py:61:0: Cannot resolve type variables [incompatible_call] +./generics_paramspec_semantics.py:98:3: Incompatible argument type for @0: expected str but got Literal[1] [incompatible_argument] +./generics_paramspec_semantics.py:108:0: Incompatible argument type for args: expected tuple[bool, ...] but got tuple[Literal[1]] [incompatible_argument] +./generics_paramspec_semantics.py:120:3: Incompatible argument type for @0: expected str but got Literal[1] [incompatible_argument] +./generics_paramspec_semantics.py:127:1: Incompatible argument type for x: expected (int, /, ****P) -> int but got (x: str) -> int [incompatible_argument] +./generics_paramspec_semantics.py:132:1: Incompatible argument type for x: expected (int, /, ****P) -> int but got (*, x: int) -> int [incompatible_argument] +./generics_paramspec_semantics.py:137:1: Incompatible argument type for x: expected (int, /, ****P) -> int but got (**kwargs: dict[str, int]) -> int [incompatible_argument] +""" diff --git a/conformance/results/pycroscope/generics_paramspec_specialization.toml b/conformance/results/pycroscope/generics_paramspec_specialization.toml new file mode 100644 index 000000000..5dd4d8c8c --- /dev/null +++ b/conformance/results/pycroscope/generics_paramspec_specialization.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_paramspec_specialization.py:44:14: ParamSpec specialization must use list form, Concatenate[..., P], P, or ... [invalid_annotation] +./generics_paramspec_specialization.py:54:8: Incompatible argument type for @0: expected int but got Literal[''] [incompatible_argument] +./generics_paramspec_specialization.py:55:15: Incompatible argument type for @2: expected bool but got Literal[''] [incompatible_argument] +./generics_paramspec_specialization.py:60:8: Incompatible argument type for @0: expected int but got Literal[''] [incompatible_argument] +./generics_paramspec_specialization.py:61:15: Incompatible argument type for @2: expected bool but got Literal[''] [incompatible_argument] +""" diff --git a/conformance/results/pycroscope/generics_paramspec_variance.toml b/conformance/results/pycroscope/generics_paramspec_variance.toml new file mode 100644 index 000000000..edfa0a813 --- /dev/null +++ b/conformance/results/pycroscope/generics_paramspec_variance.toml @@ -0,0 +1,27 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_paramspec_variance.py:14:0: Incompatible assignment: expected ./generics_paramspec_variance.py.InvariantParamSpec[(object, /) -> Any[generic_argument]], got ./generics_paramspec_variance.py.InvariantParamSpec[(int, /) -> Any[generic_argument]] [incompatible_assignment] +./generics_paramspec_variance.py:15:0: Incompatible assignment: expected ./generics_paramspec_variance.py.InvariantParamSpec[(int, /) -> Any[generic_argument]], got ./generics_paramspec_variance.py.InvariantParamSpec[(object, /) -> Any[generic_argument]] [incompatible_assignment] +./generics_paramspec_variance.py:21:0: Incompatible assignment: expected ./generics_paramspec_variance.py.ContravariantParamSpec[(object, /) -> Any[generic_argument]], got ./generics_paramspec_variance.py.ContravariantParamSpec[(int, /) -> Any[generic_argument]] [incompatible_assignment] +./generics_paramspec_variance.py:30:0: Incompatible assignment: expected ./generics_paramspec_variance.py.CovariantParamSpec[(int, /) -> Any[generic_argument]], got ./generics_paramspec_variance.py.CovariantParamSpec[(object, /) -> Any[generic_argument]] [incompatible_assignment] +./generics_paramspec_variance.py:61:0: Incompatible types in assignment to attribute 't': expected ./generics_paramspec_variance.py.InitP[(a: int) -> Any[unannotated]], got ./generics_paramspec_variance.py.InitP[(*, a: int) -> Any[unannotated]] [incompatible_assignment] +./generics_paramspec_variance.py:63:0: Incompatible types in assignment to attribute 't': expected ./generics_paramspec_variance.py.InitP[(a: int) -> Any[unannotated]], got ./generics_paramspec_variance.py.InitP[(a: int, /) -> Any[unannotated]] [incompatible_assignment] +./generics_paramspec_variance.py:65:0: Incompatible types in assignment to attribute 't': expected ./generics_paramspec_variance.py.InitP[(a: int) -> Any[unannotated]], got ./generics_paramspec_variance.py.InitP[(b: int) -> Any[unannotated]] [incompatible_assignment] +./generics_paramspec_variance.py:69:0: Incompatible types in assignment to attribute 't': expected ./generics_paramspec_variance.py.InitP[(a: int) -> Any[unannotated]], got ./generics_paramspec_variance.py.InitP[(a: int, b: str) -> Any[unannotated]] [incompatible_assignment] +./generics_paramspec_variance.py:88:0: Incompatible types in assignment to attribute 't': expected ./generics_paramspec_variance.py.OutitP[(a: int) -> Any[unannotated]], got ./generics_paramspec_variance.py.OutitP[(b: int) -> Any[unannotated]] [incompatible_assignment] +./generics_paramspec_variance.py:90:0: Incompatible types in assignment to attribute 't': expected ./generics_paramspec_variance.py.OutitP[(a: int) -> Any[unannotated]], got ./generics_paramspec_variance.py.OutitP[(a: int = Literal[1]) -> Any[unannotated]] [incompatible_assignment] +./generics_paramspec_variance.py:92:0: Incompatible types in assignment to attribute 't': expected ./generics_paramspec_variance.py.OutitP[(a: int) -> Any[unannotated]], got ./generics_paramspec_variance.py.OutitP[(a: int, b: str) -> Any[unannotated]] [incompatible_assignment] +./generics_paramspec_variance.py:100:8: Bivariant types are not supported [incompatible_call] +./generics_paramspec_variance.py:101:8: Type parameter cannot combine infer_variance with explicit variance [incompatible_call] +./generics_paramspec_variance.py:102:8: Type parameter cannot combine infer_variance with explicit variance [incompatible_call] +./generics_paramspec_variance.py:110:0: Incompatible assignment: expected ./generics_paramspec_variance.py.InvariantParamSpecOld[(int, /) -> Any[generic_argument]], got ./generics_paramspec_variance.py.InvariantParamSpecOld[(bool, /) -> Any[generic_argument]] [incompatible_assignment] +./generics_paramspec_variance.py:111:0: Incompatible assignment: expected ./generics_paramspec_variance.py.InvariantParamSpecOld[(int, /) -> Any[generic_argument]], got ./generics_paramspec_variance.py.InvariantParamSpecOld[(object, /) -> Any[generic_argument]] [incompatible_assignment] +./generics_paramspec_variance.py:117:4: InP has incompatible variance in method [invalid_annotation] +./generics_paramspec_variance.py:121:0: Incompatible assignment: expected ./generics_paramspec_variance.py.ContravariantParamSpecOld[(object, /) -> Any[generic_argument]], got ./generics_paramspec_variance.py.ContravariantParamSpecOld[(int, /) -> Any[generic_argument]] [incompatible_assignment] +./generics_paramspec_variance.py:126:4: OutP has incompatible variance in method [invalid_annotation] +./generics_paramspec_variance.py:132:0: Incompatible assignment: expected ./generics_paramspec_variance.py.CovariantParamSpecOld[(int, /) -> Any[generic_argument]], got ./generics_paramspec_variance.py.CovariantParamSpecOld[(object, /) -> Any[generic_argument]] [incompatible_assignment] +./generics_paramspec_variance.py:142:0: Incompatible assignment: expected ./generics_paramspec_variance.py.InferredContravariantParamSpecOld[(object, /) -> Any[generic_argument]], got ./generics_paramspec_variance.py.InferredContravariantParamSpecOld[(int, /) -> Any[generic_argument]] [incompatible_assignment] +./generics_paramspec_variance.py:151:0: Incompatible assignment: expected ./generics_paramspec_variance.py.InferredCovariantParamSpecOld[(int, /) -> Any[generic_argument]], got ./generics_paramspec_variance.py.InferredCovariantParamSpecOld[(object, /) -> Any[generic_argument]] [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/generics_scoping.toml b/conformance/results/pycroscope/generics_scoping.toml new file mode 100644 index 000000000..3238868ee --- /dev/null +++ b/conformance/results/pycroscope/generics_scoping.toml @@ -0,0 +1,19 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_scoping.py:15:12: Literal[1] is not equivalent to int +./generics_scoping.py:19:12: Literal['a'] is not equivalent to str +./generics_scoping.py:34:9: Incompatible argument type for x: expected int but got Literal['a'] [incompatible_argument] +./generics_scoping.py:49:12: Literal['abc'] is not equivalent to str +./generics_scoping.py:53:12: Literal[b'abc'] is not equivalent to bytes +./generics_scoping.py:61:12: Type parameter is not valid in this annotation context [invalid_annotation] +./generics_scoping.py:65:18: Type parameter is not valid in this annotation context [invalid_annotation] +./generics_scoping.py:76:28: Type parameter is not valid in this annotation context [invalid_annotation] +./generics_scoping.py:86:23: Type parameter is not valid in this annotation context [invalid_annotation] +./generics_scoping.py:89:16: Type parameter is not valid in this annotation context [invalid_annotation] +./generics_scoping.py:98:28: Type parameter is not valid in this annotation context [invalid_annotation] +./generics_scoping.py:105:13: Type parameter is not valid in this annotation context [invalid_annotation] +./generics_scoping.py:106:18: Type parameter is not valid in this annotation context [invalid_annotation] +./generics_scoping.py:107:5: Type parameter is not valid in this annotation context [invalid_annotation] +""" diff --git a/conformance/results/pycroscope/generics_self_advanced.toml b/conformance/results/pycroscope/generics_self_advanced.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/pycroscope/generics_self_advanced.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pycroscope/generics_self_attributes.toml b/conformance/results/pycroscope/generics_self_attributes.toml new file mode 100644 index 000000000..c49b0428e --- /dev/null +++ b/conformance/results/pycroscope/generics_self_attributes.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_self_attributes.py:26:37: Incompatible argument type for next: expected generics_self_attributes.OrdinalLinkedList | None but got generics_self_attributes.LinkedList[int] [incompatible_argument] +./generics_self_attributes.py:32:4: Incompatible types in assignment to attribute 'next': expected generics_self_attributes.OrdinalLinkedList | None, got generics_self_attributes.LinkedList[int] [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/generics_self_basic.toml b/conformance/results/pycroscope/generics_self_basic.toml new file mode 100644 index 000000000..d93d9f37a --- /dev/null +++ b/conformance/results/pycroscope/generics_self_basic.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_self_basic.py:20:8: Incompatible return type: expected ~SelfT@./generics_self_basic.py.Shape, got ./generics_self_basic.py.Shape [incompatible_return_value] +./generics_self_basic.py:33:8: Incompatible return type: expected ~SelfT@./generics_self_basic.py.Shape, got ./generics_self_basic.py.Shape [incompatible_return_value] +./generics_self_basic.py:68:25: Self cannot be further subscripted [invalid_specialization] +""" diff --git a/conformance/results/pycroscope/generics_self_protocols.toml b/conformance/results/pycroscope/generics_self_protocols.toml new file mode 100644 index 000000000..cfcf2f650 --- /dev/null +++ b/conformance/results/pycroscope/generics_self_protocols.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_self_protocols.py:61:18: Incompatible argument type for shape: expected generics_self_protocols.ShapeProtocol but got generics_self_protocols.BadReturnType [incompatible_argument] +./generics_self_protocols.py:64:18: Incompatible argument type for shape: expected generics_self_protocols.ShapeProtocol but got generics_self_protocols.ReturnDifferentClass [incompatible_argument] +""" diff --git a/conformance/results/pycroscope/generics_self_usage.toml b/conformance/results/pycroscope/generics_self_usage.toml new file mode 100644 index 000000000..b3b83f3d6 --- /dev/null +++ b/conformance/results/pycroscope/generics_self_usage.toml @@ -0,0 +1,17 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_self_usage.py:73:13: Self cannot be used outside a class [invalid_self_usage] +./generics_self_usage.py:73:22: Self cannot be used outside a class [invalid_self_usage] +./generics_self_usage.py:76:5: Self can only be used in class attribute annotations [invalid_self_usage] +./generics_self_usage.py:82:4: Self methods using Self must annotate the receiver with Self or leave it unannotated [invalid_self_usage] +./generics_self_usage.py:87:8: Incompatible return type: expected ~SelfT@./generics_self_usage.py.Foo3, got ./generics_self_usage.py.Foo3 [incompatible_return_value] +./generics_self_usage.py:103:10: Self cannot be used in base class expressions [invalid_base] +./generics_self_usage.py:105:11: Self cannot be used in base class expressions [invalid_base] +./generics_self_usage.py:108:23: Self cannot be used in type aliases [invalid_self_usage] +./generics_self_usage.py:113:4: Self cannot be used in staticmethod signatures [invalid_self_usage] +./generics_self_usage.py:118:4: Self cannot be used in staticmethod signatures [invalid_self_usage] +./generics_self_usage.py:123:4: Self cannot be used in metaclass definitions [invalid_self_usage] +./generics_self_usage.py:127:4: Self cannot be used in metaclass definitions [invalid_self_usage] +""" diff --git a/conformance/results/pycroscope/generics_syntax_compatibility.toml b/conformance/results/pycroscope/generics_syntax_compatibility.toml new file mode 100644 index 000000000..d4f3d5172 --- /dev/null +++ b/conformance/results/pycroscope/generics_syntax_compatibility.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_syntax_compatibility.py:14:21: Class definition cannot combine old-style TypeVar declarations with type parameter syntax [invalid_annotation] +./generics_syntax_compatibility.py:26:34: Function definition cannot combine old-style TypeVar declarations with type parameter syntax [invalid_annotation] +""" diff --git a/conformance/results/pycroscope/generics_syntax_declarations.toml b/conformance/results/pycroscope/generics_syntax_declarations.toml new file mode 100644 index 000000000..663c7959f --- /dev/null +++ b/conformance/results/pycroscope/generics_syntax_declarations.toml @@ -0,0 +1,15 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_syntax_declarations.py:17:16: Class definition cannot specialize Generic or Protocol bases when using type parameter syntax [invalid_base] +./generics_syntax_declarations.py:25:19: Class definition cannot specialize Generic or Protocol bases when using type parameter syntax [invalid_base] +./generics_syntax_declarations.py:32:8: str has no attribute 'is_integer' [undefined_attribute] +./generics_syntax_declarations.py:44:20: TypeVar bound cannot be parameterized by type variables [invalid_annotation] +./generics_syntax_declarations.py:48:16: Invalid type annotation [, ] [invalid_annotation] +./generics_syntax_declarations.py:60:16: TypeVar constraints must contain at least two types [invalid_annotation] +./generics_syntax_declarations.py:64:16: TypeVar constraints must contain at least two types [invalid_annotation] +./generics_syntax_declarations.py:71:16: Invalid type annotation (, ) [invalid_annotation] +./generics_syntax_declarations.py:75:17: Invalid type annotation 3 [invalid_annotation] +./generics_syntax_declarations.py:79:22: Undefined name: S [undefined_name] +""" diff --git a/conformance/results/pycroscope/generics_syntax_infer_variance.toml b/conformance/results/pycroscope/generics_syntax_infer_variance.toml new file mode 100644 index 000000000..df6ccefcf --- /dev/null +++ b/conformance/results/pycroscope/generics_syntax_infer_variance.toml @@ -0,0 +1,23 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_syntax_infer_variance.py:15:5: Type parameter cannot combine infer_variance with explicit variance [incompatible_call] +./generics_syntax_infer_variance.py:17:5: Type parameter cannot combine infer_variance with explicit variance [incompatible_call] +./generics_syntax_infer_variance.py:29:0: Incompatible assignment: expected ./generics_syntax_infer_variance.py.ShouldBeCovariant1[int], got ./generics_syntax_infer_variance.py.ShouldBeCovariant1[float | int] [incompatible_assignment] +./generics_syntax_infer_variance.py:47:0: Incompatible assignment: expected ./generics_syntax_infer_variance.py.ShouldBeCovariant2[int], got ./generics_syntax_infer_variance.py.ShouldBeCovariant2[float | int] [incompatible_assignment] +./generics_syntax_infer_variance.py:56:0: Incompatible assignment: expected ./generics_syntax_infer_variance.py.ShouldBeCovariant3[int], got ./generics_syntax_infer_variance.py.ShouldBeCovariant3[float | int] [incompatible_assignment] +./generics_syntax_infer_variance.py:85:0: Incompatible assignment: expected ./generics_syntax_infer_variance.py.ShouldBeCovariant5[int], got ./generics_syntax_infer_variance.py.ShouldBeCovariant5[float | int] [incompatible_assignment] +./generics_syntax_infer_variance.py:96:0: Incompatible assignment: expected ./generics_syntax_infer_variance.py.ShouldBeCovariant6[int], got ./generics_syntax_infer_variance.py.ShouldBeCovariant6[float | int] [incompatible_assignment] +./generics_syntax_infer_variance.py:112:0: Incompatible assignment: expected ./generics_syntax_infer_variance.py.ShouldBeInvariant1[float | int], got ./generics_syntax_infer_variance.py.ShouldBeInvariant1[int] [incompatible_assignment] +./generics_syntax_infer_variance.py:113:0: Incompatible assignment: expected ./generics_syntax_infer_variance.py.ShouldBeInvariant1[int], got ./generics_syntax_infer_variance.py.ShouldBeInvariant1[float | int] [incompatible_assignment] +./generics_syntax_infer_variance.py:127:0: Incompatible assignment: expected ./generics_syntax_infer_variance.py.ShouldBeInvariant2[float | int], got ./generics_syntax_infer_variance.py.ShouldBeInvariant2[int] [incompatible_assignment] +./generics_syntax_infer_variance.py:128:0: Incompatible assignment: expected ./generics_syntax_infer_variance.py.ShouldBeInvariant2[int], got ./generics_syntax_infer_variance.py.ShouldBeInvariant2[float | int] [incompatible_assignment] +./generics_syntax_infer_variance.py:135:0: Incompatible assignment: expected ./generics_syntax_infer_variance.py.ShouldBeInvariant3[float | int, str], got ./generics_syntax_infer_variance.py.ShouldBeInvariant3[int, str] [incompatible_assignment] +./generics_syntax_infer_variance.py:136:0: Incompatible assignment: expected ./generics_syntax_infer_variance.py.ShouldBeInvariant3[int, str], got ./generics_syntax_infer_variance.py.ShouldBeInvariant3[float | int, str] [incompatible_assignment] +./generics_syntax_infer_variance.py:137:0: Incompatible assignment: expected ./generics_syntax_infer_variance.py.ShouldBeInvariant3[str, float | int], got ./generics_syntax_infer_variance.py.ShouldBeInvariant3[str, int] [incompatible_assignment] +./generics_syntax_infer_variance.py:138:0: Incompatible assignment: expected ./generics_syntax_infer_variance.py.ShouldBeInvariant3[str, int], got ./generics_syntax_infer_variance.py.ShouldBeInvariant3[str, float | int] [incompatible_assignment] +./generics_syntax_infer_variance.py:146:0: Incompatible assignment: expected ./generics_syntax_infer_variance.py.ShouldBeInvariant4[float | int], got ./generics_syntax_infer_variance.py.ShouldBeInvariant4[int] [incompatible_assignment] +./generics_syntax_infer_variance.py:154:0: Incompatible assignment: expected ./generics_syntax_infer_variance.py.ShouldBeInvariant5[float | int], got ./generics_syntax_infer_variance.py.ShouldBeInvariant5[int] [incompatible_assignment] +./generics_syntax_infer_variance.py:165:0: Incompatible assignment: expected ./generics_syntax_infer_variance.py.ShouldBeContravariant1[float | int], got ./generics_syntax_infer_variance.py.ShouldBeContravariant1[int] [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/generics_syntax_scoping.toml b/conformance/results/pycroscope/generics_syntax_scoping.toml new file mode 100644 index 000000000..4f2903c6f --- /dev/null +++ b/conformance/results/pycroscope/generics_syntax_scoping.toml @@ -0,0 +1,13 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_syntax_scoping.py:14:19: TypeVar bound cannot be parameterized by type variables [invalid_annotation] +./generics_syntax_scoping.py:18:13: Type parameter bound cannot reference a later type parameter [invalid_type_parameter] +./generics_syntax_scoping.py:26:6: Undefined name: T [undefined_name] +./generics_syntax_scoping.py:35:12: Incompatible argument type for x: expected type[./generics_syntax_scoping.py.Foo[~T@./generics_syntax_scoping.py.decorator1..decorator1]] but got types.GenericAlias (partial from [Any[error]]) [incompatible_argument] +./generics_syntax_scoping.py:35:16: Undefined name: T [undefined_name] +./generics_syntax_scoping.py:83:16: Type parameter 'T' is already in use by an outer scope [invalid_type_parameter] +./generics_syntax_scoping.py:86:16: Type parameter 'T' is already in use by an outer scope [invalid_type_parameter] +./generics_syntax_scoping.py:89:16: Type parameter 'T' is already in use by an outer scope [invalid_type_parameter] +""" diff --git a/conformance/results/pycroscope/generics_type_erasure.toml b/conformance/results/pycroscope/generics_type_erasure.toml new file mode 100644 index 000000000..9ffdc5c1e --- /dev/null +++ b/conformance/results/pycroscope/generics_type_erasure.toml @@ -0,0 +1,12 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_type_erasure.py:38:15: Incompatible argument type for label: expected int | None but got Literal[''] [incompatible_argument] +./generics_type_erasure.py:40:15: Incompatible argument type for label: expected str | None but got Literal[0] [incompatible_argument] +./generics_type_erasure.py:42:0: Cannot assign to instance attribute 'label' via class object [incompatible_assignment] +./generics_type_erasure.py:43:0: types.GenericAlias (partial from [type 'int']) has no attribute 'label' [undefined_attribute] +./generics_type_erasure.py:44:0: Cannot assign to instance attribute 'label' via class object [incompatible_assignment] +./generics_type_erasure.py:45:0: has no attribute 'label' [undefined_attribute] +./generics_type_erasure.py:46:0: type[./generics_type_erasure.py.Node[int]] has no attribute 'label' [undefined_attribute] +""" diff --git a/conformance/results/pycroscope/generics_typevartuple_args.toml b/conformance/results/pycroscope/generics_typevartuple_args.toml new file mode 100644 index 000000000..e65813587 --- /dev/null +++ b/conformance/results/pycroscope/generics_typevartuple_args.toml @@ -0,0 +1,13 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_typevartuple_args.py:33:4: Incompatible argument type for args: expected tuple[*tuple[Ts, ...], generics_typevartuple_args.Env] but got tuple[Literal[0], Literal['']] [incompatible_argument] +./generics_typevartuple_args.py:34:4: Incompatible argument type for args: expected tuple[*tuple[Ts, ...], generics_typevartuple_args.Env] but got tuple[Literal[0], Literal['']] [incompatible_argument] +./generics_typevartuple_args.py:48:0: Incompatible argument type for args: expected tuple[int, ...] but got tuple[Literal[1], Literal['2'], Literal[3]] [incompatible_argument] +./generics_typevartuple_args.py:57:0: Incompatible argument type for args: expected tuple[int, *tuple[str, ...], str] but got tuple[Literal[1], Literal[1], Literal['']] [incompatible_argument] +./generics_typevartuple_args.py:58:0: Incompatible argument type for args: expected tuple[int, *tuple[str, ...], str] but got tuple[Literal[1]] [incompatible_argument] +./generics_typevartuple_args.py:59:0: Incompatible argument type for args: expected tuple[int, *tuple[str, ...], str] but got tuple[Literal['']] [incompatible_argument] +./generics_typevartuple_args.py:67:0: In call to generics_typevartuple_args.func3: Missing required positional argument at position 1 [incompatible_call] +./generics_typevartuple_args.py:75:0: In call to generics_typevartuple_args.func4: Cannot resolve type variables [incompatible_call] +""" diff --git a/conformance/results/pycroscope/generics_typevartuple_basic.toml b/conformance/results/pycroscope/generics_typevartuple_basic.toml new file mode 100644 index 000000000..482d88b8c --- /dev/null +++ b/conformance/results/pycroscope/generics_typevartuple_basic.toml @@ -0,0 +1,19 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_typevartuple_basic.py:43:33: Incompatible argument type for shape: expected tuple[*tuple[Shape, ...]] but got NewType('Height', int) [incompatible_argument] +./generics_typevartuple_basic.py:44:0: Incompatible assignment: expected ./generics_typevartuple_basic.py.Array[NewType('Batch', int), NewType('Height', int), NewType('Width', int)], got ./generics_typevartuple_basic.py.Array~[NewType('Batch', int), NewType('Width', int)] [incompatible_assignment] +./generics_typevartuple_basic.py:45:0: Incompatible assignment: expected ./generics_typevartuple_basic.py.Array[NewType('Time', int), NewType('Batch', int), NewType('Height', int), NewType('Width', int)], got ./generics_typevartuple_basic.py.Array~[NewType('Time', int), NewType('Batch', int), NewType('Width', int), NewType('Height', int)] [incompatible_assignment] +./generics_typevartuple_basic.py:53:21: TypeVarTuple must be unpacked [invalid_base] +./generics_typevartuple_basic.py:54:30: TypeVarTuple must be unpacked [invalid_annotation] +./generics_typevartuple_basic.py:57:27: TypeVarTuple must be unpacked [invalid_annotation] +./generics_typevartuple_basic.py:60:17: TypeVarTuple must be unpacked [invalid_annotation] +./generics_typevartuple_basic.py:66:6: In call to typing.TypeVarTuple: Takes 1 positional arguments but 3 were given [incompatible_call] +./generics_typevartuple_basic.py:67:6: In call to typing.TypeVarTuple: Got an unexpected keyword argument 'bound' [incompatible_call] +./generics_typevartuple_basic.py:91:0: Cannot resolve type variables [incompatible_call] +./generics_typevartuple_basic.py:100:4: Cannot resolve type variables [incompatible_call] +./generics_typevartuple_basic.py:101:4: Cannot resolve type variables [incompatible_call] +./generics_typevartuple_basic.py:107:21: Only one TypeVarTuple can be used in a type parameter list [invalid_base] +./generics_typevartuple_basic.py:111:19: Only one TypeVarTuple may appear in a type parameter list [invalid_type_parameter] +""" diff --git a/conformance/results/pycroscope/generics_typevartuple_callable.toml b/conformance/results/pycroscope/generics_typevartuple_callable.toml new file mode 100644 index 000000000..cf4dd26c6 --- /dev/null +++ b/conformance/results/pycroscope/generics_typevartuple_callable.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_typevartuple_callable.py:26:0: Cannot resolve type variables [incompatible_call] +""" diff --git a/conformance/results/pycroscope/generics_typevartuple_concat.toml b/conformance/results/pycroscope/generics_typevartuple_concat.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/pycroscope/generics_typevartuple_concat.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pycroscope/generics_typevartuple_overloads.toml b/conformance/results/pycroscope/generics_typevartuple_overloads.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/pycroscope/generics_typevartuple_overloads.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pycroscope/generics_typevartuple_specialization.toml b/conformance/results/pycroscope/generics_typevartuple_specialization.toml new file mode 100644 index 000000000..9de610e51 --- /dev/null +++ b/conformance/results/pycroscope/generics_typevartuple_specialization.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_typevartuple_specialization.py:109:0: Unpacked TypeVarTuple cannot specialize this type alias [invalid_annotation] +./generics_typevartuple_specialization.py:110:0: Unpacked TypeVarTuple cannot specialize this type alias [invalid_annotation] +./generics_typevartuple_specialization.py:121:6: Only one unbounded tuple can be used inside a tuple type [invalid_annotation] +./generics_typevartuple_specialization.py:122:6: Only one unbounded tuple can be used inside a tuple type [invalid_annotation] +./generics_typevartuple_specialization.py:127:4: Expected 3 type arguments for type alias, got 1 [invalid_specialization] +./generics_typevartuple_specialization.py:163:7: Unpacked TypeVarTuple cannot specialize this type alias [invalid_annotation] +""" diff --git a/conformance/results/pycroscope/generics_typevartuple_unpack.toml b/conformance/results/pycroscope/generics_typevartuple_unpack.toml new file mode 100644 index 000000000..7c7e107eb --- /dev/null +++ b/conformance/results/pycroscope/generics_typevartuple_unpack.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_typevartuple_unpack.py:30:27: Incompatible argument type for x: expected generics_typevartuple_unpack.Array[NewType('Batch', int), *tuple[Any[explicit], ...], NewType('Channels', int)] but got generics_typevartuple_unpack.Array[NewType('Batch', int)] [incompatible_argument] +""" diff --git a/conformance/results/pycroscope/generics_typevartuple_variance.toml b/conformance/results/pycroscope/generics_typevartuple_variance.toml new file mode 100644 index 000000000..74e9e79f4 --- /dev/null +++ b/conformance/results/pycroscope/generics_typevartuple_variance.toml @@ -0,0 +1,31 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_typevartuple_variance.py:14:0: Incompatible assignment: expected generics_typevartuple_variance.InvariantTypeVarTuple[object], got generics_typevartuple_variance.InvariantTypeVarTuple[int] [incompatible_assignment] +./generics_typevartuple_variance.py:15:0: Incompatible assignment: expected generics_typevartuple_variance.InvariantTypeVarTuple[int], got generics_typevartuple_variance.InvariantTypeVarTuple[object] [incompatible_assignment] +./generics_typevartuple_variance.py:17:0: Incompatible assignment: expected generics_typevartuple_variance.InvariantTypeVarTuple[*tuple[int, ...]], got generics_typevartuple_variance.InvariantTypeVarTuple[*tuple[object, ...]] [incompatible_assignment] +./generics_typevartuple_variance.py:18:0: Incompatible assignment: expected generics_typevartuple_variance.InvariantTypeVarTuple[*tuple[object, ...]], got generics_typevartuple_variance.InvariantTypeVarTuple[*tuple[int, ...]] [incompatible_assignment] +./generics_typevartuple_variance.py:20:0: Incompatible assignment: expected generics_typevartuple_variance.InvariantTypeVarTuple[int], got generics_typevartuple_variance.InvariantTypeVarTuple[*tuple[int, ...]] [incompatible_assignment] +./generics_typevartuple_variance.py:21:0: Incompatible assignment: expected generics_typevartuple_variance.InvariantTypeVarTuple[*tuple[int, ...]], got generics_typevartuple_variance.InvariantTypeVarTuple[int] [incompatible_assignment] +./generics_typevartuple_variance.py:28:0: Incompatible assignment: expected generics_typevartuple_variance.ContravariantTypeVarTuple[object, object], got generics_typevartuple_variance.ContravariantTypeVarTuple[object, int] [incompatible_assignment] +./generics_typevartuple_variance.py:31:0: Incompatible assignment: expected generics_typevartuple_variance.ContravariantTypeVarTuple[*tuple[object, ...]], got generics_typevartuple_variance.ContravariantTypeVarTuple[*tuple[int, ...]] [incompatible_assignment] +./generics_typevartuple_variance.py:34:0: Incompatible assignment: expected generics_typevartuple_variance.ContravariantTypeVarTuple[*tuple[int, ...]], got generics_typevartuple_variance.ContravariantTypeVarTuple[int] [incompatible_assignment] +./generics_typevartuple_variance.py:42:0: Incompatible assignment: expected generics_typevartuple_variance.CovariantTypeVarTuple[int], got generics_typevartuple_variance.CovariantTypeVarTuple[object] [incompatible_assignment] +./generics_typevartuple_variance.py:45:0: Incompatible assignment: expected generics_typevartuple_variance.CovariantTypeVarTuple[int, int], got generics_typevartuple_variance.CovariantTypeVarTuple[bool, object] [incompatible_assignment] +./generics_typevartuple_variance.py:46:0: Incompatible assignment: expected generics_typevartuple_variance.CovariantTypeVarTuple[int, int], got generics_typevartuple_variance.CovariantTypeVarTuple[object, bool] [incompatible_assignment] +./generics_typevartuple_variance.py:47:0: Incompatible assignment: expected generics_typevartuple_variance.CovariantTypeVarTuple[int, int], got generics_typevartuple_variance.CovariantTypeVarTuple[object, object] [incompatible_assignment] +./generics_typevartuple_variance.py:48:0: Incompatible assignment: expected generics_typevartuple_variance.CovariantTypeVarTuple[*tuple[int, ...]], got generics_typevartuple_variance.CovariantTypeVarTuple[*tuple[object, ...]] [incompatible_assignment] +./generics_typevartuple_variance.py:51:0: Incompatible assignment: expected generics_typevartuple_variance.CovariantTypeVarTuple[int], got generics_typevartuple_variance.CovariantTypeVarTuple[*tuple[int, ...]] [incompatible_assignment] +./generics_typevartuple_variance.py:56:9: Bivariant types are not supported [incompatible_call] +./generics_typevartuple_variance.py:57:9: Type parameter cannot combine infer_variance with explicit variance [incompatible_call] +./generics_typevartuple_variance.py:58:9: Type parameter cannot combine infer_variance with explicit variance [incompatible_call] +./generics_typevartuple_variance.py:68:0: Incompatible assignment: expected generics_typevartuple_variance.InvariantTypeVarTupleOld[object], got generics_typevartuple_variance.InvariantTypeVarTupleOld[int] [incompatible_assignment] +./generics_typevartuple_variance.py:69:0: Incompatible assignment: expected generics_typevartuple_variance.InvariantTypeVarTupleOld[int], got generics_typevartuple_variance.InvariantTypeVarTupleOld[object] [incompatible_assignment] +./generics_typevartuple_variance.py:79:4: InTs has incompatible variance in method [invalid_annotation] +./generics_typevartuple_variance.py:83:0: Incompatible assignment: expected generics_typevartuple_variance.ContravariantTypeVarTupleOld[object], got generics_typevartuple_variance.ContravariantTypeVarTupleOld[int] [incompatible_assignment] +./generics_typevartuple_variance.py:90:4: OutTs has incompatible variance in method [invalid_annotation] +./generics_typevartuple_variance.py:97:0: Incompatible assignment: expected generics_typevartuple_variance.CovariantTypeVarTupleOld[int], got generics_typevartuple_variance.CovariantTypeVarTupleOld[object] [incompatible_assignment] +./generics_typevartuple_variance.py:107:0: Incompatible assignment: expected generics_typevartuple_variance.InferredContravariantTypeVarTupleOld[object], got generics_typevartuple_variance.InferredContravariantTypeVarTupleOld[int] [incompatible_assignment] +./generics_typevartuple_variance.py:116:0: Incompatible assignment: expected generics_typevartuple_variance.InferredCovariantTypeVarTupleOld[int], got generics_typevartuple_variance.InferredCovariantTypeVarTupleOld[object] [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/generics_upper_bound.toml b/conformance/results/pycroscope/generics_upper_bound.toml new file mode 100644 index 000000000..4cd6263ee --- /dev/null +++ b/conformance/results/pycroscope/generics_upper_bound.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_upper_bound.py:24:37: TypeVar bounds and constraints cannot contain type parameters [invalid_annotation] +./generics_upper_bound.py:44:16: list[int] | set[int] is not equivalent to collections.abc.Collection[int] +./generics_upper_bound.py:52:7: Incompatible argument type for x: expected ~ST@./generics_upper_bound.py.longer..longer but got Literal[3] [incompatible_argument] +./generics_upper_bound.py:57:9: TypeVar cannot have both bound and constraints [incompatible_call] +""" diff --git a/conformance/results/pycroscope/generics_variance.toml b/conformance/results/pycroscope/generics_variance.toml new file mode 100644 index 000000000..a4eb7dcae --- /dev/null +++ b/conformance/results/pycroscope/generics_variance.toml @@ -0,0 +1,18 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_variance.py:14:5: Bivariant types are not supported [incompatible_call] +./generics_variance.py:77:13: T_co has incompatible variance in base class [invalid_base] +./generics_variance.py:81:13: T_contra has incompatible variance in base class [invalid_base] +./generics_variance.py:93:16: T_contra has incompatible variance in base class [invalid_base] +./generics_variance.py:105:20: T_co has incompatible variance in base class [invalid_base] +./generics_variance.py:113:20: T_co has incompatible variance in base class [invalid_base] +./generics_variance.py:126:4: T_co has incompatible variance in base class [invalid_base] +./generics_variance.py:132:4: T_contra has incompatible variance in base class [invalid_base] +./generics_variance.py:142:4: T_co has incompatible variance in base class [invalid_base] +./generics_variance.py:163:25: T_contra has incompatible variance in base class [invalid_base] +./generics_variance.py:167:29: T_co has incompatible variance in base class [invalid_base] +./generics_variance.py:191:32: T_contra has incompatible variance in base class [invalid_base] +./generics_variance.py:196:4: T_co has incompatible variance in base class [invalid_base] +""" diff --git a/conformance/results/pycroscope/generics_variance_inference.toml b/conformance/results/pycroscope/generics_variance_inference.toml new file mode 100644 index 000000000..e968d354f --- /dev/null +++ b/conformance/results/pycroscope/generics_variance_inference.toml @@ -0,0 +1,29 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./generics_variance_inference.py:24:4: Incompatible assignment: expected generics_variance_inference.ClassA[int, int, int], got generics_variance_inference.ClassA[float | int, int, int] [incompatible_assignment] +./generics_variance_inference.py:25:4: Incompatible assignment: expected generics_variance_inference.ClassA[float | int, float | int, int], got generics_variance_inference.ClassA[float | int, int, int] [incompatible_assignment] +./generics_variance_inference.py:28:4: Incompatible assignment: expected generics_variance_inference.ClassA[int, int, int], got generics_variance_inference.ClassA[int, float | int, float | int] [incompatible_assignment] +./generics_variance_inference.py:41:0: Incompatible assignment: expected generics_variance_inference.ShouldBeCovariant1[int], got generics_variance_inference.ShouldBeCovariant1[float | int] [incompatible_assignment] +./generics_variance_inference.py:49:0: Incompatible assignment: expected generics_variance_inference.ShouldBeCovariant2[int], got generics_variance_inference.ShouldBeCovariant2[float | int] [incompatible_assignment] +./generics_variance_inference.py:58:0: Incompatible assignment: expected generics_variance_inference.ShouldBeCovariant3[int], got generics_variance_inference.ShouldBeCovariant3[float | int] [incompatible_assignment] +./generics_variance_inference.py:67:0: Incompatible assignment: expected generics_variance_inference.ShouldBeCovariant4[int], got generics_variance_inference.ShouldBeCovariant4[float | int] [incompatible_assignment] +./generics_variance_inference.py:80:0: Incompatible assignment: expected generics_variance_inference.ShouldBeCovariant5[int], got generics_variance_inference.ShouldBeCovariant5[float | int] [incompatible_assignment] +./generics_variance_inference.py:96:0: Incompatible assignment: expected generics_variance_inference.ShouldBeInvariant1[float | int], got generics_variance_inference.ShouldBeInvariant1[int] [incompatible_assignment] +./generics_variance_inference.py:97:0: Incompatible assignment: expected generics_variance_inference.ShouldBeInvariant1[int], got generics_variance_inference.ShouldBeInvariant1[float | int] [incompatible_assignment] +./generics_variance_inference.py:111:0: Incompatible assignment: expected generics_variance_inference.ShouldBeInvariant2[float | int], got generics_variance_inference.ShouldBeInvariant2[int] [incompatible_assignment] +./generics_variance_inference.py:112:0: Incompatible assignment: expected generics_variance_inference.ShouldBeInvariant2[int], got generics_variance_inference.ShouldBeInvariant2[float | int] [incompatible_assignment] +./generics_variance_inference.py:119:0: Incompatible assignment: expected generics_variance_inference.ShouldBeInvariant3[float | int, str], got generics_variance_inference.ShouldBeInvariant3[int, str] [incompatible_assignment] +./generics_variance_inference.py:120:0: Incompatible assignment: expected generics_variance_inference.ShouldBeInvariant3[int, str], got generics_variance_inference.ShouldBeInvariant3[float | int, str] [incompatible_assignment] +./generics_variance_inference.py:121:0: Incompatible assignment: expected generics_variance_inference.ShouldBeInvariant3[str, float | int], got generics_variance_inference.ShouldBeInvariant3[str, int] [incompatible_assignment] +./generics_variance_inference.py:122:0: Incompatible assignment: expected generics_variance_inference.ShouldBeInvariant3[str, int], got generics_variance_inference.ShouldBeInvariant3[str, float | int] [incompatible_assignment] +./generics_variance_inference.py:130:0: Incompatible assignment: expected generics_variance_inference.ShouldBeInvariant4[float | int], got generics_variance_inference.ShouldBeInvariant4[int] [incompatible_assignment] +./generics_variance_inference.py:138:0: Incompatible assignment: expected generics_variance_inference.ShouldBeInvariant5[float | int], got generics_variance_inference.ShouldBeInvariant5[int] [incompatible_assignment] +./generics_variance_inference.py:149:0: Incompatible assignment: expected generics_variance_inference.ShouldBeContravariant1[float | int], got generics_variance_inference.ShouldBeContravariant1[int] [incompatible_assignment] +./generics_variance_inference.py:169:0: Incompatible assignment: expected generics_variance_inference.ShouldBeInvariant6[int], got generics_variance_inference.ShouldBeInvariant6[float | int] [incompatible_assignment] +./generics_variance_inference.py:170:0: Incompatible assignment: expected generics_variance_inference.ShouldBeInvariant6[float | int], got generics_variance_inference.ShouldBeInvariant6[int] [incompatible_assignment] +./generics_variance_inference.py:181:0: Incompatible assignment: expected generics_variance_inference.ShouldBeCovariant6[int], got generics_variance_inference.ShouldBeCovariant6[float | int] [incompatible_assignment] +./generics_variance_inference.py:194:0: Incompatible assignment: expected generics_variance_inference.ShouldBeContravariant2[float | int], got generics_variance_inference.ShouldBeContravariant2[int] [incompatible_assignment] +./generics_variance_inference.py:205:0: Incompatible assignment: expected generics_variance_inference.ShouldBeCovariant7[int], got generics_variance_inference.ShouldBeCovariant7[object] [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/historical_positional.toml b/conformance/results/pycroscope/historical_positional.toml new file mode 100644 index 000000000..d8bfa937a --- /dev/null +++ b/conformance/results/pycroscope/historical_positional.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./historical_positional.py:18:0: Missing required positional argument '__x' [incompatible_call] +./historical_positional.py:26:15: Historical positional-only parameter may not follow a positional-or-keyword parameter [invalid_positional_only] +./historical_positional.py:54:25: Historical positional-only parameter may not follow a positional-or-keyword parameter [invalid_positional_only] +./historical_positional.py:59:0: Missing required positional argument '__x' [incompatible_call] +""" diff --git a/conformance/results/pycroscope/literals_interactions.toml b/conformance/results/pycroscope/literals_interactions.toml new file mode 100644 index 000000000..e13017ec5 --- /dev/null +++ b/conformance/results/pycroscope/literals_interactions.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./literals_interactions.py:14:4: Tuple index out of range: Literal[5] [incompatible_call] +./literals_interactions.py:15:4: Tuple index out of range: Literal[-5] [incompatible_call] +./literals_interactions.py:16:4: Tuple index out of range: Literal[4] [incompatible_call] +./literals_interactions.py:17:4: Tuple index out of range: Literal[-4] [incompatible_call] +""" diff --git a/conformance/results/pycroscope/literals_literalstring.toml b/conformance/results/pycroscope/literals_literalstring.toml new file mode 100644 index 000000000..742999f58 --- /dev/null +++ b/conformance/results/pycroscope/literals_literalstring.toml @@ -0,0 +1,14 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./literals_literalstring.py:36:11: Arguments to Literal[] must be None, bool, int, str, bytes, or enum members; got typing.LiteralString [invalid_literal] +./literals_literalstring.py:37:13: Arguments to Literal[] must be None, bool, int, str, bytes, or enum members; got typing.LiteralString [invalid_literal] +./literals_literalstring.py:43:4: Incompatible assignment: expected Literal[''], got Literal['two'] [incompatible_assignment] +./literals_literalstring.py:65:4: Incompatible assignment: expected LiteralString, got str [incompatible_assignment] +./literals_literalstring.py:73:4: Incompatible assignment: expected LiteralString, got Literal[3] [incompatible_assignment] +./literals_literalstring.py:74:4: Incompatible assignment: expected LiteralString, got Literal[b'test'] [incompatible_assignment] +./literals_literalstring.py:119:21: Incompatible argument type for s: expected ~TLiteral but got str [incompatible_argument] +./literals_literalstring.py:133:50: Incompatible argument type for value: expected ~T@literals_literalstring.Container but got str [incompatible_argument] +./literals_literalstring.py:171:4: Incompatible assignment: expected list[str], got list[LiteralString] [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/literals_parameterizations.toml b/conformance/results/pycroscope/literals_parameterizations.toml new file mode 100644 index 000000000..d6be8e851 --- /dev/null +++ b/conformance/results/pycroscope/literals_parameterizations.toml @@ -0,0 +1,27 @@ +conformant = "Partial" +notes = """ +Fails to reject various invalid literal parameterizations. +""" +conformance_automated = "Fail" +errors_diff = """ +Line 41: Expected 1 errors +Line 42: Expected 1 errors +Line 44: Expected 1 errors +Line 45: Expected 1 errors +Line 46: Expected 1 errors +Line 49: Expected 1 errors +Line 56: Expected 1 errors +""" +output = """ +./literals_parameterizations.py:43:6: Arguments to Literal[] must be None, bool, int, str, bytes, or enum members; got (4+3j) [invalid_literal] +./literals_parameterizations.py:47:6: Arguments to Literal[] must be None, bool, int, str, bytes, or enum members; got {'a': 'b', 'c': 'd'} [invalid_literal] +./literals_parameterizations.py:48:6: Arguments to Literal[] must be None, bool, int, str, bytes, or enum members; got [invalid_literal] +./literals_parameterizations.py:50:7: Arguments to Literal[] must be literals, not (PartialCallValue(callee=KnownValue(val=), arguments={'name': KnownValue(val='T'), 'constraints': SequenceValue(typ=, literal_only=False, args=(MultiValuedValue(vals=()),), weak=True, members=()), 'bound': KnownValue(val=no argument given), 'covariant': KnownValue(val=False), 'contravariant': KnownValue(val=False), 'infer_variance': KnownValue(val=False), 'default': KnownValue(val=no argument given)}, runtime_value=TypedValue(typ=, literal_only=False), node=),) [invalid_literal] +./literals_parameterizations.py:50:15: Type parameter is not valid in this annotation context [invalid_annotation] +./literals_parameterizations.py:51:7: Arguments to Literal[] must be None, bool, int, str, bytes, or enum members; got 3.14 [invalid_literal] +./literals_parameterizations.py:52:7: Arguments to Literal[] must be None, bool, int, str, bytes, or enum members; got typing.Any [invalid_literal] +./literals_parameterizations.py:53:7: Arguments to Literal[] must be None, bool, int, str, bytes, or enum members; got Ellipsis [invalid_literal] +./literals_parameterizations.py:60:3: Invalid type annotation typing.Literal [invalid_annotation] +./literals_parameterizations.py:61:3: Arguments to Literal[] must be None, bool, int, str, bytes, or enum members; got [invalid_literal] +./literals_parameterizations.py:65:4: Incompatible assignment: expected Literal['Color.RED'], got Literal[] [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/literals_semantics.toml b/conformance/results/pycroscope/literals_semantics.toml new file mode 100644 index 000000000..89d3a423c --- /dev/null +++ b/conformance/results/pycroscope/literals_semantics.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./literals_semantics.py:10:0: Incompatible assignment: expected Literal[3], got Literal[4] [incompatible_assignment] +./literals_semantics.py:24:4: Incompatible assignment: expected Literal[False], got Literal[0] [incompatible_assignment] +./literals_semantics.py:25:4: Incompatible assignment: expected Literal[0], got Literal[False] [incompatible_assignment] +./literals_semantics.py:33:4: Incompatible assignment: expected Literal[3, 4, 5], got Literal[6, 7, 8] [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/namedtuples_define_class.toml b/conformance/results/pycroscope/namedtuples_define_class.toml new file mode 100644 index 000000000..b09002fc2 --- /dev/null +++ b/conformance/results/pycroscope/namedtuples_define_class.toml @@ -0,0 +1,20 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./namedtuples_define_class.py:33:6: Tuple index out of range: Literal[3] [incompatible_call] +./namedtuples_define_class.py:34:6: Tuple index out of range: Literal[-4] [incompatible_call] +./namedtuples_define_class.py:45:5: Missing required argument 'y' [incompatible_call] +./namedtuples_define_class.py:46:5: Missing required argument 'y' [incompatible_call] +./namedtuples_define_class.py:47:14: Incompatible argument type for y: expected int but got Literal[''] [incompatible_argument] +./namedtuples_define_class.py:48:23: Incompatible argument type for units: expected str but got Literal[3] [incompatible_argument] +./namedtuples_define_class.py:49:5: Takes 3 positional arguments but 4 were given [incompatible_call] +./namedtuples_define_class.py:50:6: Got an unexpected keyword argument 'other' [incompatible_call] +./namedtuples_define_class.py:70:6: Takes 2 positional arguments but 3 were given [incompatible_call] +./namedtuples_define_class.py:77:4: NamedTuple field names cannot start with an underscore [invalid_namedtuple] +./namedtuples_define_class.py:87:4: NamedTuple fields without defaults cannot follow fields with defaults [invalid_namedtuple] +./namedtuples_define_class.py:107:4: Field 'x' conflicts with base NamedTuple field [incompatible_override] +./namedtuples_define_class.py:121:0: Takes 2 positional arguments but 3 were given [incompatible_call] +./namedtuples_define_class.py:140:18: Incompatible argument type for value: expected str but got Literal[3.1] [incompatible_argument] +./namedtuples_define_class.py:147:23: NamedTuple classes may only inherit from NamedTuple and Generic [invalid_base] +""" diff --git a/conformance/results/pycroscope/namedtuples_define_functional.toml b/conformance/results/pycroscope/namedtuples_define_functional.toml new file mode 100644 index 000000000..eaa0de901 --- /dev/null +++ b/conformance/results/pycroscope/namedtuples_define_functional.toml @@ -0,0 +1,18 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./namedtuples_define_functional.py:16:7: In call to pycroscope.signature.Point1: Missing required argument 'y' [incompatible_call] +./namedtuples_define_functional.py:21:7: In call to pycroscope.signature.Point2: Missing required argument 'x' [incompatible_call] +./namedtuples_define_functional.py:26:7: In call to pycroscope.signature.Point3: Takes 2 positional arguments but 3 were given [incompatible_call] +./namedtuples_define_functional.py:31:7: In call to pycroscope.signature.Point4: Missing required argument 'y' [incompatible_call] +./namedtuples_define_functional.py:36:17: Incompatible argument type for y: expected int but got Literal['1'] [incompatible_argument] +./namedtuples_define_functional.py:37:7: In call to pycroscope.signature.Point5: Takes 2 positional arguments but 3 were given [incompatible_call] +./namedtuples_define_functional.py:42:17: Incompatible argument type for y: expected int but got Literal['1'] [incompatible_argument] +./namedtuples_define_functional.py:43:16: Incompatible argument type for x: expected int but got Literal[1.1] [incompatible_argument] +./namedtuples_define_functional.py:52:6: Error calling (typename: str, field_names: str | collections.abc.Iterable[str], *, rename: bool = Literal[False], module: str | None = None, defaults: collections.abc.Iterable[Any[explicit]] | None = None) -> type[tuple[Any[explicit], ...]]: Encountered duplicate field name: 'a' [incompatible_call] +./namedtuples_define_functional.py:53:6: Error calling (typename: str, field_names: str | collections.abc.Iterable[str], *, rename: bool = Literal[False], module: str | None = None, defaults: collections.abc.Iterable[Any[explicit]] | None = None) -> type[tuple[Any[explicit], ...]]: Type names and field names cannot be a keyword: 'def' [incompatible_call] +./namedtuples_define_functional.py:54:6: Error calling (typename: str, field_names: str | collections.abc.Iterable[str], *, rename: bool = Literal[False], module: str | None = None, defaults: collections.abc.Iterable[Any[explicit]] | None = None) -> type[tuple[Any[explicit], ...]]: Type names and field names cannot be a keyword: 'def' [incompatible_call] +./namedtuples_define_functional.py:55:6: Error calling (typename: str, field_names: str | collections.abc.Iterable[str], *, rename: bool = Literal[False], module: str | None = None, defaults: collections.abc.Iterable[Any[explicit]] | None = None) -> type[tuple[Any[explicit], ...]]: Field names cannot start with an underscore: '_d' [incompatible_call] +./namedtuples_define_functional.py:69:0: In call to pycroscope.signature.NT7: Missing required argument 'a' [incompatible_call] +""" diff --git a/conformance/results/pycroscope/namedtuples_type_compat.toml b/conformance/results/pycroscope/namedtuples_type_compat.toml new file mode 100644 index 000000000..15ccafae4 --- /dev/null +++ b/conformance/results/pycroscope/namedtuples_type_compat.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./namedtuples_type_compat.py:22:0: Incompatible assignment: expected tuple[int, int], got Literal[Point(x=1, y=2, units='inches')] [incompatible_assignment] +./namedtuples_type_compat.py:23:0: Incompatible assignment: expected tuple[int, str, str], got Literal[Point(x=1, y=2, units='inches')] [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/namedtuples_usage.toml b/conformance/results/pycroscope/namedtuples_usage.toml new file mode 100644 index 000000000..8c47f786e --- /dev/null +++ b/conformance/results/pycroscope/namedtuples_usage.toml @@ -0,0 +1,13 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./namedtuples_usage.py:34:6: Tuple index out of range: Literal[3] [incompatible_call] +./namedtuples_usage.py:35:6: Tuple index out of range: Literal[-4] [incompatible_call] +./namedtuples_usage.py:40:0: Cannot assign to read-only attribute 'x' [incompatible_assignment] +./namedtuples_usage.py:41:0: Object of type tuple[int, int, str] does not support '__setitem__' [unsupported_operation] +./namedtuples_usage.py:42:4: Cannot delete read-only attribute 'x' [incompatible_assignment] +./namedtuples_usage.py:43:4: Object of type tuple[int, int, str] does not support '__delitem__' [unsupported_operation] +./namedtuples_usage.py:52:0: Cannot unpack ./namedtuples_usage.py.Point [bad_unpack] +./namedtuples_usage.py:53:0: Cannot unpack ./namedtuples_usage.py.Point [bad_unpack] +""" diff --git a/conformance/results/pycroscope/narrowing_typeguard.toml b/conformance/results/pycroscope/narrowing_typeguard.toml new file mode 100644 index 000000000..9b9824070 --- /dev/null +++ b/conformance/results/pycroscope/narrowing_typeguard.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./narrowing_typeguard.py:102:4: TypeGuard must be used on a function taking at least one positional parameter [invalid_typeguard] +./narrowing_typeguard.py:107:4: TypeGuard must be used on a function taking at least one positional parameter [invalid_typeguard] +./narrowing_typeguard.py:128:19: Incompatible argument type for f: expected (object, /) -> str but got function 'narrowing_typeguard.simple_typeguard' [incompatible_argument] +./narrowing_typeguard.py:148:25: Incompatible argument type for f: expected narrowing_typeguard.CallableStrProto but got function 'narrowing_typeguard.simple_typeguard' [incompatible_argument] +""" diff --git a/conformance/results/pycroscope/narrowing_typeis.toml b/conformance/results/pycroscope/narrowing_typeis.toml new file mode 100644 index 000000000..d466f5fc3 --- /dev/null +++ b/conformance/results/pycroscope/narrowing_typeis.toml @@ -0,0 +1,14 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./narrowing_typeis.py:110:4: TypeIs must be used on a function taking at least one positional parameter [invalid_typeguard] +./narrowing_typeis.py:115:4: TypeIs must be used on a function taking at least one positional parameter [invalid_typeguard] +./narrowing_typeis.py:137:19: Incompatible argument type for f: expected (object, /) -> str but got function 'narrowing_typeis.simple_typeguard' [incompatible_argument] +./narrowing_typeis.py:157:25: Incompatible argument type for f: expected narrowing_typeis.CallableStrProto but got function 'narrowing_typeis.simple_typeguard' [incompatible_argument] +./narrowing_typeis.py:174:16: Incompatible argument type for f: expected (object, /) -> Annotated[bool, TypeGuardExtension(guarded_type=TypedValue(typ=, literal_only=False))] but got function 'narrowing_typeis.is_int_typeis' [incompatible_argument] +./narrowing_typeis.py:175:13: Incompatible argument type for f: expected (object, /) -> Annotated[bool, TypeIsExtension(guarded_type=TypedValue(typ=, literal_only=False))] but got function 'narrowing_typeis.is_int_typeguard' [incompatible_argument] +./narrowing_typeis.py:196:17: Incompatible argument type for f: expected (object, /) -> Annotated[bool, TypeIsExtension(guarded_type=TypedValue(typ=, literal_only=False))] but got function 'narrowing_typeis.bool_typeis' [incompatible_argument] +./narrowing_typeis.py:200:26: TypeIs narrowed type str is incompatible with parameter x [typeis_must_be_subtype] +./narrowing_typeis.py:204:44: TypeIs narrowed type list[int] is incompatible with parameter x [typeis_must_be_subtype] +""" diff --git a/conformance/results/pycroscope/overloads_basic.toml b/conformance/results/pycroscope/overloads_basic.toml new file mode 100644 index 000000000..beb836472 --- /dev/null +++ b/conformance/results/pycroscope/overloads_basic.toml @@ -0,0 +1,14 @@ +conformant = "Partial" +notes = """ +Does less literal promotion than the test asks for. +""" +conformance_automated = "Fail" +errors_diff = """ +Line 37: Unexpected errors ['./overloads_basic.py:37:12: Literal[0] is not equivalent to int'] +Line 38: Unexpected errors ["./overloads_basic.py:38:12: Literal[b''] is not equivalent to bytes"] +""" +output = """ +./overloads_basic.py:37:12: Literal[0] is not equivalent to int +./overloads_basic.py:38:12: Literal[b''] is not equivalent to bytes +./overloads_basic.py:39:0: Cannot call overloaded function [incompatible_argument] +""" diff --git a/conformance/results/pycroscope/overloads_consistency.toml b/conformance/results/pycroscope/overloads_consistency.toml new file mode 100644 index 000000000..69bde2f94 --- /dev/null +++ b/conformance/results/pycroscope/overloads_consistency.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./overloads_consistency.py:25:0: Overload for 'return_type' is inconsistent with implementation [inconsistent_overload] +./overloads_consistency.py:41:0: Overload for 'parameter_type' is inconsistent with implementation [inconsistent_overload] +""" diff --git a/conformance/results/pycroscope/overloads_definitions.toml b/conformance/results/pycroscope/overloads_definitions.toml new file mode 100644 index 000000000..bb487e497 --- /dev/null +++ b/conformance/results/pycroscope/overloads_definitions.toml @@ -0,0 +1,16 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./overloads_definitions.py:16:0: At least two overload signatures are required [invalid_overload] +./overloads_definitions.py:28:0: Overloaded function is missing an implementation [invalid_overload] +./overloads_definitions.py:59:4: Overloaded function is missing an implementation [invalid_overload] +./overloads_definitions.py:81:4: Overload implementation has incompatible @staticmethod/@classmethod decorator [invalid_overload] +./overloads_definitions.py:86:4: @staticmethod/@classmethod usage must be consistent across overloads [invalid_overload] +./overloads_definitions.py:124:4: @final should be applied only to the overload implementation [invalid_final] +./overloads_definitions.py:139:4: @final should be applied only to the overload implementation [invalid_final] +./overloads_definitions.py:144:4: @final should be applied only to the overload implementation [invalid_final] +./overloads_definitions.py:186:4: Cannot override final attribute final_method [incompatible_override] +./overloads_definitions.py:203:4: Method does not override any base method [override_does_not_override] +./overloads_definitions.py:228:4: @override decorator in invalid location [invalid_override_decorator] +""" diff --git a/conformance/results/pycroscope/overloads_definitions_stub.toml b/conformance/results/pycroscope/overloads_definitions_stub.toml new file mode 100644 index 000000000..5e2d111cb --- /dev/null +++ b/conformance/results/pycroscope/overloads_definitions_stub.toml @@ -0,0 +1,17 @@ +conformant = "Unsupported" +notes = """ +Does not support checking stubs. +""" +conformance_automated = "Fail" +errors_diff = """ +Lines 13, 14: Expected error (tag 'func1') +Lines 32, 33, 37: Expected error (tag 'func5') +Lines 39, 41, 44: Expected error (tag 'func6') +Lines 67, 69, 71, 72, 73: Expected error (tag 'invalid_final') +Lines 80, 82, 84, 85, 86: Expected error (tag 'invalid_final_2') +Lines 102, 107, 108, 111, 113: Expected error (tag 'override-final') +Lines 120, 121, 122: Expected error (tag 'bad_override') +Lines 143, 146, 147, 149: Expected error (tag 'override_impl') +""" +output = """ +""" diff --git a/conformance/results/pycroscope/overloads_evaluation.toml b/conformance/results/pycroscope/overloads_evaluation.toml new file mode 100644 index 000000000..f04831ec5 --- /dev/null +++ b/conformance/results/pycroscope/overloads_evaluation.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./overloads_evaluation.py:38:0: Cannot call overloaded function [incompatible_call] +./overloads_evaluation.py:46:0: Cannot call overloaded function [incompatible_argument] +./overloads_evaluation.py:51:0: Cannot call overloaded function [incompatible_argument] +./overloads_evaluation.py:116:4: Cannot call overloaded function [incompatible_argument] +""" diff --git a/conformance/results/pycroscope/protocols_class_objects.toml b/conformance/results/pycroscope/protocols_class_objects.toml new file mode 100644 index 000000000..0df48dfc7 --- /dev/null +++ b/conformance/results/pycroscope/protocols_class_objects.toml @@ -0,0 +1,17 @@ +conformant = "Partial" +notes = """ +Abstract `type[Proto]` still allows protocol class objects in some paths. +""" +conformance_automated = "Fail" +errors_diff = """ +Line 29: Expected 1 errors +Line 34: Expected 1 errors +Line 107: Expected 1 errors +""" +output = """ +./protocols_class_objects.py:58:0: Incompatible assignment: expected ./protocols_class_objects.py.ProtoA1, got [incompatible_assignment] +./protocols_class_objects.py:74:0: Incompatible assignment: expected ./protocols_class_objects.py.ProtoB1, got [incompatible_assignment] +./protocols_class_objects.py:104:0: Incompatible assignment: expected ./protocols_class_objects.py.ProtoC1, got [incompatible_assignment] +./protocols_class_objects.py:106:0: Incompatible assignment: expected ./protocols_class_objects.py.ProtoC1, got [incompatible_assignment] +./protocols_class_objects.py:108:0: Incompatible assignment: expected ./protocols_class_objects.py.ProtoC1, got [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/protocols_definition.toml b/conformance/results/pycroscope/protocols_definition.toml new file mode 100644 index 000000000..ee40e33ff --- /dev/null +++ b/conformance/results/pycroscope/protocols_definition.toml @@ -0,0 +1,28 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./protocols_definition.py:30:10: Incompatible argument type for things: expected collections.abc.Iterable[./protocols_definition.py.SupportsClose] but got Literal[[1]] [incompatible_argument] +./protocols_definition.py:67:8: Protocol members cannot be defined via assignment to self [invalid_protocol] +./protocols_definition.py:114:0: Incompatible assignment: expected ./protocols_definition.py.Template2, got ./protocols_definition.py.Concrete2_Bad1 [incompatible_assignment] +./protocols_definition.py:115:0: Incompatible assignment: expected ./protocols_definition.py.Template2, got ./protocols_definition.py.Concrete2_Bad2 [incompatible_assignment] +./protocols_definition.py:116:0: Incompatible assignment: expected ./protocols_definition.py.Template2, got ./protocols_definition.py.Concrete2_Bad3 [incompatible_assignment] +./protocols_definition.py:117:0: Incompatible assignment: expected ./protocols_definition.py.Template2, got ./protocols_definition.py.Concrete2_Bad4 [incompatible_assignment] +./protocols_definition.py:156:0: Incompatible assignment: expected ./protocols_definition.py.Template3, got ./protocols_definition.py.Concrete3_Bad1 [incompatible_assignment] +./protocols_definition.py:157:0: Incompatible assignment: expected ./protocols_definition.py.Template3, got ./protocols_definition.py.Concrete3_Bad2 [incompatible_assignment] +./protocols_definition.py:158:0: Incompatible assignment: expected ./protocols_definition.py.Template3, got ./protocols_definition.py.Concrete3_Bad3 [incompatible_assignment] +./protocols_definition.py:159:0: Incompatible assignment: expected ./protocols_definition.py.Template3, got ./protocols_definition.py.Concrete3_Bad4 [incompatible_assignment] +./protocols_definition.py:160:0: Incompatible assignment: expected ./protocols_definition.py.Template3, got ./protocols_definition.py.Concrete3_Bad5 [incompatible_assignment] +./protocols_definition.py:218:0: Incompatible assignment: expected ./protocols_definition.py.Template4, got ./protocols_definition.py.Concrete4_Bad1 [incompatible_assignment] +./protocols_definition.py:219:0: Incompatible assignment: expected ./protocols_definition.py.Template4, got ./protocols_definition.py.Concrete4_Bad2 [incompatible_assignment] +./protocols_definition.py:285:0: Incompatible assignment: expected ./protocols_definition.py.Template5, got ./protocols_definition.py.Concrete5_Bad1 [incompatible_assignment] +./protocols_definition.py:286:0: Incompatible assignment: expected ./protocols_definition.py.Template5, got ./protocols_definition.py.Concrete5_Bad2 [incompatible_assignment] +./protocols_definition.py:287:0: Incompatible assignment: expected ./protocols_definition.py.Template5, got ./protocols_definition.py.Concrete5_Bad3 [incompatible_assignment] +./protocols_definition.py:288:0: Incompatible assignment: expected ./protocols_definition.py.Template5, got ./protocols_definition.py.Concrete5_Bad4 [incompatible_assignment] +./protocols_definition.py:289:0: Incompatible assignment: expected ./protocols_definition.py.Template5, got ./protocols_definition.py.Concrete5_Bad5 [incompatible_assignment] +./protocols_definition.py:339:0: Incompatible assignment: expected ./protocols_definition.py.Template6, got ./protocols_definition.py.Concrete6_Bad1 [incompatible_assignment] +./protocols_definition.py:340:0: Incompatible assignment: expected ./protocols_definition.py.Template6, got ./protocols_definition.py.Concrete6_Bad2 [incompatible_assignment] +./protocols_definition.py:341:0: Incompatible assignment: expected ./protocols_definition.py.Template6, got ./protocols_definition.py.Concrete6_Bad3 [incompatible_assignment] +./protocols_definition.py:369:0: Incompatible assignment: expected ./protocols_definition.py.Template7, got ./protocols_definition.py.Concrete7_Bad1 [incompatible_assignment] +./protocols_definition.py:370:0: Incompatible assignment: expected ./protocols_definition.py.Template7, got ./protocols_definition.py.Concrete7_Bad2 [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/protocols_explicit.toml b/conformance/results/pycroscope/protocols_explicit.toml new file mode 100644 index 000000000..e0bf74a47 --- /dev/null +++ b/conformance/results/pycroscope/protocols_explicit.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./protocols_explicit.py:27:15: Call to abstract protocol member via super() has no default implementation [bad_super_call] +./protocols_explicit.py:56:8: Incompatible types in assignment to attribute 'rgb': expected tuple[int, int, int], got tuple[int, int, str] [incompatible_assignment] +./protocols_explicit.py:60:4: Cannot instantiate abstract class Point [incompatible_call] +./protocols_explicit.py:89:5: Cannot instantiate abstract class Concrete1 [incompatible_call] +./protocols_explicit.py:134:5: Cannot instantiate abstract class Concrete5 [incompatible_call] +./protocols_explicit.py:164:6: Cannot instantiate abstract class Concrete7A [incompatible_call] +""" diff --git a/conformance/results/pycroscope/protocols_generic.toml b/conformance/results/pycroscope/protocols_generic.toml new file mode 100644 index 000000000..5986ddd50 --- /dev/null +++ b/conformance/results/pycroscope/protocols_generic.toml @@ -0,0 +1,20 @@ +conformant = "Partial" +notes = """ +Treats global object as a literal. +""" +conformance_automated = "Fail" +errors_diff = """ +Line 107: Unexpected errors ['./protocols_generic.py:107:12: Literal[] is not equivalent to protocols_generic.ConcreteHasParent'] +""" +output = """ +./protocols_generic.py:40:0: Incompatible assignment: expected protocols_generic.Proto1[int, str], got protocols_generic.Concrete1 [incompatible_assignment] +./protocols_generic.py:44:0: Protocol type parameter shorthand cannot be combined with Generic [invalid_base] +./protocols_generic.py:56:4: Incompatible assignment: expected protocols_generic.Box[int], got protocols_generic.Box[float | int] [incompatible_assignment] +./protocols_generic.py:66:4: Incompatible assignment: expected protocols_generic.Sender[float | int], got protocols_generic.Sender[int] [incompatible_assignment] +./protocols_generic.py:74:4: Incompatible assignment: expected protocols_generic.AttrProto[float | int], got protocols_generic.AttrProto[int] [incompatible_assignment] +./protocols_generic.py:75:4: Incompatible assignment: expected protocols_generic.AttrProto[int], got protocols_generic.AttrProto[float | int] [incompatible_assignment] +./protocols_generic.py:107:12: Literal[] is not equivalent to protocols_generic.ConcreteHasParent +./protocols_generic.py:133:0: Incompatible assignment: expected protocols_generic.HasParentProperty, got protocols_generic.InvalidParentProperty [incompatible_assignment] +./protocols_generic.py:153:0: Incompatible assignment: expected protocols_generic.HasMethod, got protocols_generic.InvalidHasMethod [incompatible_assignment] +./protocols_generic.py:185:0: Incompatible assignment: expected protocols_generic.HasGreaterThan, got protocols_generic.InvalidGreaterThan [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/protocols_merging.toml b/conformance/results/pycroscope/protocols_merging.toml new file mode 100644 index 000000000..78edb0b62 --- /dev/null +++ b/conformance/results/pycroscope/protocols_merging.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./protocols_merging.py:52:0: Incompatible assignment: expected ./protocols_merging.py.SizedAndClosable1, got ./protocols_merging.py.SCConcrete2 [incompatible_assignment] +./protocols_merging.py:53:0: Incompatible assignment: expected ./protocols_merging.py.SizedAndClosable2, got ./protocols_merging.py.SCConcrete2 [incompatible_assignment] +./protocols_merging.py:54:0: Incompatible assignment: expected ./protocols_merging.py.SizedAndClosable3, got ./protocols_merging.py.SCConcrete2 [incompatible_assignment] +./protocols_merging.py:67:15: Protocols can only inherit from protocol bases [invalid_base] +./protocols_merging.py:82:4: Cannot instantiate abstract class SizedAndClosable4 [incompatible_call] +./protocols_merging.py:83:0: Incompatible assignment: expected ./protocols_merging.py.SizedAndClosable4, got ./protocols_merging.py.SCConcrete1 [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/protocols_modules.toml b/conformance/results/pycroscope/protocols_modules.toml new file mode 100644 index 000000000..21a190037 --- /dev/null +++ b/conformance/results/pycroscope/protocols_modules.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./protocols_modules.py:26:0: Incompatible assignment: expected protocols_modules.Options2, got module '_protocols_modules1' [incompatible_assignment] +./protocols_modules.py:48:0: Incompatible assignment: expected protocols_modules.Reporter2, got module '_protocols_modules2' [incompatible_assignment] +./protocols_modules.py:49:0: Incompatible assignment: expected protocols_modules.Reporter3, got module '_protocols_modules2' [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/protocols_recursive.toml b/conformance/results/pycroscope/protocols_recursive.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/pycroscope/protocols_recursive.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pycroscope/protocols_runtime_checkable.toml b/conformance/results/pycroscope/protocols_runtime_checkable.toml new file mode 100644 index 000000000..adc077e7e --- /dev/null +++ b/conformance/results/pycroscope/protocols_runtime_checkable.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./protocols_runtime_checkable.py:23:21: Second argument to "isinstance" cannot be a protocol that is not @runtime_checkable [incompatible_argument] +./protocols_runtime_checkable.py:55:21: Second argument to "issubclass" cannot be a runtime-checkable protocol with non-method members [incompatible_argument] +./protocols_runtime_checkable.py:61:21: Second argument to "issubclass" cannot be a runtime-checkable protocol with non-method members [incompatible_argument] +./protocols_runtime_checkable.py:88:18: First argument to "isinstance" has unsafe overlap between 'Concrete3A' and protocol 'Proto3' [incompatible_argument] +./protocols_runtime_checkable.py:91:18: First argument to "isinstance" has unsafe overlap between 'Concrete3B' and protocol 'Proto3' [incompatible_argument] +./protocols_runtime_checkable.py:94:18: First argument to "issubclass" has unsafe overlap between 'Concrete3A' and protocol 'Proto3' [incompatible_argument] +""" diff --git a/conformance/results/pycroscope/protocols_self.toml b/conformance/results/pycroscope/protocols_self.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/pycroscope/protocols_self.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pycroscope/protocols_subtyping.toml b/conformance/results/pycroscope/protocols_subtyping.toml new file mode 100644 index 000000000..3e0ba0a35 --- /dev/null +++ b/conformance/results/pycroscope/protocols_subtyping.toml @@ -0,0 +1,12 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./protocols_subtyping.py:16:5: Cannot instantiate protocol class Proto1 [incompatible_call] +./protocols_subtyping.py:38:4: Incompatible assignment: expected ./protocols_subtyping.py.Concrete2, got ./protocols_subtyping.py.Proto2 [incompatible_assignment] +./protocols_subtyping.py:55:4: Incompatible assignment: expected ./protocols_subtyping.py.Proto3, got ./protocols_subtyping.py.Proto2 [incompatible_assignment] +./protocols_subtyping.py:79:4: Incompatible assignment: expected ./protocols_subtyping.py.Proto4[int, float | int], got ./protocols_subtyping.py.Proto5[int] [incompatible_assignment] +./protocols_subtyping.py:80:4: Incompatible assignment: expected ./protocols_subtyping.py.Proto5[float | int], got ./protocols_subtyping.py.Proto4[int, int] [incompatible_assignment] +./protocols_subtyping.py:102:4: Incompatible assignment: expected ./protocols_subtyping.py.Proto7[int, float | int], got ./protocols_subtyping.py.Proto6[float | int, float | int] [incompatible_assignment] +./protocols_subtyping.py:103:4: Incompatible assignment: expected ./protocols_subtyping.py.Proto7[float | int, object], got ./protocols_subtyping.py.Proto6[float | int, float | int] [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/protocols_variance.toml b/conformance/results/pycroscope/protocols_variance.toml new file mode 100644 index 000000000..43efcf3a7 --- /dev/null +++ b/conformance/results/pycroscope/protocols_variance.toml @@ -0,0 +1,12 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./protocols_variance.py:22:0: T1 should be covariant [invalid_protocol] +./protocols_variance.py:41:0: T3 should be contravariant [invalid_protocol] +./protocols_variance.py:57:0: T1 should be contravariant [invalid_protocol] +./protocols_variance.py:62:0: T1_co should be contravariant [invalid_protocol] +./protocols_variance.py:67:0: T1 should be covariant [invalid_protocol] +./protocols_variance.py:72:0: T1_contra should be covariant [invalid_protocol] +./protocols_variance.py:105:0: T1 should be covariant [invalid_protocol] +""" diff --git a/conformance/results/pycroscope/qualifiers_annotated.toml b/conformance/results/pycroscope/qualifiers_annotated.toml new file mode 100644 index 000000000..13fd7743f --- /dev/null +++ b/conformance/results/pycroscope/qualifiers_annotated.toml @@ -0,0 +1,32 @@ +conformant = "Partial" +notes = """ +Fails to reject various weird annotations. +False positive on lambda in `Annotated`. +""" +conformance_automated = "Fail" +errors_diff = """ +Line 42: Expected 1 errors +Line 43: Expected 1 errors +Line 44: Expected 1 errors +Line 49: Expected 1 errors +Line 88: Expected 1 errors +Line 55: Unexpected errors ['./qualifiers_annotated.py:55:46: Type parameter is not valid in this annotation context [invalid_annotation]'] +""" +output = """ +./qualifiers_annotated.py:38:6: Invalid type annotation [, ] [invalid_annotation] +./qualifiers_annotated.py:39:6: Invalid type annotation ((, ),) [invalid_annotation] +./qualifiers_annotated.py:40:6: Unrecognized annotation [invalid_annotation] +./qualifiers_annotated.py:41:6: Invalid type annotation {'a': 'b'} [invalid_annotation] +./qualifiers_annotated.py:45:16: Undefined name: var1 [undefined_name] +./qualifiers_annotated.py:46:6: Invalid type annotation True [invalid_annotation] +./qualifiers_annotated.py:47:7: Invalid type annotation 1 [invalid_annotation] +./qualifiers_annotated.py:48:17: Annotated[type 'list', (<+list is_truthy None> == NullConstraint())] is always True because it does not provide __bool__ [type_always_true] +./qualifiers_annotated.py:55:46: Type parameter is not valid in this annotation context [invalid_annotation] +./qualifiers_annotated.py:59:7: Annotated[] requires at least two arguments [invalid_annotation] +./qualifiers_annotated.py:71:0: Incompatible assignment: expected type, got Literal[typing.Annotated[int, '']] [incompatible_assignment] +./qualifiers_annotated.py:72:0: Incompatible assignment: expected type, got TypeForm[.SmallInt] (synthetic from Literal[typing.Annotated[int, '']]) [incompatible_assignment] +./qualifiers_annotated.py:79:6: Incompatible argument type for x: expected type[~T@./qualifiers_annotated.py.func4..func4] but got Literal[typing.Annotated[str, '']] [incompatible_argument] +./qualifiers_annotated.py:80:6: Incompatible argument type for x: expected type[~T@./qualifiers_annotated.py.func4..func4] but got TypeForm[.SmallInt] (synthetic from Literal[typing.Annotated[int, '']]) [incompatible_argument] +./qualifiers_annotated.py:86:0: Annotated cannot be called [not_callable] +./qualifiers_annotated.py:87:0: Annotated cannot be called [not_callable] +""" diff --git a/conformance/results/pycroscope/qualifiers_final_annotation.toml b/conformance/results/pycroscope/qualifiers_final_annotation.toml new file mode 100644 index 000000000..0784a273e --- /dev/null +++ b/conformance/results/pycroscope/qualifiers_final_annotation.toml @@ -0,0 +1,35 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./qualifiers_final_annotation.py:16:6: Final annotation without assignment requires an explicit type [invalid_qualifier] +./qualifiers_final_annotation.py:18:6: Invalid type annotation (, ) [invalid_annotation] +./qualifiers_final_annotation.py:34:9: Final annotation without assignment requires an explicit type [invalid_qualifier] +./qualifiers_final_annotation.py:34:4: Final class attributes without initializers must be assigned in __init__ [invalid_qualifier] +./qualifiers_final_annotation.py:38:4: Final class attributes without initializers must be assigned in __init__ [invalid_qualifier] +./qualifiers_final_annotation.py:54:8: Cannot assign to final name ID5 [incompatible_assignment] +./qualifiers_final_annotation.py:62:18: Final instance attributes may be declared only in __init__ [invalid_qualifier] +./qualifiers_final_annotation.py:63:18: Final instance attributes may be declared only in __init__ [invalid_qualifier] +./qualifiers_final_annotation.py:65:8: Cannot assign to final name ID7 [incompatible_assignment] +./qualifiers_final_annotation.py:67:8: Cannot assign to final name ID7 [incompatible_assignment] +./qualifiers_final_annotation.py:71:0: Cannot assign to final name RATE [incompatible_assignment] +./qualifiers_final_annotation.py:81:0: Cannot assign to final name DEFAULT_ID [incompatible_assignment] +./qualifiers_final_annotation.py:94:4: Cannot override final attribute BORDER_WIDTH [incompatible_override] +./qualifiers_final_annotation.py:107:12: Final cannot be combined with ClassVar [invalid_qualifier] +./qualifiers_final_annotation.py:108:12: Final cannot be combined with ClassVar [invalid_qualifier] +./qualifiers_final_annotation.py:118:3: Unrecognized annotation typing.Final[] [invalid_annotation] +./qualifiers_final_annotation.py:121:13: Unexpected Final annotation [invalid_qualifier] +./qualifiers_final_annotation.py:131:7: Unexpected Final annotation [invalid_qualifier] +./qualifiers_final_annotation.py:136:4: Final class attributes without initializers must be assigned in __init__ [invalid_qualifier] +./qualifiers_final_annotation.py:148:0: In call to pycroscope.signature.N: Missing required argument 'x' [incompatible_call] +./qualifiers_final_annotation.py:149:4: Incompatible argument type for x: expected int but got Literal[''] [incompatible_argument] +./qualifiers_final_annotation.py:149:10: Incompatible argument type for y: expected int but got Literal[''] [incompatible_argument] +./qualifiers_final_annotation.py:155:4: Cannot assign to final name ID1 [incompatible_assignment] +./qualifiers_final_annotation.py:159:4: Cannot assign to final name x [incompatible_assignment] +./qualifiers_final_annotation.py:161:9: Cannot assign to final name x [incompatible_assignment] +./qualifiers_final_annotation.py:163:8: Cannot assign to final name x [incompatible_assignment] +./qualifiers_final_annotation.py:166:29: Cannot assign to final name x [incompatible_assignment] +./qualifiers_final_annotation.py:169:8: Cannot assign to final name x [incompatible_assignment] +./qualifiers_final_annotation.py:180:0: Cannot assign to final name TEN [incompatible_assignment] +./qualifiers_final_annotation.py:184:0: Cannot assign to final name PI [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/qualifiers_final_decorator.toml b/conformance/results/pycroscope/qualifiers_final_decorator.toml new file mode 100644 index 000000000..fc2652a74 --- /dev/null +++ b/conformance/results/pycroscope/qualifiers_final_decorator.toml @@ -0,0 +1,15 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./qualifiers_final_decorator.py:21:15: Cannot inherit from final class [invalid_base] +./qualifiers_final_decorator.py:56:4: Cannot override final attribute method1 [incompatible_override] +./qualifiers_final_decorator.py:60:4: Cannot override final attribute method2 [incompatible_override] +./qualifiers_final_decorator.py:64:4: Cannot override final attribute method3 [incompatible_override] +./qualifiers_final_decorator.py:75:4: Cannot override final attribute method4 [incompatible_override] +./qualifiers_final_decorator.py:86:4: @final should be applied only to the overload implementation [invalid_final] +./qualifiers_final_decorator.py:89:4: Cannot override final attribute method [incompatible_override] +./qualifiers_final_decorator.py:102:4: Cannot override final attribute method [incompatible_override] +./qualifiers_final_decorator.py:118:4: Cannot override final attribute method [incompatible_override] +./qualifiers_final_decorator.py:126:0: @final is not allowed on non-method functions [invalid_final] +""" diff --git a/conformance/results/pycroscope/specialtypes_any.toml b/conformance/results/pycroscope/specialtypes_any.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/pycroscope/specialtypes_any.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pycroscope/specialtypes_never.toml b/conformance/results/pycroscope/specialtypes_never.toml new file mode 100644 index 000000000..47dfa3ac0 --- /dev/null +++ b/conformance/results/pycroscope/specialtypes_never.toml @@ -0,0 +1,17 @@ +conformant = "Partial" +notes = """ +Does not enforce invariance in some contexts +Does not allow `Any` to be assigned to `Never` +""" +conformance_automated = "Fail" +errors_diff = """ +Line 104: Expected 1 errors +Line 51: Unexpected errors ['./specialtypes_never.py:51:4: Incompatible return type: expected list[Never], got Literal[[]] [incompatible_return_value]'] +Line 84: Unexpected errors ['./specialtypes_never.py:84:4: Incompatible assignment: expected Never, got Any[explicit] [incompatible_assignment]'] +""" +output = """ +./specialtypes_never.py:19:0: Function is annotated as NoReturn but may return [no_return_may_return] +./specialtypes_never.py:51:4: Incompatible return type: expected list[Never], got Literal[[]] [incompatible_return_value] +./specialtypes_never.py:84:4: Incompatible assignment: expected Never, got Any[explicit] [incompatible_assignment] +./specialtypes_never.py:85:4: Incompatible assignment: expected list[int], got list[Never] [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/specialtypes_none.toml b/conformance/results/pycroscope/specialtypes_none.toml new file mode 100644 index 000000000..f3684f779 --- /dev/null +++ b/conformance/results/pycroscope/specialtypes_none.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./specialtypes_none.py:21:6: Incompatible argument type for val1: expected None but got type 'NoneType' [incompatible_argument] +./specialtypes_none.py:27:0: Incompatible assignment: expected collections.abc.Iterable, got None [incompatible_assignment] +./specialtypes_none.py:41:6: Incompatible argument type for val1: expected type[NoneType] but got None [incompatible_argument] +""" diff --git a/conformance/results/pycroscope/specialtypes_promotions.toml b/conformance/results/pycroscope/specialtypes_promotions.toml new file mode 100644 index 000000000..8e32e247b --- /dev/null +++ b/conformance/results/pycroscope/specialtypes_promotions.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./specialtypes_promotions.py:13:4: float has no attribute 'numerator' [undefined_attribute] +""" diff --git a/conformance/results/pycroscope/specialtypes_sentinels.toml b/conformance/results/pycroscope/specialtypes_sentinels.toml new file mode 100644 index 000000000..77f5d331c --- /dev/null +++ b/conformance/results/pycroscope/specialtypes_sentinels.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./specialtypes_sentinels.py:14:10: Default value for argument x incompatible with declared type int [incompatible_default] +./specialtypes_sentinels.py:36:6: Incompatible argument type for x: expected int | Literal[, SPECIAL] but got Cls.IN_CLASS [incompatible_argument] +./specialtypes_sentinels.py:39:6: Incompatible argument type for x: expected int | Literal[Cls.IN_CLASS] but got [incompatible_argument] +""" diff --git a/conformance/results/pycroscope/specialtypes_type.toml b/conformance/results/pycroscope/specialtypes_type.toml new file mode 100644 index 000000000..3bfe1708c --- /dev/null +++ b/conformance/results/pycroscope/specialtypes_type.toml @@ -0,0 +1,14 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./specialtypes_type.py:56:6: Incompatible argument type for user_class: expected type[./specialtypes_type.py.BasicUser] | type[./specialtypes_type.py.ProUser] but got [incompatible_argument] +./specialtypes_type.py:70:6: Incompatible argument type for x: expected type[~T@./specialtypes_type.py.func5..func5] but got Literal[typing.Callable] [incompatible_argument] +./specialtypes_type.py:76:11: Type[] requires a single argument [invalid_annotation] +./specialtypes_type.py:117:4: type[object] has no attribute 'unknown' [undefined_attribute] +./specialtypes_type.py:120:4: type[object] has no attribute 'unknown' [undefined_attribute] +./specialtypes_type.py:143:0: Literal[typing.Type] has no attribute 'unknown' [undefined_attribute] +./specialtypes_type.py:144:0: Literal[typing.Type[typing.Any]] has no attribute 'unknown' [undefined_attribute] +./specialtypes_type.py:145:0: type 'type' has no attribute 'unknown' [undefined_attribute] +./specialtypes_type.py:146:0: Literal[type[typing.Any]] has no attribute 'unknown' [undefined_attribute] +""" diff --git a/conformance/results/pycroscope/tuples_type_compat.toml b/conformance/results/pycroscope/tuples_type_compat.toml new file mode 100644 index 000000000..cefaf21ac --- /dev/null +++ b/conformance/results/pycroscope/tuples_type_compat.toml @@ -0,0 +1,29 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./tuples_type_compat.py:15:4: Incompatible assignment: expected tuple[int, int], got tuple[float | int, complex | float | int] [incompatible_assignment] +./tuples_type_compat.py:29:4: Incompatible assignment: expected tuple[int, *tuple[int, ...]], got tuple[int, ...] [incompatible_assignment] +./tuples_type_compat.py:32:4: Incompatible assignment: expected tuple[int], got tuple[int, *tuple[int, ...]] [incompatible_assignment] +./tuples_type_compat.py:33:4: Incompatible assignment: expected tuple[int], got tuple[int, ...] [incompatible_assignment] +./tuples_type_compat.py:43:4: Incompatible assignment: expected tuple[int], got tuple[int, ...] [incompatible_assignment] +./tuples_type_compat.py:62:4: Incompatible assignment: expected tuple[int, int], got tuple[int, ...] [incompatible_assignment] +./tuples_type_compat.py:76:20: tuple[int] is not equivalent to .Func5Input = tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int] +./tuples_type_compat.py:81:20: tuple[str, str] | tuple[int, int] is not equivalent to .Func5Input = tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int] +./tuples_type_compat.py:86:20: tuple[int, str, int] is not equivalent to .Func5Input = tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int] +./tuples_type_compat.py:102:24: tuple[int] is not equivalent to .Func6Input = tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int] +./tuples_type_compat.py:107:24: tuple[str, str] | tuple[int, int] is not equivalent to .Func6Input = tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int] +./tuples_type_compat.py:112:24: tuple[int, str, int] is not equivalent to .Func6Input = tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int] +./tuples_type_compat.py:126:24: .Func7Input = tuple[int | str, int | str] is not equivalent to tuple[int | str, str] +./tuples_type_compat.py:129:24: .Func7Input = tuple[int | str, int | str] is not equivalent to tuple[int | str, int] +./tuples_type_compat.py:157:0: Incompatible assignment: expected tuple[int, str], got Literal[(1, '', '')] [incompatible_assignment] +./tuples_type_compat.py:162:0: Incompatible assignment: expected tuple[int, *tuple[str, ...]], got Literal[(1, 1, '')] [incompatible_assignment] +./tuples_type_compat.py:163:0: Incompatible assignment: expected tuple[int, *tuple[str, ...]], got Literal[(1, '', 1)] [incompatible_assignment] +./tuples_type_compat.py:169:0: Incompatible assignment: expected tuple[int, *tuple[str, ...], int], got Literal[(1, '', '')] [incompatible_assignment] +./tuples_type_compat.py:170:0: Incompatible assignment: expected tuple[int, *tuple[str, ...], int], got Literal[(1, '', '', 1.2)] [incompatible_assignment] +./tuples_type_compat.py:175:0: Incompatible assignment: expected tuple[*tuple[str, ...], int], got Literal[(1, '', 1)] [incompatible_assignment] +./tuples_type_compat.py:176:0: Incompatible assignment: expected tuple[*tuple[str, ...], int], got Literal[('', '', 1.2)] [incompatible_assignment] +./tuples_type_compat.py:181:4: Incompatible assignment: expected tuple[str, str, int], got tuple[str, str] [incompatible_assignment] +./tuples_type_compat.py:184:4: Incompatible assignment: expected tuple[str, str, str, *tuple[str, ...]], got tuple[str, str] [incompatible_assignment] +./tuples_type_compat.py:188:4: Incompatible assignment: expected tuple[*tuple[str, ...], str, str, str], got tuple[str, str] [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/tuples_type_form.toml b/conformance/results/pycroscope/tuples_type_form.toml new file mode 100644 index 000000000..021d00028 --- /dev/null +++ b/conformance/results/pycroscope/tuples_type_form.toml @@ -0,0 +1,16 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./tuples_type_form.py:12:0: Incompatible assignment: expected tuple[int], got Literal[(1, 2)] [incompatible_assignment] +./tuples_type_form.py:14:0: Incompatible assignment: expected tuple[int, int], got Literal[(1,)] [incompatible_assignment] +./tuples_type_form.py:15:0: Incompatible assignment: expected tuple[int, int], got Literal[(1, '')] [incompatible_assignment] +./tuples_type_form.py:25:0: Incompatible assignment: expected tuple[()], got Literal[(1,)] [incompatible_assignment] +./tuples_type_form.py:36:0: Incompatible assignment: expected tuple[int, ...], got Literal[(1, 2, 3, '')] [incompatible_assignment] +./tuples_type_form.py:40:5: Ellipsis can be used only in tuple[T, ...] [invalid_annotation] +./tuples_type_form.py:41:5: Ellipsis can be used only in tuple[T, ...] [invalid_annotation] +./tuples_type_form.py:42:5: Ellipsis can be used only in tuple[T, ...] [invalid_annotation] +./tuples_type_form.py:43:5: Ellipsis can be used only in tuple[T, ...] [invalid_annotation] +./tuples_type_form.py:44:5: Ellipsis can be used only in tuple[T, ...] [invalid_annotation] +./tuples_type_form.py:45:5: Ellipsis can be used only in tuple[T, ...] [invalid_annotation] +""" diff --git a/conformance/results/pycroscope/tuples_unpacked.toml b/conformance/results/pycroscope/tuples_unpacked.toml new file mode 100644 index 000000000..f7d1ae069 --- /dev/null +++ b/conformance/results/pycroscope/tuples_unpacked.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./tuples_unpacked.py:40:4: Only one unbounded tuple can be used inside a tuple type [invalid_annotation] +./tuples_unpacked.py:41:4: Only one unbounded tuple can be used inside a tuple type [invalid_annotation] +./tuples_unpacked.py:51:8: Only one unbounded tuple can be used inside a tuple type [invalid_annotation] +./tuples_unpacked.py:59:5: Only one unbounded tuple can be used inside a tuple type [invalid_annotation] +./tuples_unpacked.py:60:5: Only one unbounded tuple can be used inside a tuple type [invalid_annotation] +""" diff --git a/conformance/results/pycroscope/typeddicts_alt_syntax.toml b/conformance/results/pycroscope/typeddicts_alt_syntax.toml new file mode 100644 index 000000000..a91070ecd --- /dev/null +++ b/conformance/results/pycroscope/typeddicts_alt_syntax.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./typeddicts_alt_syntax.py:23:43: TypedDict fields argument must be a dictionary literal [incompatible_call] +./typeddicts_alt_syntax.py:27:44: TypedDict field names must be string literals [incompatible_call] +./typeddicts_alt_syntax.py:31:26: TypedDict named 'WrongName' must be assigned to a variable with the same name [must_have_same_name] +./typeddicts_alt_syntax.py:35:71: TypedDict takes either a dict or keyword arguments, but not both [incompatible_call] +./typeddicts_alt_syntax.py:45:0: Incompatible assignment: expected TypedDict({"name": str, "year": int}), got Literal[{'name': 'Blade Runner', 'year': ''}] [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/typeddicts_class_syntax.toml b/conformance/results/pycroscope/typeddicts_class_syntax.toml new file mode 100644 index 000000000..049715347 --- /dev/null +++ b/conformance/results/pycroscope/typeddicts_class_syntax.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./typeddicts_class_syntax.py:30:4: Methods are not allowed in TypedDict definitions [invalid_typeddict] +./typeddicts_class_syntax.py:35:4: Methods are not allowed in TypedDict definitions [invalid_typeddict] +./typeddicts_class_syntax.py:40:4: Methods are not allowed in TypedDict definitions [invalid_typeddict] +./typeddicts_class_syntax.py:49:31: TypedDict definitions cannot specify a metaclass [invalid_typeddict] +./typeddicts_class_syntax.py:54:31: Unexpected keyword argument 'other' in TypedDict definition [invalid_typeddict] +./typeddicts_class_syntax.py:69:0: Got an unexpected keyword argument 'z' [incompatible_call] +""" diff --git a/conformance/results/pycroscope/typeddicts_extra_items.toml b/conformance/results/pycroscope/typeddicts_extra_items.toml new file mode 100644 index 000000000..fa51d53a8 --- /dev/null +++ b/conformance/results/pycroscope/typeddicts_extra_items.toml @@ -0,0 +1,33 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./typeddicts_extra_items.py:15:0: Incompatible assignment: expected TypedDict({"name": str, "__extra_items__": bool}, closed=True), got Literal[{'name': 'Blade Runner', 'year': 1982}] [incompatible_assignment] +./typeddicts_extra_items.py:22:0: Incompatible assignment: expected TypedDict({"name": str, "__extra_items__": bool}, closed=True), got Literal[{'name': 'Blade Runner', 'year': 1982}] [incompatible_assignment] +./typeddicts_extra_items.py:39:0: Incompatible assignment: expected TypedDict({"name": str, "year": int, "__extra_items__": ReadOnly[int | None]}, closed=True), got Literal[{'name': 'Blade Runner', 'year': None}] [incompatible_assignment] +./typeddicts_extra_items.py:49:34: Argument to "closed" must be a literal True or False [invalid_typeddict] +./typeddicts_extra_items.py:67:0: Cannot set 'closed=False' when superclass is closed or has 'extra_items' [invalid_typeddict] +./typeddicts_extra_items.py:73:0: Cannot set 'closed=False' when superclass is closed or has 'extra_items' [invalid_typeddict] +./typeddicts_extra_items.py:92:4: "MovieC" is a closed TypedDict; extra key 'age' not allowed [invalid_typeddict] +./typeddicts_extra_items.py:95:4: "MovieD" is a closed TypedDict; extra key 'age' not allowed [invalid_typeddict] +./typeddicts_extra_items.py:109:0: Cannot set 'closed=True' when superclass has non-read-only 'extra_items' [invalid_typeddict] +./typeddicts_extra_items.py:114:49: 'extra_items' value cannot be 'Required[...]' [invalid_qualifier] +./typeddicts_extra_items.py:117:56: 'extra_items' value cannot be 'NotRequired[...]' [invalid_qualifier] +./typeddicts_extra_items.py:128:14: Cannot delete required TypedDict key Literal['name'] [incompatible_argument] +./typeddicts_extra_items.py:143:0: Got an unexpected keyword argument 'year' [incompatible_call] +./typeddicts_extra_items.py:174:0: Cannot change 'extra_items' type unless it is 'ReadOnly' in the superclass [invalid_typeddict] +./typeddicts_extra_items.py:185:4: Required key 'year' is not known to base TypedDict [invalid_typeddict] +./typeddicts_extra_items.py:188:4: int is not consistent with 'extra_items' type int | None [invalid_typeddict] +./typeddicts_extra_items.py:197:4: str is not assignable to 'extra_items' type int | None [invalid_typeddict] +./typeddicts_extra_items.py:215:0: Incompatible assignment: expected TypedDict({"name": str, "__extra_items__": int | None}, closed=True), got TypedDict({"name": str, "year": NotRequired[int], "__extra_items__": int | None}, closed=True) [incompatible_assignment] +./typeddicts_extra_items.py:222:0: Incompatible assignment: expected TypedDict({"name": str, "__extra_items__": int | None}, closed=True), got TypedDict({"name": str, "year": int | None, "__extra_items__": int | None}, closed=True) [incompatible_assignment] +./typeddicts_extra_items.py:242:0: Incompatible assignment: expected TypedDict({"name": str, "__extra_items__": ReadOnly[str | int]}, closed=True), got TypedDict({"name": str, "actors": list[str], "__extra_items__": int}, closed=True) [incompatible_assignment] +./typeddicts_extra_items.py:256:0: Incompatible assignment: expected TypedDict({"name": str, "__extra_items__": int}, closed=True), got TypedDict({"name": str, "__extra_items__": str}, closed=True) [incompatible_assignment] +./typeddicts_extra_items.py:257:0: Incompatible assignment: expected TypedDict({"name": str, "__extra_items__": str}, closed=True), got TypedDict({"name": str, "__extra_items__": int}, closed=True) [incompatible_assignment] +./typeddicts_extra_items.py:268:0: Incompatible assignment: expected TypedDict({"name": str, "__extra_items__": int}, closed=True), got TypedDict({"name": str}) [incompatible_assignment] +./typeddicts_extra_items.py:278:0: Got an unexpected keyword argument 'year' [incompatible_call] +./typeddicts_extra_items.py:285:0: Incompatible argument type for %kwargs: expected dict[str, int] but got [incompatible_argument] +./typeddicts_extra_items.py:293:0: Incompatible argument type for %kwargs: expected dict[str, Never] but got [incompatible_argument] +./typeddicts_extra_items.py:303:0: Incompatible assignment: expected collections.abc.Mapping[str, int], got TypedDict({"name": str, "__extra_items__": int}, closed=True) [incompatible_assignment] +./typeddicts_extra_items.py:352:4: Incompatible assignment: expected TypedDict({"__extra_items__": int}, closed=True), got dict[str, int] [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/typeddicts_final.toml b/conformance/results/pycroscope/typeddicts_final.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/pycroscope/typeddicts_final.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pycroscope/typeddicts_inheritance.toml b/conformance/results/pycroscope/typeddicts_inheritance.toml new file mode 100644 index 000000000..6dace629a --- /dev/null +++ b/conformance/results/pycroscope/typeddicts_inheritance.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./typeddicts_inheritance.py:44:30: TypedDict classes may only inherit from TypedDict types and Generic [invalid_base] +./typeddicts_inheritance.py:55:3: Incompatible TypedDict override for key 'x' [invalid_typeddict] +./typeddicts_inheritance.py:65:0: TypedDict base classes define key 'x' with incompatible types [invalid_base] +""" diff --git a/conformance/results/pycroscope/typeddicts_operations.toml b/conformance/results/pycroscope/typeddicts_operations.toml new file mode 100644 index 000000000..20850460c --- /dev/null +++ b/conformance/results/pycroscope/typeddicts_operations.toml @@ -0,0 +1,17 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./typeddicts_operations.py:22:0: Value for key 'name' must be str, not Literal[1982] [incompatible_argument] +./typeddicts_operations.py:23:0: Value for key 'year' must be int, not Literal[''] [incompatible_argument] +./typeddicts_operations.py:24:6: Key 'other' does not exist in TypedDict({"name": str, "year": int}) [invalid_typeddict_key] +./typeddicts_operations.py:26:12: Unknown TypedDict key 'other' [invalid_typeddict_key] +./typeddicts_operations.py:28:0: Incompatible assignment: expected TypedDict({"name": str, "year": int}), got Literal[{'name': 'Blade Runner'}] [incompatible_assignment] +./typeddicts_operations.py:29:0: Incompatible assignment: expected TypedDict({"name": str, "year": int}), got Literal[{'name': 'Blade Runner', 'year': 1982.1}] [incompatible_assignment] +./typeddicts_operations.py:32:0: Incompatible assignment: expected TypedDict({"name": str, "year": int}), got Literal[{'name': '', 'year': 1900, 'other': 2}] [incompatible_assignment] +./typeddicts_operations.py:37:4: Incompatible assignment: expected TypedDict({"name": str, "year": int}), got [incompatible_assignment] +./typeddicts_operations.py:44:0: Unknown TypedDict key 'other' [invalid_typeddict_key] +./typeddicts_operations.py:47:0: Cannot call clear() on non-closed TypedDict [incompatible_call] +./typeddicts_operations.py:49:10: Cannot delete required TypedDict key Literal['name'] [incompatible_argument] +./typeddicts_operations.py:62:0: Cannot call clear() on non-closed TypedDict [incompatible_call] +""" diff --git a/conformance/results/pycroscope/typeddicts_readonly.toml b/conformance/results/pycroscope/typeddicts_readonly.toml new file mode 100644 index 000000000..51ab83000 --- /dev/null +++ b/conformance/results/pycroscope/typeddicts_readonly.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./typeddicts_readonly.py:24:3: Cannot set readonly key 'members' in TypedDict TypedDict({"name": str, "members": Readonly[list[str]]}) [readonly_typeddict] +./typeddicts_readonly.py:36:3: Cannot set readonly key 'members' in TypedDict TypedDict({"name": str, "members": Readonly[list[str]]}) [readonly_typeddict] +./typeddicts_readonly.py:50:3: Cannot set readonly key 'title' in TypedDict TypedDict({"title": Readonly[str], "year": NotRequired[Readonly[int]]}) [readonly_typeddict] +./typeddicts_readonly.py:51:3: Cannot set readonly key 'year' in TypedDict TypedDict({"title": Readonly[str], "year": NotRequired[Readonly[int]]}) [readonly_typeddict] +./typeddicts_readonly.py:60:3: Cannot set readonly key 'title' in TypedDict TypedDict({"title": Readonly[str], "year": NotRequired[Readonly[int]]}) [readonly_typeddict] +./typeddicts_readonly.py:61:3: Cannot set readonly key 'year' in TypedDict TypedDict({"title": Readonly[str], "year": NotRequired[Readonly[int]]}) [readonly_typeddict] +""" diff --git a/conformance/results/pycroscope/typeddicts_readonly_consistency.toml b/conformance/results/pycroscope/typeddicts_readonly_consistency.toml new file mode 100644 index 000000000..3fd93c951 --- /dev/null +++ b/conformance/results/pycroscope/typeddicts_readonly_consistency.toml @@ -0,0 +1,12 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./typeddicts_readonly_consistency.py:37:4: Incompatible assignment: expected TypedDict({"x": int, "y": NotRequired[str]}), got TypedDict({"x": int}) [incompatible_assignment] +./typeddicts_readonly_consistency.py:38:4: Incompatible assignment: expected TypedDict({"x": int, "y": NotRequired[str]}), got TypedDict({"x": int, "y": NotRequired[Readonly[str]]}) [incompatible_assignment] +./typeddicts_readonly_consistency.py:40:4: Incompatible assignment: expected TypedDict({"x": int, "y": NotRequired[Readonly[str]]}), got TypedDict({"x": int}) [incompatible_assignment] +./typeddicts_readonly_consistency.py:81:4: Incompatible assignment: expected TypedDict({"x": NotRequired[str]}), got TypedDict({"x": NotRequired[Readonly[str]]}) [incompatible_assignment] +./typeddicts_readonly_consistency.py:82:4: Incompatible assignment: expected TypedDict({"x": NotRequired[str]}), got TypedDict({"x": str}) [incompatible_assignment] +./typeddicts_readonly_consistency.py:84:4: Incompatible assignment: expected TypedDict({"x": str}), got TypedDict({"x": NotRequired[Readonly[str]]}) [incompatible_assignment] +./typeddicts_readonly_consistency.py:85:4: Incompatible assignment: expected TypedDict({"x": str}), got TypedDict({"x": NotRequired[str]}) [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/typeddicts_readonly_inheritance.toml b/conformance/results/pycroscope/typeddicts_readonly_inheritance.toml new file mode 100644 index 000000000..f04b52a05 --- /dev/null +++ b/conformance/results/pycroscope/typeddicts_readonly_inheritance.toml @@ -0,0 +1,16 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./typeddicts_readonly_inheritance.py:36:3: Cannot set readonly key 'name' in TypedDict TypedDict({"name": Readonly[str], "year": int}) [readonly_typeddict] +./typeddicts_readonly_inheritance.py:50:4: Incompatible TypedDict override for key 'alt' [invalid_typeddict] +./typeddicts_readonly_inheritance.py:65:0: Incompatible assignment: expected TypedDict({"name": Readonly[str]}), got Literal[{}] [incompatible_assignment] +./typeddicts_readonly_inheritance.py:82:0: Value for key 'ident' must be str, not Literal[3] [incompatible_argument] +./typeddicts_readonly_inheritance.py:83:0: Incompatible assignment: expected TypedDict({"ident": str}), got Literal[{'ident': 3}] [incompatible_assignment] +./typeddicts_readonly_inheritance.py:84:0: Incompatible assignment: expected TypedDict({"ident": str}), got Literal[{}] [incompatible_assignment] +./typeddicts_readonly_inheritance.py:94:4: Incompatible TypedDict override for key 'a' [invalid_typeddict] +./typeddicts_readonly_inheritance.py:98:4: Incompatible TypedDict override for key 'a' [invalid_typeddict] +./typeddicts_readonly_inheritance.py:106:4: Incompatible TypedDict override for key 'c' [invalid_typeddict] +./typeddicts_readonly_inheritance.py:119:0: TypedDict base classes define key 'x' with incompatible types [invalid_base] +./typeddicts_readonly_inheritance.py:132:0: TypedDict base classes define key 'x' with incompatible requiredness [invalid_base] +""" diff --git a/conformance/results/pycroscope/typeddicts_readonly_kwargs.toml b/conformance/results/pycroscope/typeddicts_readonly_kwargs.toml new file mode 100644 index 000000000..af09a4abb --- /dev/null +++ b/conformance/results/pycroscope/typeddicts_readonly_kwargs.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./typeddicts_readonly_kwargs.py:33:11: Cannot set readonly key 'key1' in TypedDict TypedDict({"key1": Readonly[int], "key2": Readonly[str]}) [readonly_typeddict] +""" diff --git a/conformance/results/pycroscope/typeddicts_readonly_update.toml b/conformance/results/pycroscope/typeddicts_readonly_update.toml new file mode 100644 index 000000000..f7e82a4ba --- /dev/null +++ b/conformance/results/pycroscope/typeddicts_readonly_update.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./typeddicts_readonly_update.py:23:0: Cannot set readonly key 'x' in TypedDict TypedDict({"x": Readonly[int], "y": int}) [readonly_typeddict] +""" diff --git a/conformance/results/pycroscope/typeddicts_required.toml b/conformance/results/pycroscope/typeddicts_required.toml new file mode 100644 index 000000000..26527f84a --- /dev/null +++ b/conformance/results/pycroscope/typeddicts_required.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./typeddicts_required.py:12:7: Unexpected Required annotation [invalid_qualifier] +./typeddicts_required.py:16:7: Unexpected NotRequired annotation [invalid_qualifier] +./typeddicts_required.py:60:16: Required[] cannot be nested [invalid_qualifier] +./typeddicts_required.py:61:7: Required[] and NotRequired[] cannot be nested [invalid_qualifier] +""" diff --git a/conformance/results/pycroscope/typeddicts_type_consistency.toml b/conformance/results/pycroscope/typeddicts_type_consistency.toml new file mode 100644 index 000000000..06f5d3185 --- /dev/null +++ b/conformance/results/pycroscope/typeddicts_type_consistency.toml @@ -0,0 +1,14 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./typeddicts_type_consistency.py:21:0: Incompatible assignment: expected TypedDict({"x": int | None}), got TypedDict({"x": int}) [incompatible_assignment] +./typeddicts_type_consistency.py:38:0: Incompatible assignment: expected TypedDict({"x": NotRequired[int]}), got TypedDict({"x": int}) [incompatible_assignment] +./typeddicts_type_consistency.py:65:0: Incompatible assignment: expected TypedDict({"x": int, "y": int}), got TypedDict({"x": int}) [incompatible_assignment] +./typeddicts_type_consistency.py:69:0: Incompatible assignment: expected TypedDict({"x": int}), got Literal[{'x': 0, 'y': 0}] [incompatible_assignment] +./typeddicts_type_consistency.py:76:0: Incompatible assignment: expected dict[str, int], got TypedDict({"x": int, "y": int}) [incompatible_assignment] +./typeddicts_type_consistency.py:77:0: Incompatible assignment: expected dict[str, object], got TypedDict({"x": int, "y": int}) [incompatible_assignment] +./typeddicts_type_consistency.py:78:0: Incompatible assignment: expected dict[Any[explicit], Any[explicit]], got TypedDict({"x": int, "y": int}) [incompatible_assignment] +./typeddicts_type_consistency.py:82:0: Incompatible assignment: expected collections.abc.Mapping[str, int], got TypedDict({"x": int, "y": int}) [incompatible_assignment] +./typeddicts_type_consistency.py:126:0: Incompatible assignment: expected TypedDict({"outer_key": TypedDict({"inner_key": TypedDict({"inner_key": str})})}), got Literal[{'outer_key': {'inner_key': {'inner_key': 1}}}] [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/typeddicts_usage.toml b/conformance/results/pycroscope/typeddicts_usage.toml new file mode 100644 index 000000000..0c836ae99 --- /dev/null +++ b/conformance/results/pycroscope/typeddicts_usage.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +./typeddicts_usage.py:23:6: Key 'director' does not exist in TypedDict({"name": str, "year": int}) [invalid_typeddict_key] +./typeddicts_usage.py:24:0: Value for key 'year' must be int, not Literal['1982'] [incompatible_argument] +./typeddicts_usage.py:28:0: Incompatible assignment: expected TypedDict({"name": str, "year": int}), got Literal[{'title': 'Blade Runner', 'year': 1982}] [incompatible_assignment] +./typeddicts_usage.py:35:21: Second argument to "isinstance" cannot be a TypedDict [incompatible_argument] +./typeddicts_usage.py:40:23: TypedDict cannot be used as a TypeVar bound [invalid_annotation] +""" diff --git a/conformance/results/pycroscope/typeforms_typeform.toml b/conformance/results/pycroscope/typeforms_typeform.toml new file mode 100644 index 000000000..01e46a0a1 --- /dev/null +++ b/conformance/results/pycroscope/typeforms_typeform.toml @@ -0,0 +1,25 @@ +conformant = "Partial" +notes = """ +Fails to reject various weird annotations +""" +conformance_automated = "Fail" +errors_diff = """ +Line 88: Expected 1 errors +""" +output = """ +./typeforms_typeform.py:23:0: Incompatible assignment: expected TypeForm[str | None], got Literal[str | int] [incompatible_assignment] +./typeforms_typeform.py:24:0: Incompatible assignment: expected TypeForm[str | None], got types.GenericAlias (partial from type 'list'[Any[inference] (partial from type 'str' | None)]) [incompatible_assignment] +./typeforms_typeform.py:59:6: Incompatible argument type for x: expected TypeForm[Any[explicit]] but got Literal['not a type'] [incompatible_argument] +./typeforms_typeform.py:67:0: Incompatible assignment: expected TypeForm[Any[explicit]], got Literal[()] [incompatible_assignment] +./typeforms_typeform.py:68:0: Incompatible assignment: expected TypeForm[Any[explicit]], got Literal[(1, 2)] [incompatible_assignment] +./typeforms_typeform.py:69:0: Incompatible assignment: expected TypeForm[Any[explicit]], got Literal[1] [incompatible_assignment] +./typeforms_typeform.py:70:0: Incompatible assignment: expected TypeForm[Any[explicit]], got Literal[typing.Self] [incompatible_assignment] +./typeforms_typeform.py:71:0: Incompatible assignment: expected TypeForm[Any[explicit]], got Literal[typing.ClassVar[int]] [incompatible_assignment] +./typeforms_typeform.py:72:0: Incompatible assignment: expected TypeForm[Any[explicit]], got Literal[typing.Final[int]] [incompatible_assignment] +./typeforms_typeform.py:73:0: Incompatible assignment: expected TypeForm[Any[explicit]], got Literal[typing.Unpack[Ts]] [incompatible_assignment] +./typeforms_typeform.py:74:0: Incompatible assignment: expected TypeForm[Any[explicit]], got Literal[typing.Optional] [incompatible_assignment] +./typeforms_typeform.py:75:0: Incompatible assignment: expected TypeForm[Any[explicit]], got Literal['int + str'] [incompatible_assignment] +./typeforms_typeform.py:86:5: Unrecognized annotation type [invalid_annotation] +./typeforms_typeform.py:98:0: Incompatible assignment: expected TypeForm[str], got TypeForm[int] [incompatible_assignment] +./typeforms_typeform.py:108:0: Incompatible assignment: expected TypeForm[str], got type[int] [incompatible_assignment] +""" diff --git a/conformance/results/pycroscope/version.toml b/conformance/results/pycroscope/version.toml new file mode 100644 index 000000000..e5d8a823f --- /dev/null +++ b/conformance/results/pycroscope/version.toml @@ -0,0 +1 @@ +version = "pycroscope 0.5.0" diff --git a/conformance/results/pyre/aliases_explicit.toml b/conformance/results/pyre/aliases_explicit.toml deleted file mode 100644 index 473b04ee3..000000000 --- a/conformance/results/pyre/aliases_explicit.toml +++ /dev/null @@ -1,48 +0,0 @@ -conformant = "Partial" -notes = """ -Incorrectly reports error for type alias defined with ParamSpec. -Incorrectly rejects some valid type aliases when used in annotations. -Incorrectly evaluates generic type alias with ParamSpec with missing type argument. -Does not report some illegal annotation forms as invalid type aliases. -Does not report invalid specialization of generic type aliases. -Incorrectly rejects import alias of `TypeAlias` when used to define type alias. -Does not report invalid specialization of already-specialized generic type alias. -""" -output = """ -aliases_explicit.py:23:0 Incompatible variable type [9]: GoodTypeAlias9 is declared to have type `TA` but is used as type `Type[typing.Callable[..., Variable[$synthetic_attribute_resolution_variable]]]`. -aliases_explicit.py:23:30 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[typing.Any, Type[Variable[$synthetic_attribute_resolution_variable]]]` but got `Tuple[object, TypeVar]`. -aliases_explicit.py:26:0 Incompatible variable type [9]: GoodTypeAlias12 is declared to have type `TA` but is used as type `Type[typing.Callable[..., Variable[$synthetic_attribute_resolution_variable]]]`. -aliases_explicit.py:26:31 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[typing.Any, Type[Variable[$synthetic_attribute_resolution_variable]]]` but got `Tuple[ParamSpec, None]`. -aliases_explicit.py:41:8 Undefined or invalid type [11]: Annotation `GoodTypeAlias9` is not defined as a type. -aliases_explicit.py:44:9 Undefined or invalid type [11]: Annotation `GoodTypeAlias12` is not defined as a type. -aliases_explicit.py:80:0 Incompatible variable type [9]: BadTypeAlias2 is declared to have type `TA` but is used as type `List[Type[Union[int, str]]]`. -aliases_explicit.py:81:0 Incompatible variable type [9]: BadTypeAlias3 is declared to have type `TA` but is used as type `Tuple[Tuple[Type[int], Type[str]]]`. -aliases_explicit.py:82:0 Incompatible variable type [9]: BadTypeAlias4 is declared to have type `TA` but is used as type `List[Type[int]]`. -aliases_explicit.py:83:0 Incompatible variable type [9]: BadTypeAlias5 is declared to have type `TA` but is used as type `Dict[str, str]`. -aliases_explicit.py:84:0 Incompatible variable type [9]: BadTypeAlias6 is declared to have type `TA` but is used as type `Type[int]`. -aliases_explicit.py:85:0 Incompatible variable type [9]: BadTypeAlias7 is declared to have type `TA` but is used as type `Type[int]`. -aliases_explicit.py:86:0 Incompatible variable type [9]: BadTypeAlias8 is declared to have type `TA` but is used as type `Type[Union[int, str]]`. -aliases_explicit.py:87:0 Incompatible variable type [9]: BadTypeAlias9 is declared to have type `TA` but is used as type `int`. -aliases_explicit.py:88:0 Incompatible variable type [9]: BadTypeAlias10 is declared to have type `TA` but is used as type `bool`. -aliases_explicit.py:89:0 Incompatible variable type [9]: BadTypeAlias11 is declared to have type `TA` but is used as type `int`. -aliases_explicit.py:90:0 Incompatible variable type [9]: BadTypeAlias12 is declared to have type `TA` but is used as type `Type[Union[list, set]]`. -aliases_explicit.py:91:0 Incompatible variable type [9]: BadTypeAlias13 is declared to have type `TA` but is used as type `str`. -aliases_explicit.py:97:16 Call error [29]: `TA` is not a function. -aliases_explicit.py:101:5 Call error [29]: `TA` is not a function. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 67: Expected 1 errors -Line 68: Expected 1 errors -Line 69: Expected 1 errors -Line 70: Expected 1 errors -Line 71: Expected 1 errors -Line 79: Expected 1 errors -Line 100: Expected 1 errors -Line 102: Expected 1 errors -Line 23: Unexpected errors ['aliases_explicit.py:23:0 Incompatible variable type [9]: GoodTypeAlias9 is declared to have type `TA` but is used as type `Type[typing.Callable[..., Variable[$synthetic_attribute_resolution_variable]]]`.', 'aliases_explicit.py:23:30 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[typing.Any, Type[Variable[$synthetic_attribute_resolution_variable]]]` but got `Tuple[object, TypeVar]`.'] -Line 26: Unexpected errors ['aliases_explicit.py:26:0 Incompatible variable type [9]: GoodTypeAlias12 is declared to have type `TA` but is used as type `Type[typing.Callable[..., Variable[$synthetic_attribute_resolution_variable]]]`.', 'aliases_explicit.py:26:31 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[typing.Any, Type[Variable[$synthetic_attribute_resolution_variable]]]` but got `Tuple[ParamSpec, None]`.'] -Line 41: Unexpected errors ['aliases_explicit.py:41:8 Undefined or invalid type [11]: Annotation `GoodTypeAlias9` is not defined as a type.'] -Line 44: Unexpected errors ['aliases_explicit.py:44:9 Undefined or invalid type [11]: Annotation `GoodTypeAlias12` is not defined as a type.'] -Line 97: Unexpected errors ['aliases_explicit.py:97:16 Call error [29]: `TA` is not a function.'] -""" diff --git a/conformance/results/pyre/aliases_implicit.toml b/conformance/results/pyre/aliases_implicit.toml deleted file mode 100644 index 1d00603e1..000000000 --- a/conformance/results/pyre/aliases_implicit.toml +++ /dev/null @@ -1,46 +0,0 @@ -conformant = "Partial" -notes = """ -Incorrectly reports error for type alias defined with ParamSpec. -Incorrectly rejects some valid type aliases when used in annotations. -Incorrectly evaluates generic type alias with ParamSpec with missing type argument. -Does not report invalid specialization of generic type aliases. -Does not report error for attempt to instantiate union type alias. -Does not report invalid specialization of already-specialized generic type alias. -""" -output = """ -aliases_implicit.py:38:26 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[typing.Any, Type[Variable[$synthetic_attribute_resolution_variable]]]` but got `Tuple[object, TypeVar]`. -aliases_implicit.py:42:27 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[typing.Any, Type[Variable[$synthetic_attribute_resolution_variable]]]` but got `Tuple[ParamSpec, None]`. -aliases_implicit.py:54:8 Undefined or invalid type [11]: Annotation `GoodTypeAlias9` is not defined as a type. -aliases_implicit.py:58:9 Undefined or invalid type [11]: Annotation `GoodTypeAlias13` is not defined as a type. -aliases_implicit.py:106:8 Undefined or invalid type [11]: Annotation `BadTypeAlias1` is not defined as a type. -aliases_implicit.py:107:8 Undefined or invalid type [11]: Annotation `BadTypeAlias2` is not defined as a type. -aliases_implicit.py:108:8 Undefined or invalid type [11]: Annotation `BadTypeAlias3` is not defined as a type. -aliases_implicit.py:109:8 Undefined or invalid type [11]: Annotation `BadTypeAlias4` is not defined as a type. -aliases_implicit.py:110:8 Undefined or invalid type [11]: Annotation `BadTypeAlias5` is not defined as a type. -aliases_implicit.py:111:8 Undefined or invalid type [11]: Annotation `BadTypeAlias6` is not defined as a type. -aliases_implicit.py:112:8 Undefined or invalid type [11]: Annotation `BadTypeAlias7` is not defined as a type. -aliases_implicit.py:113:8 Undefined or invalid type [11]: Annotation `BadTypeAlias8` is not defined as a type. -aliases_implicit.py:114:8 Undefined or invalid type [11]: Annotation `BadTypeAlias9` is not defined as a type. -aliases_implicit.py:115:9 Undefined or invalid type [11]: Annotation `BadTypeAlias10` is not defined as a type. -aliases_implicit.py:116:9 Undefined or invalid type [11]: Annotation `BadTypeAlias11` is not defined as a type. -aliases_implicit.py:117:9 Undefined or invalid type [11]: Annotation `BadTypeAlias12` is not defined as a type. -aliases_implicit.py:118:9 Undefined or invalid type [11]: Annotation `BadTypeAlias13` is not defined as a type. -aliases_implicit.py:119:9 Undefined or invalid type [11]: Annotation `BadTypeAlias14` is not defined as a type. -aliases_implicit.py:131:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `List[int]` but got `typing.Any`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 76: Expected 1 errors -Line 77: Expected 1 errors -Line 78: Expected 1 errors -Line 79: Expected 1 errors -Line 80: Expected 1 errors -Line 81: Expected 1 errors -Line 133: Expected 1 errors -Line 135: Expected 1 errors -Line 38: Unexpected errors ['aliases_implicit.py:38:26 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[typing.Any, Type[Variable[$synthetic_attribute_resolution_variable]]]` but got `Tuple[object, TypeVar]`.'] -Line 42: Unexpected errors ['aliases_implicit.py:42:27 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[typing.Any, Type[Variable[$synthetic_attribute_resolution_variable]]]` but got `Tuple[ParamSpec, None]`.'] -Line 54: Unexpected errors ['aliases_implicit.py:54:8 Undefined or invalid type [11]: Annotation `GoodTypeAlias9` is not defined as a type.'] -Line 58: Unexpected errors ['aliases_implicit.py:58:9 Undefined or invalid type [11]: Annotation `GoodTypeAlias13` is not defined as a type.'] -Line 131: Unexpected errors ['aliases_implicit.py:131:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `List[int]` but got `typing.Any`.'] -""" diff --git a/conformance/results/pyre/aliases_newtype.toml b/conformance/results/pyre/aliases_newtype.toml deleted file mode 100644 index e9de50146..000000000 --- a/conformance/results/pyre/aliases_newtype.toml +++ /dev/null @@ -1,28 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject use of NewType in `isinstance` call. -Does not reject use of NewType in class definition statement. -Does not report inconsistency between name of NewType and assigned identifier name. -Does not reject use of NewType with generic class with TypeVar. -Does not reject use of NewType with protocol class. -Does not reject use of NewType with TypedDict class. -Does not reject use of NewType with Any. -""" -output = """ -aliases_newtype.py:11:7 Incompatible parameter type [6]: In call `UserId.__init__`, for 1st positional argument, expected `int` but got `str`. -aliases_newtype.py:12:0 Incompatible variable type [9]: u1 is declared to have type `UserId` but is used as type `int`. -aliases_newtype.py:38:5 Invalid type parameters [24]: Non-generic type `GoodNewType1` cannot take parameters. -aliases_newtype.py:44:37 Invalid inheritance [39]: `typing.Union[int, str]` is not a valid parent class. -aliases_newtype.py:51:37 Invalid inheritance [39]: `typing_extensions.Literal[7]` is not a valid parent class. -aliases_newtype.py:60:14 Too many arguments [19]: Call `NewType.__init__` expects 2 positional arguments, 3 were provided. -aliases_newtype.py:62:37 Invalid inheritance [39]: `typing.Any` is not a valid parent class. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 20: Expected 1 errors -Line 23: Expected 1 errors -Line 32: Expected 1 errors -Line 47: Expected 1 errors -Line 49: Expected 1 errors -Line 58: Expected 1 errors -""" diff --git a/conformance/results/pyre/aliases_recursive.toml b/conformance/results/pyre/aliases_recursive.toml deleted file mode 100644 index a87f4cf4d..000000000 --- a/conformance/results/pyre/aliases_recursive.toml +++ /dev/null @@ -1,38 +0,0 @@ -conformant = "Partial" -notes = """ -Does not properly handle some recursive type aliases. -Does not properly handle specialization of generic recursive type aliases. -""" -output = """ -aliases_recursive.py:19:0 Incompatible variable type [9]: j4 is declared to have type `aliases_recursive.Json (resolves to Union[None, Dict[str, Json], List[Json], float, int, str])` but is used as type `Dict[str, complex]`. -aliases_recursive.py:20:0 Incompatible variable type [9]: j5 is declared to have type `aliases_recursive.Json (resolves to Union[None, Dict[str, Json], List[Json], float, int, str])` but is used as type `List[complex]`. -aliases_recursive.py:30:29 Undefined attribute [16]: `tuple` has no attribute `__getitem__`. -aliases_recursive.py:33:4 Undefined or invalid type [11]: Annotation `RecursiveTuple` is not defined as a type. -aliases_recursive.py:42:39 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[Type[Variable[_KT]], Type[Variable[_VT_co](covariant)]]` but got `Tuple[Type[str], str]`. -aliases_recursive.py:44:4 Undefined or invalid type [11]: Annotation `RecursiveMapping` is not defined as a type. -aliases_recursive.py:58:20 Undefined attribute [16]: `list` has no attribute `__getitem__`. -aliases_recursive.py:61:4 Undefined or invalid type [11]: Annotation `SpecializedTypeAlias1` is not defined as a type. -aliases_recursive.py:62:4 Undefined or invalid type [11]: Annotation `GenericTypeAlias1` is not defined as a type. -aliases_recursive.py:67:4 Undefined or invalid type [11]: Annotation `GenericTypeAlias2` is not defined as a type. -aliases_recursive.py:72:0 Incompatible variable type [9]: RecursiveUnion is declared to have type `TypeAlias` but is used as type `Type[typing.Any]`. -aliases_recursive.py:75:0 Incompatible variable type [9]: MutualReference1 is declared to have type `TypeAlias` but is used as type `Type[typing.Any]`. -aliases_recursive.py:75:62 Incompatible variable type [9]: MutualReference2 is declared to have type `TypeAlias` but is used as type `Type[typing.Any]`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 38: Expected 1 errors -Line 39: Expected 1 errors -Line 50: Expected 1 errors -Line 51: Expected 1 errors -Line 52: Expected 1 errors -Line 63: Expected 1 errors -Line 69: Expected 1 errors -Line 30: Unexpected errors ['aliases_recursive.py:30:29 Undefined attribute [16]: `tuple` has no attribute `__getitem__`.'] -Line 33: Unexpected errors ['aliases_recursive.py:33:4 Undefined or invalid type [11]: Annotation `RecursiveTuple` is not defined as a type.'] -Line 42: Unexpected errors ['aliases_recursive.py:42:39 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[Type[Variable[_KT]], Type[Variable[_VT_co](covariant)]]` but got `Tuple[Type[str], str]`.'] -Line 44: Unexpected errors ['aliases_recursive.py:44:4 Undefined or invalid type [11]: Annotation `RecursiveMapping` is not defined as a type.'] -Line 58: Unexpected errors ['aliases_recursive.py:58:20 Undefined attribute [16]: `list` has no attribute `__getitem__`.'] -Line 61: Unexpected errors ['aliases_recursive.py:61:4 Undefined or invalid type [11]: Annotation `SpecializedTypeAlias1` is not defined as a type.'] -Line 62: Unexpected errors ['aliases_recursive.py:62:4 Undefined or invalid type [11]: Annotation `GenericTypeAlias1` is not defined as a type.'] -Line 67: Unexpected errors ['aliases_recursive.py:67:4 Undefined or invalid type [11]: Annotation `GenericTypeAlias2` is not defined as a type.'] -""" diff --git a/conformance/results/pyre/aliases_type_statement.toml b/conformance/results/pyre/aliases_type_statement.toml deleted file mode 100644 index 02d923e11..000000000 --- a/conformance/results/pyre/aliases_type_statement.toml +++ /dev/null @@ -1,38 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support `type` statement. -""" -output = """ -aliases_type_statement.py:8:6 Parsing failure [404]: invalid syntax -""" -conformance_automated = "Fail" -errors_diff = """ -Line 17: Expected 1 errors -Line 19: Expected 1 errors -Line 23: Expected 1 errors -Line 26: Expected 1 errors -Line 31: Expected 1 errors -Line 37: Expected 1 errors -Line 38: Expected 1 errors -Line 39: Expected 1 errors -Line 40: Expected 1 errors -Line 41: Expected 1 errors -Line 42: Expected 1 errors -Line 43: Expected 1 errors -Line 44: Expected 1 errors -Line 45: Expected 1 errors -Line 46: Expected 1 errors -Line 47: Expected 1 errors -Line 48: Expected 1 errors -Line 49: Expected 1 errors -Line 52: Expected 1 errors -Line 58: Expected 1 errors -Line 64: Expected 1 errors -Line 69: Expected 1 errors -Line 79: Expected 1 errors -Line 81: Expected 1 errors -Line 84: Expected 1 errors -Line 86: Expected 1 errors -Line 90: Expected 1 errors -Line 8: Unexpected errors ['aliases_type_statement.py:8:6 Parsing failure [404]: invalid syntax'] -""" diff --git a/conformance/results/pyre/aliases_typealiastype.toml b/conformance/results/pyre/aliases_typealiastype.toml deleted file mode 100644 index 1e88186be..000000000 --- a/conformance/results/pyre/aliases_typealiastype.toml +++ /dev/null @@ -1,44 +0,0 @@ -conformant = "Unsupported" -notes = """ -Support for TypeAliasType is not implemented. -""" -output = """ -aliases_typealiastype.py:17:41 Undefined attribute [16]: `list` has no attribute `__getitem__`. -aliases_typealiastype.py:22:13 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[typing.Any, Type[Variable[$synthetic_attribute_resolution_variable]]]` but got `Tuple[ParamSpec, TypeVar]`. -aliases_typealiastype.py:22:65 Undefined attribute [16]: `tuple` has no attribute `__getitem__`. -aliases_typealiastype.py:27:45 Undefined attribute [16]: `list` has no attribute `__getitem__`. -aliases_typealiastype.py:32:6 Undefined attribute [16]: `TypeAliasType` has no attribute `other_attrib`. -aliases_typealiastype.py:35:4 Undefined or invalid type [11]: Annotation `GoodAlias4` is not defined as a type. -aliases_typealiastype.py:37:4 Undefined or invalid type [11]: Annotation `...` is not defined as a type. -aliases_typealiastype.py:37:4 Undefined or invalid type [11]: Annotation `GoodAlias5` is not defined as a type. -aliases_typealiastype.py:39:4 Invalid type [31]: Expression `$local_aliases_typealiastype$GoodAlias5[(int, str, [int, str], *tuple[(int, str, int)])]` is not a valid type. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 40: Expected 1 errors -Line 43: Expected 1 errors -Line 44: Expected 1 errors -Line 45: Expected 1 errors -Line 46: Expected 1 errors -Line 47: Expected 1 errors -Line 48: Expected 1 errors -Line 52: Expected 1 errors -Line 53: Expected 1 errors -Line 54: Expected 1 errors -Line 55: Expected 1 errors -Line 56: Expected 1 errors -Line 57: Expected 1 errors -Line 58: Expected 1 errors -Line 59: Expected 1 errors -Line 60: Expected 1 errors -Line 61: Expected 1 errors -Line 62: Expected 1 errors -Line 63: Expected 1 errors -Line 64: Expected 1 errors -Line 17: Unexpected errors ['aliases_typealiastype.py:17:41 Undefined attribute [16]: `list` has no attribute `__getitem__`.'] -Line 22: Unexpected errors ['aliases_typealiastype.py:22:13 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[typing.Any, Type[Variable[$synthetic_attribute_resolution_variable]]]` but got `Tuple[ParamSpec, TypeVar]`.', 'aliases_typealiastype.py:22:65 Undefined attribute [16]: `tuple` has no attribute `__getitem__`.'] -Line 27: Unexpected errors ['aliases_typealiastype.py:27:45 Undefined attribute [16]: `list` has no attribute `__getitem__`.'] -Line 35: Unexpected errors ['aliases_typealiastype.py:35:4 Undefined or invalid type [11]: Annotation `GoodAlias4` is not defined as a type.'] -Line 37: Unexpected errors ['aliases_typealiastype.py:37:4 Undefined or invalid type [11]: Annotation `...` is not defined as a type.', 'aliases_typealiastype.py:37:4 Undefined or invalid type [11]: Annotation `GoodAlias5` is not defined as a type.'] -Line 39: Unexpected errors ['aliases_typealiastype.py:39:4 Invalid type [31]: Expression `$local_aliases_typealiastype$GoodAlias5[(int, str, [int, str], *tuple[(int, str, int)])]` is not a valid type.'] -""" diff --git a/conformance/results/pyre/aliases_variance.toml b/conformance/results/pyre/aliases_variance.toml deleted file mode 100644 index 76fec94ce..000000000 --- a/conformance/results/pyre/aliases_variance.toml +++ /dev/null @@ -1,10 +0,0 @@ -conformant = "Pass" -output = """ -aliases_variance.py:24:0 Invalid type variance [46]: The type variable `Variable[T_co](covariant)` is incompatible with parent class type variable `Variable[T]` because subclasses cannot use more permissive type variables than their superclasses. -aliases_variance.py:28:0 Invalid type variance [46]: The type variable `Variable[T_co](covariant)` is incompatible with parent class type variable `Variable[T]` because subclasses cannot use more permissive type variables than their superclasses. -aliases_variance.py:32:0 Invalid type variance [46]: The type variable `Variable[T_co](covariant)` is incompatible with parent class type variable `Variable[T]` because subclasses cannot use more permissive type variables than their superclasses. -aliases_variance.py:44:0 Invalid type variance [46]: The type variable `Variable[T_contra](contravariant)` is incompatible with parent class type variable `Variable[T]` because subclasses cannot use more permissive type variables than their superclasses. -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pyre/annotations_coroutines.toml b/conformance/results/pyre/annotations_coroutines.toml deleted file mode 100644 index 5e485e856..000000000 --- a/conformance/results/pyre/annotations_coroutines.toml +++ /dev/null @@ -1,6 +0,0 @@ -conformant = "Pass" -output = """ -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pyre/annotations_forward_refs.toml b/conformance/results/pyre/annotations_forward_refs.toml deleted file mode 100644 index 9c41a7acc..000000000 --- a/conformance/results/pyre/annotations_forward_refs.toml +++ /dev/null @@ -1,42 +0,0 @@ -conformant = "Partial" -notes = """ -Does not report error for a forward reference that is not enclosed in quotes. -Does not report error for use of quoted type with "|" operator (runtime error). -Does not reject f-string in quoted type annotation. -Incorrectly generates error for quoted type defined in class scope. -Does not generate error for unquoted type defined in class scope. -Does not treat triple-quoted forward reference annotation as implicitly parenthesized. -""" -output = """ -annotations_forward_refs.py:41:8 Undefined or invalid type [11]: Annotation `eval(.join(map(chr, [105, 110, 116])))` is not defined as a type. -annotations_forward_refs.py:42:8 Invalid type [31]: Expression `"[int, str]"` is not a valid type. -annotations_forward_refs.py:43:8 Invalid type [31]: Expression `"(int, str)"` is not a valid type. -annotations_forward_refs.py:44:8 Undefined or invalid type [11]: Annotation `comprehension(int for generators(generator($target$i in range(1) if )))` is not defined as a type. -annotations_forward_refs.py:45:8 Invalid type [31]: Expression `"{ }"` is not a valid type. -annotations_forward_refs.py:46:8 Undefined or invalid type [11]: Annotation `lambda () (int)()` is not defined as a type. -annotations_forward_refs.py:47:8 Invalid type [31]: Expression `[int][0]` is not a valid type. -annotations_forward_refs.py:48:8 Invalid type [31]: Expression `"int if 1 < 3 else str"` is not a valid type. -annotations_forward_refs.py:49:8 Undefined or invalid type [11]: Annotation `var1` is not defined as a type. -annotations_forward_refs.py:50:9 Invalid type [31]: Expression `"True"` is not a valid type. -annotations_forward_refs.py:51:9 Invalid type [31]: Expression `"1"` is not a valid type. -annotations_forward_refs.py:52:9 Invalid type [31]: Expression `"-1"` is not a valid type. -annotations_forward_refs.py:53:9 Invalid type [31]: Expression `"int or str"` is not a valid type. -annotations_forward_refs.py:55:9 Undefined or invalid type [11]: Annotation `types` is not defined as a type. -annotations_forward_refs.py:77:0 Uninitialized attribute [13]: Attribute `ClassC` is declared in class `ClassD` to have type `ClassC` but is never initialized. -annotations_forward_refs.py:80:12 Undefined or invalid type [11]: Annotation `ClassF` is not defined as a type. -annotations_forward_refs.py:87:7 Undefined or invalid type [11]: Annotation `ClassD.int` is not defined as a type. -annotations_forward_refs.py:100:7 Undefined or invalid type [11]: Annotation ` -""" -conformance_automated = "Fail" -errors_diff = """ -Line 22: Expected 1 errors -Line 23: Expected 1 errors -Line 24: Expected 1 errors -Line 25: Expected 1 errors -Line 54: Expected 1 errors -Line 66: Expected 1 errors -Line 89: Expected 1 errors -Line 77: Unexpected errors ['annotations_forward_refs.py:77:0 Uninitialized attribute [13]: Attribute `ClassC` is declared in class `ClassD` to have type `ClassC` but is never initialized.'] -Line 87: Unexpected errors ['annotations_forward_refs.py:87:7 Undefined or invalid type [11]: Annotation `ClassD.int` is not defined as a type.'] -Line 100: Unexpected errors ['annotations_forward_refs.py:100:7 Undefined or invalid type [11]: Annotation `'] -""" diff --git a/conformance/results/pyre/annotations_generators.toml b/conformance/results/pyre/annotations_generators.toml deleted file mode 100644 index 4f05a0844..000000000 --- a/conformance/results/pyre/annotations_generators.toml +++ /dev/null @@ -1,26 +0,0 @@ -conformant = "Partial" -notes = """ -Does not report invalid return type for generator when function implicitly returns None. -Incorrectly evaluates type of call to async generator. -""" -output = """ -annotations_generators.py:54:8 Incompatible return type [7]: Expected `Generator[A, B, C]` but got `Generator[typing.Any, typing.Any, bool]`. -annotations_generators.py:57:8 Incompatible return type [7]: Expected `Generator[A, B, C]` but got `Generator[int, typing.Any, typing.Any]`. -annotations_generators.py:66:8 Incompatible return type [7]: Expected `Generator[A, int, typing.Any]` but got `Generator[int, typing.Any, typing.Any]`. -annotations_generators.py:75:4 Incompatible return type [7]: Expected `Iterator[A]` but got `Generator[B, typing.Any, typing.Any]`. -annotations_generators.py:87:4 Incompatible return type [7]: Expected `int` but got `Generator[None, typing.Any, typing.Any]`. -annotations_generators.py:88:4 Incompatible return type [7]: Expected `int` but got `Generator[typing.Any, typing.Any, int]`. -annotations_generators.py:91:0 Incompatible async generator return type [57]: Expected return annotation to be AsyncGenerator or a superclass but got `int`. -annotations_generators.py:92:4 Incompatible return type [7]: Expected `int` but got `AsyncGenerator[None, typing.Any]`. -annotations_generators.py:118:4 Incompatible return type [7]: Expected `Iterator[B]` but got `Generator[A, None, typing.Any]`. -annotations_generators.py:119:4 Incompatible return type [7]: Expected `Iterator[B]` but got `Generator[int, None, typing.Any]`. -annotations_generators.py:135:4 Incompatible return type [7]: Expected `Generator[None, str, None]` but got `Generator[None, int, typing.Any]`. -annotations_generators.py:182:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing.Callable[[], Coroutine[typing.Any, typing.Any, AsyncIterator[int]]]` but got `typing.Callable(generator29)[[], AsyncIterator[int]]`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 51: Expected 1 errors -Line 86: Expected 1 errors -Line 88: Unexpected errors ['annotations_generators.py:88:4 Incompatible return type [7]: Expected `int` but got `Generator[typing.Any, typing.Any, int]`.'] -Line 182: Unexpected errors ['annotations_generators.py:182:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing.Callable[[], Coroutine[typing.Any, typing.Any, AsyncIterator[int]]]` but got `typing.Callable(generator29)[[], AsyncIterator[int]]`.'] -""" diff --git a/conformance/results/pyre/annotations_methods.toml b/conformance/results/pyre/annotations_methods.toml deleted file mode 100644 index c6be1388e..000000000 --- a/conformance/results/pyre/annotations_methods.toml +++ /dev/null @@ -1,10 +0,0 @@ -conformant = "Pass" -notes = """ -Type evaluation differs from other type checkers because of ambiguity in the spec related to method bindings. -""" -output = """ -annotations_methods.py:42:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `A` but got `B`. -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pyre/annotations_typeexpr.toml b/conformance/results/pyre/annotations_typeexpr.toml deleted file mode 100644 index f3a6f06cd..000000000 --- a/conformance/results/pyre/annotations_typeexpr.toml +++ /dev/null @@ -1,21 +0,0 @@ -conformant = "Pass" -output = """ -annotations_typeexpr.py:88:8 Invalid type [31]: Expression `eval("".join(map(chr, [105, 110, 116])))` is not a valid type. -annotations_typeexpr.py:89:8 Invalid type [31]: Expression `[int, str]` is not a valid type. -annotations_typeexpr.py:90:8 Invalid type [31]: Expression `(int, str)` is not a valid type. -annotations_typeexpr.py:91:8 Invalid type [31]: Expression `comprehension(int for generators(generator($target$i in range(1) if )))` is not a valid type. -annotations_typeexpr.py:92:8 Invalid type [31]: Expression `{ }` is not a valid type. -annotations_typeexpr.py:93:8 Invalid type [31]: Expression `lambda () (int)()` is not a valid type. -annotations_typeexpr.py:94:8 Invalid type [31]: Expression `[int][0]` is not a valid type. -annotations_typeexpr.py:95:8 Invalid type [31]: Expression `int if 1 < 3 else str` is not a valid type. -annotations_typeexpr.py:96:8 Undefined or invalid type [11]: Annotation `var1` is not defined as a type. -annotations_typeexpr.py:97:9 Invalid type [31]: Expression `True` is not a valid type. -annotations_typeexpr.py:98:9 Invalid type [31]: Expression `1` is not a valid type. -annotations_typeexpr.py:99:9 Invalid type [31]: Expression `-1` is not a valid type. -annotations_typeexpr.py:100:9 Invalid type [31]: Expression `int or str` is not a valid type. -annotations_typeexpr.py:101:9 Invalid type [31]: Expression `"int"` is not a valid type. -annotations_typeexpr.py:102:9 Undefined or invalid type [11]: Annotation `types` is not defined as a type. -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pyre/callables_annotation.toml b/conformance/results/pyre/callables_annotation.toml deleted file mode 100644 index 900125346..000000000 --- a/conformance/results/pyre/callables_annotation.toml +++ /dev/null @@ -1,50 +0,0 @@ -conformant = "Partial" -notes = """ -Does not evaluate correct type for `*args: int` parameter. -Does not reject illegal form `Callable[[...], int]`. -Does not correctly implement type compatibility rules for "...". -Does not treat "*args: Any, **kwargs: Any" as "...". -""" -output = """ -callables_annotation.py:25:4 Missing argument [20]: PositionalOnly call expects argument in position 1. -callables_annotation.py:26:10 Incompatible parameter type [6]: In anonymous call, for 2nd positional argument, expected `str` but got `int`. -callables_annotation.py:27:4 Too many arguments [19]: PositionalOnly call expects 2 positional arguments, 3 were provided. -callables_annotation.py:29:4 Unexpected keyword [28]: Unexpected keyword argument `a` to anonymous call. -callables_annotation.py:35:4 Too many arguments [19]: PositionalOnly call expects 0 positional arguments, 1 was provided. -callables_annotation.py:55:4 Invalid type [31]: Expression `typing.Callable[int]` is not a valid type. -callables_annotation.py:56:4 Invalid type [31]: Expression `typing.Callable[(int, int)]` is not a valid type. -callables_annotation.py:57:4 Invalid type [31]: Expression `typing.Callable[([], [int])]` is not a valid type. -callables_annotation.py:58:4 Invalid type [31]: Expression `typing.Callable[(int, int, int)]` is not a valid type. -callables_annotation.py:59:4 Undefined or invalid type [11]: Annotation `...` is not defined as a type. -callables_annotation.py:89:5 Invalid type [31]: Expression `typing.Callable[(typing.Concatenate[(int, ...)], str)]` is not a valid type. -callables_annotation.py:145:8 Invalid type [31]: Expression `typing.Callable[(typing.Concatenate[(int, ...)], None)]` is not a valid type. -callables_annotation.py:151:9 Invalid type [31]: Expression `typing.Callable[(typing.Concatenate[(int, ...)], None)]` is not a valid type. -callables_annotation.py:157:4 Incompatible variable type [9]: ok11 is declared to have type `Proto6` but is used as type `Proto7`. -callables_annotation.py:159:4 Incompatible variable type [9]: err1 is declared to have type `Proto5[typing.Any]` but is used as type `Proto8`. -callables_annotation.py:166:0 Incompatible variable type [9]: Callback1 is declared to have type `TypeAlias` but is used as type `Type[typing.Callable[..., str]]`. -callables_annotation.py:167:0 Incompatible variable type [9]: Callback2 is declared to have type `TypeAlias` but is used as type `Type[typing.Callable[..., str]]`. -callables_annotation.py:171:8 Undefined or invalid type [11]: Annotation `Callback1` is not defined as a type. -callables_annotation.py:172:8 Undefined or invalid type [11]: Annotation `Callback2` is not defined as a type. -callables_annotation.py:181:0 Incompatible variable type [9]: CallbackWithInt is declared to have type `TypeAlias` but is used as type `Type[typing.Callable[..., str]]`. -callables_annotation.py:182:0 Incompatible variable type [9]: CallbackWithStr is declared to have type `TypeAlias` but is used as type `Type[typing.Callable[..., str]]`. -callables_annotation.py:186:8 Invalid type [31]: Expression `typing.Callable[(typing.Concatenate[(int, ...)], str)]` is not a valid type. -callables_annotation.py:187:8 Invalid type [31]: Expression `typing.Callable[(typing.Concatenate[(str, ...)], str)]` is not a valid type. -callables_annotation.py:188:8 Undefined or invalid type [11]: Annotation `CallbackWithInt` is not defined as a type. -callables_annotation.py:189:8 Undefined or invalid type [11]: Annotation `CallbackWithStr` is not defined as a type. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 91: Expected 1 errors -Line 93: Expected 1 errors -Line 89: Unexpected errors ['callables_annotation.py:89:5 Invalid type [31]: Expression `typing.Callable[(typing.Concatenate[(int, ...)], str)]` is not a valid type.'] -Line 145: Unexpected errors ['callables_annotation.py:145:8 Invalid type [31]: Expression `typing.Callable[(typing.Concatenate[(int, ...)], None)]` is not a valid type.'] -Line 151: Unexpected errors ['callables_annotation.py:151:9 Invalid type [31]: Expression `typing.Callable[(typing.Concatenate[(int, ...)], None)]` is not a valid type.'] -Line 157: Unexpected errors ['callables_annotation.py:157:4 Incompatible variable type [9]: ok11 is declared to have type `Proto6` but is used as type `Proto7`.'] -Line 166: Unexpected errors ['callables_annotation.py:166:0 Incompatible variable type [9]: Callback1 is declared to have type `TypeAlias` but is used as type `Type[typing.Callable[..., str]]`.'] -Line 167: Unexpected errors ['callables_annotation.py:167:0 Incompatible variable type [9]: Callback2 is declared to have type `TypeAlias` but is used as type `Type[typing.Callable[..., str]]`.'] -Line 171: Unexpected errors ['callables_annotation.py:171:8 Undefined or invalid type [11]: Annotation `Callback1` is not defined as a type.'] -Line 181: Unexpected errors ['callables_annotation.py:181:0 Incompatible variable type [9]: CallbackWithInt is declared to have type `TypeAlias` but is used as type `Type[typing.Callable[..., str]]`.'] -Line 182: Unexpected errors ['callables_annotation.py:182:0 Incompatible variable type [9]: CallbackWithStr is declared to have type `TypeAlias` but is used as type `Type[typing.Callable[..., str]]`.'] -Line 186: Unexpected errors ['callables_annotation.py:186:8 Invalid type [31]: Expression `typing.Callable[(typing.Concatenate[(int, ...)], str)]` is not a valid type.'] -Line 188: Unexpected errors ['callables_annotation.py:188:8 Undefined or invalid type [11]: Annotation `CallbackWithInt` is not defined as a type.'] -""" diff --git a/conformance/results/pyre/callables_kwargs.toml b/conformance/results/pyre/callables_kwargs.toml deleted file mode 100644 index 596abc4d4..000000000 --- a/conformance/results/pyre/callables_kwargs.toml +++ /dev/null @@ -1,31 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not understand Unpack in the context of **kwargs annotation. -""" -output = """ -callables_kwargs.py:22:20 Undefined or invalid type [11]: Annotation `Unpack` is not defined as a type. -callables_kwargs.py:24:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing.Any`. -callables_kwargs.py:32:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `typing.Any`. -callables_kwargs.py:35:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `typing.Any`. -callables_kwargs.py:52:4 Too many arguments [19]: Call `func1` expects 1 positional argument, 4 were provided. -callables_kwargs.py:62:12 Incompatible parameter type [6]: In call `func2`, for 1st positional argument, expected `str` but got `object`. -callables_kwargs.py:64:10 Incompatible parameter type [6]: In call `func2`, for 1st positional argument, expected `str` but got `int`. -callables_kwargs.py:65:18 Incompatible parameter type [6]: In call `func2`, for 2nd positional argument, expected `str` but got `object`. -callables_kwargs.py:122:20 Invalid type variable [34]: The type variable `Variable[T (bound to callables_kwargs.TD2)]` isn't present in the function's parameters. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 46: Expected 1 errors -Line 51: Expected 1 errors -Line 58: Expected 1 errors -Line 63: Expected 1 errors -Line 101: Expected 1 errors -Line 102: Expected 1 errors -Line 103: Expected 1 errors -Line 111: Expected 1 errors -Line 22: Unexpected errors ['callables_kwargs.py:22:20 Undefined or invalid type [11]: Annotation `Unpack` is not defined as a type.'] -Line 24: Unexpected errors ['callables_kwargs.py:24:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing.Any`.'] -Line 32: Unexpected errors ['callables_kwargs.py:32:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `typing.Any`.'] -Line 35: Unexpected errors ['callables_kwargs.py:35:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `typing.Any`.'] -Line 62: Unexpected errors ['callables_kwargs.py:62:12 Incompatible parameter type [6]: In call `func2`, for 1st positional argument, expected `str` but got `object`.'] -""" diff --git a/conformance/results/pyre/callables_protocol.toml b/conformance/results/pyre/callables_protocol.toml deleted file mode 100644 index c4630b5ee..000000000 --- a/conformance/results/pyre/callables_protocol.toml +++ /dev/null @@ -1,34 +0,0 @@ -conformant = "Partial" -notes = """ -Does not correctly handle callback protocol that declares attributes in all functions. -Does not report type incompatibility for callback protocol with positional-only parameters. -Incorrectly reports type compatibility error with callback that has *args and **kwargs. -Does not report type incompatibility for callback missing a default argument for positional parameter. -Does not report type incompatibility for callback missing a default argument for keyword parameter. -""" -output = """ -callables_protocol.py:35:0 Incompatible variable type [9]: cb1 is declared to have type `Proto1` but is used as type `typing.Callable(cb1_bad1)[[Variable(bytes), KeywordOnly(max_items, Optional[int])], List[bytes]]`. -callables_protocol.py:36:0 Incompatible variable type [9]: cb1 is declared to have type `Proto1` but is used as type `typing.Callable(cb1_bad2)[[Variable(bytes)], List[bytes]]`. -callables_protocol.py:37:0 Incompatible variable type [9]: cb1 is declared to have type `Proto1` but is used as type `typing.Callable(cb1_bad3)[[Variable(bytes), KeywordOnly(max_len, Optional[str])], List[bytes]]`. -callables_protocol.py:67:0 Incompatible variable type [9]: cb2 is declared to have type `Proto2` but is used as type `typing.Callable(cb2_bad1)[[Variable(bytes)], typing.Any]`. -callables_protocol.py:68:0 Incompatible variable type [9]: cb2 is declared to have type `Proto2` but is used as type `typing.Callable(cb2_bad2)[[Variable(str), Keywords(str)], typing.Any]`. -callables_protocol.py:69:0 Incompatible variable type [9]: cb2 is declared to have type `Proto2` but is used as type `typing.Callable(cb2_bad3)[[Variable(bytes), Keywords(bytes)], typing.Any]`. -callables_protocol.py:70:0 Incompatible variable type [9]: cb2 is declared to have type `Proto2` but is used as type `typing.Callable(cb2_bad4)[[Keywords(str)], typing.Any]`. -callables_protocol.py:97:0 Incompatible variable type [9]: var4 is declared to have type `Proto4` but is used as type `typing.Callable(cb4_bad1)[[Named(x, int)], None]`. -callables_protocol.py:121:0 Incompatible variable type [9]: cb6 is declared to have type `NotProto6` but is used as type `typing.Callable(cb6_bad1)[[Variable(bytes), KeywordOnly(max_len, Optional[int], default)], List[bytes]]`. -callables_protocol.py:169:0 Incompatible variable type [9]: cb8 is declared to have type `Proto8` but is used as type `typing.Callable(cb8_bad1)[[Named(x, int)], typing.Any]`. -callables_protocol.py:186:4 Incompatible attribute type [8]: Attribute `other_attribute` declared in class `Proto9` has type `int` but is used as type `str`. -callables_protocol.py:187:4 Undefined attribute [16]: `Proto9` has no attribute `xxx`. -callables_protocol.py:197:6 Undefined attribute [16]: `Proto9` has no attribute `other_attribute2`. -callables_protocol.py:216:0 Incompatible variable type [9]: cb10 is declared to have type `Proto10` but is used as type `typing.Callable(cb10_good)[[], None]`. -callables_protocol.py:259:0 Incompatible variable type [9]: cb12 is declared to have type `Proto12` but is used as type `typing.Callable(cb12_good2)[[Variable(typing.Any), Keywords(typing.Any)], None]`. -callables_protocol.py:260:0 Incompatible variable type [9]: cb12 is declared to have type `Proto12` but is used as type `typing.Callable(cb12_bad1)[[Variable(typing.Any), KeywordOnly(kwarg0, typing.Any)], None]`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 238: Expected 1 errors -Line 284: Expected 1 errors -Line 311: Expected 1 errors -Line 216: Unexpected errors ['callables_protocol.py:216:0 Incompatible variable type [9]: cb10 is declared to have type `Proto10` but is used as type `typing.Callable(cb10_good)[[], None]`.'] -Line 259: Unexpected errors ['callables_protocol.py:259:0 Incompatible variable type [9]: cb12 is declared to have type `Proto12` but is used as type `typing.Callable(cb12_good2)[[Variable(typing.Any), Keywords(typing.Any)], None]`.'] -""" diff --git a/conformance/results/pyre/callables_subtyping.toml b/conformance/results/pyre/callables_subtyping.toml deleted file mode 100644 index 4c686d89e..000000000 --- a/conformance/results/pyre/callables_subtyping.toml +++ /dev/null @@ -1,59 +0,0 @@ -conformant = "Partial" -notes = """ -Rejects standard parameter as incompatible with keyword-only parameter. -Rejects use of Callable with ParamSpec in TypeAlias definition. -""" -errors_diff = """ -Line 236: Expected 1 errors -Line 57: Unexpected errors ['callables_subtyping.py:57:4 Incompatible variable type [9]: f5 is declared to have type `KwOnly2` but is used as type `Standard2`.'] -Line 188: Unexpected errors ['callables_subtyping.py:188:4 Incompatible variable type [9]: f2 is declared to have type `KwOnly6` but is used as type `IntStrKwargs6`.'] -Line 189: Unexpected errors ['callables_subtyping.py:189:4 Incompatible variable type [9]: f3 is declared to have type `KwOnly6` but is used as type `StrKwargs6`.'] -Line 192: Unexpected errors ['callables_subtyping.py:192:4 Incompatible variable type [9]: f6 is declared to have type `StrKwargs6` but is used as type `IntStrKwargs6`.'] -Line 208: Unexpected errors ['callables_subtyping.py:208:0 Incompatible variable type [9]: TypeAliasWithP is declared to have type `TypeAlias` but is used as type `Type[typing.Callable[..., Variable[$synthetic_attribute_resolution_variable]]]`.', 'callables_subtyping.py:208:37 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[typing.Any, Type[Variable[$synthetic_attribute_resolution_variable]]]` but got `Tuple[ParamSpec, None]`.'] -Line 211: Unexpected errors ['callables_subtyping.py:211:39 Undefined or invalid type [11]: Annotation `TypeAliasWithP` is not defined as a type.'] -Line 253: Unexpected errors ['callables_subtyping.py:253:4 Missing overload implementation [42]: Overloaded function `Overloaded9.__call__` must have an implementation.'] -Line 282: Unexpected errors ['callables_subtyping.py:282:4 Missing overload implementation [42]: Overloaded function `Overloaded10.__call__` must have an implementation.'] -""" -output = """ -callables_subtyping.py:26:4 Incompatible variable type [9]: f6 is declared to have type `typing.Callable[[float], float]` but is used as type `typing.Callable[[int], int]`. -callables_subtyping.py:29:4 Incompatible variable type [9]: f8 is declared to have type `typing.Callable[[int], int]` but is used as type `typing.Callable[[float], float]`. -callables_subtyping.py:51:4 Incompatible variable type [9]: f1 is declared to have type `Standard2` but is used as type `PosOnly2`. -callables_subtyping.py:52:4 Incompatible variable type [9]: f2 is declared to have type `Standard2` but is used as type `KwOnly2`. -callables_subtyping.py:55:4 Incompatible variable type [9]: f4 is declared to have type `PosOnly2` but is used as type `KwOnly2`. -callables_subtyping.py:57:4 Incompatible variable type [9]: f5 is declared to have type `KwOnly2` but is used as type `Standard2`. -callables_subtyping.py:58:4 Incompatible variable type [9]: f6 is declared to have type `KwOnly2` but is used as type `PosOnly2`. -callables_subtyping.py:82:4 Incompatible variable type [9]: f3 is declared to have type `IntArgs3` but is used as type `NoArgs3`. -callables_subtyping.py:85:4 Incompatible variable type [9]: f5 is declared to have type `FloatArgs3` but is used as type `NoArgs3`. -callables_subtyping.py:86:4 Incompatible variable type [9]: f6 is declared to have type `FloatArgs3` but is used as type `IntArgs3`. -callables_subtyping.py:116:4 Incompatible variable type [9]: f1 is declared to have type `PosOnly4` but is used as type `IntArgs4`. -callables_subtyping.py:119:4 Incompatible variable type [9]: f4 is declared to have type `IntStrArgs4` but is used as type `StrArgs4`. -callables_subtyping.py:120:4 Incompatible variable type [9]: f5 is declared to have type `IntStrArgs4` but is used as type `IntArgs4`. -callables_subtyping.py:122:4 Incompatible variable type [9]: f7 is declared to have type `StrArgs4` but is used as type `IntArgs4`. -callables_subtyping.py:124:4 Incompatible variable type [9]: f9 is declared to have type `IntArgs4` but is used as type `StrArgs4`. -callables_subtyping.py:125:4 Incompatible variable type [9]: f10 is declared to have type `Standard4` but is used as type `IntStrArgs4`. -callables_subtyping.py:126:4 Incompatible variable type [9]: f11 is declared to have type `Standard4` but is used as type `StrArgs4`. -callables_subtyping.py:151:4 Incompatible variable type [9]: f3 is declared to have type `IntKwargs5` but is used as type `NoKwargs5`. -callables_subtyping.py:154:4 Incompatible variable type [9]: f5 is declared to have type `FloatKwargs5` but is used as type `NoKwargs5`. -callables_subtyping.py:155:4 Incompatible variable type [9]: f6 is declared to have type `FloatKwargs5` but is used as type `IntKwargs5`. -callables_subtyping.py:187:4 Incompatible variable type [9]: f1 is declared to have type `KwOnly6` but is used as type `IntKwargs6`. -callables_subtyping.py:188:4 Incompatible variable type [9]: f2 is declared to have type `KwOnly6` but is used as type `IntStrKwargs6`. -callables_subtyping.py:189:4 Incompatible variable type [9]: f3 is declared to have type `KwOnly6` but is used as type `StrKwargs6`. -callables_subtyping.py:190:4 Incompatible variable type [9]: f4 is declared to have type `IntStrKwargs6` but is used as type `StrKwargs6`. -callables_subtyping.py:191:4 Incompatible variable type [9]: f5 is declared to have type `IntStrKwargs6` but is used as type `IntKwargs6`. -callables_subtyping.py:192:4 Incompatible variable type [9]: f6 is declared to have type `StrKwargs6` but is used as type `IntStrKwargs6`. -callables_subtyping.py:193:4 Incompatible variable type [9]: f7 is declared to have type `StrKwargs6` but is used as type `IntKwargs6`. -callables_subtyping.py:195:4 Incompatible variable type [9]: f9 is declared to have type `IntKwargs6` but is used as type `StrKwargs6`. -callables_subtyping.py:196:4 Incompatible variable type [9]: f10 is declared to have type `Standard6` but is used as type `IntStrKwargs6`. -callables_subtyping.py:197:4 Incompatible variable type [9]: f11 is declared to have type `Standard6` but is used as type `StrKwargs6`. -callables_subtyping.py:208:0 Incompatible variable type [9]: TypeAliasWithP is declared to have type `TypeAlias` but is used as type `Type[typing.Callable[..., Variable[$synthetic_attribute_resolution_variable]]]`. -callables_subtyping.py:208:37 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[typing.Any, Type[Variable[$synthetic_attribute_resolution_variable]]]` but got `Tuple[ParamSpec, None]`. -callables_subtyping.py:211:39 Undefined or invalid type [11]: Annotation `TypeAliasWithP` is not defined as a type. -callables_subtyping.py:237:4 Incompatible variable type [9]: f2 is declared to have type `DefaultArg8` but is used as type `NoX8`. -callables_subtyping.py:240:4 Incompatible variable type [9]: f4 is declared to have type `NoDefaultArg8` but is used as type `NoX8`. -callables_subtyping.py:243:4 Incompatible variable type [9]: f6 is declared to have type `NoX8` but is used as type `NoDefaultArg8`. -callables_subtyping.py:253:4 Missing overload implementation [42]: Overloaded function `Overloaded9.__call__` must have an implementation. -callables_subtyping.py:273:4 Incompatible variable type [9]: f3 is declared to have type `FloatArg9` but is used as type `Overloaded9`. -callables_subtyping.py:282:4 Missing overload implementation [42]: Overloaded function `Overloaded10.__call__` must have an implementation. -callables_subtyping.py:297:4 Incompatible variable type [9]: f2 is declared to have type `Overloaded10` but is used as type `StrArg10`. -""" -conformance_automated = "Fail" diff --git a/conformance/results/pyre/classes_classvar.toml b/conformance/results/pyre/classes_classvar.toml deleted file mode 100644 index 9c4e661ca..000000000 --- a/conformance/results/pyre/classes_classvar.toml +++ /dev/null @@ -1,45 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject use of TypeVar in ClassVar. -Does not reject use of ParamSpec in ClassVar. -Does not reject use of ClassVar as a generic type argument. -Does not reject use of ClassVar in parameter type annotation. -Does not reject use of ClassVar in local variable annotation. -Does not reject use of ClassVar in instance variable annotation. -Does not reject use of ClassVar in return type annotation. -Does not reject use of ClassVar in type alias definition. -Does not infer type from initialization for bare ClassVar. -""" -output = """ -classes_classvar.py:34:0 Uninitialized attribute [13]: Attribute `bad1` is declared in class `ClassA` to have type `typing.Any` but is never initialized. -classes_classvar.py:34:0 Uninitialized attribute [13]: Attribute `bad4` is declared in class `ClassA` to have type `Variable[T]` but is never initialized. -classes_classvar.py:34:0 Uninitialized attribute [13]: Attribute `bad5` is declared in class `ClassA` to have type `typing.List[Variable[T]]` but is never initialized. -classes_classvar.py:34:0 Uninitialized attribute [13]: Attribute `bad6` is declared in class `ClassA` to have type `typing.Callable[classes_classvar.P, typing.Any]` but is never initialized. -classes_classvar.py:37:10 Invalid type parameters [24]: Generic type `CV` expects 1 type parameter, received 2. -classes_classvar.py:38:10 Invalid type [31]: Expression `typing.ClassVar[3]` is not a valid type. -classes_classvar.py:39:13 Unbound name [10]: Name `var` is used but not defined in the current scope. -classes_classvar.py:51:4 Incompatible attribute type [8]: Attribute `bad8` declared in class `ClassA` has type `List[str]` but is used as type `Dict[Variable[_KT], Variable[_VT]]`. -classes_classvar.py:64:8 Undefined attribute [16]: `ClassA` has no attribute `xx`. -classes_classvar.py:67:8 Incompatible return type [7]: Expected `CV[int]` but got `int`. -classes_classvar.py:77:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `float` but got `typing.Any`. -classes_classvar.py:80:0 Uninitialized attribute [13]: Attribute `damage` is declared in class `BasicStarship` to have type `int` but is never initialized. -classes_classvar.py:101:0 Invalid assignment [41]: Assigning to class variable through instance, did you mean to assign to `Starship.stats` instead? -classes_classvar.py:130:0 Incompatible variable type [9]: a is declared to have type `ProtoA` but is used as type `ProtoAImpl`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 44: Expected 1 errors -Line 45: Expected 1 errors -Line 46: Expected 1 errors -Line 53: Expected 1 errors -Line 54: Expected 1 errors -Line 62: Expected 1 errors -Line 63: Expected 1 errors -Line 66: Expected 1 errors -Line 70: Expected 1 errors -Line 71: Expected 1 errors -Line 34: Unexpected errors ['classes_classvar.py:34:0 Uninitialized attribute [13]: Attribute `bad1` is declared in class `ClassA` to have type `typing.Any` but is never initialized.', 'classes_classvar.py:34:0 Uninitialized attribute [13]: Attribute `bad4` is declared in class `ClassA` to have type `Variable[T]` but is never initialized.', 'classes_classvar.py:34:0 Uninitialized attribute [13]: Attribute `bad5` is declared in class `ClassA` to have type `typing.List[Variable[T]]` but is never initialized.', 'classes_classvar.py:34:0 Uninitialized attribute [13]: Attribute `bad6` is declared in class `ClassA` to have type `typing.Callable[classes_classvar.P, typing.Any]` but is never initialized.'] -Line 67: Unexpected errors ['classes_classvar.py:67:8 Incompatible return type [7]: Expected `CV[int]` but got `int`.'] -Line 77: Unexpected errors ['classes_classvar.py:77:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `float` but got `typing.Any`.'] -Line 80: Unexpected errors ['classes_classvar.py:80:0 Uninitialized attribute [13]: Attribute `damage` is declared in class `BasicStarship` to have type `int` but is never initialized.'] -""" diff --git a/conformance/results/pyre/classes_override.toml b/conformance/results/pyre/classes_override.toml deleted file mode 100644 index ac73d049b..000000000 --- a/conformance/results/pyre/classes_override.toml +++ /dev/null @@ -1,19 +0,0 @@ -conformant = "Partial" -notes = """ -Does not allow Any as a base class, leading to false positives. -""" -output = """ -classes_override.py:53:4 Invalid override [40]: `classes_override.ChildA.method3` is decorated with @override, but no method of the same name exists in superclasses of `ChildA`. -classes_override.py:65:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s). -classes_override.py:65:4 Invalid override [40]: `classes_override.ChildA.method4` is decorated with @override, but no method of the same name exists in superclasses of `ChildA`. -classes_override.py:79:4 Invalid override [40]: `classes_override.ChildA.static_method1` is decorated with @override, but no method of the same name exists in superclasses of `ChildA`. -classes_override.py:84:4 Invalid override [40]: `classes_override.ChildA.class_method1` is decorated with @override, but no method of the same name exists in superclasses of `ChildA`. -classes_override.py:89:4 Invalid override [40]: `classes_override.ChildA.property1` is decorated with @override, but no method of the same name exists in superclasses of `ChildA`. -classes_override.py:95:14 Invalid inheritance [39]: `typing.Any` is not a valid parent class. -classes_override.py:101:4 Invalid override [40]: `classes_override.ChildB.method1` is decorated with @override, but no method of the same name exists in superclasses of `ChildB`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 95: Unexpected errors ['classes_override.py:95:14 Invalid inheritance [39]: `typing.Any` is not a valid parent class.'] -Line 101: Unexpected errors ['classes_override.py:101:4 Invalid override [40]: `classes_override.ChildB.method1` is decorated with @override, but no method of the same name exists in superclasses of `ChildB`.'] -""" diff --git a/conformance/results/pyre/constructors_call_init.toml b/conformance/results/pyre/constructors_call_init.toml deleted file mode 100644 index 9358ef095..000000000 --- a/conformance/results/pyre/constructors_call_init.toml +++ /dev/null @@ -1,26 +0,0 @@ -conformant = "Partial" -notes = """ -Does not infer type of Self for self parameter of __init__ method. -Does not report errors during binding to self parameter of __init__ method. -Does not reject use of class-scoped type variables in annotation of self parameter in __init__ method. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 42: Expected 1 errors -Line 56: Expected 1 errors -Line 107: Expected 1 errors -Line 24: Unexpected errors ['constructors_call_init.py:24:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class1[int]` but got `Class1[typing_extensions.Literal[1]]`.'] -Line 61: Unexpected errors ['constructors_call_init.py:61:4 Incompatible overload [43]: The implementation of `Class5.__init__` does not accept all possible arguments of overload defined on line `61`.'] -Line 63: Unexpected errors ['constructors_call_init.py:63:4 Incompatible overload [43]: The implementation of `Class5.__init__` does not accept all possible arguments of overload defined on line `63`.'] -Line 91: Unexpected errors ["constructors_call_init.py:91:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class6[int, str]` but got `Class6[typing_extensions.Literal[0], typing_extensions.Literal['']]`."] -Line 99: Unexpected errors ["constructors_call_init.py:99:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class7[str, int]` but got `Class7[typing_extensions.Literal[''], typing_extensions.Literal[0]]`."] -""" -output = """ -constructors_call_init.py:21:12 Incompatible parameter type [6]: In call `Class1.__init__`, for 1st positional argument, expected `int` but got `float`. -constructors_call_init.py:24:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class1[int]` but got `Class1[typing_extensions.Literal[1]]`. -constructors_call_init.py:61:4 Incompatible overload [43]: The implementation of `Class5.__init__` does not accept all possible arguments of overload defined on line `61`. -constructors_call_init.py:63:4 Incompatible overload [43]: The implementation of `Class5.__init__` does not accept all possible arguments of overload defined on line `63`. -constructors_call_init.py:91:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class6[int, str]` but got `Class6[typing_extensions.Literal[0], typing_extensions.Literal['']]`. -constructors_call_init.py:99:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class7[str, int]` but got `Class7[typing_extensions.Literal[''], typing_extensions.Literal[0]]`. -constructors_call_init.py:130:0 Too many arguments [19]: Call `object.__init__` expects 0 positional arguments, 1 was provided. -""" diff --git a/conformance/results/pyre/constructors_call_metaclass.toml b/conformance/results/pyre/constructors_call_metaclass.toml deleted file mode 100644 index 9fb54b5f8..000000000 --- a/conformance/results/pyre/constructors_call_metaclass.toml +++ /dev/null @@ -1,11 +0,0 @@ -conformant = "Partial" -notes = """ -Does not evaluate __new__ if metaclass __call__ is defined. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 51: Expected 1 errors -Line 65: Expected 1 errors -""" -output = """ -""" diff --git a/conformance/results/pyre/constructors_call_new.toml b/conformance/results/pyre/constructors_call_new.toml deleted file mode 100644 index 3974f524a..000000000 --- a/conformance/results/pyre/constructors_call_new.toml +++ /dev/null @@ -1,30 +0,0 @@ -conformant = "Partial" -notes = """ -Does not support __new__ return type that is not a subclass of the class being constructed. -Does not report errors during binding to cls parameter of __new__ method. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 145: Expected 1 errors -Line 23: Unexpected errors ['constructors_call_new.py:23:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class1[int]` but got `Class1[typing_extensions.Literal[1]]`.'] -Line 35: Unexpected errors ['constructors_call_new.py:35:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class2[int]` but got `Class2[typing_extensions.Literal[1]]`.'] -Line 36: Unexpected errors ["constructors_call_new.py:36:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class2[str]` but got `Class2[typing_extensions.Literal['']]`."] -Line 49: Unexpected errors ['constructors_call_new.py:49:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `Class3`.', 'constructors_call_new.py:49:12 Missing argument [20]: Call `Class3.__init__` expects argument `x`.'] -Line 64: Unexpected errors ['constructors_call_new.py:64:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing.Any` but got `Class4`.', 'constructors_call_new.py:64:12 Missing argument [20]: Call `Class4.__init__` expects argument `x`.'] -Line 76: Unexpected errors ['constructors_call_new.py:76:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `NoReturn` but got `Class5`.', 'constructors_call_new.py:76:16 Missing argument [20]: Call `Class5.__init__` expects argument `x`.'] -Line 89: Unexpected errors ['constructors_call_new.py:89:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Union[Class6, int]` but got `Class6`.', 'constructors_call_new.py:89:12 Missing argument [20]: Call `Class6.__init__` expects argument `x`.'] -""" -output = """ -constructors_call_new.py:21:12 Incompatible parameter type [6]: In call `Class1.__new__`, for 1st positional argument, expected `int` but got `float`. -constructors_call_new.py:23:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class1[int]` but got `Class1[typing_extensions.Literal[1]]`. -constructors_call_new.py:35:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class2[int]` but got `Class2[typing_extensions.Literal[1]]`. -constructors_call_new.py:36:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class2[str]` but got `Class2[typing_extensions.Literal['']]`. -constructors_call_new.py:49:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `Class3`. -constructors_call_new.py:49:12 Missing argument [20]: Call `Class3.__init__` expects argument `x`. -constructors_call_new.py:64:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing.Any` but got `Class4`. -constructors_call_new.py:64:12 Missing argument [20]: Call `Class4.__init__` expects argument `x`. -constructors_call_new.py:76:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `NoReturn` but got `Class5`. -constructors_call_new.py:76:16 Missing argument [20]: Call `Class5.__init__` expects argument `x`. -constructors_call_new.py:89:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Union[Class6, int]` but got `Class6`. -constructors_call_new.py:89:12 Missing argument [20]: Call `Class6.__init__` expects argument `x`. -""" diff --git a/conformance/results/pyre/constructors_call_type.toml b/conformance/results/pyre/constructors_call_type.toml deleted file mode 100644 index 1e06c340a..000000000 --- a/conformance/results/pyre/constructors_call_type.toml +++ /dev/null @@ -1,13 +0,0 @@ -conformant = "Pass" -errors_diff = """ -""" -output = """ -constructors_call_type.py:30:4 Missing argument [20]: Call `Meta1.__call__` expects argument `x`. -constructors_call_type.py:40:4 Missing argument [20]: Call `Class2.__new__` expects argument `x`. -constructors_call_type.py:50:4 Missing argument [20]: Call `Class3.__init__` expects argument `x`. -constructors_call_type.py:59:4 Too many arguments [19]: Call `object.__init__` expects 0 positional arguments, 1 was provided. -constructors_call_type.py:64:4 Too many arguments [19]: Call `object.__init__` expects 0 positional arguments, 1 was provided. -constructors_call_type.py:72:4 Missing argument [20]: Call `Meta1.__call__` expects argument `x`. -constructors_call_type.py:81:4 Missing argument [20]: Call `Class2.__new__` expects argument `y`. -constructors_call_type.py:82:11 Incompatible parameter type [6]: In call `Class2.__new__`, for 2nd positional argument, expected `str` but got `int`. -""" diff --git a/conformance/results/pyre/constructors_callable.toml b/conformance/results/pyre/constructors_callable.toml deleted file mode 100644 index bc7ec6948..000000000 --- a/conformance/results/pyre/constructors_callable.toml +++ /dev/null @@ -1,71 +0,0 @@ -conformant = "Partial" -notes = """ -Does not generate a union type for __new__ and __init__ when converting class to callable. -Does not ignore __init__ based on __new__ return type when converting class to callable. -Does not support __new__ return type that is different from class being constructed. -Does not use annotated type of self in __init__ method to generate return type of callable. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 127: Expected 1 errors -Line 144: Expected 1 errors -Line 184: Expected 1 errors -Line 195: Expected 1 errors -Line 36: Unexpected errors ['constructors_callable.py:36:0 Revealed type [-1]: Revealed type for `r1` is `typing.Callable[[Named(x, int)], Class1]`.'] -Line 49: Unexpected errors ['constructors_callable.py:49:0 Revealed type [-1]: Revealed type for `r2` is `typing.Callable[[], Class2]`.'] -Line 63: Unexpected errors ['constructors_callable.py:63:0 Revealed type [-1]: Revealed type for `r3` is `typing.Callable[[Named(x, int)], Class3]`.'] -Line 77: Unexpected errors ['constructors_callable.py:77:0 Revealed type [-1]: Revealed type for `r4` is `typing.Callable[[Named(x, int)], Class4]`.'] -Line 78: Unexpected errors ['constructors_callable.py:78:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `Class4`.'] -Line 97: Unexpected errors ['constructors_callable.py:97:0 Revealed type [-1]: Revealed type for `r5` is `typing.Callable[[Variable(typing.Any), Keywords(typing.Any)], NoReturn]`.'] -Line 117: Unexpected errors ['constructors_callable.py:117:8 Incompatible return type [7]: Expected `Class6Proxy` but got `Class6`.'] -Line 125: Unexpected errors ['constructors_callable.py:125:0 Revealed type [-1]: Revealed type for `r6` is `typing.Callable[[Named(x, int)], Class6]`.'] -Line 126: Unexpected errors ['constructors_callable.py:126:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class6Proxy` but got `Class6`.', 'constructors_callable.py:126:12 Missing argument [20]: PositionalOnly call expects argument `x`.'] -Line 142: Unexpected errors ['constructors_callable.py:142:0 Revealed type [-1]: Revealed type for `r6_any` is `typing.Callable[[Named(x, int)], Class6Any]`.'] -Line 143: Unexpected errors ['constructors_callable.py:143:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing.Any` but got `Class6Any`.', 'constructors_callable.py:143:12 Missing argument [20]: PositionalOnly call expects argument `x`.'] -Line 153: Unexpected errors ['constructors_callable.py:153:4 Incompatible overload [43]: The implementation of `Class7.__init__` does not accept all possible arguments of overload defined on line `153`.'] -Line 155: Unexpected errors ['constructors_callable.py:155:4 Incompatible overload [43]: The implementation of `Class7.__init__` does not accept all possible arguments of overload defined on line `155`.'] -Line 161: Unexpected errors ['constructors_callable.py:161:0 Revealed type [-1]: Revealed type for `r7` is `typing.Callable[[Named(x, int)], Class7[typing.Any]]`.'] -Line 164: Unexpected errors ['constructors_callable.py:164:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class7[int]` but got `Class7[typing.Any]`.'] -Line 165: Unexpected errors ['constructors_callable.py:165:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class7[str]` but got `Class7[typing.Any]`.', 'constructors_callable.py:165:15 Incompatible parameter type [6]: In anonymous call, for 1st positional argument, expected `int` but got `str`.'] -Line 181: Unexpected errors ['constructors_callable.py:181:22 Incompatible parameter type [6]: In call `accepts_callable`, for 1st positional argument, expected `typing.Callable[constructors_callable.P, Variable[R]]` but got `Type[Class8]`.'] -Line 182: Unexpected errors ['constructors_callable.py:182:0 Revealed type [-1]: Revealed type for `r8` is `typing.Callable[..., typing.Any]`.'] -Line 183: Unexpected errors ['constructors_callable.py:183:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class8[str]` but got `typing.Any`.'] -Line 192: Unexpected errors ['constructors_callable.py:192:22 Incompatible parameter type [6]: In call `accepts_callable`, for 1st positional argument, expected `typing.Callable[constructors_callable.P, Variable[R]]` but got `Type[Class9]`.'] -Line 193: Unexpected errors ['constructors_callable.py:193:0 Revealed type [-1]: Revealed type for `r9` is `typing.Callable[..., typing.Any]`.'] -Line 194: Unexpected errors ['constructors_callable.py:194:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class9` but got `typing.Any`.'] -""" -output = """ -constructors_callable.py:36:0 Revealed type [-1]: Revealed type for `r1` is `typing.Callable[[Named(x, int)], Class1]`. -constructors_callable.py:38:0 Missing argument [20]: PositionalOnly call expects argument `x`. -constructors_callable.py:39:0 Unexpected keyword [28]: Unexpected keyword argument `y` to anonymous call. -constructors_callable.py:49:0 Revealed type [-1]: Revealed type for `r2` is `typing.Callable[[], Class2]`. -constructors_callable.py:51:0 Too many arguments [19]: PositionalOnly call expects 0 positional arguments, 1 was provided. -constructors_callable.py:63:0 Revealed type [-1]: Revealed type for `r3` is `typing.Callable[[Named(x, int)], Class3]`. -constructors_callable.py:65:0 Missing argument [20]: PositionalOnly call expects argument `x`. -constructors_callable.py:66:0 Unexpected keyword [28]: Unexpected keyword argument `y` to anonymous call. -constructors_callable.py:67:0 Too many arguments [19]: PositionalOnly call expects 1 positional argument, 2 were provided. -constructors_callable.py:77:0 Revealed type [-1]: Revealed type for `r4` is `typing.Callable[[Named(x, int)], Class4]`. -constructors_callable.py:78:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `Class4`. -constructors_callable.py:79:0 Missing argument [20]: PositionalOnly call expects argument `x`. -constructors_callable.py:80:0 Unexpected keyword [28]: Unexpected keyword argument `y` to anonymous call. -constructors_callable.py:97:0 Revealed type [-1]: Revealed type for `r5` is `typing.Callable[[Variable(typing.Any), Keywords(typing.Any)], NoReturn]`. -constructors_callable.py:117:8 Incompatible return type [7]: Expected `Class6Proxy` but got `Class6`. -constructors_callable.py:125:0 Revealed type [-1]: Revealed type for `r6` is `typing.Callable[[Named(x, int)], Class6]`. -constructors_callable.py:126:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class6Proxy` but got `Class6`. -constructors_callable.py:126:12 Missing argument [20]: PositionalOnly call expects argument `x`. -constructors_callable.py:142:0 Revealed type [-1]: Revealed type for `r6_any` is `typing.Callable[[Named(x, int)], Class6Any]`. -constructors_callable.py:143:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing.Any` but got `Class6Any`. -constructors_callable.py:143:12 Missing argument [20]: PositionalOnly call expects argument `x`. -constructors_callable.py:153:4 Incompatible overload [43]: The implementation of `Class7.__init__` does not accept all possible arguments of overload defined on line `153`. -constructors_callable.py:155:4 Incompatible overload [43]: The implementation of `Class7.__init__` does not accept all possible arguments of overload defined on line `155`. -constructors_callable.py:161:0 Revealed type [-1]: Revealed type for `r7` is `typing.Callable[[Named(x, int)], Class7[typing.Any]]`. -constructors_callable.py:164:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class7[int]` but got `Class7[typing.Any]`. -constructors_callable.py:165:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class7[str]` but got `Class7[typing.Any]`. -constructors_callable.py:165:15 Incompatible parameter type [6]: In anonymous call, for 1st positional argument, expected `int` but got `str`. -constructors_callable.py:181:22 Incompatible parameter type [6]: In call `accepts_callable`, for 1st positional argument, expected `typing.Callable[constructors_callable.P, Variable[R]]` but got `Type[Class8]`. -constructors_callable.py:182:0 Revealed type [-1]: Revealed type for `r8` is `typing.Callable[..., typing.Any]`. -constructors_callable.py:183:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class8[str]` but got `typing.Any`. -constructors_callable.py:192:22 Incompatible parameter type [6]: In call `accepts_callable`, for 1st positional argument, expected `typing.Callable[constructors_callable.P, Variable[R]]` but got `Type[Class9]`. -constructors_callable.py:193:0 Revealed type [-1]: Revealed type for `r9` is `typing.Callable[..., typing.Any]`. -constructors_callable.py:194:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class9` but got `typing.Any`. -""" diff --git a/conformance/results/pyre/constructors_consistency.toml b/conformance/results/pyre/constructors_consistency.toml deleted file mode 100644 index 225d7847a..000000000 --- a/conformance/results/pyre/constructors_consistency.toml +++ /dev/null @@ -1,4 +0,0 @@ -conformant = "Pass" -notes = """ -Does not report inconsistency between __new__ and __init__ (optional). -""" diff --git a/conformance/results/pyre/dataclasses_descriptors.toml b/conformance/results/pyre/dataclasses_descriptors.toml deleted file mode 100644 index 0f99b5978..000000000 --- a/conformance/results/pyre/dataclasses_descriptors.toml +++ /dev/null @@ -1,19 +0,0 @@ -conformant = "Partial" -notes = """ -Incorrectly generates error when calling constructor of dataclass with descriptor. -""" -output = """ -dataclasses_descriptors.py:35:10 Incompatible parameter type [6]: In call `DC1.__init__`, for 1st positional argument, expected `Desc1` but got `int`. -dataclasses_descriptors.py:61:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `List[int]` but got `Desc2[int]`. -dataclasses_descriptors.py:62:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `List[str]` but got `Desc2[str]`. -dataclasses_descriptors.py:66:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `Desc2[int]`. -dataclasses_descriptors.py:67:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `Desc2[str]`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 35: Unexpected errors ['dataclasses_descriptors.py:35:10 Incompatible parameter type [6]: In call `DC1.__init__`, for 1st positional argument, expected `Desc1` but got `int`.'] -Line 61: Unexpected errors ['dataclasses_descriptors.py:61:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `List[int]` but got `Desc2[int]`.'] -Line 62: Unexpected errors ['dataclasses_descriptors.py:62:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `List[str]` but got `Desc2[str]`.'] -Line 66: Unexpected errors ['dataclasses_descriptors.py:66:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `Desc2[int]`.'] -Line 67: Unexpected errors ['dataclasses_descriptors.py:67:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `Desc2[str]`.'] -""" diff --git a/conformance/results/pyre/dataclasses_final.toml b/conformance/results/pyre/dataclasses_final.toml deleted file mode 100644 index 00886a3ba..000000000 --- a/conformance/results/pyre/dataclasses_final.toml +++ /dev/null @@ -1,19 +0,0 @@ -conformant = "Partial" -notes = """ -Mis-handles Final nested inside ClassVar. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 18: Unexpected errors ['dataclasses_final.py:18:4 Incompatible attribute type [8]: Attribute `final_classvar` declared in class `D` has type `Final[int]` but is used as type `int`.', 'dataclasses_final.py:18:4 Invalid type [31]: Expression `Final[int]` is not a valid type. Final cannot be nested.'] -Line 24: Unexpected errors ['dataclasses_final.py:24:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `Final[int]`.'] -""" -output = """ -dataclasses_final.py:18:4 Incompatible attribute type [8]: Attribute `final_classvar` declared in class `D` has type `Final[int]` but is used as type `int`. -dataclasses_final.py:18:4 Invalid type [31]: Expression `Final[int]` is not a valid type. Final cannot be nested. -dataclasses_final.py:24:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `Final[int]`. -dataclasses_final.py:27:0 Incompatible attribute type [8]: Attribute `final_classvar` declared in class `D` has type `Final[int]` but is used as type `int`. -dataclasses_final.py:35:0 Invalid assignment [41]: Cannot reassign final attribute `d.final_no_default`. -dataclasses_final.py:36:0 Invalid assignment [41]: Cannot reassign final attribute `d.final_with_default`. -dataclasses_final.py:37:0 Invalid assignment [41]: Cannot reassign final attribute `D.final_no_default`. -dataclasses_final.py:38:0 Invalid assignment [41]: Cannot reassign final attribute `D.final_with_default`. -""" diff --git a/conformance/results/pyre/dataclasses_frozen.toml b/conformance/results/pyre/dataclasses_frozen.toml deleted file mode 100644 index 109a4dbeb..000000000 --- a/conformance/results/pyre/dataclasses_frozen.toml +++ /dev/null @@ -1,14 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject frozen dataclass inherited from non-frozen dataclass. -Does not reject non-frozen dataclass inherited from frozen dataclass. -""" -output = """ -dataclasses_frozen.py:16:0 Invalid assignment [41]: Cannot reassign final attribute `dc1.a`. -dataclasses_frozen.py:17:0 Invalid assignment [41]: Cannot reassign final attribute `dc1.b`. -""" -conformance_automated = "Fail" -errors_diff = """ -Lines 22, 23: Expected error (tag 'DC2') -Lines 32, 33: Expected error (tag 'DC4') -""" diff --git a/conformance/results/pyre/dataclasses_hash.toml b/conformance/results/pyre/dataclasses_hash.toml deleted file mode 100644 index 7af6dcbdc..000000000 --- a/conformance/results/pyre/dataclasses_hash.toml +++ /dev/null @@ -1,11 +0,0 @@ -conformant = "Partial" -notes = """ -Does not report when dataclass is not compatible with Hashable protocol. -""" -output = """ -""" -conformance_automated = "Fail" -errors_diff = """ -Line 15: Expected 1 errors -Line 32: Expected 1 errors -""" diff --git a/conformance/results/pyre/dataclasses_inheritance.toml b/conformance/results/pyre/dataclasses_inheritance.toml deleted file mode 100644 index eb0547dd5..000000000 --- a/conformance/results/pyre/dataclasses_inheritance.toml +++ /dev/null @@ -1,12 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject ClassVar that is overridden by instance variable. -Does not reject instance variable that is overridden by ClassVar. -""" -output = """ -""" -conformance_automated = "Fail" -errors_diff = """ -Line 60: Expected 1 errors -Line 64: Expected 1 errors -""" diff --git a/conformance/results/pyre/dataclasses_kwonly.toml b/conformance/results/pyre/dataclasses_kwonly.toml deleted file mode 100644 index 7ee1c34ef..000000000 --- a/conformance/results/pyre/dataclasses_kwonly.toml +++ /dev/null @@ -1,9 +0,0 @@ -conformant = "Pass" -output = """ -dataclasses_kwonly.py:23:0 Too many arguments [19]: Call `DC1.__init__` expects 1 positional argument, 2 were provided. -dataclasses_kwonly.py:38:0 Too many arguments [19]: Call `DC2.__init__` expects 1 positional argument, 2 were provided. -dataclasses_kwonly.py:53:0 Too many arguments [19]: Call `DC3.__init__` expects 1 positional argument, 2 were provided. -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pyre/dataclasses_order.toml b/conformance/results/pyre/dataclasses_order.toml deleted file mode 100644 index 0452db28b..000000000 --- a/conformance/results/pyre/dataclasses_order.toml +++ /dev/null @@ -1,7 +0,0 @@ -conformant = "Pass" -output = """ -dataclasses_order.py:50:3 Unsupported operand [58]: `<` is not supported for operand types `DC1` and `DC2`. -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pyre/dataclasses_postinit.toml b/conformance/results/pyre/dataclasses_postinit.toml deleted file mode 100644 index 311994866..000000000 --- a/conformance/results/pyre/dataclasses_postinit.toml +++ /dev/null @@ -1,28 +0,0 @@ -conformant = "Partial" -notes = """ -Does not perform validation of `__post_init__` method. -Incorrectly complains on the assignment of `InitVar` in class bodies. -""" -output = """ -dataclasses_postinit.py:15:4 Undefined attribute [16]: `typing.Type` has no attribute `x`. -dataclasses_postinit.py:17:4 Undefined attribute [16]: `typing.Type` has no attribute `y`. -dataclasses_postinit.py:28:6 Undefined attribute [16]: `DC1` has no attribute `x`. -dataclasses_postinit.py:29:6 Undefined attribute [16]: `DC1` has no attribute `y`. -dataclasses_postinit.py:33:4 Undefined attribute [16]: `typing.Type` has no attribute `x`. -dataclasses_postinit.py:34:4 Undefined attribute [16]: `typing.Type` has no attribute `y`. -dataclasses_postinit.py:42:4 Undefined attribute [16]: `typing.Type` has no attribute `_name`. -dataclasses_postinit.py:51:4 Undefined attribute [16]: `typing.Type` has no attribute `_age`. -dataclasses_postinit.py:54:4 Inconsistent override [14]: `dataclasses_postinit.DC4.__post_init__` overrides method defined in `DC3` inconsistently. Could not find parameter `_age` in overridden signature. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 19: Expected 1 errors -Line 36: Expected 1 errors -Line 15: Unexpected errors ['dataclasses_postinit.py:15:4 Undefined attribute [16]: `typing.Type` has no attribute `x`.'] -Line 17: Unexpected errors ['dataclasses_postinit.py:17:4 Undefined attribute [16]: `typing.Type` has no attribute `y`.'] -Line 33: Unexpected errors ['dataclasses_postinit.py:33:4 Undefined attribute [16]: `typing.Type` has no attribute `x`.'] -Line 34: Unexpected errors ['dataclasses_postinit.py:34:4 Undefined attribute [16]: `typing.Type` has no attribute `y`.'] -Line 42: Unexpected errors ['dataclasses_postinit.py:42:4 Undefined attribute [16]: `typing.Type` has no attribute `_name`.'] -Line 51: Unexpected errors ['dataclasses_postinit.py:51:4 Undefined attribute [16]: `typing.Type` has no attribute `_age`.'] -Line 54: Unexpected errors ['dataclasses_postinit.py:54:4 Inconsistent override [14]: `dataclasses_postinit.DC4.__post_init__` overrides method defined in `DC3` inconsistently. Could not find parameter `_age` in overridden signature.'] -""" diff --git a/conformance/results/pyre/dataclasses_slots.toml b/conformance/results/pyre/dataclasses_slots.toml deleted file mode 100644 index ca83a885b..000000000 --- a/conformance/results/pyre/dataclasses_slots.toml +++ /dev/null @@ -1,16 +0,0 @@ -conformant = "Partial" -notes = """ -Does not report error when `slots=True` is used with `__slots__` definition. -Does not reject write to instance variable that is not defined in __slots__. -Does not reject access to `__slots__` from dataclass instance when `slots=False`. -""" -output = """ -dataclasses_slots.py:66:0 Undefined attribute [16]: `DC6` has no attribute `__slots__`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 25: Expected 1 errors -Line 38: Expected 1 errors -Line 69: Expected 1 errors -Lines 10, 11: Expected error (tag 'DC1') -""" diff --git a/conformance/results/pyre/dataclasses_transform_class.toml b/conformance/results/pyre/dataclasses_transform_class.toml deleted file mode 100644 index e340ff43a..000000000 --- a/conformance/results/pyre/dataclasses_transform_class.toml +++ /dev/null @@ -1,24 +0,0 @@ -conformant = "Partial" -notes = """ -Does not validate when a non-frozen model derives from a frozen one. -Does not support field specifiers. -""" -output = """ -dataclasses_transform_class.py:27:0 Uninitialized attribute [13]: Attribute `not_a_field` is declared in class `ModelBase` to have type `str` but is never initialized. -dataclasses_transform_class.py:57:7 Unexpected keyword [28]: Unexpected keyword argument `other_name` to call `Customer1.__init__`. -dataclasses_transform_class.py:60:0 Invalid assignment [41]: Cannot reassign final attribute `c1_1.id`. -dataclasses_transform_class.py:63:7 Too many arguments [19]: Call `Customer1.__init__` expects 0 positional arguments, 2 were provided. -dataclasses_transform_class.py:69:5 Unsupported operand [58]: `<` is not supported for operand types `Customer1` and `Customer1`. -dataclasses_transform_class.py:79:7 Too many arguments [19]: Call `Customer2.__init__` expects 0 positional arguments, 2 were provided. -dataclasses_transform_class.py:86:0 Uninitialized attribute [13]: Attribute `not_a_field` is declared in class `GenericModelBase` to have type `Variable[T]` but is never initialized. -dataclasses_transform_class.py:107:0 Uninitialized attribute [13]: Attribute `not_a_field` is declared in class `ModelBaseFrozen` to have type `str` but is never initialized. -dataclasses_transform_class.py:119:0 Invalid assignment [41]: Cannot reassign final attribute `c3_1.id`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 48: Expected 1 errors -Line 27: Unexpected errors ['dataclasses_transform_class.py:27:0 Uninitialized attribute [13]: Attribute `not_a_field` is declared in class `ModelBase` to have type `str` but is never initialized.'] -Line 57: Unexpected errors ['dataclasses_transform_class.py:57:7 Unexpected keyword [28]: Unexpected keyword argument `other_name` to call `Customer1.__init__`.'] -Line 86: Unexpected errors ['dataclasses_transform_class.py:86:0 Uninitialized attribute [13]: Attribute `not_a_field` is declared in class `GenericModelBase` to have type `Variable[T]` but is never initialized.'] -Line 107: Unexpected errors ['dataclasses_transform_class.py:107:0 Uninitialized attribute [13]: Attribute `not_a_field` is declared in class `ModelBaseFrozen` to have type `str` but is never initialized.'] -""" diff --git a/conformance/results/pyre/dataclasses_transform_field.toml b/conformance/results/pyre/dataclasses_transform_field.toml deleted file mode 100644 index b17502676..000000000 --- a/conformance/results/pyre/dataclasses_transform_field.toml +++ /dev/null @@ -1,19 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not understand dataclass transform field specifiers. -""" -output = """ -dataclasses_transform_field.py:49:42 Invalid type variable [34]: The type variable `Variable[T]` isn't present in the function's parameters. -dataclasses_transform_field.py:59:0 Missing argument [20]: Call `CustomerModel1.__init__` expects argument `id`. -dataclasses_transform_field.py:60:0 Missing argument [20]: Call `CustomerModel1.__init__` expects argument `id`. -dataclasses_transform_field.py:75:0 Too many arguments [19]: Call `CustomerModel2.__init__` expects 0 positional arguments, 1 was provided. -dataclasses_transform_field.py:77:0 Missing argument [20]: Call `CustomerModel2.__init__` expects argument `id`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 64: Expected 1 errors -Line 49: Unexpected errors ["dataclasses_transform_field.py:49:42 Invalid type variable [34]: The type variable `Variable[T]` isn't present in the function's parameters."] -Line 59: Unexpected errors ['dataclasses_transform_field.py:59:0 Missing argument [20]: Call `CustomerModel1.__init__` expects argument `id`.'] -Line 60: Unexpected errors ['dataclasses_transform_field.py:60:0 Missing argument [20]: Call `CustomerModel1.__init__` expects argument `id`.'] -Line 77: Unexpected errors ['dataclasses_transform_field.py:77:0 Missing argument [20]: Call `CustomerModel2.__init__` expects argument `id`.'] -""" diff --git a/conformance/results/pyre/dataclasses_transform_func.toml b/conformance/results/pyre/dataclasses_transform_func.toml deleted file mode 100644 index 461f76dc0..000000000 --- a/conformance/results/pyre/dataclasses_transform_func.toml +++ /dev/null @@ -1,39 +0,0 @@ -conformant = "Partial" -notes = """ -Does not understand @dataclass_transform when it is -applied only to overloads of a decorator but not the -definition. -""" -output = """ -dataclasses_transform_func.py:20:0 Incompatible overload [43]: The implementation of `create_model` does not accept all possible arguments of overload defined on line `20`. -dataclasses_transform_func.py:25:5 Invalid type variable [34]: The type variable `Variable[T]` isn't present in the function's parameters. -dataclasses_transform_func.py:29:0 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s). -dataclasses_transform_func.py:34:0 Uninitialized attribute [13]: Attribute `id` is declared in class `Customer1` to have type `int` but is never initialized. -dataclasses_transform_func.py:34:0 Uninitialized attribute [13]: Attribute `name` is declared in class `Customer1` to have type `str` but is never initialized. -dataclasses_transform_func.py:40:0 Uninitialized attribute [13]: Attribute `id` is declared in class `Customer2` to have type `int` but is never initialized. -dataclasses_transform_func.py:40:0 Uninitialized attribute [13]: Attribute `name` is declared in class `Customer2` to have type `str` but is never initialized. -dataclasses_transform_func.py:46:0 Uninitialized attribute [13]: Attribute `salary` is declared in class `Customer2Subclass` to have type `float` but is never initialized. -dataclasses_transform_func.py:50:7 Unexpected keyword [28]: Unexpected keyword argument `id` to call `object.__init__`. -dataclasses_transform_func.py:53:7 Too many arguments [19]: Call `object.__init__` expects 0 positional arguments, 2 were provided. -dataclasses_transform_func.py:57:0 Incompatible attribute type [8]: Attribute `name` declared in class `Customer1` has type `str` but is used as type `int`. -dataclasses_transform_func.py:61:5 Unsupported operand [58]: `<` is not supported for operand types `Customer1` and `Customer1`. -dataclasses_transform_func.py:65:7 Unexpected keyword [28]: Unexpected keyword argument `id` to call `object.__init__`. -dataclasses_transform_func.py:67:7 Unexpected keyword [28]: Unexpected keyword argument `id` to call `object.__init__`. -dataclasses_transform_func.py:71:7 Too many arguments [19]: Call `object.__init__` expects 0 positional arguments, 2 were provided. -dataclasses_transform_func.py:73:5 Unsupported operand [58]: `<` is not supported for operand types `Customer2` and `Customer2`. -dataclasses_transform_func.py:90:0 Uninitialized attribute [13]: Attribute `age` is declared in class `Customer3Subclass` to have type `int` but is never initialized. -dataclasses_transform_func.py:97:0 Invalid assignment [41]: Cannot reassign final attribute `c3_1.id`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 20: Unexpected errors ['dataclasses_transform_func.py:20:0 Incompatible overload [43]: The implementation of `create_model` does not accept all possible arguments of overload defined on line `20`.'] -Line 25: Unexpected errors ["dataclasses_transform_func.py:25:5 Invalid type variable [34]: The type variable `Variable[T]` isn't present in the function's parameters."] -Line 29: Unexpected errors ['dataclasses_transform_func.py:29:0 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).'] -Line 34: Unexpected errors ['dataclasses_transform_func.py:34:0 Uninitialized attribute [13]: Attribute `id` is declared in class `Customer1` to have type `int` but is never initialized.', 'dataclasses_transform_func.py:34:0 Uninitialized attribute [13]: Attribute `name` is declared in class `Customer1` to have type `str` but is never initialized.'] -Line 40: Unexpected errors ['dataclasses_transform_func.py:40:0 Uninitialized attribute [13]: Attribute `id` is declared in class `Customer2` to have type `int` but is never initialized.', 'dataclasses_transform_func.py:40:0 Uninitialized attribute [13]: Attribute `name` is declared in class `Customer2` to have type `str` but is never initialized.'] -Line 46: Unexpected errors ['dataclasses_transform_func.py:46:0 Uninitialized attribute [13]: Attribute `salary` is declared in class `Customer2Subclass` to have type `float` but is never initialized.'] -Line 50: Unexpected errors ['dataclasses_transform_func.py:50:7 Unexpected keyword [28]: Unexpected keyword argument `id` to call `object.__init__`.'] -Line 53: Unexpected errors ['dataclasses_transform_func.py:53:7 Too many arguments [19]: Call `object.__init__` expects 0 positional arguments, 2 were provided.'] -Line 67: Unexpected errors ['dataclasses_transform_func.py:67:7 Unexpected keyword [28]: Unexpected keyword argument `id` to call `object.__init__`.'] -Line 73: Unexpected errors ['dataclasses_transform_func.py:73:5 Unsupported operand [58]: `<` is not supported for operand types `Customer2` and `Customer2`.'] -""" diff --git a/conformance/results/pyre/dataclasses_transform_meta.toml b/conformance/results/pyre/dataclasses_transform_meta.toml deleted file mode 100644 index b773b53e4..000000000 --- a/conformance/results/pyre/dataclasses_transform_meta.toml +++ /dev/null @@ -1,19 +0,0 @@ -conformant = "Partial" -notes = """ -Does not understand custom field specifiers. -""" -output = """ -dataclasses_transform_meta.py:25:0 Uninitialized attribute [13]: Attribute `not_a_field` is declared in class `ModelMeta` to have type `str` but is never initialized. -dataclasses_transform_meta.py:57:7 Unexpected keyword [28]: Unexpected keyword argument `other_name` to call `Customer1.__init__`. -dataclasses_transform_meta.py:60:0 Invalid assignment [41]: Cannot reassign final attribute `c1_1.id`. -dataclasses_transform_meta.py:63:7 Too many arguments [19]: Call `Customer1.__init__` expects 0 positional arguments, 2 were provided. -dataclasses_transform_meta.py:70:5 Unsupported operand [58]: `<` is not supported for operand types `Customer1` and `Customer1`. -dataclasses_transform_meta.py:80:7 Too many arguments [19]: Call `Customer2.__init__` expects 0 positional arguments, 2 were provided. -dataclasses_transform_meta.py:100:0 Invalid assignment [41]: Cannot reassign final attribute `c3_1.id`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 48: Expected 1 errors -Line 25: Unexpected errors ['dataclasses_transform_meta.py:25:0 Uninitialized attribute [13]: Attribute `not_a_field` is declared in class `ModelMeta` to have type `str` but is never initialized.'] -Line 57: Unexpected errors ['dataclasses_transform_meta.py:57:7 Unexpected keyword [28]: Unexpected keyword argument `other_name` to call `Customer1.__init__`.'] -""" diff --git a/conformance/results/pyre/dataclasses_usage.toml b/conformance/results/pyre/dataclasses_usage.toml deleted file mode 100644 index c3feb171e..000000000 --- a/conformance/results/pyre/dataclasses_usage.toml +++ /dev/null @@ -1,37 +0,0 @@ -conformant = "Partial" -notes = """ -Does not report error when field with no default follows field with default. -Incorrectly reports error with InitVar that has default value. -Complains on `assert_type` when used for bound methods vs `Callable`. -Does not understand `__dataclass_fields__`. -""" -output = """ -dataclasses_usage.py:50:5 Missing argument [20]: Call `InventoryItem.__init__` expects argument `unit_price`. -dataclasses_usage.py:51:27 Incompatible parameter type [6]: In call `InventoryItem.__init__`, for 2nd positional argument, expected `float` but got `str`. -dataclasses_usage.py:52:5 Too many arguments [19]: Call `InventoryItem.__init__` expects 3 positional arguments, 4 were provided. -dataclasses_usage.py:72:4 Incompatible attribute type [8]: Attribute `a` declared in class `DC3` has type `InitVar[int]` but is used as type `int`. -dataclasses_usage.py:72:4 Undefined attribute [16]: `typing.Type` has no attribute `a`. -dataclasses_usage.py:83:5 Too many arguments [19]: Call `DC4.__init__` expects 1 positional argument, 2 were provided. -dataclasses_usage.py:88:4 Incompatible attribute type [8]: Attribute `a` declared in class `DC5` has type `int` but is used as type `str`. -dataclasses_usage.py:106:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing.Callable[[str], int]` but got `BoundMethod[typing.Callable[[str], int], DC6]`. -dataclasses_usage.py:115:0 Uninitialized attribute [13]: Attribute `y` is declared in class `DC8` to have type `int` but is never initialized. -dataclasses_usage.py:126:0 Too many arguments [19]: Call `DC7.__init__` expects 1 positional argument, 2 were provided. -dataclasses_usage.py:129:0 Missing argument [20]: Call `DC8.__init__` expects argument `y`. -dataclasses_usage.py:171:0 Uninitialized attribute [13]: Attribute `x` is declared in class `DC13` to have type `int` but is never initialized. -dataclasses_usage.py:171:0 Uninitialized attribute [13]: Attribute `x_squared` is declared in class `DC13` to have type `int` but is never initialized. -dataclasses_usage.py:178:0 Too many arguments [19]: Call `object.__init__` expects 0 positional arguments, 1 was provided. -dataclasses_usage.py:204:0 Incompatible variable type [9]: v7 is declared to have type `DataclassProto` but is used as type `DC15`. -dataclasses_usage.py:212:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `DC16[int]` but got `DC16[typing_extensions.Literal[1]]`. -""" -conformance_automated = "Fail" -errors_diff = """ -Lines 58, 61: Expected error (tag 'DC1') -Lines 64, 67: Expected error (tag 'DC2') -Lines 70, 73: Expected error (tag 'DC3') -Line 72: Unexpected errors ['dataclasses_usage.py:72:4 Incompatible attribute type [8]: Attribute `a` declared in class `DC3` has type `InitVar[int]` but is used as type `int`.', 'dataclasses_usage.py:72:4 Undefined attribute [16]: `typing.Type` has no attribute `a`.'] -Line 106: Unexpected errors ['dataclasses_usage.py:106:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing.Callable[[str], int]` but got `BoundMethod[typing.Callable[[str], int], DC6]`.'] -Line 115: Unexpected errors ['dataclasses_usage.py:115:0 Uninitialized attribute [13]: Attribute `y` is declared in class `DC8` to have type `int` but is never initialized.'] -Line 171: Unexpected errors ['dataclasses_usage.py:171:0 Uninitialized attribute [13]: Attribute `x` is declared in class `DC13` to have type `int` but is never initialized.', 'dataclasses_usage.py:171:0 Uninitialized attribute [13]: Attribute `x_squared` is declared in class `DC13` to have type `int` but is never initialized.'] -Line 204: Unexpected errors ['dataclasses_usage.py:204:0 Incompatible variable type [9]: v7 is declared to have type `DataclassProto` but is used as type `DC15`.'] -Line 212: Unexpected errors ['dataclasses_usage.py:212:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `DC16[int]` but got `DC16[typing_extensions.Literal[1]]`.'] -""" diff --git a/conformance/results/pyre/directives_assert_type.toml b/conformance/results/pyre/directives_assert_type.toml deleted file mode 100644 index 2afa3ee8f..000000000 --- a/conformance/results/pyre/directives_assert_type.toml +++ /dev/null @@ -1,15 +0,0 @@ -conformant = "Pass" -notes = """ -Does not weaken literal types in `assert_type`, which some (other) tests rely on. -""" -output = """ -directives_assert_type.py:27:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `Union[int, str]`. -directives_assert_type.py:28:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing.Any`. -directives_assert_type.py:29:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing_extensions.Literal[4]`. -directives_assert_type.py:31:4 Missing argument [20]: Call `assert_type` expects argument in position 0. -directives_assert_type.py:32:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `str`. -directives_assert_type.py:33:4 Too many arguments [19]: Call `assert_type` expects 2 positional arguments, 3 were provided. -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pyre/directives_cast.toml b/conformance/results/pyre/directives_cast.toml deleted file mode 100644 index 8046276e2..000000000 --- a/conformance/results/pyre/directives_cast.toml +++ /dev/null @@ -1,9 +0,0 @@ -conformant = "Pass" -output = """ -directives_cast.py:15:7 Missing argument [20]: Call `cast` expects argument `typ`. -directives_cast.py:16:12 Invalid type [31]: Expression `1` is not a valid type. -directives_cast.py:17:7 Too many arguments [19]: Call `cast` expects 2 positional arguments, 3 were provided. -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pyre/directives_no_type_check.toml b/conformance/results/pyre/directives_no_type_check.toml deleted file mode 100644 index f08913eaf..000000000 --- a/conformance/results/pyre/directives_no_type_check.toml +++ /dev/null @@ -1,15 +0,0 @@ -conformant = "Pass" -notes = """ -Does not honor @no_type_check decorator. -""" -output = """ -directives_no_type_check.py:15:4 Incompatible attribute type [8]: Attribute `x` declared in class `ClassA` has type `int` but is used as type `str`. -directives_no_type_check.py:25:12 Unsupported operand [58]: `+` is not supported for operand types `int` and `str`. -directives_no_type_check.py:26:4 Incompatible return type [7]: Expected `None` but got `int`. -directives_no_type_check.py:29:6 Incompatible parameter type [6]: In call `func1`, for 1st positional argument, expected `int` but got `bytes`. -directives_no_type_check.py:29:18 Incompatible parameter type [6]: In call `func1`, for 2nd positional argument, expected `str` but got `bytes`. -directives_no_type_check.py:32:0 Missing argument [20]: Call `func1` expects argument `a`. -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pyre/directives_reveal_type.toml b/conformance/results/pyre/directives_reveal_type.toml deleted file mode 100644 index 92a179946..000000000 --- a/conformance/results/pyre/directives_reveal_type.toml +++ /dev/null @@ -1,19 +0,0 @@ -conformant = "Partial" -notes = """" -Produces errors rather than warnings on `reveal_type`. -""" -output = """ -directives_reveal_type.py:14:4 Revealed type [-1]: Revealed type for `a` is `typing.Union[int, str]`. -directives_reveal_type.py:15:4 Revealed type [-1]: Revealed type for `b` is `typing.List[int]`. -directives_reveal_type.py:16:4 Revealed type [-1]: Revealed type for `c` is `typing.Any`. -directives_reveal_type.py:17:4 Revealed type [-1]: Revealed type for `d` is `ForwardReference`. -directives_reveal_type.py:19:4 Missing argument [20]: Call `reveal_type` expects argument in position 0. -directives_reveal_type.py:20:4 Revealed type [-1]: Revealed type for `a` is `typing.Union[int, str]`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 14: Unexpected errors ['directives_reveal_type.py:14:4 Revealed type [-1]: Revealed type for `a` is `typing.Union[int, str]`.'] -Line 15: Unexpected errors ['directives_reveal_type.py:15:4 Revealed type [-1]: Revealed type for `b` is `typing.List[int]`.'] -Line 16: Unexpected errors ['directives_reveal_type.py:16:4 Revealed type [-1]: Revealed type for `c` is `typing.Any`.'] -Line 17: Unexpected errors ['directives_reveal_type.py:17:4 Revealed type [-1]: Revealed type for `d` is `ForwardReference`.'] -""" diff --git a/conformance/results/pyre/directives_type_checking.toml b/conformance/results/pyre/directives_type_checking.toml deleted file mode 100644 index 5e485e856..000000000 --- a/conformance/results/pyre/directives_type_checking.toml +++ /dev/null @@ -1,6 +0,0 @@ -conformant = "Pass" -output = """ -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pyre/directives_type_ignore.toml b/conformance/results/pyre/directives_type_ignore.toml deleted file mode 100644 index 5e485e856..000000000 --- a/conformance/results/pyre/directives_type_ignore.toml +++ /dev/null @@ -1,6 +0,0 @@ -conformant = "Pass" -output = """ -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pyre/directives_type_ignore_file1.toml b/conformance/results/pyre/directives_type_ignore_file1.toml deleted file mode 100644 index 3efc56a3e..000000000 --- a/conformance/results/pyre/directives_type_ignore_file1.toml +++ /dev/null @@ -1,11 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support file-level `#type: ignore` comment. -""" -output = """ -directives_type_ignore_file1.py:16:0 Incompatible variable type [9]: x is declared to have type `int` but is used as type `str`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 16: Unexpected errors ['directives_type_ignore_file1.py:16:0 Incompatible variable type [9]: x is declared to have type `int` but is used as type `str`.'] -""" diff --git a/conformance/results/pyre/directives_type_ignore_file2.toml b/conformance/results/pyre/directives_type_ignore_file2.toml deleted file mode 100644 index 7e43e7dcf..000000000 --- a/conformance/results/pyre/directives_type_ignore_file2.toml +++ /dev/null @@ -1,7 +0,0 @@ -conformant = "Pass" -output = """ -directives_type_ignore_file2.py:14:0 Incompatible variable type [9]: x is declared to have type `int` but is used as type `str`. -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pyre/directives_version_platform.toml b/conformance/results/pyre/directives_version_platform.toml deleted file mode 100644 index 24d9f1ea7..000000000 --- a/conformance/results/pyre/directives_version_platform.toml +++ /dev/null @@ -1,16 +0,0 @@ -conformant = "Partial" -notes = """ -Does not support sys.platform checks. -Does not support os.name checks. -""" -output = """ -directives_version_platform.py:31:4 Incompatible variable type [9]: val5 is declared to have type `int` but is used as type `str`. -directives_version_platform.py:36:4 Incompatible variable type [9]: val6 is declared to have type `int` but is used as type `str`. -directives_version_platform.py:40:4 Incompatible variable type [9]: val7 is declared to have type `int` but is used as type `str`. -directives_version_platform.py:45:4 Incompatible variable type [9]: val8 is declared to have type `int` but is used as type `str`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 31: Unexpected errors ['directives_version_platform.py:31:4 Incompatible variable type [9]: val5 is declared to have type `int` but is used as type `str`.'] -Line 36: Unexpected errors ['directives_version_platform.py:36:4 Incompatible variable type [9]: val6 is declared to have type `int` but is used as type `str`.'] -""" diff --git a/conformance/results/pyre/exceptions_context_managers.toml b/conformance/results/pyre/exceptions_context_managers.toml deleted file mode 100644 index 9dff9945b..000000000 --- a/conformance/results/pyre/exceptions_context_managers.toml +++ /dev/null @@ -1,13 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not understand context manager exception rules. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 50: Unexpected errors ['exceptions_context_managers.py:50:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Union[int, str]` but got `str`.'] -Line 57: Unexpected errors ['exceptions_context_managers.py:57:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Union[int, str]` but got `str`.'] -""" -output = """ -exceptions_context_managers.py:50:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Union[int, str]` but got `str`. -exceptions_context_managers.py:57:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Union[int, str]` but got `str`. -""" diff --git a/conformance/results/pyre/generics_base_class.toml b/conformance/results/pyre/generics_base_class.toml deleted file mode 100644 index 0e50c8f7e..000000000 --- a/conformance/results/pyre/generics_base_class.toml +++ /dev/null @@ -1,16 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject illegal use of Generic. -Does not allow using generic in assert_type expression. -""" -output = """ -generics_base_class.py:26:25 Incompatible parameter type [6]: In call `takes_dict_incorrect`, for 1st positional argument, expected `Dict[str, List[object]]` but got `SymbolTable`. -generics_base_class.py:49:21 Invalid type parameters [24]: Generic type `LinkedList` expects 1 type parameter, received 2. -generics_base_class.py:61:17 Invalid type parameters [24]: Generic type `MyDict` expects 1 type parameter, received 2. -generics_base_class.py:68:0 Duplicate type variables [59]: Duplicate type variable `T` in Generic[...]. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 29: Expected 1 errors -Line 30: Expected 1 errors -""" diff --git a/conformance/results/pyre/generics_basic.toml b/conformance/results/pyre/generics_basic.toml deleted file mode 100644 index b7e8d00b0..000000000 --- a/conformance/results/pyre/generics_basic.toml +++ /dev/null @@ -1,25 +0,0 @@ -conformant = "Partial" -notes = """ -False positives in examples using constrained type variables. -False negative for constraint parameterized by a type variable. -False negative in custom map example. -False positive using `iter`. -False negative for generic metaclass. -""" -output = """ -generics_basic.py:34:4 Incompatible return type [7]: Expected `Variable[AnyStr <: [str, bytes]]` but got `str`. -generics_basic.py:34:15 Incompatible parameter type [6]: In call `str.__add__`, for 1st positional argument, expected `str` but got `Variable[AnyStr <: [str, bytes]]`. -generics_basic.py:40:14 Incompatible parameter type [6]: In call `concat`, for 2nd positional argument, expected `Variable[AnyStr <: [str, bytes]]` but got `bytes`. -generics_basic.py:41:14 Incompatible parameter type [6]: In call `concat`, for 2nd positional argument, expected `Variable[AnyStr <: [str, bytes]]` but got `str`. -generics_basic.py:49:0 Invalid type [31]: TypeVar can't have a single explicit constraint. Did you mean `bound=str`? -generics_basic.py:55:52 Undefined attribute [16]: `list` has no attribute `__getitem__`. -generics_basic.py:69:14 Incompatible parameter type [6]: In call `concat`, for 2nd positional argument, expected `Variable[AnyStr <: [str, bytes]]` but got `bytes`. -generics_basic.py:121:0 Duplicate type variables [59]: Duplicate type variable `T` in Generic[...]. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 157: Expected 1 errors -Line 158: Expected 1 errors -Line 191: Expected 1 errors -Line 34: Unexpected errors ['generics_basic.py:34:4 Incompatible return type [7]: Expected `Variable[AnyStr <: [str, bytes]]` but got `str`.', 'generics_basic.py:34:15 Incompatible parameter type [6]: In call `str.__add__`, for 1st positional argument, expected `str` but got `Variable[AnyStr <: [str, bytes]]`.'] -""" diff --git a/conformance/results/pyre/generics_defaults.toml b/conformance/results/pyre/generics_defaults.toml deleted file mode 100644 index 2d4d4749a..000000000 --- a/conformance/results/pyre/generics_defaults.toml +++ /dev/null @@ -1,108 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support generic defaults. -""" -output = """ -generics_defaults.py:24:31 Undefined or invalid type [11]: Annotation `DefaultStrT` is not defined as a type. -generics_defaults.py:24:31 Undefined or invalid type [11]: Annotation `T` is not defined as a type. -generics_defaults.py:27:20 Undefined or invalid type [11]: Annotation `DefaultIntT` is not defined as a type. -generics_defaults.py:30:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[NoNonDefaults[]]` but got `Type[NoNonDefaults]`. -generics_defaults.py:30:27 Invalid type parameters [24]: Non-generic type `NoNonDefaults` cannot take parameters. -generics_defaults.py:31:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[NoNonDefaults[]]` but got `typing.Any`. -generics_defaults.py:31:12 Undefined attribute [16]: `NoNonDefaults` has no attribute `__getitem__`. -generics_defaults.py:31:32 Invalid type parameters [24]: Non-generic type `NoNonDefaults` cannot take parameters. -generics_defaults.py:32:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[NoNonDefaults[]]` but got `typing.Any`. -generics_defaults.py:32:37 Invalid type parameters [24]: Non-generic type `NoNonDefaults` cannot take parameters. -generics_defaults.py:35:17 Undefined or invalid type [11]: Annotation `DefaultBoolT` is not defined as a type. -generics_defaults.py:38:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[OneDefault[]]` but got `typing.Any`. -generics_defaults.py:38:12 Undefined attribute [16]: `OneDefault` has no attribute `__getitem__`. -generics_defaults.py:38:31 Invalid type parameters [24]: Non-generic type `OneDefault` cannot take parameters. -generics_defaults.py:39:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `OneDefault[]` but got `typing.Any`. -generics_defaults.py:39:33 Invalid type parameters [24]: Non-generic type `OneDefault` cannot take parameters. -generics_defaults.py:42:21 Undefined or invalid type [11]: Annotation `T1` is not defined as a type. -generics_defaults.py:42:21 Undefined or invalid type [11]: Annotation `T2` is not defined as a type. -generics_defaults.py:45:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[AllTheDefaults[]]` but got `Type[AllTheDefaults]`. -generics_defaults.py:45:28 Invalid type parameters [24]: Non-generic type `AllTheDefaults` cannot take parameters. -generics_defaults.py:46:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[AllTheDefaults[]]` but got `typing.Any`. -generics_defaults.py:47:4 Undefined attribute [16]: `AllTheDefaults` has no attribute `__getitem__`. -generics_defaults.py:47:34 Invalid type parameters [24]: Non-generic type `AllTheDefaults` cannot take parameters. -generics_defaults.py:52:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[AllTheDefaults[]]` but got `typing.Any`. -generics_defaults.py:53:34 Invalid type parameters [24]: Non-generic type `AllTheDefaults` cannot take parameters. -generics_defaults.py:55:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[AllTheDefaults[]]` but got `typing.Any`. -generics_defaults.py:57:4 Invalid type parameters [24]: Non-generic type `AllTheDefaults` cannot take parameters. -generics_defaults.py:59:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[AllTheDefaults[]]` but got `typing.Any`. -generics_defaults.py:61:4 Invalid type parameters [24]: Non-generic type `AllTheDefaults` cannot take parameters. -generics_defaults.py:63:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[AllTheDefaults[]]` but got `typing.Any`. -generics_defaults.py:65:4 Invalid type parameters [24]: Non-generic type `AllTheDefaults` cannot take parameters. -generics_defaults.py:73:33 Incompatible parameter type [6]: In call `ParamSpec.__init__`, for argument `default`, expected `Union[None, Type[typing.Any], str]` but got `List[Type[Union[int, str]]]`. -generics_defaults.py:76:22 Undefined or invalid type [11]: Annotation `DefaultP` is not defined as a type. -generics_defaults.py:79:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[Class_ParamSpec[]]` but got `Type[Class_ParamSpec]`. -generics_defaults.py:79:29 Invalid type parameters [24]: Non-generic type `Class_ParamSpec` cannot take parameters. -generics_defaults.py:80:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class_ParamSpec[]` but got `Class_ParamSpec`. -generics_defaults.py:80:31 Invalid type parameters [24]: Non-generic type `Class_ParamSpec` cannot take parameters. -generics_defaults.py:81:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class_ParamSpec[]` but got `typing.Any`. -generics_defaults.py:81:12 Undefined attribute [16]: `Class_ParamSpec` has no attribute `__getitem__`. -generics_defaults.py:81:45 Invalid type parameters [24]: Non-generic type `Class_ParamSpec` cannot take parameters. -generics_defaults.py:88:53 Undefined attribute [16]: `tuple` has no attribute `__getitem__`. -generics_defaults.py:91:25 Invalid type [31]: Expression `typing.Generic[(*$local_generics_defaults$DefaultTs)]` is not a valid type. -generics_defaults.py:94:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[Class_TypeVarTuple[]]` but got `Type[Class_TypeVarTuple]`. -generics_defaults.py:94:32 Invalid type [31]: Expression `type[generics_defaults.Class_TypeVarTuple[(*tuple[(str, int)])]]` is not a valid type. -generics_defaults.py:94:32 Invalid type parameters [24]: Non-generic type `Class_TypeVarTuple` cannot take parameters. -generics_defaults.py:95:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class_TypeVarTuple[]` but got `Class_TypeVarTuple`. -generics_defaults.py:95:34 Invalid type parameters [24]: Non-generic type `Class_TypeVarTuple` cannot take parameters. -generics_defaults.py:96:31 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[Type[int], Type[bool]]`. Expected has length 0, but actual has length 2. -generics_defaults.py:124:13 Undefined or invalid type [11]: Annotation `T4` is not defined as a type. -generics_defaults.py:138:11 Invalid type [31]: Expression `typing.Generic[(*$local_generics_defaults$Ts, $local_generics_defaults$T5)]` is not a valid type. -generics_defaults.py:138:11 Undefined or invalid type [11]: Annotation `T5` is not defined as a type. -generics_defaults.py:145:19 Incompatible parameter type [6]: In call `ParamSpec.__init__`, for argument `default`, expected `Union[None, Type[typing.Any], str]` but got `List[Type[float]]`. -generics_defaults.py:148:11 Invalid type [31]: Expression `typing.Generic[(*$local_generics_defaults$Ts, $local_generics_defaults$P)]` is not a valid type. -generics_defaults.py:148:11 Undefined or invalid type [11]: Annotation `P` is not defined as a type. -generics_defaults.py:151:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[Foo6[]]` but got `typing.Any`. -generics_defaults.py:151:12 Undefined attribute [16]: `Foo6` has no attribute `__getitem__`. -generics_defaults.py:151:28 Invalid type parameters [24]: Non-generic type `Foo6` cannot take parameters. -generics_defaults.py:152:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[Foo6[]]` but got `typing.Any`. -generics_defaults.py:152:37 Invalid type parameters [24]: Non-generic type `Foo6` cannot take parameters. -generics_defaults.py:166:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing.Callable[[Foo7[]], Foo7[]]` but got `typing.Callable(Foo7.meth)[[Variable[_Self_generics_defaults_Foo7__ (bound to Foo7)]], Variable[_Self_generics_defaults_Foo7__ (bound to Foo7)]]`. -generics_defaults.py:166:23 Invalid type parameters [24]: Non-generic type `Foo7` cannot take parameters. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 50: Expected 1 errors -Line 104: Expected 1 errors -Line 111: Expected 1 errors -Line 27: Unexpected errors ['generics_defaults.py:27:20 Undefined or invalid type [11]: Annotation `DefaultIntT` is not defined as a type.'] -Line 30: Unexpected errors ['generics_defaults.py:30:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[NoNonDefaults[]]` but got `Type[NoNonDefaults]`.', 'generics_defaults.py:30:27 Invalid type parameters [24]: Non-generic type `NoNonDefaults` cannot take parameters.'] -Line 31: Unexpected errors ['generics_defaults.py:31:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[NoNonDefaults[]]` but got `typing.Any`.', 'generics_defaults.py:31:12 Undefined attribute [16]: `NoNonDefaults` has no attribute `__getitem__`.', 'generics_defaults.py:31:32 Invalid type parameters [24]: Non-generic type `NoNonDefaults` cannot take parameters.'] -Line 32: Unexpected errors ['generics_defaults.py:32:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[NoNonDefaults[]]` but got `typing.Any`.', 'generics_defaults.py:32:37 Invalid type parameters [24]: Non-generic type `NoNonDefaults` cannot take parameters.'] -Line 35: Unexpected errors ['generics_defaults.py:35:17 Undefined or invalid type [11]: Annotation `DefaultBoolT` is not defined as a type.'] -Line 38: Unexpected errors ['generics_defaults.py:38:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[OneDefault[]]` but got `typing.Any`.', 'generics_defaults.py:38:12 Undefined attribute [16]: `OneDefault` has no attribute `__getitem__`.', 'generics_defaults.py:38:31 Invalid type parameters [24]: Non-generic type `OneDefault` cannot take parameters.'] -Line 39: Unexpected errors ['generics_defaults.py:39:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `OneDefault[]` but got `typing.Any`.', 'generics_defaults.py:39:33 Invalid type parameters [24]: Non-generic type `OneDefault` cannot take parameters.'] -Line 42: Unexpected errors ['generics_defaults.py:42:21 Undefined or invalid type [11]: Annotation `T1` is not defined as a type.', 'generics_defaults.py:42:21 Undefined or invalid type [11]: Annotation `T2` is not defined as a type.'] -Line 45: Unexpected errors ['generics_defaults.py:45:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[AllTheDefaults[]]` but got `Type[AllTheDefaults]`.', 'generics_defaults.py:45:28 Invalid type parameters [24]: Non-generic type `AllTheDefaults` cannot take parameters.'] -Line 46: Unexpected errors ['generics_defaults.py:46:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[AllTheDefaults[]]` but got `typing.Any`.'] -Line 47: Unexpected errors ['generics_defaults.py:47:4 Undefined attribute [16]: `AllTheDefaults` has no attribute `__getitem__`.', 'generics_defaults.py:47:34 Invalid type parameters [24]: Non-generic type `AllTheDefaults` cannot take parameters.'] -Line 52: Unexpected errors ['generics_defaults.py:52:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[AllTheDefaults[]]` but got `typing.Any`.'] -Line 53: Unexpected errors ['generics_defaults.py:53:34 Invalid type parameters [24]: Non-generic type `AllTheDefaults` cannot take parameters.'] -Line 55: Unexpected errors ['generics_defaults.py:55:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[AllTheDefaults[]]` but got `typing.Any`.'] -Line 57: Unexpected errors ['generics_defaults.py:57:4 Invalid type parameters [24]: Non-generic type `AllTheDefaults` cannot take parameters.'] -Line 59: Unexpected errors ['generics_defaults.py:59:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[AllTheDefaults[]]` but got `typing.Any`.'] -Line 61: Unexpected errors ['generics_defaults.py:61:4 Invalid type parameters [24]: Non-generic type `AllTheDefaults` cannot take parameters.'] -Line 63: Unexpected errors ['generics_defaults.py:63:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[AllTheDefaults[]]` but got `typing.Any`.'] -Line 65: Unexpected errors ['generics_defaults.py:65:4 Invalid type parameters [24]: Non-generic type `AllTheDefaults` cannot take parameters.'] -Line 73: Unexpected errors ['generics_defaults.py:73:33 Incompatible parameter type [6]: In call `ParamSpec.__init__`, for argument `default`, expected `Union[None, Type[typing.Any], str]` but got `List[Type[Union[int, str]]]`.'] -Line 76: Unexpected errors ['generics_defaults.py:76:22 Undefined or invalid type [11]: Annotation `DefaultP` is not defined as a type.'] -Line 79: Unexpected errors ['generics_defaults.py:79:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[Class_ParamSpec[]]` but got `Type[Class_ParamSpec]`.', 'generics_defaults.py:79:29 Invalid type parameters [24]: Non-generic type `Class_ParamSpec` cannot take parameters.'] -Line 80: Unexpected errors ['generics_defaults.py:80:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class_ParamSpec[]` but got `Class_ParamSpec`.', 'generics_defaults.py:80:31 Invalid type parameters [24]: Non-generic type `Class_ParamSpec` cannot take parameters.'] -Line 81: Unexpected errors ['generics_defaults.py:81:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class_ParamSpec[]` but got `typing.Any`.', 'generics_defaults.py:81:12 Undefined attribute [16]: `Class_ParamSpec` has no attribute `__getitem__`.', 'generics_defaults.py:81:45 Invalid type parameters [24]: Non-generic type `Class_ParamSpec` cannot take parameters.'] -Line 88: Unexpected errors ['generics_defaults.py:88:53 Undefined attribute [16]: `tuple` has no attribute `__getitem__`.'] -Line 91: Unexpected errors ['generics_defaults.py:91:25 Invalid type [31]: Expression `typing.Generic[(*$local_generics_defaults$DefaultTs)]` is not a valid type.'] -Line 94: Unexpected errors ['generics_defaults.py:94:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[Class_TypeVarTuple[]]` but got `Type[Class_TypeVarTuple]`.', 'generics_defaults.py:94:32 Invalid type [31]: Expression `type[generics_defaults.Class_TypeVarTuple[(*tuple[(str, int)])]]` is not a valid type.', 'generics_defaults.py:94:32 Invalid type parameters [24]: Non-generic type `Class_TypeVarTuple` cannot take parameters.'] -Line 95: Unexpected errors ['generics_defaults.py:95:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Class_TypeVarTuple[]` but got `Class_TypeVarTuple`.', 'generics_defaults.py:95:34 Invalid type parameters [24]: Non-generic type `Class_TypeVarTuple` cannot take parameters.'] -Line 96: Unexpected errors ['generics_defaults.py:96:31 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[Type[int], Type[bool]]`. Expected has length 0, but actual has length 2.'] -Line 124: Unexpected errors ['generics_defaults.py:124:13 Undefined or invalid type [11]: Annotation `T4` is not defined as a type.'] -Line 145: Unexpected errors ['generics_defaults.py:145:19 Incompatible parameter type [6]: In call `ParamSpec.__init__`, for argument `default`, expected `Union[None, Type[typing.Any], str]` but got `List[Type[float]]`.'] -Line 148: Unexpected errors ['generics_defaults.py:148:11 Invalid type [31]: Expression `typing.Generic[(*$local_generics_defaults$Ts, $local_generics_defaults$P)]` is not a valid type.', 'generics_defaults.py:148:11 Undefined or invalid type [11]: Annotation `P` is not defined as a type.'] -Line 151: Unexpected errors ['generics_defaults.py:151:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[Foo6[]]` but got `typing.Any`.', 'generics_defaults.py:151:12 Undefined attribute [16]: `Foo6` has no attribute `__getitem__`.', 'generics_defaults.py:151:28 Invalid type parameters [24]: Non-generic type `Foo6` cannot take parameters.'] -Line 152: Unexpected errors ['generics_defaults.py:152:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[Foo6[]]` but got `typing.Any`.', 'generics_defaults.py:152:37 Invalid type parameters [24]: Non-generic type `Foo6` cannot take parameters.'] -Line 166: Unexpected errors ['generics_defaults.py:166:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing.Callable[[Foo7[]], Foo7[]]` but got `typing.Callable(Foo7.meth)[[Variable[_Self_generics_defaults_Foo7__ (bound to Foo7)]], Variable[_Self_generics_defaults_Foo7__ (bound to Foo7)]]`.', 'generics_defaults.py:166:23 Invalid type parameters [24]: Non-generic type `Foo7` cannot take parameters.'] -""" diff --git a/conformance/results/pyre/generics_defaults_referential.toml b/conformance/results/pyre/generics_defaults_referential.toml deleted file mode 100644 index 3da14a215..000000000 --- a/conformance/results/pyre/generics_defaults_referential.toml +++ /dev/null @@ -1,61 +0,0 @@ -conformant = "Unsupported" -output = """ -generics_defaults_referential.py:20:12 Undefined or invalid type [11]: Annotation `StartT` is not defined as a type. -generics_defaults_referential.py:20:12 Undefined or invalid type [11]: Annotation `StepT` is not defined as a type. -generics_defaults_referential.py:20:12 Undefined or invalid type [11]: Annotation `StopT` is not defined as a type. -generics_defaults_referential.py:23:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[slice[]]` but got `Type[slice]`. -generics_defaults_referential.py:23:19 Invalid type parameters [24]: Non-generic type `slice` cannot take parameters. -generics_defaults_referential.py:24:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `slice[]` but got `slice`. -generics_defaults_referential.py:24:21 Invalid type parameters [24]: Non-generic type `slice` cannot take parameters. -generics_defaults_referential.py:25:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `slice[]` but got `typing.Any`. -generics_defaults_referential.py:25:12 Undefined attribute [16]: `slice` has no attribute `__getitem__`. -generics_defaults_referential.py:25:26 Invalid type parameters [24]: Non-generic type `slice` cannot take parameters. -generics_defaults_referential.py:26:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `slice[]` but got `typing.Any`. -generics_defaults_referential.py:26:41 Invalid type parameters [24]: Non-generic type `slice` cannot take parameters. -generics_defaults_referential.py:31:10 Undefined or invalid type [11]: Annotation `DefaultStrT` is not defined as a type. -generics_defaults_referential.py:31:10 Undefined or invalid type [11]: Annotation `T2` is not defined as a type. -generics_defaults_referential.py:35:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Foo[]` but got `Foo`. -generics_defaults_referential.py:35:24 Invalid type parameters [24]: Non-generic type `Foo` cannot take parameters. -generics_defaults_referential.py:36:0 Undefined attribute [16]: `Foo` has no attribute `__getitem__`. -generics_defaults_referential.py:46:11 Undefined or invalid type [11]: Annotation `S1` is not defined as a type. -generics_defaults_referential.py:46:11 Undefined or invalid type [11]: Annotation `S2` is not defined as a type. -generics_defaults_referential.py:53:13 Undefined or invalid type [11]: Annotation `Start2T` is not defined as a type. -generics_defaults_referential.py:53:13 Undefined or invalid type [11]: Annotation `Stop2T` is not defined as a type. -generics_defaults_referential.py:87:47 Undefined attribute [16]: `list` has no attribute `__getitem__`. -generics_defaults_referential.py:90:10 Undefined or invalid type [11]: Annotation `ListDefaultT` is not defined as a type. -generics_defaults_referential.py:90:10 Undefined or invalid type [11]: Annotation `Z1` is not defined as a type. -generics_defaults_referential.py:94:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[Bar[]]` but got `Type[Bar]`. -generics_defaults_referential.py:94:17 Invalid type parameters [24]: Non-generic type `Bar` cannot take parameters. -generics_defaults_referential.py:95:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[Bar[]]` but got `typing.Any`. -generics_defaults_referential.py:95:12 Undefined attribute [16]: `Bar` has no attribute `__getitem__`. -generics_defaults_referential.py:95:22 Invalid type parameters [24]: Non-generic type `Bar` cannot take parameters. -generics_defaults_referential.py:96:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Bar[]` but got `typing.Any`. -generics_defaults_referential.py:96:29 Invalid type parameters [24]: Non-generic type `Bar` cannot take parameters. -generics_defaults_referential.py:97:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Bar[]` but got `typing.Any`. -generics_defaults_referential.py:97:40 Invalid type parameters [24]: Non-generic type `Bar` cannot take parameters. -generics_defaults_referential.py:98:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Bar[]` but got `typing.Any`. -generics_defaults_referential.py:98:34 Invalid type parameters [24]: Non-generic type `Bar` cannot take parameters. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 37: Expected 1 errors -Line 60: Expected 1 errors -Line 68: Expected 1 errors -Line 74: Expected 1 errors -Line 78: Expected 1 errors -Line 20: Unexpected errors ['generics_defaults_referential.py:20:12 Undefined or invalid type [11]: Annotation `StartT` is not defined as a type.', 'generics_defaults_referential.py:20:12 Undefined or invalid type [11]: Annotation `StepT` is not defined as a type.', 'generics_defaults_referential.py:20:12 Undefined or invalid type [11]: Annotation `StopT` is not defined as a type.'] -Line 23: Unexpected errors ['generics_defaults_referential.py:23:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[slice[]]` but got `Type[slice]`.', 'generics_defaults_referential.py:23:19 Invalid type parameters [24]: Non-generic type `slice` cannot take parameters.'] -Line 24: Unexpected errors ['generics_defaults_referential.py:24:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `slice[]` but got `slice`.', 'generics_defaults_referential.py:24:21 Invalid type parameters [24]: Non-generic type `slice` cannot take parameters.'] -Line 25: Unexpected errors ['generics_defaults_referential.py:25:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `slice[]` but got `typing.Any`.', 'generics_defaults_referential.py:25:12 Undefined attribute [16]: `slice` has no attribute `__getitem__`.', 'generics_defaults_referential.py:25:26 Invalid type parameters [24]: Non-generic type `slice` cannot take parameters.'] -Line 26: Unexpected errors ['generics_defaults_referential.py:26:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `slice[]` but got `typing.Any`.', 'generics_defaults_referential.py:26:41 Invalid type parameters [24]: Non-generic type `slice` cannot take parameters.'] -Line 31: Unexpected errors ['generics_defaults_referential.py:31:10 Undefined or invalid type [11]: Annotation `DefaultStrT` is not defined as a type.', 'generics_defaults_referential.py:31:10 Undefined or invalid type [11]: Annotation `T2` is not defined as a type.'] -Line 35: Unexpected errors ['generics_defaults_referential.py:35:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Foo[]` but got `Foo`.', 'generics_defaults_referential.py:35:24 Invalid type parameters [24]: Non-generic type `Foo` cannot take parameters.'] -Line 46: Unexpected errors ['generics_defaults_referential.py:46:11 Undefined or invalid type [11]: Annotation `S1` is not defined as a type.', 'generics_defaults_referential.py:46:11 Undefined or invalid type [11]: Annotation `S2` is not defined as a type.'] -Line 87: Unexpected errors ['generics_defaults_referential.py:87:47 Undefined attribute [16]: `list` has no attribute `__getitem__`.'] -Line 90: Unexpected errors ['generics_defaults_referential.py:90:10 Undefined or invalid type [11]: Annotation `ListDefaultT` is not defined as a type.', 'generics_defaults_referential.py:90:10 Undefined or invalid type [11]: Annotation `Z1` is not defined as a type.'] -Line 94: Unexpected errors ['generics_defaults_referential.py:94:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[Bar[]]` but got `Type[Bar]`.', 'generics_defaults_referential.py:94:17 Invalid type parameters [24]: Non-generic type `Bar` cannot take parameters.'] -Line 95: Unexpected errors ['generics_defaults_referential.py:95:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[Bar[]]` but got `typing.Any`.', 'generics_defaults_referential.py:95:12 Undefined attribute [16]: `Bar` has no attribute `__getitem__`.', 'generics_defaults_referential.py:95:22 Invalid type parameters [24]: Non-generic type `Bar` cannot take parameters.'] -Line 96: Unexpected errors ['generics_defaults_referential.py:96:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Bar[]` but got `typing.Any`.', 'generics_defaults_referential.py:96:29 Invalid type parameters [24]: Non-generic type `Bar` cannot take parameters.'] -Line 97: Unexpected errors ['generics_defaults_referential.py:97:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Bar[]` but got `typing.Any`.', 'generics_defaults_referential.py:97:40 Invalid type parameters [24]: Non-generic type `Bar` cannot take parameters.'] -Line 98: Unexpected errors ['generics_defaults_referential.py:98:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Bar[]` but got `typing.Any`.', 'generics_defaults_referential.py:98:34 Invalid type parameters [24]: Non-generic type `Bar` cannot take parameters.'] -""" diff --git a/conformance/results/pyre/generics_defaults_specialization.toml b/conformance/results/pyre/generics_defaults_specialization.toml deleted file mode 100644 index 7de25df9c..000000000 --- a/conformance/results/pyre/generics_defaults_specialization.toml +++ /dev/null @@ -1,41 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support generic defaults. -""" -output = """ -generics_defaults_specialization.py:19:30 Undefined or invalid type [11]: Annotation `T1` is not defined as a type. -generics_defaults_specialization.py:19:30 Undefined or invalid type [11]: Annotation `T2` is not defined as a type. -generics_defaults_specialization.py:22:21 Undefined attribute [16]: `SomethingWithNoDefaults` has no attribute `__getitem__`. -generics_defaults_specialization.py:25:14 Undefined or invalid type [11]: Annotation `MyAlias` is not defined as a type. -generics_defaults_specialization.py:26:20 Invalid type parameters [24]: Non-generic type `SomethingWithNoDefaults` cannot take parameters. -generics_defaults_specialization.py:27:20 Invalid type parameters [24]: Non-generic type `SomethingWithNoDefaults` cannot take parameters. -generics_defaults_specialization.py:30:0 Undefined attribute [16]: `TypeAlias` has no attribute `__getitem__`. -generics_defaults_specialization.py:38:17 Undefined or invalid type [11]: Annotation `DefaultStrT` is not defined as a type. -generics_defaults_specialization.py:45:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[Bar[]]` but got `Type[Bar]`. -generics_defaults_specialization.py:45:17 Invalid type parameters [24]: Non-generic type `Bar` cannot take parameters. -generics_defaults_specialization.py:46:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Bar[]` but got `Bar`. -generics_defaults_specialization.py:46:19 Invalid type parameters [24]: Non-generic type `Bar` cannot take parameters. -generics_defaults_specialization.py:47:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Bar[]` but got `typing.Any`. -generics_defaults_specialization.py:47:12 Undefined attribute [16]: `Bar` has no attribute `__getitem__`. -generics_defaults_specialization.py:47:25 Invalid type parameters [24]: Non-generic type `Bar` cannot take parameters. -generics_defaults_specialization.py:50:10 Invalid type parameters [24]: Non-generic type `SubclassMe` cannot take parameters. -generics_defaults_specialization.py:55:0 Undefined attribute [16]: `Foo` has no attribute `__getitem__`. -generics_defaults_specialization.py:58:10 Undefined or invalid type [11]: Annotation `DefaultIntT` is not defined as a type. -generics_defaults_specialization.py:65:0 Incompatible variable type [9]: v1 is declared to have type `Baz[]` but is used as type `Spam`. -generics_defaults_specialization.py:65:4 Invalid type parameters [24]: Non-generic type `Baz` cannot take parameters. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 19: Unexpected errors ['generics_defaults_specialization.py:19:30 Undefined or invalid type [11]: Annotation `T1` is not defined as a type.', 'generics_defaults_specialization.py:19:30 Undefined or invalid type [11]: Annotation `T2` is not defined as a type.'] -Line 22: Unexpected errors ['generics_defaults_specialization.py:22:21 Undefined attribute [16]: `SomethingWithNoDefaults` has no attribute `__getitem__`.'] -Line 25: Unexpected errors ['generics_defaults_specialization.py:25:14 Undefined or invalid type [11]: Annotation `MyAlias` is not defined as a type.'] -Line 26: Unexpected errors ['generics_defaults_specialization.py:26:20 Invalid type parameters [24]: Non-generic type `SomethingWithNoDefaults` cannot take parameters.'] -Line 27: Unexpected errors ['generics_defaults_specialization.py:27:20 Invalid type parameters [24]: Non-generic type `SomethingWithNoDefaults` cannot take parameters.'] -Line 38: Unexpected errors ['generics_defaults_specialization.py:38:17 Undefined or invalid type [11]: Annotation `DefaultStrT` is not defined as a type.'] -Line 45: Unexpected errors ['generics_defaults_specialization.py:45:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Type[Bar[]]` but got `Type[Bar]`.', 'generics_defaults_specialization.py:45:17 Invalid type parameters [24]: Non-generic type `Bar` cannot take parameters.'] -Line 46: Unexpected errors ['generics_defaults_specialization.py:46:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Bar[]` but got `Bar`.', 'generics_defaults_specialization.py:46:19 Invalid type parameters [24]: Non-generic type `Bar` cannot take parameters.'] -Line 47: Unexpected errors ['generics_defaults_specialization.py:47:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Bar[]` but got `typing.Any`.', 'generics_defaults_specialization.py:47:12 Undefined attribute [16]: `Bar` has no attribute `__getitem__`.', 'generics_defaults_specialization.py:47:25 Invalid type parameters [24]: Non-generic type `Bar` cannot take parameters.'] -Line 50: Unexpected errors ['generics_defaults_specialization.py:50:10 Invalid type parameters [24]: Non-generic type `SubclassMe` cannot take parameters.'] -Line 58: Unexpected errors ['generics_defaults_specialization.py:58:10 Undefined or invalid type [11]: Annotation `DefaultIntT` is not defined as a type.'] -Line 65: Unexpected errors ['generics_defaults_specialization.py:65:0 Incompatible variable type [9]: v1 is declared to have type `Baz[]` but is used as type `Spam`.', 'generics_defaults_specialization.py:65:4 Invalid type parameters [24]: Non-generic type `Baz` cannot take parameters.'] -""" diff --git a/conformance/results/pyre/generics_paramspec_basic.toml b/conformance/results/pyre/generics_paramspec_basic.toml deleted file mode 100644 index 74f97773a..000000000 --- a/conformance/results/pyre/generics_paramspec_basic.toml +++ /dev/null @@ -1,25 +0,0 @@ -conformant = "Partial" -notes = """ -Does not enforce name consistency for ParamSpec assigned to identifier. -Incorrectly reports error for legitimate use of ParamSpec in generic type alias. -Does not reject ParamSpec when used in various invalid locations. -""" -output = """ -generics_paramspec_basic.py:15:0 Undefined or invalid type [11]: Annotation `P` is not defined as a type. -generics_paramspec_basic.py:17:0 Incompatible variable type [9]: TA2 is declared to have type `TypeAlias` but is used as type `Type[typing.Callable[..., Variable[$synthetic_attribute_resolution_variable]]]`. -generics_paramspec_basic.py:17:26 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[typing.Any, Type[Variable[$synthetic_attribute_resolution_variable]]]` but got `Tuple[ParamSpec, None]`. -generics_paramspec_basic.py:18:0 Incompatible variable type [9]: TA3 is declared to have type `TypeAlias` but is used as type `Type[typing.Callable[..., Variable[$synthetic_attribute_resolution_variable]]]`. -generics_paramspec_basic.py:18:26 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[typing.Any, Type[Variable[$synthetic_attribute_resolution_variable]]]` but got `Tuple[object, None]`. -generics_paramspec_basic.py:27:13 Invalid type variable [34]: The type variable `P` isn't present in the function's parameters. -generics_paramspec_basic.py:27:13 Undefined or invalid type [11]: Annotation `Concatenate` is not defined as a type. -generics_paramspec_basic.py:31:13 Invalid type parameters [24]: Single type parameter `Variable[_T]` expected, but a callable parameters `generics_paramspec_basic.P` was given for generic type list. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 10: Expected 1 errors -Line 23: Expected 1 errors -Line 35: Expected 1 errors -Line 39: Expected 1 errors -Line 17: Unexpected errors ['generics_paramspec_basic.py:17:0 Incompatible variable type [9]: TA2 is declared to have type `TypeAlias` but is used as type `Type[typing.Callable[..., Variable[$synthetic_attribute_resolution_variable]]]`.', 'generics_paramspec_basic.py:17:26 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[typing.Any, Type[Variable[$synthetic_attribute_resolution_variable]]]` but got `Tuple[ParamSpec, None]`.'] -Line 18: Unexpected errors ['generics_paramspec_basic.py:18:0 Incompatible variable type [9]: TA3 is declared to have type `TypeAlias` but is used as type `Type[typing.Callable[..., Variable[$synthetic_attribute_resolution_variable]]]`.', 'generics_paramspec_basic.py:18:26 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[typing.Any, Type[Variable[$synthetic_attribute_resolution_variable]]]` but got `Tuple[object, None]`.'] -""" diff --git a/conformance/results/pyre/generics_paramspec_components.toml b/conformance/results/pyre/generics_paramspec_components.toml deleted file mode 100644 index daf77e2f1..000000000 --- a/conformance/results/pyre/generics_paramspec_components.toml +++ /dev/null @@ -1,32 +0,0 @@ -conformant = "Partial" -notes = """ -Does not report illegal use of "P.args" on normal parameter. -Does not report error when P.args is specified but P.kwargs is missing. -Does not report error when P is out of scope and P.args and P.kwargs is used. -Does not report error when calling callback defined with ParamSpec with incorrect arguments. -Does not report error when keyword argument is specified between P.args and P.kwargs. -Does not report error when calling callable and argument is missing for concatenated parameters. -""" -output = """ -generics_paramspec_components.py:17:24 Undefined or invalid type [11]: Annotation `P.kwargs` is not defined as a type. -generics_paramspec_components.py:17:44 Undefined or invalid type [11]: Annotation `P.args` is not defined as a type. -generics_paramspec_components.py:49:8 Call error [29]: `typing.Callable[generics_paramspec_components.P, int]` cannot be safely called because the types and kinds of its parameters depend on a type variable. -generics_paramspec_components.py:70:8 Call error [29]: `typing.Callable[typing.Concatenate[int, generics_paramspec_components.P], int]` cannot be safely called because the types and kinds of its parameters depend on a type variable. -generics_paramspec_components.py:72:8 Missing argument [20]: PositionalOnly call expects argument in position 0. -generics_paramspec_components.py:83:8 Unexpected keyword [28]: Unexpected keyword argument `x` to call `foo`. -generics_paramspec_components.py:98:19 Incompatible parameter type [6]: In call `twice`, for 2nd positional argument, expected `int` but got `str`. -generics_paramspec_components.py:98:24 Incompatible parameter type [6]: In call `twice`, for 3rd positional argument, expected `str` but got `int`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 20: Expected 1 errors -Line 23: Expected 1 errors -Line 26: Expected 1 errors -Line 30: Expected 1 errors -Line 35: Expected 1 errors -Line 36: Expected 1 errors -Line 38: Expected 1 errors -Line 41: Expected 1 errors -Line 51: Expected 1 errors -Line 60: Expected 1 errors -""" diff --git a/conformance/results/pyre/generics_paramspec_semantics.toml b/conformance/results/pyre/generics_paramspec_semantics.toml deleted file mode 100644 index df19bc773..000000000 --- a/conformance/results/pyre/generics_paramspec_semantics.toml +++ /dev/null @@ -1,18 +0,0 @@ -conformant = "Pass" -output = """ -generics_paramspec_semantics.py:26:0 Unexpected keyword [28]: Unexpected keyword argument `a` to anonymous call. -generics_paramspec_semantics.py:27:8 Incompatible parameter type [6]: In anonymous call, for 2nd positional argument, expected `bool` but got `str`. -generics_paramspec_semantics.py:46:16 Incompatible parameter type [6]: In call `func1`, for 2nd positional argument, expected `typing.Callable[generics_paramspec_semantics.P, int]` but got `typing.Callable(y_x)[[Named(y, int), Named(x, str)], int]`. -generics_paramspec_semantics.py:61:22 Incompatible parameter type [6]: In call `func1`, for 2nd positional argument, expected `typing.Callable[generics_paramspec_semantics.P, int]` but got `typing.Callable(keyword_only_y)[[KeywordOnly(y, int)], int]`. -generics_paramspec_semantics.py:81:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Y[int, [int]]` but got `Y[typing_extensions.Literal[1], [int]]`. -generics_paramspec_semantics.py:97:3 Incompatible parameter type [6]: In anonymous call, for 1st positional argument, expected `str` but got `int`. -generics_paramspec_semantics.py:107:3 Incompatible parameter type [6]: In anonymous call, for 1st positional argument, expected `bool` but got `int`. -generics_paramspec_semantics.py:119:3 Incompatible parameter type [6]: In anonymous call, for 1st positional argument, expected `str` but got `int`. -generics_paramspec_semantics.py:126:1 Invalid decoration [56]: Pyre doesn't yet support decorators with ParamSpec applied to generic functions Please add # pyre-ignore[56] to `generics_paramspec_semantics.expects_int_first`. -generics_paramspec_semantics.py:131:1 Invalid decoration [56]: Pyre doesn't yet support decorators with ParamSpec applied to generic functions Please add # pyre-ignore[56] to `generics_paramspec_semantics.expects_int_first`. -generics_paramspec_semantics.py:136:1 Invalid decoration [56]: Pyre doesn't yet support decorators with ParamSpec applied to generic functions Please add # pyre-ignore[56] to `generics_paramspec_semantics.expects_int_first`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 81: Unexpected errors ['generics_paramspec_semantics.py:81:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Y[int, [int]]` but got `Y[typing_extensions.Literal[1], [int]]`.'] -""" diff --git a/conformance/results/pyre/generics_paramspec_specialization.toml b/conformance/results/pyre/generics_paramspec_specialization.toml deleted file mode 100644 index b152cb021..000000000 --- a/conformance/results/pyre/generics_paramspec_specialization.toml +++ /dev/null @@ -1,25 +0,0 @@ -conformant = "Partial" -notes = """ -Reports error for legitimate use of `...` to specialize ParamSpec -""" -output = """ -generics_paramspec_specialization.py:14:0 Uninitialized attribute [13]: Attribute `f` is declared in class `ClassA` to have type `typing.Callable[generics_paramspec_specialization.P1, int]` but is never initialized. -generics_paramspec_specialization.py:14:0 Uninitialized attribute [13]: Attribute `x` is declared in class `ClassA` to have type `Variable[T]` but is never initialized. -generics_paramspec_specialization.py:19:0 Uninitialized attribute [13]: Attribute `f1` is declared in class `ClassB` to have type `typing.Callable[generics_paramspec_specialization.P1, int]` but is never initialized. -generics_paramspec_specialization.py:19:0 Uninitialized attribute [13]: Attribute `f2` is declared in class `ClassB` to have type `typing.Callable[generics_paramspec_specialization.P2, int]` but is never initialized. -generics_paramspec_specialization.py:19:0 Uninitialized attribute [13]: Attribute `x` is declared in class `ClassB` to have type `Variable[T]` but is never initialized. -generics_paramspec_specialization.py:33:14 Undefined or invalid type [11]: Annotation `...` is not defined as a type. -generics_paramspec_specialization.py:45:14 Invalid type parameters [24]: Callable parameters expected for parameter specification `P1`, but a single type `int` was given for generic type ClassA. -generics_paramspec_specialization.py:49:0 Uninitialized attribute [13]: Attribute `f` is declared in class `ClassC` to have type `typing.Callable[generics_paramspec_specialization.P1, int]` but is never initialized. -generics_paramspec_specialization.py:55:8 Incompatible parameter type [6]: In anonymous call, for 1st positional argument, expected `int` but got `str`. -generics_paramspec_specialization.py:56:15 Incompatible parameter type [6]: In anonymous call, for 3rd positional argument, expected `bool` but got `str`. -generics_paramspec_specialization.py:61:8 Incompatible parameter type [6]: In anonymous call, for 1st positional argument, expected `int` but got `str`. -generics_paramspec_specialization.py:62:15 Incompatible parameter type [6]: In anonymous call, for 3rd positional argument, expected `bool` but got `str`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 14: Unexpected errors ['generics_paramspec_specialization.py:14:0 Uninitialized attribute [13]: Attribute `f` is declared in class `ClassA` to have type `typing.Callable[generics_paramspec_specialization.P1, int]` but is never initialized.', 'generics_paramspec_specialization.py:14:0 Uninitialized attribute [13]: Attribute `x` is declared in class `ClassA` to have type `Variable[T]` but is never initialized.'] -Line 19: Unexpected errors ['generics_paramspec_specialization.py:19:0 Uninitialized attribute [13]: Attribute `f1` is declared in class `ClassB` to have type `typing.Callable[generics_paramspec_specialization.P1, int]` but is never initialized.', 'generics_paramspec_specialization.py:19:0 Uninitialized attribute [13]: Attribute `f2` is declared in class `ClassB` to have type `typing.Callable[generics_paramspec_specialization.P2, int]` but is never initialized.', 'generics_paramspec_specialization.py:19:0 Uninitialized attribute [13]: Attribute `x` is declared in class `ClassB` to have type `Variable[T]` but is never initialized.'] -Line 33: Unexpected errors ['generics_paramspec_specialization.py:33:14 Undefined or invalid type [11]: Annotation `...` is not defined as a type.'] -Line 49: Unexpected errors ['generics_paramspec_specialization.py:49:0 Uninitialized attribute [13]: Attribute `f` is declared in class `ClassC` to have type `typing.Callable[generics_paramspec_specialization.P1, int]` but is never initialized.'] -""" diff --git a/conformance/results/pyre/generics_scoping.toml b/conformance/results/pyre/generics_scoping.toml deleted file mode 100644 index c29afaebc..000000000 --- a/conformance/results/pyre/generics_scoping.toml +++ /dev/null @@ -1,31 +0,0 @@ -conformant = "Partial" -notes = """ -False negative on generic class nested within generic function with same type variable. -False negative on generic class nested within generic class with same type variable. -""" -output = """ -generics_scoping.py:14:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing_extensions.Literal[1]`. -generics_scoping.py:15:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `typing_extensions.Literal['a']`. -generics_scoping.py:29:9 Incompatible parameter type [6]: In call `MyClass.meth_2`, for 1st positional argument, expected `int` but got `str`. -generics_scoping.py:42:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `typing_extensions.Literal['abc']`. -generics_scoping.py:43:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `bytes` but got `typing_extensions.Literal[b'abc']`. -generics_scoping.py:50:7 Invalid type variable [34]: The type variable `Variable[S]` isn't present in the function's parameters. -generics_scoping.py:54:13 Invalid type variable [34]: The current class isn't generic with respect to the type variable `Variable[S]`. To reference the type variable, you can modify the class to inherit from `typing.Generic[S]`. -generics_scoping.py:74:0 Uninitialized attribute [13]: Attribute `attr` is declared in class `Outer` to have type `Outer.Inner[Variable[T]]` but is never initialized. -generics_scoping.py:77:4 Uninitialized attribute [13]: Attribute `x` is declared in class `Outer.AlsoBad` to have type `typing.List[Variable[T]]` but is never initialized. -generics_scoping.py:78:11 Invalid type variable [34]: The current class isn't generic with respect to the type variable `Variable[T]`. To reference the type variable, you can modify the class to inherit from `typing.Generic[T]`. -generics_scoping.py:84:23 Undefined attribute [16]: `list` has no attribute `__getitem__`. -generics_scoping.py:88:13 Invalid type variable [34]: The type variable `Variable[T]` can only be used to annotate generic classes or functions. -generics_scoping.py:89:13 Invalid type variable [34]: The type variable `Variable[T]` can only be used to annotate generic classes or functions. -generics_scoping.py:90:0 Undefined attribute [16]: `list` has no attribute `__getitem__`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 65: Expected 1 errors -Line 75: Expected 1 errors -Line 14: Unexpected errors ['generics_scoping.py:14:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing_extensions.Literal[1]`.'] -Line 15: Unexpected errors ["generics_scoping.py:15:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `typing_extensions.Literal['a']`."] -Line 42: Unexpected errors ["generics_scoping.py:42:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `typing_extensions.Literal['abc']`."] -Line 43: Unexpected errors ["generics_scoping.py:43:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `bytes` but got `typing_extensions.Literal[b'abc']`."] -""" -ignore_errors = ["Uninitialized attribute [13]"] diff --git a/conformance/results/pyre/generics_self_advanced.toml b/conformance/results/pyre/generics_self_advanced.toml deleted file mode 100644 index e7ef9d28d..000000000 --- a/conformance/results/pyre/generics_self_advanced.toml +++ /dev/null @@ -1,23 +0,0 @@ -conformant = "Partial" -notes = """ -Does not handle use of `Self` within class body correctly. -""" -output = """ -generics_self_advanced.py:25:7 Undefined or invalid type [11]: Annotation `Self` is not defined as a type. -generics_self_advanced.py:35:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `unknown` but got `ChildB`. -generics_self_advanced.py:37:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `unknown` but got `typing.Any`. -generics_self_advanced.py:38:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `unknown` but got `ChildB`. -generics_self_advanced.py:42:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `unknown` but got `Type[ChildB]`. -generics_self_advanced.py:44:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `unknown` but got `typing.Any`. -generics_self_advanced.py:45:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `unknown` but got `ChildB`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 25: Unexpected errors ['generics_self_advanced.py:25:7 Undefined or invalid type [11]: Annotation `Self` is not defined as a type.'] -Line 35: Unexpected errors ['generics_self_advanced.py:35:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `unknown` but got `ChildB`.'] -Line 37: Unexpected errors ['generics_self_advanced.py:37:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `unknown` but got `typing.Any`.'] -Line 38: Unexpected errors ['generics_self_advanced.py:38:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `unknown` but got `ChildB`.'] -Line 42: Unexpected errors ['generics_self_advanced.py:42:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `unknown` but got `Type[ChildB]`.'] -Line 44: Unexpected errors ['generics_self_advanced.py:44:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `unknown` but got `typing.Any`.'] -Line 45: Unexpected errors ['generics_self_advanced.py:45:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `unknown` but got `ChildB`.'] -""" diff --git a/conformance/results/pyre/generics_self_attributes.toml b/conformance/results/pyre/generics_self_attributes.toml deleted file mode 100644 index 557fadbf7..000000000 --- a/conformance/results/pyre/generics_self_attributes.toml +++ /dev/null @@ -1,15 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not understand `Self` type. -""" -output = """ -generics_self_attributes.py:16:10 Undefined or invalid type [11]: Annotation `Self` is not defined as a type. -generics_self_attributes.py:26:5 Unexpected keyword [28]: Unexpected keyword argument `next` to call `OrdinalLinkedList.__init__`. -generics_self_attributes.py:29:14 Unexpected keyword [28]: Unexpected keyword argument `next` to call `OrdinalLinkedList.__init__`. -generics_self_attributes.py:32:14 Unexpected keyword [28]: Unexpected keyword argument `next` to call `LinkedList.__init__`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 16: Unexpected errors ['generics_self_attributes.py:16:10 Undefined or invalid type [11]: Annotation `Self` is not defined as a type.'] -Line 29: Unexpected errors ['generics_self_attributes.py:29:14 Unexpected keyword [28]: Unexpected keyword argument `next` to call `OrdinalLinkedList.__init__`.'] -""" diff --git a/conformance/results/pyre/generics_self_basic.toml b/conformance/results/pyre/generics_self_basic.toml deleted file mode 100644 index a2f0dfbe7..000000000 --- a/conformance/results/pyre/generics_self_basic.toml +++ /dev/null @@ -1,21 +0,0 @@ -conformant = "Partial" -notes = """ -Does not handle use of `Self` as a generic type. -""" -output = """ -generics_self_basic.py:14:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `unknown` but got `Variable[_Self_generics_self_basic_Shape__ (bound to Shape)]`. -generics_self_basic.py:14:26 Undefined or invalid type [11]: Annotation `Self` is not defined as a type. -generics_self_basic.py:20:8 Incompatible return type [7]: Expected `Variable[_Self_generics_self_basic_Shape__ (bound to Shape)]` but got `Shape`. -generics_self_basic.py:27:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `unknown` but got `Type[Variable[_Self_generics_self_basic_Shape__ (bound to Shape)]]`. -generics_self_basic.py:33:8 Incompatible return type [7]: Expected `Variable[_Self_generics_self_basic_Shape__ (bound to Shape)]` but got `Shape`. -generics_self_basic.py:40:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `unknown` but got `Variable[_Self_generics_self_basic_Shape__ (bound to Shape)]`. -generics_self_basic.py:58:0 Uninitialized attribute [13]: Attribute `value` is declared in class `Container` to have type `Variable[T]` but is never initialized. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 64: Expected 1 errors -Line 14: Unexpected errors ['generics_self_basic.py:14:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `unknown` but got `Variable[_Self_generics_self_basic_Shape__ (bound to Shape)]`.', 'generics_self_basic.py:14:26 Undefined or invalid type [11]: Annotation `Self` is not defined as a type.'] -Line 27: Unexpected errors ['generics_self_basic.py:27:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `unknown` but got `Type[Variable[_Self_generics_self_basic_Shape__ (bound to Shape)]]`.'] -Line 40: Unexpected errors ['generics_self_basic.py:40:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `unknown` but got `Variable[_Self_generics_self_basic_Shape__ (bound to Shape)]`.'] -Line 58: Unexpected errors ['generics_self_basic.py:58:0 Uninitialized attribute [13]: Attribute `value` is declared in class `Container` to have type `Variable[T]` but is never initialized.'] -""" diff --git a/conformance/results/pyre/generics_self_protocols.toml b/conformance/results/pyre/generics_self_protocols.toml deleted file mode 100644 index 309def8b8..000000000 --- a/conformance/results/pyre/generics_self_protocols.toml +++ /dev/null @@ -1,11 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject protocol compatibility due to method `Self` return type. -""" -output = """ -generics_self_protocols.py:61:18 Incompatible parameter type [6]: In call `accepts_shape`, for 1st positional argument, expected `ShapeProtocol` but got `BadReturnType`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 64: Expected 1 errors -""" diff --git a/conformance/results/pyre/generics_self_usage.toml b/conformance/results/pyre/generics_self_usage.toml deleted file mode 100644 index 8907b5e76..000000000 --- a/conformance/results/pyre/generics_self_usage.toml +++ /dev/null @@ -1,28 +0,0 @@ -conformant = "Partial" -notes = """ -Complains in some cases when `self: Self` is used explicitly. -Does not complain when `Self` is used on a function outside any class definition. -Does not complain when `self` is annotated explicitly (without `Self`) and `Self` is returned. -Does not complain on inheritance involving `Self`. -Does not complain on use of `Self` in static methods. -Does not complain on use of `Self` in metaclasses. -""" -output = """ -generics_self_usage.py:20:34 Undefined or invalid type [11]: Annotation `Self` is not defined as a type. -generics_self_usage.py:86:8 Incompatible return type [7]: Expected `Variable[_Self_generics_self_usage_Foo3__ (bound to Foo3)]` but got `Foo3`. -generics_self_usage.py:106:23 Undefined attribute [16]: `tuple` has no attribute `__getitem__`. -generics_self_usage.py:106:29 Undefined attribute [16]: Module `typing` has no attribute `Self`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 73: Expected 1 errors -Line 76: Expected 1 errors -Line 82: Expected 1 errors -Line 101: Expected 1 errors -Line 103: Expected 1 errors -Line 111: Expected 1 errors -Line 116: Expected 1 errors -Line 121: Expected 1 errors -Line 125: Expected 1 errors -Line 20: Unexpected errors ['generics_self_usage.py:20:34 Undefined or invalid type [11]: Annotation `Self` is not defined as a type.'] -""" diff --git a/conformance/results/pyre/generics_syntax_compatibility.toml b/conformance/results/pyre/generics_syntax_compatibility.toml deleted file mode 100644 index 46268f566..000000000 --- a/conformance/results/pyre/generics_syntax_compatibility.toml +++ /dev/null @@ -1,11 +0,0 @@ -conformant = "Unsupported" -notes = """ -Type parameter syntax not yet support. -""" -output = """ -generics_syntax_compatibility.py:14:13 Parsing failure [404]: invalid syntax -""" -conformance_automated = "Fail" -errors_diff = """ -Line 26: Expected 1 errors -""" diff --git a/conformance/results/pyre/generics_syntax_declarations.toml b/conformance/results/pyre/generics_syntax_declarations.toml deleted file mode 100644 index 59b938d56..000000000 --- a/conformance/results/pyre/generics_syntax_declarations.toml +++ /dev/null @@ -1,21 +0,0 @@ -conformant = "Unsupported" -notes = """ -Type parameter syntax not yet support. -""" -output = """ -generics_syntax_declarations.py:13:17 Parsing failure [404]: invalid syntax -""" -conformance_automated = "Fail" -errors_diff = """ -Line 19: Expected 1 errors -Line 27: Expected 1 errors -Line 34: Expected 1 errors -Line 46: Expected 1 errors -Line 50: Expected 1 errors -Line 62: Expected 1 errors -Line 66: Expected 1 errors -Line 73: Expected 1 errors -Line 77: Expected 1 errors -Line 81: Expected 1 errors -Line 13: Unexpected errors ['generics_syntax_declarations.py:13:17 Parsing failure [404]: invalid syntax'] -""" diff --git a/conformance/results/pyre/generics_syntax_infer_variance.toml b/conformance/results/pyre/generics_syntax_infer_variance.toml deleted file mode 100644 index 2a2c10d66..000000000 --- a/conformance/results/pyre/generics_syntax_infer_variance.toml +++ /dev/null @@ -1,30 +0,0 @@ -conformant = "Unsupported" -notes = """ -Type parameter syntax not yet support. -""" -output = """ -generics_syntax_infer_variance.py:125:25 Parsing failure [404]: invalid syntax -""" -conformance_automated = "Fail" -errors_diff = """ -Line 15: Expected 1 errors -Line 17: Expected 1 errors -Line 29: Expected 1 errors -Line 37: Expected 1 errors -Line 46: Expected 1 errors -Line 55: Expected 1 errors -Line 68: Expected 1 errors -Line 79: Expected 1 errors -Line 95: Expected 1 errors -Line 96: Expected 1 errors -Line 110: Expected 1 errors -Line 111: Expected 1 errors -Line 118: Expected 1 errors -Line 119: Expected 1 errors -Line 120: Expected 1 errors -Line 121: Expected 1 errors -Line 129: Expected 1 errors -Line 137: Expected 1 errors -Line 148: Expected 1 errors -Line 125: Unexpected errors ['generics_syntax_infer_variance.py:125:25 Parsing failure [404]: invalid syntax'] -""" diff --git a/conformance/results/pyre/generics_syntax_scoping.toml b/conformance/results/pyre/generics_syntax_scoping.toml deleted file mode 100644 index db9a56f1a..000000000 --- a/conformance/results/pyre/generics_syntax_scoping.toml +++ /dev/null @@ -1,16 +0,0 @@ -conformant = "Unsupported" -notes = """ -Type parameter syntax not yet support. -""" -output = """ -generics_syntax_scoping.py:14:13 Parsing failure [404]: invalid syntax -""" -conformance_automated = "Fail" -errors_diff = """ -Line 18: Expected 1 errors -Line 35: Expected 1 errors -Line 44: Expected 1 errors -Line 92: Expected 1 errors -Line 95: Expected 1 errors -Line 98: Expected 1 errors -""" diff --git a/conformance/results/pyre/generics_type_erasure.toml b/conformance/results/pyre/generics_type_erasure.toml deleted file mode 100644 index a4669c746..000000000 --- a/conformance/results/pyre/generics_type_erasure.toml +++ /dev/null @@ -1,30 +0,0 @@ -conformant = "Partial" -notes = """ -Does not erase unspecified type variables to `Any` prior to `assert_type` handling. -False negatives on instance attribute access on the type. -Does not infer type of `DefaultDict` with explicit type parameters on constructor. -""" -output = """ -generics_type_erasure.py:11:0 Uninitialized attribute [13]: Attribute `label` is declared in class `Node` to have type `Variable[T]` but is never initialized. -generics_type_erasure.py:15:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Node[str]` but got `Node[typing_extensions.Literal['']]`. -generics_type_erasure.py:16:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Node[int]` but got `Node[typing_extensions.Literal[0]]`. -generics_type_erasure.py:17:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Node[typing.Any]` but got `Node[Variable[T]]`. -generics_type_erasure.py:19:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing_extensions.Literal[0]`. -generics_type_erasure.py:36:15 Incompatible parameter type [6]: In call `Node.__init__`, for 1st positional argument, expected `Optional[int]` but got `str`. -generics_type_erasure.py:38:15 Incompatible parameter type [6]: In call `Node.__init__`, for 1st positional argument, expected `Optional[str]` but got `int`. -generics_type_erasure.py:54:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `bytes` but got `typing.Any`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 40: Expected 1 errors -Line 41: Expected 1 errors -Line 42: Expected 1 errors -Line 43: Expected 1 errors -Line 44: Expected 1 errors -Line 11: Unexpected errors ['generics_type_erasure.py:11:0 Uninitialized attribute [13]: Attribute `label` is declared in class `Node` to have type `Variable[T]` but is never initialized.'] -Line 15: Unexpected errors ["generics_type_erasure.py:15:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Node[str]` but got `Node[typing_extensions.Literal['']]`."] -Line 16: Unexpected errors ['generics_type_erasure.py:16:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Node[int]` but got `Node[typing_extensions.Literal[0]]`.'] -Line 17: Unexpected errors ['generics_type_erasure.py:17:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Node[typing.Any]` but got `Node[Variable[T]]`.'] -Line 19: Unexpected errors ['generics_type_erasure.py:19:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing_extensions.Literal[0]`.'] -Line 54: Unexpected errors ['generics_type_erasure.py:54:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `bytes` but got `typing.Any`.'] -""" diff --git a/conformance/results/pyre/generics_typevartuple_args.toml b/conformance/results/pyre/generics_typevartuple_args.toml deleted file mode 100644 index c42d5409b..000000000 --- a/conformance/results/pyre/generics_typevartuple_args.toml +++ /dev/null @@ -1,32 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support star expressions for `Unpack`. -""" -output = """ -generics_typevartuple_args.py:16:25 Invalid type [31]: Expression `*$local_generics_typevartuple_args$Ts` is not a valid type. -generics_typevartuple_args.py:16:33 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_args$Ts)]` is not a valid type. -generics_typevartuple_args.py:27:30 Invalid type [31]: Expression `*tuple[(*$local_generics_typevartuple_args$Ts, generics_typevartuple_args.Env)]` is not a valid type. -generics_typevartuple_args.py:27:76 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_args$Ts)]` is not a valid type. -generics_typevartuple_args.py:42:17 Invalid type [31]: Expression `*tuple[(int, ...)]` is not a valid type. -generics_typevartuple_args.py:51:17 Invalid type [31]: Expression `*tuple[(int, *tuple[(str, ...)], str)]` is not a valid type. -generics_typevartuple_args.py:62:17 Invalid type [31]: Expression `*tuple[(int, str)]` is not a valid type. -generics_typevartuple_args.py:70:17 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_args$Ts)]` is not a valid type. -generics_typevartuple_args.py:75:12 Incompatible parameter type [6]: In call `func4`, for 2nd positional argument, expected `Tuple[]` but got `Tuple[int, int]`. Expected has length 1, but actual has length 2. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 33: Expected 1 errors -Line 34: Expected 1 errors -Line 48: Expected 1 errors -Line 57: Expected 1 errors -Line 58: Expected 1 errors -Line 59: Expected 1 errors -Line 67: Expected 1 errors -Line 76: Expected 1 errors -Line 16: Unexpected errors ['generics_typevartuple_args.py:16:25 Invalid type [31]: Expression `*$local_generics_typevartuple_args$Ts` is not a valid type.', 'generics_typevartuple_args.py:16:33 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_args$Ts)]` is not a valid type.'] -Line 27: Unexpected errors ['generics_typevartuple_args.py:27:30 Invalid type [31]: Expression `*tuple[(*$local_generics_typevartuple_args$Ts, generics_typevartuple_args.Env)]` is not a valid type.', 'generics_typevartuple_args.py:27:76 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_args$Ts)]` is not a valid type.'] -Line 42: Unexpected errors ['generics_typevartuple_args.py:42:17 Invalid type [31]: Expression `*tuple[(int, ...)]` is not a valid type.'] -Line 51: Unexpected errors ['generics_typevartuple_args.py:51:17 Invalid type [31]: Expression `*tuple[(int, *tuple[(str, ...)], str)]` is not a valid type.'] -Line 62: Unexpected errors ['generics_typevartuple_args.py:62:17 Invalid type [31]: Expression `*tuple[(int, str)]` is not a valid type.'] -Line 70: Unexpected errors ['generics_typevartuple_args.py:70:17 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_args$Ts)]` is not a valid type.'] -""" diff --git a/conformance/results/pyre/generics_typevartuple_basic.toml b/conformance/results/pyre/generics_typevartuple_basic.toml deleted file mode 100644 index 4e1ea5a34..000000000 --- a/conformance/results/pyre/generics_typevartuple_basic.toml +++ /dev/null @@ -1,74 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support TypeVarTuple. -""" -output = """ -generics_typevartuple_basic.py:12:13 Invalid type [31]: Expression `typing.Generic[(*$local_generics_typevartuple_basic$Ts)]` is not a valid type. -generics_typevartuple_basic.py:16:17 Invalid type [31]: Expression `*$local_generics_typevartuple_basic$Ts` is not a valid type. -generics_typevartuple_basic.py:16:25 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_basic$Ts)]` is not a valid type. -generics_typevartuple_basic.py:23:12 Invalid type [31]: Expression `typing.Generic[(*$local_generics_typevartuple_basic$Shape)]` is not a valid type. -generics_typevartuple_basic.py:24:30 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_basic$Shape)]` is not a valid type. -generics_typevartuple_basic.py:25:21 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_basic$Shape)]` is not a valid type. -generics_typevartuple_basic.py:27:27 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_basic$Shape)]` is not a valid type. -generics_typevartuple_basic.py:36:0 Incompatible variable type [9]: v1 is declared to have type `Array[]` but is used as type `Array`. -generics_typevartuple_basic.py:36:4 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_basic.py:36:33 Incompatible parameter type [6]: In call `Array.__init__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[Height, Width]`. Expected has length 1, but actual has length 2. -generics_typevartuple_basic.py:37:0 Incompatible variable type [9]: v2 is declared to have type `Array[]` but is used as type `Array`. -generics_typevartuple_basic.py:37:4 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_basic.py:37:40 Incompatible parameter type [6]: In call `Array.__init__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[Batch, Height, Width]`. Expected has length 1, but actual has length 3. -generics_typevartuple_basic.py:38:0 Incompatible variable type [9]: v3 is declared to have type `Array[]` but is used as type `Array`. -generics_typevartuple_basic.py:38:4 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_basic.py:39:4 Incompatible parameter type [6]: In call `Array.__init__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[Time, Batch, Height, Width]`. Expected has length 1, but actual has length 4. -generics_typevartuple_basic.py:42:0 Incompatible variable type [9]: v4 is declared to have type `Array[]` but is used as type `Array`. -generics_typevartuple_basic.py:42:4 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_basic.py:42:33 Incompatible parameter type [6]: In call `Array.__init__`, for 1st positional argument, expected `Tuple[]` but got `Height`. -generics_typevartuple_basic.py:43:0 Incompatible variable type [9]: v5 is declared to have type `Array[]` but is used as type `Array`. -generics_typevartuple_basic.py:43:4 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_basic.py:43:40 Incompatible parameter type [6]: In call `Array.__init__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[Batch, Width]`. Expected has length 1, but actual has length 2. -generics_typevartuple_basic.py:44:0 Incompatible variable type [9]: v6 is declared to have type `Array[]` but is used as type `Array`. -generics_typevartuple_basic.py:44:4 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_basic.py:45:4 Incompatible parameter type [6]: In call `Array.__init__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[Time, Batch, Width, Height]`. Expected has length 1, but actual has length 4. -generics_typevartuple_basic.py:52:13 Undefined or invalid type [11]: Annotation `Shape` is not defined as a type. -generics_typevartuple_basic.py:54:21 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_basic$Shape)]` is not a valid type. -generics_typevartuple_basic.py:65:6 Unexpected keyword [28]: Unexpected keyword argument `covariant` to call `TypeVarTuple.__init__`. -generics_typevartuple_basic.py:66:6 Too many arguments [19]: Call `TypeVarTuple.__init__` expects 1 positional argument, 3 were provided. -generics_typevartuple_basic.py:67:6 Unexpected keyword [28]: Unexpected keyword argument `bound` to call `TypeVarTuple.__init__`. -generics_typevartuple_basic.py:75:16 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_basic$Ts)]` is not a valid type. -generics_typevartuple_basic.py:75:34 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_basic$Ts)]` is not a valid type. -generics_typevartuple_basic.py:75:49 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_basic$Ts)]` is not a valid type. -generics_typevartuple_basic.py:90:6 Incompatible parameter type [6]: In call `func2`, for 1st positional argument, expected `Tuple[]` but got `Tuple[int, int]`. Expected has length 1, but actual has length 2. -generics_typevartuple_basic.py:93:16 Invalid type [31]: Expression `Array[(*$local_generics_typevartuple_basic$Shape)]` is not a valid type. -generics_typevartuple_basic.py:93:16 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_basic.py:93:34 Invalid type [31]: Expression `Array[(*$local_generics_typevartuple_basic$Shape)]` is not a valid type. -generics_typevartuple_basic.py:93:34 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_basic.py:93:52 Invalid type [31]: Expression `Array[(*$local_generics_typevartuple_basic$Shape)]` is not a valid type. -generics_typevartuple_basic.py:93:52 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_basic.py:97:13 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_basic.py:97:31 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_basic.py:97:48 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_basic.py:106:13 Invalid type [31]: Expression `typing.Generic[(*$local_generics_typevartuple_basic$Ts1, *$local_generics_typevartuple_basic$Ts2)]` is not a valid type. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 53: Expected 1 errors -Line 56: Expected 1 errors -Line 59: Expected 1 errors -Line 89: Expected 1 errors -Line 99: Expected 1 errors -Line 100: Expected 1 errors -Line 12: Unexpected errors ['generics_typevartuple_basic.py:12:13 Invalid type [31]: Expression `typing.Generic[(*$local_generics_typevartuple_basic$Ts)]` is not a valid type.'] -Line 16: Unexpected errors ['generics_typevartuple_basic.py:16:17 Invalid type [31]: Expression `*$local_generics_typevartuple_basic$Ts` is not a valid type.', 'generics_typevartuple_basic.py:16:25 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_basic$Ts)]` is not a valid type.'] -Line 23: Unexpected errors ['generics_typevartuple_basic.py:23:12 Invalid type [31]: Expression `typing.Generic[(*$local_generics_typevartuple_basic$Shape)]` is not a valid type.'] -Line 24: Unexpected errors ['generics_typevartuple_basic.py:24:30 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_basic$Shape)]` is not a valid type.'] -Line 25: Unexpected errors ['generics_typevartuple_basic.py:25:21 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_basic$Shape)]` is not a valid type.'] -Line 27: Unexpected errors ['generics_typevartuple_basic.py:27:27 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_basic$Shape)]` is not a valid type.'] -Line 36: Unexpected errors ['generics_typevartuple_basic.py:36:0 Incompatible variable type [9]: v1 is declared to have type `Array[]` but is used as type `Array`.', 'generics_typevartuple_basic.py:36:4 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.', 'generics_typevartuple_basic.py:36:33 Incompatible parameter type [6]: In call `Array.__init__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[Height, Width]`. Expected has length 1, but actual has length 2.'] -Line 37: Unexpected errors ['generics_typevartuple_basic.py:37:0 Incompatible variable type [9]: v2 is declared to have type `Array[]` but is used as type `Array`.', 'generics_typevartuple_basic.py:37:4 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.', 'generics_typevartuple_basic.py:37:40 Incompatible parameter type [6]: In call `Array.__init__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[Batch, Height, Width]`. Expected has length 1, but actual has length 3.'] -Line 38: Unexpected errors ['generics_typevartuple_basic.py:38:0 Incompatible variable type [9]: v3 is declared to have type `Array[]` but is used as type `Array`.', 'generics_typevartuple_basic.py:38:4 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.'] -Line 39: Unexpected errors ['generics_typevartuple_basic.py:39:4 Incompatible parameter type [6]: In call `Array.__init__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[Time, Batch, Height, Width]`. Expected has length 1, but actual has length 4.'] -Line 45: Unexpected errors ['generics_typevartuple_basic.py:45:4 Incompatible parameter type [6]: In call `Array.__init__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[Time, Batch, Width, Height]`. Expected has length 1, but actual has length 4.'] -Line 54: Unexpected errors ['generics_typevartuple_basic.py:54:21 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_basic$Shape)]` is not a valid type.'] -Line 75: Unexpected errors ['generics_typevartuple_basic.py:75:16 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_basic$Ts)]` is not a valid type.', 'generics_typevartuple_basic.py:75:34 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_basic$Ts)]` is not a valid type.', 'generics_typevartuple_basic.py:75:49 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_basic$Ts)]` is not a valid type.'] -Line 93: Unexpected errors ['generics_typevartuple_basic.py:93:16 Invalid type [31]: Expression `Array[(*$local_generics_typevartuple_basic$Shape)]` is not a valid type.', 'generics_typevartuple_basic.py:93:16 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.', 'generics_typevartuple_basic.py:93:34 Invalid type [31]: Expression `Array[(*$local_generics_typevartuple_basic$Shape)]` is not a valid type.', 'generics_typevartuple_basic.py:93:34 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.', 'generics_typevartuple_basic.py:93:52 Invalid type [31]: Expression `Array[(*$local_generics_typevartuple_basic$Shape)]` is not a valid type.', 'generics_typevartuple_basic.py:93:52 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.'] -Line 97: Unexpected errors ['generics_typevartuple_basic.py:97:13 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.', 'generics_typevartuple_basic.py:97:31 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.', 'generics_typevartuple_basic.py:97:48 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.'] -""" diff --git a/conformance/results/pyre/generics_typevartuple_callable.toml b/conformance/results/pyre/generics_typevartuple_callable.toml deleted file mode 100644 index edff454cb..000000000 --- a/conformance/results/pyre/generics_typevartuple_callable.toml +++ /dev/null @@ -1,28 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support TypeVarTuple. -""" -output = """ -generics_typevartuple_callable.py:17:31 Invalid type [31]: Expression `typing.Callable[([*$local_generics_typevartuple_callable$Ts], None)]` is not a valid type. -generics_typevartuple_callable.py:17:60 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_callable$Ts)]` is not a valid type. -generics_typevartuple_callable.py:25:8 Incompatible parameter type [6]: In call `Process.__init__`, for argument `target`, expected `typing.Callable[[unknown], None]` but got `typing.Callable(func1)[[Named(arg1, int), Named(arg2, str)], None]`. -generics_typevartuple_callable.py:25:22 Incompatible parameter type [6]: In call `Process.__init__`, for argument `args`, expected `Tuple[]` but got `Tuple[int, str]`. Expected has length 1, but actual has length 2. -generics_typevartuple_callable.py:26:8 Incompatible parameter type [6]: In call `Process.__init__`, for argument `target`, expected `typing.Callable[[unknown], None]` but got `typing.Callable(func1)[[Named(arg1, int), Named(arg2, str)], None]`. -generics_typevartuple_callable.py:26:22 Incompatible parameter type [6]: In call `Process.__init__`, for argument `args`, expected `Tuple[]` but got `Tuple[str, int]`. Expected has length 1, but actual has length 2. -generics_typevartuple_callable.py:29:13 Invalid type [31]: Expression `typing.Callable[([int, *$local_generics_typevartuple_callable$Ts, $local_generics_typevartuple_callable$T], tuple[($local_generics_typevartuple_callable$T, *$local_generics_typevartuple_callable$Ts)])]` is not a valid type. -generics_typevartuple_callable.py:29:56 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_callable$Ts, $local_generics_typevartuple_callable$T)]` is not a valid type. -generics_typevartuple_callable.py:41:18 Incompatible parameter type [6]: In call `func2`, for 1st positional argument, expected `typing.Callable[[int, unknown, Variable[T]], Tuple[Variable[T], unknown]]` but got `typing.Callable(callback1)[[Named(a, int), Named(b, str), Named(c, int), Named(d, complex)], Tuple[complex, str, int]]`. -generics_typevartuple_callable.py:42:18 Incompatible parameter type [6]: In call `func2`, for 1st positional argument, expected `typing.Callable[[int, unknown, Variable[T]], Tuple[Variable[T], unknown]]` but got `typing.Callable(callback2)[[Named(a, int), Named(d, str)], Tuple[str]]`. -generics_typevartuple_callable.py:45:17 Invalid type [31]: Expression `*tuple[(int, *$local_generics_typevartuple_callable$Ts, $local_generics_typevartuple_callable$T)]` is not a valid type. -generics_typevartuple_callable.py:45:42 Invalid type [31]: Expression `tuple[($local_generics_typevartuple_callable$T, *$local_generics_typevartuple_callable$Ts)]` is not a valid type. -generics_typevartuple_callable.py:45:42 Invalid type variable [34]: The type variable `Variable[T]` isn't present in the function's parameters. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 17: Unexpected errors ['generics_typevartuple_callable.py:17:31 Invalid type [31]: Expression `typing.Callable[([*$local_generics_typevartuple_callable$Ts], None)]` is not a valid type.', 'generics_typevartuple_callable.py:17:60 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_callable$Ts)]` is not a valid type.'] -Line 25: Unexpected errors ['generics_typevartuple_callable.py:25:8 Incompatible parameter type [6]: In call `Process.__init__`, for argument `target`, expected `typing.Callable[[unknown], None]` but got `typing.Callable(func1)[[Named(arg1, int), Named(arg2, str)], None]`.', 'generics_typevartuple_callable.py:25:22 Incompatible parameter type [6]: In call `Process.__init__`, for argument `args`, expected `Tuple[]` but got `Tuple[int, str]`. Expected has length 1, but actual has length 2.'] -Line 29: Unexpected errors ['generics_typevartuple_callable.py:29:13 Invalid type [31]: Expression `typing.Callable[([int, *$local_generics_typevartuple_callable$Ts, $local_generics_typevartuple_callable$T], tuple[($local_generics_typevartuple_callable$T, *$local_generics_typevartuple_callable$Ts)])]` is not a valid type.', 'generics_typevartuple_callable.py:29:56 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_callable$Ts, $local_generics_typevartuple_callable$T)]` is not a valid type.'] -Line 41: Unexpected errors ['generics_typevartuple_callable.py:41:18 Incompatible parameter type [6]: In call `func2`, for 1st positional argument, expected `typing.Callable[[int, unknown, Variable[T]], Tuple[Variable[T], unknown]]` but got `typing.Callable(callback1)[[Named(a, int), Named(b, str), Named(c, int), Named(d, complex)], Tuple[complex, str, int]]`.'] -Line 42: Unexpected errors ['generics_typevartuple_callable.py:42:18 Incompatible parameter type [6]: In call `func2`, for 1st positional argument, expected `typing.Callable[[int, unknown, Variable[T]], Tuple[Variable[T], unknown]]` but got `typing.Callable(callback2)[[Named(a, int), Named(d, str)], Tuple[str]]`.'] -Line 45: Unexpected errors ['generics_typevartuple_callable.py:45:17 Invalid type [31]: Expression `*tuple[(int, *$local_generics_typevartuple_callable$Ts, $local_generics_typevartuple_callable$T)]` is not a valid type.', 'generics_typevartuple_callable.py:45:42 Invalid type [31]: Expression `tuple[($local_generics_typevartuple_callable$T, *$local_generics_typevartuple_callable$Ts)]` is not a valid type.', "generics_typevartuple_callable.py:45:42 Invalid type variable [34]: The type variable `Variable[T]` isn't present in the function's parameters."] -""" diff --git a/conformance/results/pyre/generics_typevartuple_concat.toml b/conformance/results/pyre/generics_typevartuple_concat.toml deleted file mode 100644 index 751ee441c..000000000 --- a/conformance/results/pyre/generics_typevartuple_concat.toml +++ /dev/null @@ -1,39 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support TypeVarTuple. -""" -output = """ -generics_typevartuple_concat.py:22:12 Invalid type [31]: Expression `typing.Generic[(*$local_generics_typevartuple_concat$Ts)]` is not a valid type. -generics_typevartuple_concat.py:26:22 Invalid type [31]: Expression `Array[(*$local_generics_typevartuple_concat$Shape)]` is not a valid type. -generics_typevartuple_concat.py:26:22 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_concat.py:26:40 Invalid type [31]: Expression `Array[(generics_typevartuple_concat.Batch, *$local_generics_typevartuple_concat$Shape)]` is not a valid type. -generics_typevartuple_concat.py:26:40 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_concat.py:30:22 Invalid type [31]: Expression `Array[(generics_typevartuple_concat.Batch, *$local_generics_typevartuple_concat$Shape)]` is not a valid type. -generics_typevartuple_concat.py:30:22 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_concat.py:30:47 Invalid type [31]: Expression `Array[(*$local_generics_typevartuple_concat$Shape)]` is not a valid type. -generics_typevartuple_concat.py:30:47 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_concat.py:34:26 Invalid type [31]: Expression `Array[(*$local_generics_typevartuple_concat$Shape)]` is not a valid type. -generics_typevartuple_concat.py:34:26 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_concat.py:34:44 Invalid type [31]: Expression `Array[(generics_typevartuple_concat.Batch, *$local_generics_typevartuple_concat$Shape, generics_typevartuple_concat.Channels)]` is not a valid type. -generics_typevartuple_concat.py:34:44 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_concat.py:38:13 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_concat.py:47:26 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_concat$Ts)]` is not a valid type. -generics_typevartuple_concat.py:47:41 Invalid type [31]: Expression `tuple[($local_generics_typevartuple_concat$T, *$local_generics_typevartuple_concat$Ts)]` is not a valid type. -generics_typevartuple_concat.py:51:22 Incompatible parameter type [6]: In call `prefix_tuple`, for argument `y`, expected `Tuple[]` but got `Tuple[bool, str]`. Expected has length 1, but actual has length 2. -generics_typevartuple_concat.py:55:36 Invalid type [31]: Expression `tuple[($local_generics_typevartuple_concat$T, *$local_generics_typevartuple_concat$Ts)]` is not a valid type. -generics_typevartuple_concat.py:55:54 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_concat$Ts, $local_generics_typevartuple_concat$T)]` is not a valid type. -generics_typevartuple_concat.py:56:11 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `Variable[generics_typevartuple_concat.T]`. -generics_typevartuple_concat.py:56:17 Incompatible parameter type [6]: In call `tuple.__getitem__`, for 1st positional argument, expected `typing_extensions.Literal[0]` but got `slice`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 22: Unexpected errors ['generics_typevartuple_concat.py:22:12 Invalid type [31]: Expression `typing.Generic[(*$local_generics_typevartuple_concat$Ts)]` is not a valid type.'] -Line 26: Unexpected errors ['generics_typevartuple_concat.py:26:22 Invalid type [31]: Expression `Array[(*$local_generics_typevartuple_concat$Shape)]` is not a valid type.', 'generics_typevartuple_concat.py:26:22 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.', 'generics_typevartuple_concat.py:26:40 Invalid type [31]: Expression `Array[(generics_typevartuple_concat.Batch, *$local_generics_typevartuple_concat$Shape)]` is not a valid type.', 'generics_typevartuple_concat.py:26:40 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.'] -Line 30: Unexpected errors ['generics_typevartuple_concat.py:30:22 Invalid type [31]: Expression `Array[(generics_typevartuple_concat.Batch, *$local_generics_typevartuple_concat$Shape)]` is not a valid type.', 'generics_typevartuple_concat.py:30:22 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.', 'generics_typevartuple_concat.py:30:47 Invalid type [31]: Expression `Array[(*$local_generics_typevartuple_concat$Shape)]` is not a valid type.', 'generics_typevartuple_concat.py:30:47 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.'] -Line 34: Unexpected errors ['generics_typevartuple_concat.py:34:26 Invalid type [31]: Expression `Array[(*$local_generics_typevartuple_concat$Shape)]` is not a valid type.', 'generics_typevartuple_concat.py:34:26 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.', 'generics_typevartuple_concat.py:34:44 Invalid type [31]: Expression `Array[(generics_typevartuple_concat.Batch, *$local_generics_typevartuple_concat$Shape, generics_typevartuple_concat.Channels)]` is not a valid type.', 'generics_typevartuple_concat.py:34:44 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.'] -Line 38: Unexpected errors ['generics_typevartuple_concat.py:38:13 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.'] -Line 47: Unexpected errors ['generics_typevartuple_concat.py:47:26 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_concat$Ts)]` is not a valid type.', 'generics_typevartuple_concat.py:47:41 Invalid type [31]: Expression `tuple[($local_generics_typevartuple_concat$T, *$local_generics_typevartuple_concat$Ts)]` is not a valid type.'] -Line 51: Unexpected errors ['generics_typevartuple_concat.py:51:22 Incompatible parameter type [6]: In call `prefix_tuple`, for argument `y`, expected `Tuple[]` but got `Tuple[bool, str]`. Expected has length 1, but actual has length 2.'] -Line 55: Unexpected errors ['generics_typevartuple_concat.py:55:36 Invalid type [31]: Expression `tuple[($local_generics_typevartuple_concat$T, *$local_generics_typevartuple_concat$Ts)]` is not a valid type.', 'generics_typevartuple_concat.py:55:54 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_concat$Ts, $local_generics_typevartuple_concat$T)]` is not a valid type.'] -Line 56: Unexpected errors ['generics_typevartuple_concat.py:56:11 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `Variable[generics_typevartuple_concat.T]`.', 'generics_typevartuple_concat.py:56:17 Incompatible parameter type [6]: In call `tuple.__getitem__`, for 1st positional argument, expected `typing_extensions.Literal[0]` but got `slice`.'] -""" diff --git a/conformance/results/pyre/generics_typevartuple_overloads.toml b/conformance/results/pyre/generics_typevartuple_overloads.toml deleted file mode 100644 index 05291c62f..000000000 --- a/conformance/results/pyre/generics_typevartuple_overloads.toml +++ /dev/null @@ -1,20 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support star expressions for `Unpack`. -""" -output = """ -generics_typevartuple_overloads.py:16:12 Invalid type [31]: Expression `typing.Generic[(*$local_generics_typevartuple_overloads$Shape)]` is not a valid type. -generics_typevartuple_overloads.py:18:24 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_overloads.py:18:50 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_overloads.py:22:24 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_overloads.py:22:57 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_overloads.py:29:13 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_overloads.py:29:37 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 16: Unexpected errors ['generics_typevartuple_overloads.py:16:12 Invalid type [31]: Expression `typing.Generic[(*$local_generics_typevartuple_overloads$Shape)]` is not a valid type.'] -Line 18: Unexpected errors ['generics_typevartuple_overloads.py:18:24 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.', 'generics_typevartuple_overloads.py:18:50 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.'] -Line 22: Unexpected errors ['generics_typevartuple_overloads.py:22:24 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.', 'generics_typevartuple_overloads.py:22:57 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.'] -Line 29: Unexpected errors ['generics_typevartuple_overloads.py:29:13 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.', 'generics_typevartuple_overloads.py:29:37 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.'] -""" diff --git a/conformance/results/pyre/generics_typevartuple_specialization.toml b/conformance/results/pyre/generics_typevartuple_specialization.toml deleted file mode 100644 index b78a5b15f..000000000 --- a/conformance/results/pyre/generics_typevartuple_specialization.toml +++ /dev/null @@ -1,80 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support star expressions for `Unpack`. -""" -output = """ -generics_typevartuple_specialization.py:16:12 Invalid type [31]: Expression `typing.Generic[(*$local_generics_typevartuple_specialization$Ts)]` is not a valid type. -generics_typevartuple_specialization.py:24:26 Invalid type [31]: Expression `Array[(*tuple[(typing.Any, ...)])]` is not a valid type. -generics_typevartuple_specialization.py:24:26 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_specialization.py:28:13 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_specialization.py:33:13 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_specialization.py:41:11 Undefined attribute [16]: `tuple` has no attribute `__getitem__`. -generics_typevartuple_specialization.py:45:13 Undefined or invalid type [11]: Annotation `IntTuple` is not defined as a type. -generics_typevartuple_specialization.py:45:39 Undefined or invalid type [11]: Annotation `NamedArray` is not defined as a type. -generics_typevartuple_specialization.py:47:19 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_specialization.py:59:13 Invalid type [31]: Expression `typing.Generic[($local_generics_typevartuple_specialization$DType, *$local_generics_typevartuple_specialization$Shape)]` is not a valid type. -generics_typevartuple_specialization.py:59:13 Invalid type variable [34]: The current class isn't generic with respect to the type variable `Variable[DType]`. To reference the type variable, you can modify the class to inherit from `typing.Generic[DType]`. -generics_typevartuple_specialization.py:63:20 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[]` but got `typing.Tuple[Type[float], *Tuple[typing.Any, ...]]`. -generics_typevartuple_specialization.py:64:0 Invalid type parameters [24]: Non-generic type `Array2` cannot take parameters. -generics_typevartuple_specialization.py:68:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Array2[]` but got `Array2`. -generics_typevartuple_specialization.py:68:19 Invalid type parameters [24]: Non-generic type `Array2` cannot take parameters. -generics_typevartuple_specialization.py:69:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Array2[]` but got `Array2`. -generics_typevartuple_specialization.py:69:19 Invalid type parameters [24]: Non-generic type `Array2` cannot take parameters. -generics_typevartuple_specialization.py:72:38 Undefined or invalid type [11]: Annotation `FloatArray` is not defined as a type. -generics_typevartuple_specialization.py:92:13 Undefined or invalid type [11]: Annotation `VariadicTuple` is not defined as a type. -generics_typevartuple_specialization.py:95:19 Invalid type [31]: Expression `tuple[(typing.Any, *tuple[(typing.Any, ...)])]` is not a valid type. -generics_typevartuple_specialization.py:108:0 Undefined attribute [16]: `typing.Tuple` has no attribute `__getitem__`. -generics_typevartuple_specialization.py:121:12 Unable to concatenate tuple [60]: Concatenation not yet support for multiple variadic tuples: `*Ts, *Ts`. -generics_typevartuple_specialization.py:122:12 Unable to concatenate tuple [60]: Concatenation not yet support for multiple variadic tuples: `*Ts, *tuple[(int, ...)]`. -generics_typevartuple_specialization.py:127:4 Undefined or invalid type [11]: Annotation `TA7` is not defined as a type. -generics_typevartuple_specialization.py:130:13 Invalid type [31]: Expression `$local_generics_typevartuple_specialization$TA7[(*$local_generics_typevartuple_specialization$Ts, $local_generics_typevartuple_specialization$T1, $local_generics_typevartuple_specialization$T2)]` is not a valid type. -generics_typevartuple_specialization.py:130:13 Invalid type variable [34]: The type variable `Variable[T1]` isn't present in the function's parameters. -generics_typevartuple_specialization.py:130:13 Invalid type variable [34]: The type variable `Variable[T2]` isn't present in the function's parameters. -generics_typevartuple_specialization.py:130:34 Invalid type [31]: Expression `tuple[(tuple[(*$local_generics_typevartuple_specialization$Ts)], $local_generics_typevartuple_specialization$T1, $local_generics_typevartuple_specialization$T2)]` is not a valid type. -generics_typevartuple_specialization.py:130:34 Invalid type variable [34]: The type variable `Variable[T1]` isn't present in the function's parameters. -generics_typevartuple_specialization.py:130:34 Invalid type variable [34]: The type variable `Variable[T2]` isn't present in the function's parameters. -generics_typevartuple_specialization.py:143:13 Invalid type [31]: Expression `$local_generics_typevartuple_specialization$TA8[($local_generics_typevartuple_specialization$T1, *$local_generics_typevartuple_specialization$Ts, $local_generics_typevartuple_specialization$T2, $local_generics_typevartuple_specialization$T3)]` is not a valid type. -generics_typevartuple_specialization.py:143:13 Invalid type variable [34]: The type variable `Variable[T1]` isn't present in the function's parameters. -generics_typevartuple_specialization.py:143:13 Invalid type variable [34]: The type variable `Variable[T2]` isn't present in the function's parameters. -generics_typevartuple_specialization.py:143:13 Invalid type variable [34]: The type variable `Variable[T3]` isn't present in the function's parameters. -generics_typevartuple_specialization.py:143:13 Undefined or invalid type [11]: Annotation `TA8` is not defined as a type. -generics_typevartuple_specialization.py:143:38 Invalid type [31]: Expression `tuple[(tuple[(*$local_generics_typevartuple_specialization$Ts)], $local_generics_typevartuple_specialization$T1, $local_generics_typevartuple_specialization$T2, $local_generics_typevartuple_specialization$T3)]` is not a valid type. -generics_typevartuple_specialization.py:143:38 Invalid type variable [34]: The type variable `Variable[T1]` isn't present in the function's parameters. -generics_typevartuple_specialization.py:143:38 Invalid type variable [34]: The type variable `Variable[T2]` isn't present in the function's parameters. -generics_typevartuple_specialization.py:143:38 Invalid type variable [34]: The type variable `Variable[T3]` isn't present in the function's parameters. -generics_typevartuple_specialization.py:156:14 Undefined or invalid type [11]: Annotation `TA10` is not defined as a type. -generics_typevartuple_specialization.py:156:23 Invalid type [31]: Expression `$local_generics_typevartuple_specialization$TA9[(*tuple[(int, ...)], str)]` is not a valid type. -generics_typevartuple_specialization.py:156:23 Undefined or invalid type [11]: Annotation `TA9` is not defined as a type. -generics_typevartuple_specialization.py:156:54 Invalid type [31]: Expression `$local_generics_typevartuple_specialization$TA9[(*tuple[(int, ...)], str)]` is not a valid type. -generics_typevartuple_specialization.py:157:19 Invalid type [31]: Expression `tuple[(*tuple[(int, ...)], int)]` is not a valid type. -generics_typevartuple_specialization.py:158:19 Invalid type [31]: Expression `tuple[(*tuple[(int, ...)], str)]` is not a valid type. -generics_typevartuple_specialization.py:159:19 Invalid type [31]: Expression `tuple[(*tuple[(int, ...)], str)]` is not a valid type. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 109: Expected 1 errors -Line 110: Expected 1 errors -Line 163: Expected 1 errors -Line 16: Unexpected errors ['generics_typevartuple_specialization.py:16:12 Invalid type [31]: Expression `typing.Generic[(*$local_generics_typevartuple_specialization$Ts)]` is not a valid type.'] -Line 24: Unexpected errors ['generics_typevartuple_specialization.py:24:26 Invalid type [31]: Expression `Array[(*tuple[(typing.Any, ...)])]` is not a valid type.', 'generics_typevartuple_specialization.py:24:26 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.'] -Line 28: Unexpected errors ['generics_typevartuple_specialization.py:28:13 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.'] -Line 33: Unexpected errors ['generics_typevartuple_specialization.py:33:13 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.'] -Line 41: Unexpected errors ['generics_typevartuple_specialization.py:41:11 Undefined attribute [16]: `tuple` has no attribute `__getitem__`.'] -Line 45: Unexpected errors ['generics_typevartuple_specialization.py:45:13 Undefined or invalid type [11]: Annotation `IntTuple` is not defined as a type.', 'generics_typevartuple_specialization.py:45:39 Undefined or invalid type [11]: Annotation `NamedArray` is not defined as a type.'] -Line 47: Unexpected errors ['generics_typevartuple_specialization.py:47:19 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.'] -Line 59: Unexpected errors ['generics_typevartuple_specialization.py:59:13 Invalid type [31]: Expression `typing.Generic[($local_generics_typevartuple_specialization$DType, *$local_generics_typevartuple_specialization$Shape)]` is not a valid type.', "generics_typevartuple_specialization.py:59:13 Invalid type variable [34]: The current class isn't generic with respect to the type variable `Variable[DType]`. To reference the type variable, you can modify the class to inherit from `typing.Generic[DType]`."] -Line 63: Unexpected errors ['generics_typevartuple_specialization.py:63:20 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[]` but got `typing.Tuple[Type[float], *Tuple[typing.Any, ...]]`.'] -Line 64: Unexpected errors ['generics_typevartuple_specialization.py:64:0 Invalid type parameters [24]: Non-generic type `Array2` cannot take parameters.'] -Line 68: Unexpected errors ['generics_typevartuple_specialization.py:68:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Array2[]` but got `Array2`.', 'generics_typevartuple_specialization.py:68:19 Invalid type parameters [24]: Non-generic type `Array2` cannot take parameters.'] -Line 69: Unexpected errors ['generics_typevartuple_specialization.py:69:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Array2[]` but got `Array2`.', 'generics_typevartuple_specialization.py:69:19 Invalid type parameters [24]: Non-generic type `Array2` cannot take parameters.'] -Line 72: Unexpected errors ['generics_typevartuple_specialization.py:72:38 Undefined or invalid type [11]: Annotation `FloatArray` is not defined as a type.'] -Line 92: Unexpected errors ['generics_typevartuple_specialization.py:92:13 Undefined or invalid type [11]: Annotation `VariadicTuple` is not defined as a type.'] -Line 95: Unexpected errors ['generics_typevartuple_specialization.py:95:19 Invalid type [31]: Expression `tuple[(typing.Any, *tuple[(typing.Any, ...)])]` is not a valid type.'] -Line 108: Unexpected errors ['generics_typevartuple_specialization.py:108:0 Undefined attribute [16]: `typing.Tuple` has no attribute `__getitem__`.'] -Line 130: Unexpected errors ['generics_typevartuple_specialization.py:130:13 Invalid type [31]: Expression `$local_generics_typevartuple_specialization$TA7[(*$local_generics_typevartuple_specialization$Ts, $local_generics_typevartuple_specialization$T1, $local_generics_typevartuple_specialization$T2)]` is not a valid type.', "generics_typevartuple_specialization.py:130:13 Invalid type variable [34]: The type variable `Variable[T1]` isn't present in the function's parameters.", "generics_typevartuple_specialization.py:130:13 Invalid type variable [34]: The type variable `Variable[T2]` isn't present in the function's parameters.", 'generics_typevartuple_specialization.py:130:34 Invalid type [31]: Expression `tuple[(tuple[(*$local_generics_typevartuple_specialization$Ts)], $local_generics_typevartuple_specialization$T1, $local_generics_typevartuple_specialization$T2)]` is not a valid type.', "generics_typevartuple_specialization.py:130:34 Invalid type variable [34]: The type variable `Variable[T1]` isn't present in the function's parameters.", "generics_typevartuple_specialization.py:130:34 Invalid type variable [34]: The type variable `Variable[T2]` isn't present in the function's parameters."] -Line 143: Unexpected errors ['generics_typevartuple_specialization.py:143:13 Invalid type [31]: Expression `$local_generics_typevartuple_specialization$TA8[($local_generics_typevartuple_specialization$T1, *$local_generics_typevartuple_specialization$Ts, $local_generics_typevartuple_specialization$T2, $local_generics_typevartuple_specialization$T3)]` is not a valid type.', "generics_typevartuple_specialization.py:143:13 Invalid type variable [34]: The type variable `Variable[T1]` isn't present in the function's parameters.", "generics_typevartuple_specialization.py:143:13 Invalid type variable [34]: The type variable `Variable[T2]` isn't present in the function's parameters.", "generics_typevartuple_specialization.py:143:13 Invalid type variable [34]: The type variable `Variable[T3]` isn't present in the function's parameters.", 'generics_typevartuple_specialization.py:143:13 Undefined or invalid type [11]: Annotation `TA8` is not defined as a type.', 'generics_typevartuple_specialization.py:143:38 Invalid type [31]: Expression `tuple[(tuple[(*$local_generics_typevartuple_specialization$Ts)], $local_generics_typevartuple_specialization$T1, $local_generics_typevartuple_specialization$T2, $local_generics_typevartuple_specialization$T3)]` is not a valid type.', "generics_typevartuple_specialization.py:143:38 Invalid type variable [34]: The type variable `Variable[T1]` isn't present in the function's parameters.", "generics_typevartuple_specialization.py:143:38 Invalid type variable [34]: The type variable `Variable[T2]` isn't present in the function's parameters.", "generics_typevartuple_specialization.py:143:38 Invalid type variable [34]: The type variable `Variable[T3]` isn't present in the function's parameters."] -Line 156: Unexpected errors ['generics_typevartuple_specialization.py:156:14 Undefined or invalid type [11]: Annotation `TA10` is not defined as a type.', 'generics_typevartuple_specialization.py:156:23 Invalid type [31]: Expression `$local_generics_typevartuple_specialization$TA9[(*tuple[(int, ...)], str)]` is not a valid type.', 'generics_typevartuple_specialization.py:156:23 Undefined or invalid type [11]: Annotation `TA9` is not defined as a type.', 'generics_typevartuple_specialization.py:156:54 Invalid type [31]: Expression `$local_generics_typevartuple_specialization$TA9[(*tuple[(int, ...)], str)]` is not a valid type.'] -Line 157: Unexpected errors ['generics_typevartuple_specialization.py:157:19 Invalid type [31]: Expression `tuple[(*tuple[(int, ...)], int)]` is not a valid type.'] -Line 158: Unexpected errors ['generics_typevartuple_specialization.py:158:19 Invalid type [31]: Expression `tuple[(*tuple[(int, ...)], str)]` is not a valid type.'] -Line 159: Unexpected errors ['generics_typevartuple_specialization.py:159:19 Invalid type [31]: Expression `tuple[(*tuple[(int, ...)], str)]` is not a valid type.'] -""" diff --git a/conformance/results/pyre/generics_typevartuple_unpack.toml b/conformance/results/pyre/generics_typevartuple_unpack.toml deleted file mode 100644 index 8b9f13eb2..000000000 --- a/conformance/results/pyre/generics_typevartuple_unpack.toml +++ /dev/null @@ -1,27 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support star expressions for `Unpack`. -""" -output = """ -generics_typevartuple_unpack.py:17:12 Invalid type [31]: Expression `typing.Generic[(*$local_generics_typevartuple_unpack$Ts)]` is not a valid type. -generics_typevartuple_unpack.py:21:30 Invalid type [31]: Expression `Array[(generics_typevartuple_unpack.Batch, *tuple[(typing.Any, ...)], generics_typevartuple_unpack.Channels)]` is not a valid type. -generics_typevartuple_unpack.py:21:30 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_unpack.py:26:7 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_unpack.py:26:49 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_unpack.py:26:76 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_unpack.py:36:29 Invalid type [31]: Expression `Array[(generics_typevartuple_unpack.Batch, *$local_generics_typevartuple_unpack$Shape)]` is not a valid type. -generics_typevartuple_unpack.py:36:29 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_unpack.py:40:28 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -generics_typevartuple_unpack.py:44:13 Invalid type [31]: Expression `Array[(*tuple[(typing.Any, ...)])]` is not a valid type. -generics_typevartuple_unpack.py:44:13 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 30: Expected 1 errors -Line 17: Unexpected errors ['generics_typevartuple_unpack.py:17:12 Invalid type [31]: Expression `typing.Generic[(*$local_generics_typevartuple_unpack$Ts)]` is not a valid type.'] -Line 21: Unexpected errors ['generics_typevartuple_unpack.py:21:30 Invalid type [31]: Expression `Array[(generics_typevartuple_unpack.Batch, *tuple[(typing.Any, ...)], generics_typevartuple_unpack.Channels)]` is not a valid type.', 'generics_typevartuple_unpack.py:21:30 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.'] -Line 26: Unexpected errors ['generics_typevartuple_unpack.py:26:7 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.', 'generics_typevartuple_unpack.py:26:49 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.', 'generics_typevartuple_unpack.py:26:76 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.'] -Line 36: Unexpected errors ['generics_typevartuple_unpack.py:36:29 Invalid type [31]: Expression `Array[(generics_typevartuple_unpack.Batch, *$local_generics_typevartuple_unpack$Shape)]` is not a valid type.', 'generics_typevartuple_unpack.py:36:29 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.'] -Line 40: Unexpected errors ['generics_typevartuple_unpack.py:40:28 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.'] -Line 44: Unexpected errors ['generics_typevartuple_unpack.py:44:13 Invalid type [31]: Expression `Array[(*tuple[(typing.Any, ...)])]` is not a valid type.', 'generics_typevartuple_unpack.py:44:13 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters.'] -""" diff --git a/conformance/results/pyre/generics_upper_bound.toml b/conformance/results/pyre/generics_upper_bound.toml deleted file mode 100644 index b54303c54..000000000 --- a/conformance/results/pyre/generics_upper_bound.toml +++ /dev/null @@ -1,14 +0,0 @@ -conformant = "Partial" -notes = """ -False positives on valid type expression (`list[T]`) in `bound`. -Does not complain when bound is used alongside type constraints. -""" -output = """ -generics_upper_bound.py:24:37 Undefined attribute [16]: `list` has no attribute `__getitem__`. -generics_upper_bound.py:51:7 Incompatible parameter type [6]: In call `longer`, for 1st positional argument, expected `Variable[ST (bound to Sized)]` but got `int`. -generics_upper_bound.py:51:10 Incompatible parameter type [6]: In call `longer`, for 2nd positional argument, expected `Variable[ST (bound to Sized)]` but got `int`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 56: Expected 1 errors -""" diff --git a/conformance/results/pyre/generics_variance.toml b/conformance/results/pyre/generics_variance.toml deleted file mode 100644 index 3bf5ddc0c..000000000 --- a/conformance/results/pyre/generics_variance.toml +++ /dev/null @@ -1,27 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject a TypeVar that is defined as both covariant and contravariant. -Does not reject use of class-scoped TypeVar used in a base class when variance is incompatible. -""" -output = """ -generics_variance.py:77:0 Invalid type variance [46]: The type variable `Variable[T_co](covariant)` is incompatible with parent class type variable `Variable[T]` because subclasses cannot use more permissive type variables than their superclasses. -generics_variance.py:81:0 Invalid type variance [46]: The type variable `Variable[T_contra](contravariant)` is incompatible with parent class type variable `Variable[T]` because subclasses cannot use more permissive type variables than their superclasses. -generics_variance.py:93:0 Invalid type variance [46]: The type variable `Variable[T_contra](contravariant)` is incompatible with parent class type variable `Variable[T_co](covariant)` because subclasses cannot use more permissive type variables than their superclasses. -generics_variance.py:105:0 Invalid type variance [46]: The type variable `Variable[T_co](covariant)` is incompatible with parent class type variable `Variable[T_contra](contravariant)` because subclasses cannot use more permissive type variables than their superclasses. -generics_variance.py:125:0 Invalid type variance [46]: The type variable `Variable[T_co](covariant)` is incompatible with parent class type variable `Variable[T_contra](contravariant)` because subclasses cannot use more permissive type variables than their superclasses. -generics_variance.py:131:0 Invalid type variance [46]: The type variable `Variable[T_contra](contravariant)` is incompatible with parent class type variable `Variable[T_co](covariant)` because subclasses cannot use more permissive type variables than their superclasses. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 14: Expected 1 errors -Line 113: Expected 1 errors -Line 126: Expected 1 errors -Line 132: Expected 1 errors -Line 142: Expected 1 errors -Line 163: Expected 1 errors -Line 167: Expected 1 errors -Line 191: Expected 1 errors -Line 196: Expected 1 errors -Line 125: Unexpected errors ['generics_variance.py:125:0 Invalid type variance [46]: The type variable `Variable[T_co](covariant)` is incompatible with parent class type variable `Variable[T_contra](contravariant)` because subclasses cannot use more permissive type variables than their superclasses.'] -Line 131: Unexpected errors ['generics_variance.py:131:0 Invalid type variance [46]: The type variable `Variable[T_contra](contravariant)` is incompatible with parent class type variable `Variable[T_co](covariant)` because subclasses cannot use more permissive type variables than their superclasses.'] -""" diff --git a/conformance/results/pyre/generics_variance_inference.toml b/conformance/results/pyre/generics_variance_inference.toml deleted file mode 100644 index a0efdd76e..000000000 --- a/conformance/results/pyre/generics_variance_inference.toml +++ /dev/null @@ -1,34 +0,0 @@ -conformant = "Unsupported" -notes = """ -Type parameter syntax not yet support. -""" -output = """ -generics_variance_inference.py:15:13 Parsing failure [404]: invalid syntax -""" -conformance_automated = "Fail" -errors_diff = """ -Line 24: Expected 1 errors -Line 25: Expected 1 errors -Line 28: Expected 1 errors -Line 41: Expected 1 errors -Line 49: Expected 1 errors -Line 58: Expected 1 errors -Line 67: Expected 1 errors -Line 80: Expected 1 errors -Line 96: Expected 1 errors -Line 97: Expected 1 errors -Line 111: Expected 1 errors -Line 112: Expected 1 errors -Line 119: Expected 1 errors -Line 120: Expected 1 errors -Line 121: Expected 1 errors -Line 122: Expected 1 errors -Line 130: Expected 1 errors -Line 138: Expected 1 errors -Line 149: Expected 1 errors -Line 169: Expected 1 errors -Line 170: Expected 1 errors -Line 181: Expected 1 errors -Line 194: Expected 1 errors -Line 15: Unexpected errors ['generics_variance_inference.py:15:13 Parsing failure [404]: invalid syntax'] -""" diff --git a/conformance/results/pyre/historical_positional.toml b/conformance/results/pyre/historical_positional.toml deleted file mode 100644 index 9e1a52b20..000000000 --- a/conformance/results/pyre/historical_positional.toml +++ /dev/null @@ -1,19 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject positional-only parameter after non-positional-only parameter. -Incorrectly applies legacy positional-only rules when explicit *args are used. -Incorrectly applies legacy positional-only rules when PEP 570 syntax is used. -""" -output = """ -historical_positional.py:18:0 Unexpected keyword [28]: Unexpected keyword argument `__x` to call `f1`. -historical_positional.py:32:0 Unexpected keyword [28]: Unexpected keyword argument `__y` to call `f3`. -historical_positional.py:43:0 Unexpected keyword [28]: Unexpected keyword argument `__x` to call `A.m1`. -historical_positional.py:53:0 Unexpected keyword [28]: Unexpected keyword argument `__y` to call `f4`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 26: Expected 1 errors -Line 38: Expected 1 errors -Line 32: Unexpected errors ['historical_positional.py:32:0 Unexpected keyword [28]: Unexpected keyword argument `__y` to call `f3`.'] -Line 53: Unexpected errors ['historical_positional.py:53:0 Unexpected keyword [28]: Unexpected keyword argument `__y` to call `f4`.'] -""" diff --git a/conformance/results/pyre/literals_interactions.toml b/conformance/results/pyre/literals_interactions.toml deleted file mode 100644 index fd34d1f4e..000000000 --- a/conformance/results/pyre/literals_interactions.toml +++ /dev/null @@ -1,22 +0,0 @@ -conformant = "Partial" -notes = """ -Does not detect out-of-bound tuple literal index. -Does not perform exhaustiveness checks on enums. -Does not narrow type of `x` with `x in Literal` type guard pattern. -Does not narrow type of `x` with `x == Literal` type guard pattern. -""" -output = """ -literals_interactions.py:93:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `Union[Status, str]`. -literals_interactions.py:106:34 Incompatible parameter type [6]: In call `expects_bad_status`, for 1st positional argument, expected `Union[typing_extensions.Literal['ABORTED'], typing_extensions.Literal['MALFORMED']]` but got `str`. -literals_interactions.py:109:31 Non-literal string [62]: In call `expects_pending_status`, for 1st positional argument, expected `LiteralString` but got `str`. Ensure only a string literal or a `LiteralString` is used. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 15: Expected 1 errors -Line 16: Expected 1 errors -Line 17: Expected 1 errors -Line 18: Expected 1 errors -Line 93: Unexpected errors ['literals_interactions.py:93:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `Union[Status, str]`.'] -Line 106: Unexpected errors ["literals_interactions.py:106:34 Incompatible parameter type [6]: In call `expects_bad_status`, for 1st positional argument, expected `Union[typing_extensions.Literal['ABORTED'], typing_extensions.Literal['MALFORMED']]` but got `str`."] -Line 109: Unexpected errors ['literals_interactions.py:109:31 Non-literal string [62]: In call `expects_pending_status`, for 1st positional argument, expected `LiteralString` but got `str`. Ensure only a string literal or a `LiteralString` is used.'] -""" diff --git a/conformance/results/pyre/literals_literalstring.toml b/conformance/results/pyre/literals_literalstring.toml deleted file mode 100644 index d92481187..000000000 --- a/conformance/results/pyre/literals_literalstring.toml +++ /dev/null @@ -1,21 +0,0 @@ -conformant = "Partial" -notes = """ -Incorrectly infers `str` rather than `LiteralString` when literal string `join` is used. -""" -output = """ -literals_literalstring.py:36:11 Invalid type [31]: Expression `LiteralString` is not a literal value. -literals_literalstring.py:36:11 Undefined or invalid type [11]: Annotation `typing` is not defined as a type. -literals_literalstring.py:37:13 Invalid type [31]: Expression `LiteralString` is not a literal value. -literals_literalstring.py:43:4 Incompatible variable type [9]: x2 is declared to have type `typing_extensions.Literal['']` but is used as type `typing_extensions.Literal['two']`. -literals_literalstring.py:52:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing_extensions.LiteralString` but got `str`. -literals_literalstring.py:66:4 Incompatible variable type [9]: x1 is declared to have type `typing_extensions.LiteralString` but is used as type `str`. -literals_literalstring.py:74:4 Incompatible variable type [9]: x3 is declared to have type `typing_extensions.LiteralString` but is used as type `typing_extensions.Literal[3]`. -literals_literalstring.py:75:4 Incompatible variable type [9]: x4 is declared to have type `typing_extensions.LiteralString` but is used as type `typing_extensions.Literal[b'test']`. -literals_literalstring.py:120:21 Incompatible parameter type [6]: In call `literal_identity`, for 1st positional argument, expected `Variable[TLiteral (bound to typing_extensions.LiteralString)]` but got `str`. -literals_literalstring.py:134:50 Incompatible parameter type [6]: In call `Container.__init__`, for 1st positional argument, expected `Variable[T (bound to typing_extensions.LiteralString)]` but got `str`. -literals_literalstring.py:171:4 Incompatible variable type [9]: x1 is declared to have type `List[str]` but is used as type `List[typing_extensions.LiteralString]`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 52: Unexpected errors ['literals_literalstring.py:52:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `typing_extensions.LiteralString` but got `str`.'] -""" diff --git a/conformance/results/pyre/literals_parameterizations.toml b/conformance/results/pyre/literals_parameterizations.toml deleted file mode 100644 index c856e8bc8..000000000 --- a/conformance/results/pyre/literals_parameterizations.toml +++ /dev/null @@ -1,37 +0,0 @@ -conformant = "Partial" -notes = """ -Does not support type aliases in Literal type expression. -Does not support nested Literal type expression. -Does not reject tuple in Literal type expression. -Does not reject "bare" Literal in type expression. -""" -output = """ -literals_parameterizations.py:33:0 Invalid type [31]: Expression `AppendMode` is not a literal value. -literals_parameterizations.py:33:0 Invalid type [31]: Expression `ReadOnlyMode` is not a literal value. -literals_parameterizations.py:33:0 Invalid type [31]: Expression `WriteAndTruncateMode` is not a literal value. -literals_parameterizations.py:33:0 Invalid type [31]: Expression `WriteNoTruncateMode` is not a literal value. -literals_parameterizations.py:33:0 Undefined or invalid type [11]: Annotation `` is not defined as a type. -literals_parameterizations.py:35:8 Invalid type [31]: Expression `typing.Literal[(typing.Literal[(typing.Literal[(1, 2, 3)], "foo")], 5, None)]` is not a valid type. -literals_parameterizations.py:41:6 Invalid type [31]: Expression `typing.Literal[3.__add__(4)]` is not a valid type. -literals_parameterizations.py:42:6 Invalid type [31]: Expression `typing.Literal["foo".replace("o", "b")]` is not a valid type. -literals_parameterizations.py:43:6 Invalid type [31]: Expression `typing.Literal[4.__add__(3.000000j)]` is not a valid type. -literals_parameterizations.py:44:6 Invalid type [31]: Expression `typing.Literal[~ 5]` is not a valid type. -literals_parameterizations.py:45:6 Invalid type [31]: Expression `typing.Literal[not False]` is not a valid type. -literals_parameterizations.py:47:6 Invalid type [31]: Expression `typing.Literal[{ "a":"b","c":"d" }]` is not a valid type. -literals_parameterizations.py:48:6 Invalid type [31]: Expression `typing.Literal[int]` is not a valid type. -literals_parameterizations.py:49:6 Invalid type [31]: Expression `variable` is not a literal value. -literals_parameterizations.py:50:7 Invalid type [31]: Expression `T` is not a literal value. -literals_parameterizations.py:51:7 Invalid type [31]: Expression `typing.Literal[3.140000]` is not a valid type. -literals_parameterizations.py:52:7 Invalid type [31]: Expression `Any` is not a literal value. -literals_parameterizations.py:53:7 Invalid type [31]: Expression `typing.Literal[...]` is not a valid type. -literals_parameterizations.py:56:19 Invalid type [31]: Expression `typing.Literal[1.__add__(2)]` is not a valid type. -literals_parameterizations.py:61:3 Invalid type [31]: Expression `my_function` is not a literal value. -literals_parameterizations.py:65:4 Incompatible variable type [9]: x1 is declared to have type `typing_extensions.Literal['Color.RED']` but is used as type `typing_extensions.Literal[Color.RED]`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 46: Expected 1 errors -Line 60: Expected 1 errors -Line 33: Unexpected errors ['literals_parameterizations.py:33:0 Invalid type [31]: Expression `AppendMode` is not a literal value.', 'literals_parameterizations.py:33:0 Invalid type [31]: Expression `ReadOnlyMode` is not a literal value.', 'literals_parameterizations.py:33:0 Invalid type [31]: Expression `WriteAndTruncateMode` is not a literal value.', 'literals_parameterizations.py:33:0 Invalid type [31]: Expression `WriteNoTruncateMode` is not a literal value.', 'literals_parameterizations.py:33:0 Undefined or invalid type [11]: Annotation `` is not defined as a type.'] -Line 35: Unexpected errors ['literals_parameterizations.py:35:8 Invalid type [31]: Expression `typing.Literal[(typing.Literal[(typing.Literal[(1, 2, 3)], "foo")], 5, None)]` is not a valid type.'] -""" diff --git a/conformance/results/pyre/literals_semantics.toml b/conformance/results/pyre/literals_semantics.toml deleted file mode 100644 index be0b6a028..000000000 --- a/conformance/results/pyre/literals_semantics.toml +++ /dev/null @@ -1,13 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject augmented operation that modifies literal value. -""" -output = """ -literals_semantics.py:10:0 Incompatible variable type [9]: v2 is declared to have type `typing_extensions.Literal[3]` but is used as type `typing_extensions.Literal[4]`. -literals_semantics.py:24:4 Incompatible variable type [9]: x1 is declared to have type `typing_extensions.Literal[False]` but is used as type `typing_extensions.Literal[0]`. -literals_semantics.py:25:4 Incompatible variable type [9]: x2 is declared to have type `typing_extensions.Literal[0]` but is used as type `typing_extensions.Literal[False]`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 33: Expected 1 errors -""" diff --git a/conformance/results/pyre/namedtuples_define_class.toml b/conformance/results/pyre/namedtuples_define_class.toml deleted file mode 100644 index 49225bc7d..000000000 --- a/conformance/results/pyre/namedtuples_define_class.toml +++ /dev/null @@ -1,46 +0,0 @@ -conformant = "Partial" -notes = """ -Does not evaluate correct type for indexed named tuple instance with integer. -Does not evaluate correct type for indexed named tuple instance with slice. -Does not report out-of-range index access with named tuple instance. -Does not reject named tuple element with no default value after one with a default. -Incorrectly rejects assignment of named tuple to a tuple with compatible type. -Does not reject attempt to use NamedTuple with multiple inheritance. -""" -output = """ -namedtuples_define_class.py:23:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing.Any`. -namedtuples_define_class.py:24:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing.Any`. -namedtuples_define_class.py:25:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `typing.Any`. -namedtuples_define_class.py:26:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `typing.Any`. -namedtuples_define_class.py:27:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing.Any`. -namedtuples_define_class.py:28:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing.Any`. -namedtuples_define_class.py:29:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Tuple[int, int]` but got `typing.Tuple[typing.Any, ...]`. -namedtuples_define_class.py:30:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Tuple[int, int, str]` but got `typing.Tuple[typing.Any, ...]`. -namedtuples_define_class.py:44:5 Missing argument [20]: Call `Point.__init__` expects argument `y`. -namedtuples_define_class.py:45:5 Missing argument [20]: Call `Point.__init__` expects argument `y`. -namedtuples_define_class.py:46:14 Incompatible parameter type [6]: In call `Point.__init__`, for 2nd positional argument, expected `int` but got `str`. -namedtuples_define_class.py:47:17 Incompatible parameter type [6]: In call `Point.__init__`, for argument `units`, expected `str` but got `int`. -namedtuples_define_class.py:48:5 Too many arguments [19]: Call `Point.__init__` expects 3 positional arguments, 4 were provided. -namedtuples_define_class.py:49:6 Unexpected keyword [28]: Unexpected keyword argument `other` to call `Point.__init__`. -namedtuples_define_class.py:73:0 Incompatible variable type [9]: Unable to unpack `PointWithName`, expected a tuple. -namedtuples_define_class.py:79:4 Invalid assignment [41]: Cannot reassign final attribute `x`. -namedtuples_define_class.py:95:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `float` but got `typing.Any`. -namedtuples_define_class.py:98:18 Incompatible parameter type [6]: In call `Property.__init__`, for 2nd positional argument, expected `str` but got `float`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 32: Expected 1 errors -Line 33: Expected 1 errors -Line 59: Expected 1 errors -Line 105: Expected 1 errors -Line 23: Unexpected errors ['namedtuples_define_class.py:23:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing.Any`.'] -Line 24: Unexpected errors ['namedtuples_define_class.py:24:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing.Any`.'] -Line 25: Unexpected errors ['namedtuples_define_class.py:25:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `typing.Any`.'] -Line 26: Unexpected errors ['namedtuples_define_class.py:26:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `typing.Any`.'] -Line 27: Unexpected errors ['namedtuples_define_class.py:27:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing.Any`.'] -Line 28: Unexpected errors ['namedtuples_define_class.py:28:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing.Any`.'] -Line 29: Unexpected errors ['namedtuples_define_class.py:29:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Tuple[int, int]` but got `typing.Tuple[typing.Any, ...]`.'] -Line 30: Unexpected errors ['namedtuples_define_class.py:30:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Tuple[int, int, str]` but got `typing.Tuple[typing.Any, ...]`.'] -Line 73: Unexpected errors ['namedtuples_define_class.py:73:0 Incompatible variable type [9]: Unable to unpack `PointWithName`, expected a tuple.'] -Line 95: Unexpected errors ['namedtuples_define_class.py:95:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `float` but got `typing.Any`.'] -""" diff --git a/conformance/results/pyre/namedtuples_define_functional.toml b/conformance/results/pyre/namedtuples_define_functional.toml deleted file mode 100644 index 8bf701ba9..000000000 --- a/conformance/results/pyre/namedtuples_define_functional.toml +++ /dev/null @@ -1,37 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject duplicate field names in functional form. -Does not handle illegal named tuple names the same as runtime. -Does not handle defined fields correctly when extra flags like `rename` or `default` are used. -Does not support defaults in functional form. -""" -output = """ -namedtuples_define_functional.py:16:7 Missing argument [20]: Call `Point1.__init__` expects argument `y`. -namedtuples_define_functional.py:21:7 Missing argument [20]: Call `Point2.__init__` expects argument `x`. -namedtuples_define_functional.py:26:7 Too many arguments [19]: Call `Point3.__init__` expects 2 positional arguments, 3 were provided. -namedtuples_define_functional.py:31:7 Unexpected keyword [28]: Unexpected keyword argument `z` to call `Point4.__init__`. -namedtuples_define_functional.py:36:17 Incompatible parameter type [6]: In call `Point5.__init__`, for 2nd positional argument, expected `int` but got `str`. -namedtuples_define_functional.py:37:7 Too many arguments [19]: Call `Point5.__init__` expects 2 positional arguments, 3 were provided. -namedtuples_define_functional.py:42:17 Incompatible parameter type [6]: In call `Point6.__init__`, for 2nd positional argument, expected `int` but got `str`. -namedtuples_define_functional.py:43:14 Incompatible parameter type [6]: In call `Point6.__init__`, for argument `x`, expected `int` but got `float`. -namedtuples_define_functional.py:54:47 Invalid type [31]: Expression `False` is not a valid type. -namedtuples_define_functional.py:54:47 Invalid type [31]: Expression `False` is not a valid type. -namedtuples_define_functional.py:54:47 Invalid type [31]: Expression `typing.Final[False]` is not a valid type. -namedtuples_define_functional.py:56:47 Invalid type [31]: Expression `True` is not a valid type. -namedtuples_define_functional.py:56:47 Invalid type [31]: Expression `True` is not a valid type. -namedtuples_define_functional.py:56:47 Invalid type [31]: Expression `typing.Final[True]` is not a valid type. -namedtuples_define_functional.py:57:0 Unexpected keyword [28]: Unexpected keyword argument `abc` to call `NT4.__init__`. -namedtuples_define_functional.py:63:42 Invalid type [31]: Expression `(1, 2)` is not a valid type. -namedtuples_define_functional.py:63:42 Invalid type [31]: Expression `(1, 2)` is not a valid type. -namedtuples_define_functional.py:63:42 Invalid type [31]: Expression `typing.Final[(1, 2)]` is not a valid type. -namedtuples_define_functional.py:63:42 Invalid type parameters [24]: Generic type `typing.Final` expects 1 type parameter, received 2. -namedtuples_define_functional.py:65:0 Too many arguments [19]: Call `NT5.__init__` expects 1 positional argument, 3 were provided. -namedtuples_define_functional.py:66:0 Missing argument [20]: Call `NT5.__init__` expects argument `defaults`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 56: Unexpected errors ['namedtuples_define_functional.py:56:47 Invalid type [31]: Expression `True` is not a valid type.', 'namedtuples_define_functional.py:56:47 Invalid type [31]: Expression `True` is not a valid type.', 'namedtuples_define_functional.py:56:47 Invalid type [31]: Expression `typing.Final[True]` is not a valid type.'] -Line 57: Unexpected errors ['namedtuples_define_functional.py:57:0 Unexpected keyword [28]: Unexpected keyword argument `abc` to call `NT4.__init__`.'] -Line 63: Unexpected errors ['namedtuples_define_functional.py:63:42 Invalid type [31]: Expression `(1, 2)` is not a valid type.', 'namedtuples_define_functional.py:63:42 Invalid type [31]: Expression `(1, 2)` is not a valid type.', 'namedtuples_define_functional.py:63:42 Invalid type [31]: Expression `typing.Final[(1, 2)]` is not a valid type.', 'namedtuples_define_functional.py:63:42 Invalid type parameters [24]: Generic type `typing.Final` expects 1 type parameter, received 2.'] -Line 65: Unexpected errors ['namedtuples_define_functional.py:65:0 Too many arguments [19]: Call `NT5.__init__` expects 1 positional argument, 3 were provided.'] -""" diff --git a/conformance/results/pyre/namedtuples_type_compat.toml b/conformance/results/pyre/namedtuples_type_compat.toml deleted file mode 100644 index 76f3303cb..000000000 --- a/conformance/results/pyre/namedtuples_type_compat.toml +++ /dev/null @@ -1,17 +0,0 @@ -conformant = "Unsupported" -notes = """ -Rejects valid type compatibility between named tuple and tuple. -""" -output = """ -namedtuples_type_compat.py:20:0 Incompatible variable type [9]: Unable to unpack `Point`, expected a tuple. -namedtuples_type_compat.py:21:0 Incompatible variable type [9]: Unable to unpack `Point`, expected a tuple. -namedtuples_type_compat.py:22:0 Incompatible variable type [9]: Unable to unpack `Point`, expected a tuple. -namedtuples_type_compat.py:23:0 Incompatible variable type [9]: Unable to unpack `Point`, expected a tuple. -namedtuples_type_compat.py:27:0 Incompatible variable type [9]: Unable to unpack `Point`, expected a tuple. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 20: Unexpected errors ['namedtuples_type_compat.py:20:0 Incompatible variable type [9]: Unable to unpack `Point`, expected a tuple.'] -Line 21: Unexpected errors ['namedtuples_type_compat.py:21:0 Incompatible variable type [9]: Unable to unpack `Point`, expected a tuple.'] -Line 27: Unexpected errors ['namedtuples_type_compat.py:27:0 Incompatible variable type [9]: Unable to unpack `Point`, expected a tuple.'] -""" diff --git a/conformance/results/pyre/namedtuples_usage.toml b/conformance/results/pyre/namedtuples_usage.toml deleted file mode 100644 index a9956c367..000000000 --- a/conformance/results/pyre/namedtuples_usage.toml +++ /dev/null @@ -1,35 +0,0 @@ -conformant = "Partial" -notes = """ -Does not report out-of-range index access with named tuple instance. -Does not reject attempt to delete named tuple field by name. -Does not reject attempt to delete named tuple field by index. -Incorrectly handles subclasses of named tuples that add more attributes. -Does not handle unpacking of named tuples. -""" -output = """ -namedtuples_usage.py:27:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing.Any`. -namedtuples_usage.py:28:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing.Any`. -namedtuples_usage.py:29:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `typing.Any`. -namedtuples_usage.py:30:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `typing.Any`. -namedtuples_usage.py:31:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing.Any`. -namedtuples_usage.py:32:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing.Any`. -namedtuples_usage.py:40:0 Invalid assignment [41]: Cannot reassign final attribute `p.x`. -namedtuples_usage.py:41:0 Undefined attribute [16]: `Point` has no attribute `__setitem__`. -namedtuples_usage.py:52:0 Unable to unpack [23]: Unable to unpack 3 values, 2 were expected. -namedtuples_usage.py:53:0 Unable to unpack [23]: Unable to unpack 3 values, 4 were expected. -namedtuples_usage.py:61:0 Unable to unpack [23]: Unable to unpack 0 values, 3 were expected. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 34: Expected 1 errors -Line 35: Expected 1 errors -Line 42: Expected 1 errors -Line 43: Expected 1 errors -Line 27: Unexpected errors ['namedtuples_usage.py:27:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing.Any`.'] -Line 28: Unexpected errors ['namedtuples_usage.py:28:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing.Any`.'] -Line 29: Unexpected errors ['namedtuples_usage.py:29:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `typing.Any`.'] -Line 30: Unexpected errors ['namedtuples_usage.py:30:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `str` but got `typing.Any`.'] -Line 31: Unexpected errors ['namedtuples_usage.py:31:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing.Any`.'] -Line 32: Unexpected errors ['namedtuples_usage.py:32:0 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `typing.Any`.'] -Line 61: Unexpected errors ['namedtuples_usage.py:61:0 Unable to unpack [23]: Unable to unpack 0 values, 3 were expected.'] -""" diff --git a/conformance/results/pyre/narrowing_typeguard.toml b/conformance/results/pyre/narrowing_typeguard.toml deleted file mode 100644 index 7bf7ead7b..000000000 --- a/conformance/results/pyre/narrowing_typeguard.toml +++ /dev/null @@ -1,15 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject TypeGuard method with too few parameters. -""" -output = """ -narrowing_typeguard.py:128:19 Incompatible parameter type [6]: In call `takes_callable_str`, for 1st positional argument, expected `typing.Callable[[object], str]` but got `typing.Callable(simple_typeguard)[[Named(val, object)], TypeGuard[int]]`. -narrowing_typeguard.py:148:25 Incompatible parameter type [6]: In call `takes_callable_str_proto`, for 1st positional argument, expected `CallableStrProto` but got `typing.Callable(simple_typeguard)[[Named(val, object)], TypeGuard[int]]`. -narrowing_typeguard.py:167:20 Incompatible parameter type [6]: In call `takes_int_typeguard`, for 1st positional argument, expected `typing.Callable[[object], TypeGuard[int]]` but got `typing.Callable(bool_typeguard)[[Named(val, object)], TypeGuard[bool]]`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 102: Expected 1 errors -Line 107: Expected 1 errors -Line 167: Unexpected errors ['narrowing_typeguard.py:167:20 Incompatible parameter type [6]: In call `takes_int_typeguard`, for 1st positional argument, expected `typing.Callable[[object], TypeGuard[int]]` but got `typing.Callable(bool_typeguard)[[Named(val, object)], TypeGuard[bool]]`.'] -""" diff --git a/conformance/results/pyre/narrowing_typeis.toml b/conformance/results/pyre/narrowing_typeis.toml deleted file mode 100644 index 2746dc5f7..000000000 --- a/conformance/results/pyre/narrowing_typeis.toml +++ /dev/null @@ -1,39 +0,0 @@ -conformant = "Unsupported" -output = """ -narrowing_typeis.py:9:0 Undefined import [21]: Could not find a name `TypeIs` defined in module `typing_extensions`. -narrowing_typeis.py:14:48 Undefined or invalid type [11]: Annotation `TypeIs` is not defined as a type. -narrowing_typeis.py:19:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Tuple[str, str]` but got `typing.Tuple[str, ...]`. -narrowing_typeis.py:35:17 Incompatible awaitable type [12]: Expected an awaitable but got `typing.Union[typing.Awaitable[int], int]`. -narrowing_typeis.py:38:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `Union[Awaitable[int], int]`. -narrowing_typeis.py:72:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `object`. -narrowing_typeis.py:76:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `object`. -narrowing_typeis.py:80:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `object`. -narrowing_typeis.py:84:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `object`. -narrowing_typeis.py:88:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `object`. -narrowing_typeis.py:92:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `B` but got `object`. -narrowing_typeis.py:96:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `B` but got `object`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 105: Expected 1 errors -Line 110: Expected 1 errors -Line 132: Expected 1 errors -Line 152: Expected 1 errors -Line 169: Expected 1 errors -Line 170: Expected 1 errors -Line 191: Expected 1 errors -Line 195: Expected 1 errors -Line 199: Expected 1 errors -Line 9: Unexpected errors ['narrowing_typeis.py:9:0 Undefined import [21]: Could not find a name `TypeIs` defined in module `typing_extensions`.'] -Line 14: Unexpected errors ['narrowing_typeis.py:14:48 Undefined or invalid type [11]: Annotation `TypeIs` is not defined as a type.'] -Line 19: Unexpected errors ['narrowing_typeis.py:19:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Tuple[str, str]` but got `typing.Tuple[str, ...]`.'] -Line 35: Unexpected errors ['narrowing_typeis.py:35:17 Incompatible awaitable type [12]: Expected an awaitable but got `typing.Union[typing.Awaitable[int], int]`.'] -Line 38: Unexpected errors ['narrowing_typeis.py:38:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `Union[Awaitable[int], int]`.'] -Line 72: Unexpected errors ['narrowing_typeis.py:72:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `object`.'] -Line 76: Unexpected errors ['narrowing_typeis.py:76:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `object`.'] -Line 80: Unexpected errors ['narrowing_typeis.py:80:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `object`.'] -Line 84: Unexpected errors ['narrowing_typeis.py:84:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `object`.'] -Line 88: Unexpected errors ['narrowing_typeis.py:88:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `int` but got `object`.'] -Line 92: Unexpected errors ['narrowing_typeis.py:92:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `B` but got `object`.'] -Line 96: Unexpected errors ['narrowing_typeis.py:96:8 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `B` but got `object`.'] -""" diff --git a/conformance/results/pyre/overloads_basic.toml b/conformance/results/pyre/overloads_basic.toml deleted file mode 100644 index 7de070af9..000000000 --- a/conformance/results/pyre/overloads_basic.toml +++ /dev/null @@ -1,12 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject a function with a single @overload signature. -""" -output = """ -overloads_basic.py:37:2 Incompatible parameter type [6]: In call `Bytes.__getitem__`, for 1st positional argument, expected `int` but got `str`. -overloads_basic.py:75:0 Missing overload implementation [42]: Overloaded function `func2` must have an implementation. -""" -conformance_automated = "Fail" -errors_diff = """ -Lines 62, 63: Expected error (tag 'func1') -""" diff --git a/conformance/results/pyre/protocols_class_objects.toml b/conformance/results/pyre/protocols_class_objects.toml deleted file mode 100644 index 5c0a15fbe..000000000 --- a/conformance/results/pyre/protocols_class_objects.toml +++ /dev/null @@ -1,23 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject protocol class assigned to type[Proto]. -Incorrectly reports some class objects as incompatible with a protocol. -Fails to report some class objects as incompatible with a protocol. -""" -output = """ -protocols_class_objects.py:26:11 Invalid class instantiation [45]: Cannot instantiate abstract class `Proto` with abstract method `meth`. -protocols_class_objects.py:58:0 Incompatible variable type [9]: pa1 is declared to have type `ProtoA1` but is used as type `Type[ConcreteA]`. -protocols_class_objects.py:93:0 Uninitialized attribute [13]: Attribute `attr1` is declared in class `CMeta` to have type `int` but is never initialized. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 29: Expected 1 errors -Line 34: Expected 1 errors -Line 74: Expected 1 errors -Line 101: Expected 1 errors -Line 103: Expected 1 errors -Line 104: Expected 1 errors -Line 105: Expected 1 errors -Line 26: Unexpected errors ['protocols_class_objects.py:26:11 Invalid class instantiation [45]: Cannot instantiate abstract class `Proto` with abstract method `meth`.'] -Line 93: Unexpected errors ['protocols_class_objects.py:93:0 Uninitialized attribute [13]: Attribute `attr1` is declared in class `CMeta` to have type `int` but is never initialized.'] -""" diff --git a/conformance/results/pyre/protocols_definition.toml b/conformance/results/pyre/protocols_definition.toml deleted file mode 100644 index 102319974..000000000 --- a/conformance/results/pyre/protocols_definition.toml +++ /dev/null @@ -1,35 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject ClassVar in concrete class when attribute in protocol is not ClassVar or vice versa. -Does not reject read-only property in concrete class when attribute in protocol is mutable. -Does not reject covariant attribute type when protocol attribute is mutable. -Does not reject read-only property in concrete class when protocol has settable property. -Does not reject immutable named tuple attribute in concrete class when protocol attribute is mutable. -Does not reject immutable frozen dataclass attribute in concrete class when protocol attribute is mutable. -""" -output = """ -protocols_definition.py:30:10 Incompatible parameter type [6]: In call `close_all`, for 1st positional argument, expected `Iterable[SupportsClose]` but got `Iterable[int]`. -protocols_definition.py:67:8 Undefined attribute [16]: `Template` has no attribute `temp`. -protocols_definition.py:114:0 Incompatible variable type [9]: v2_bad1 is declared to have type `Template2` but is used as type `Concrete2_Bad1`. -protocols_definition.py:115:0 Incompatible variable type [9]: v2_bad2 is declared to have type `Template2` but is used as type `Concrete2_Bad2`. -protocols_definition.py:156:0 Incompatible variable type [9]: v3_bad1 is declared to have type `Template3` but is used as type `Concrete3_Bad1`. -protocols_definition.py:159:0 Incompatible variable type [9]: v3_bad4 is declared to have type `Template3` but is used as type `Concrete3_Bad4`. -protocols_definition.py:218:0 Incompatible variable type [9]: v4_bad1 is declared to have type `Template4` but is used as type `Concrete4_Bad1`. -protocols_definition.py:219:0 Incompatible variable type [9]: v4_bad2 is declared to have type `Template4` but is used as type `Concrete4_Bad2`. -protocols_definition.py:285:0 Incompatible variable type [9]: v5_bad1 is declared to have type `Template5` but is used as type `Concrete5_Bad1`. -protocols_definition.py:286:0 Incompatible variable type [9]: v5_bad2 is declared to have type `Template5` but is used as type `Concrete5_Bad2`. -protocols_definition.py:287:0 Incompatible variable type [9]: v5_bad3 is declared to have type `Template5` but is used as type `Concrete5_Bad3`. -protocols_definition.py:288:0 Incompatible variable type [9]: v5_bad4 is declared to have type `Template5` but is used as type `Concrete5_Bad4`. -protocols_definition.py:289:0 Incompatible variable type [9]: v5_bad5 is declared to have type `Template5` but is used as type `Concrete5_Bad5`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 116: Expected 1 errors -Line 117: Expected 1 errors -Line 157: Expected 1 errors -Line 158: Expected 1 errors -Line 160: Expected 1 errors -Line 339: Expected 1 errors -Line 340: Expected 1 errors -Line 341: Expected 1 errors -""" diff --git a/conformance/results/pyre/protocols_explicit.toml b/conformance/results/pyre/protocols_explicit.toml deleted file mode 100644 index 20d00e13e..000000000 --- a/conformance/results/pyre/protocols_explicit.toml +++ /dev/null @@ -1,26 +0,0 @@ -conformant = "Partial" -notes = """ -Does not report error when calling unimplemented protocol method from derived class. -Does not report error when method is not implemented in derived class. -""" -output = """ -protocols_explicit.py:54:0 Uninitialized attribute [13]: Attribute `other` inherited from protocol `RGB` in class `Point` to have type `int` but is never initialized. -protocols_explicit.py:59:4 Invalid class instantiation [45]: Cannot instantiate abstract class `Point` with abstract method `intensity`. -protocols_explicit.py:82:0 Uninitialized attribute [13]: Attribute `cm1` inherited from protocol `Proto1` in class `Concrete1` to have type `int` but is never initialized. -protocols_explicit.py:82:0 Uninitialized attribute [13]: Attribute `im1` inherited from protocol `Proto1` in class `Concrete1` to have type `int` but is never initialized. -protocols_explicit.py:97:0 Uninitialized attribute [13]: Attribute `cm10` inherited from protocol `Proto2` in class `Concrete3` to have type `int` but is never initialized. -protocols_explicit.py:97:0 Uninitialized attribute [13]: Attribute `cm11` inherited from protocol `Proto3` in class `Concrete3` to have type `int` but is never initialized. -protocols_explicit.py:97:0 Uninitialized attribute [13]: Attribute `im1` inherited from protocol `Proto1` in class `Concrete3` to have type `int` but is never initialized. -protocols_explicit.py:159:6 Invalid class instantiation [45]: Cannot instantiate abstract class `Concrete7A` with abstract method `method1`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 27: Expected 1 errors -Line 56: Expected 1 errors -Line 86: Expected 1 errors -Line 104: Expected 1 errors -Line 129: Expected 1 errors -Line 54: Unexpected errors ['protocols_explicit.py:54:0 Uninitialized attribute [13]: Attribute `other` inherited from protocol `RGB` in class `Point` to have type `int` but is never initialized.'] -Line 82: Unexpected errors ['protocols_explicit.py:82:0 Uninitialized attribute [13]: Attribute `cm1` inherited from protocol `Proto1` in class `Concrete1` to have type `int` but is never initialized.', 'protocols_explicit.py:82:0 Uninitialized attribute [13]: Attribute `im1` inherited from protocol `Proto1` in class `Concrete1` to have type `int` but is never initialized.'] -Line 97: Unexpected errors ['protocols_explicit.py:97:0 Uninitialized attribute [13]: Attribute `cm10` inherited from protocol `Proto2` in class `Concrete3` to have type `int` but is never initialized.', 'protocols_explicit.py:97:0 Uninitialized attribute [13]: Attribute `cm11` inherited from protocol `Proto3` in class `Concrete3` to have type `int` but is never initialized.', 'protocols_explicit.py:97:0 Uninitialized attribute [13]: Attribute `im1` inherited from protocol `Proto1` in class `Concrete3` to have type `int` but is never initialized.'] -""" diff --git a/conformance/results/pyre/protocols_generic.toml b/conformance/results/pyre/protocols_generic.toml deleted file mode 100644 index f1370fa7c..000000000 --- a/conformance/results/pyre/protocols_generic.toml +++ /dev/null @@ -1,18 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject the use of Protocol and Generic together as base classes. -Does not detect protocol mismatch when method-scoped TypeVar is used in protocol. -""" -output = """ -protocols_generic.py:40:0 Incompatible variable type [9]: p2 is declared to have type `Proto1[int, str]` but is used as type `Concrete1`. -protocols_generic.py:56:4 Incompatible variable type [9]: v2 is declared to have type `Box[int]` but is used as type `Box[float]`. -protocols_generic.py:66:4 Incompatible variable type [9]: v2 is declared to have type `Sender[float]` but is used as type `Sender[int]`. -protocols_generic.py:74:4 Incompatible variable type [9]: v1 is declared to have type `AttrProto[float]` but is used as type `AttrProto[int]`. -protocols_generic.py:75:4 Incompatible variable type [9]: v2 is declared to have type `AttrProto[int]` but is used as type `AttrProto[float]`. -protocols_generic.py:146:0 Incompatible variable type [9]: hp3 is declared to have type `HasPropertyProto` but is used as type `ConcreteHasProperty3`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 44: Expected 1 errors -Line 147: Expected 1 errors -""" diff --git a/conformance/results/pyre/protocols_merging.toml b/conformance/results/pyre/protocols_merging.toml deleted file mode 100644 index c471755f2..000000000 --- a/conformance/results/pyre/protocols_merging.toml +++ /dev/null @@ -1,15 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject a protocol class that derives from a non-protocol class. -""" -output = """ -protocols_merging.py:52:0 Incompatible variable type [9]: s6 is declared to have type `SizedAndClosable1` but is used as type `SCConcrete2`. -protocols_merging.py:53:0 Incompatible variable type [9]: s7 is declared to have type `SizedAndClosable2` but is used as type `SCConcrete2`. -protocols_merging.py:54:0 Incompatible variable type [9]: s8 is declared to have type `SizedAndClosable3` but is used as type `SCConcrete2`. -protocols_merging.py:82:4 Invalid class instantiation [45]: Cannot instantiate abstract class `SizedAndClosable4` with abstract method `close`. -protocols_merging.py:83:0 Incompatible variable type [9]: y is declared to have type `SizedAndClosable4` but is used as type `SCConcrete1`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 67: Expected 1 errors -""" diff --git a/conformance/results/pyre/protocols_modules.toml b/conformance/results/pyre/protocols_modules.toml deleted file mode 100644 index cce8d663c..000000000 --- a/conformance/results/pyre/protocols_modules.toml +++ /dev/null @@ -1,12 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not perform protocol checks for modules. -""" -output = """ -""" -conformance_automated = "Fail" -errors_diff = """ -Line 26: Expected 1 errors -Line 48: Expected 1 errors -Line 49: Expected 1 errors -""" diff --git a/conformance/results/pyre/protocols_recursive.toml b/conformance/results/pyre/protocols_recursive.toml deleted file mode 100644 index 5e485e856..000000000 --- a/conformance/results/pyre/protocols_recursive.toml +++ /dev/null @@ -1,6 +0,0 @@ -conformant = "Pass" -output = """ -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pyre/protocols_runtime_checkable.toml b/conformance/results/pyre/protocols_runtime_checkable.toml deleted file mode 100644 index 7b1d73b0d..000000000 --- a/conformance/results/pyre/protocols_runtime_checkable.toml +++ /dev/null @@ -1,17 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not reject isinstance or issubclass call for protocol that is not runtime_checkable. -Does not reject issubclass call for data protocol. -Does not report unsafe overlap for runtime_checkable protocol. -""" -output = """ -""" -conformance_automated = "Fail" -errors_diff = """ -Line 23: Expected 1 errors -Line 55: Expected 1 errors -Line 61: Expected 1 errors -Line 88: Expected 1 errors -Line 92: Expected 1 errors -Line 96: Expected 1 errors -""" diff --git a/conformance/results/pyre/protocols_self.toml b/conformance/results/pyre/protocols_self.toml deleted file mode 100644 index 5e485e856..000000000 --- a/conformance/results/pyre/protocols_self.toml +++ /dev/null @@ -1,6 +0,0 @@ -conformant = "Pass" -output = """ -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pyre/protocols_subtyping.toml b/conformance/results/pyre/protocols_subtyping.toml deleted file mode 100644 index 1c8c18fcc..000000000 --- a/conformance/results/pyre/protocols_subtyping.toml +++ /dev/null @@ -1,13 +0,0 @@ -conformant = "Pass" -output = """ -protocols_subtyping.py:16:5 Invalid class instantiation [45]: Cannot instantiate protocol `Proto1`. -protocols_subtyping.py:38:4 Incompatible variable type [9]: v2 is declared to have type `Concrete2` but is used as type `Proto2`. -protocols_subtyping.py:55:4 Incompatible variable type [9]: v2 is declared to have type `Proto3` but is used as type `Proto2`. -protocols_subtyping.py:79:4 Incompatible variable type [9]: v3 is declared to have type `Proto4[int, float]` but is used as type `Proto5[int]`. -protocols_subtyping.py:80:4 Incompatible variable type [9]: v4 is declared to have type `Proto5[float]` but is used as type `Proto4[int, int]`. -protocols_subtyping.py:102:4 Incompatible variable type [9]: v4 is declared to have type `Proto7[int, float]` but is used as type `Proto6[float, float]`. -protocols_subtyping.py:103:4 Incompatible variable type [9]: v5 is declared to have type `Proto7[float, object]` but is used as type `Proto6[float, float]`. -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pyre/protocols_variance.toml b/conformance/results/pyre/protocols_variance.toml deleted file mode 100644 index 5577f2529..000000000 --- a/conformance/results/pyre/protocols_variance.toml +++ /dev/null @@ -1,18 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not detect incorrect TypeVar variance within generic protocols. -""" -output = """ -protocols_variance.py:62:17 Invalid type variance [46]: The type variable `Variable[T1_co](covariant)` is covariant and cannot be a parameter type. -protocols_variance.py:72:4 Invalid type variance [46]: The type variable `Variable[T1_contra](contravariant)` is contravariant and cannot be a return type. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 21: Expected 1 errors -Line 40: Expected 1 errors -Line 56: Expected 1 errors -Line 61: Expected 1 errors -Line 66: Expected 1 errors -Line 71: Expected 1 errors -Line 104: Expected 1 errors -""" diff --git a/conformance/results/pyre/qualifiers_annotated.toml b/conformance/results/pyre/qualifiers_annotated.toml deleted file mode 100644 index f15d74fc5..000000000 --- a/conformance/results/pyre/qualifiers_annotated.toml +++ /dev/null @@ -1,34 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject Annotated with a single parameter. -Does not reject call of Annotated with no type arguments. -""" -output = """ -qualifiers_annotated.py:43:6 Undefined or invalid type [11]: Annotation `` is not defined as a type. -qualifiers_annotated.py:44:6 Invalid type [31]: Expression `typing.Annotated[(((int, str)), "")]` is not a valid type. -qualifiers_annotated.py:45:6 Invalid type [31]: Expression `typing.Annotated[(comprehension(int for generators(generator($target$i in range(1) if ))), "")]` is not a valid type. -qualifiers_annotated.py:46:6 Invalid type [31]: Expression `typing.Annotated[({ "a":"b" }, "")]` is not a valid type. -qualifiers_annotated.py:47:6 Invalid type [31]: Expression `typing.Annotated[(lambda () (int)(), "")]` is not a valid type. -qualifiers_annotated.py:48:6 Invalid type [31]: Expression `typing.Annotated[([int][0], "")]` is not a valid type. -qualifiers_annotated.py:49:6 Invalid type [31]: Expression `typing.Annotated[(int if 1 < 3 else str, "")]` is not a valid type. -qualifiers_annotated.py:50:16 Unbound name [10]: Name `var1` is used but not defined in the current scope. -qualifiers_annotated.py:51:6 Invalid type [31]: Expression `typing.Annotated[(True, "")]` is not a valid type. -qualifiers_annotated.py:52:7 Invalid type [31]: Expression `typing.Annotated[(1, "")]` is not a valid type. -qualifiers_annotated.py:53:7 Invalid type [31]: Expression `typing.Annotated[(list or set, "")]` is not a valid type. -qualifiers_annotated.py:54:7 Invalid type [31]: Expression `typing.Annotated[(f"{"int"}", "")]` is not a valid type. -qualifiers_annotated.py:76:33 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[Type[int], str]`. Expected has length 0, but actual has length 2. -qualifiers_annotated.py:77:0 Incompatible variable type [9]: not_type2 is declared to have type `Type[typing.Any]` but is used as type `TypeAlias`. -qualifiers_annotated.py:84:16 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[Type[str], str]`. Expected has length 0, but actual has length 2. -qualifiers_annotated.py:85:6 Incompatible parameter type [6]: In call `func4`, for 1st positional argument, expected `Type[Variable[T]]` but got `TypeAlias`. -qualifiers_annotated.py:92:10 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[Type[int], str]`. Expected has length 0, but actual has length 2. -qualifiers_annotated.py:93:0 Call error [29]: `TypeAlias` is not a function. -qualifiers_annotated.py:105:4 Undefined attribute [16]: `typing.Type` has no attribute `a`. -qualifiers_annotated.py:106:4 Undefined attribute [16]: `typing.Type` has no attribute `b`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 64: Expected 1 errors -Line 91: Expected 1 errors -Line 105: Unexpected errors ['qualifiers_annotated.py:105:4 Undefined attribute [16]: `typing.Type` has no attribute `a`.'] -Line 106: Unexpected errors ['qualifiers_annotated.py:106:4 Undefined attribute [16]: `typing.Type` has no attribute `b`.'] -""" diff --git a/conformance/results/pyre/qualifiers_final_annotation.toml b/conformance/results/pyre/qualifiers_final_annotation.toml deleted file mode 100644 index cf80efbd7..000000000 --- a/conformance/results/pyre/qualifiers_final_annotation.toml +++ /dev/null @@ -1,43 +0,0 @@ -conformant = "Partial" -notes = """ -Does not report Final variable with missing initialization in module scope. -Does not report error for invalid nesting of Final and ClassVar. -Does not treat use of Final name as if it was replaced by the literal in NamedTuple definition. -""" -output = """ -qualifiers_final_annotation.py:18:6 Invalid type parameters [24]: Generic type `Final` expects 1 type parameter, received 2. -qualifiers_final_annotation.py:28:0 Uninitialized attribute [13]: Attribute `ID3` is declared in class `ClassA` to have type `int` but is never initialized. -qualifiers_final_annotation.py:34:4 Invalid assignment [41]: Cannot reassign final attribute `ClassA.ID2`. -qualifiers_final_annotation.py:54:8 Invalid assignment [41]: Cannot reassign final attribute `self.ID5`. -qualifiers_final_annotation.py:62:8 Undefined attribute [16]: `ClassA` has no attribute `id3`. -qualifiers_final_annotation.py:63:8 Undefined attribute [16]: `ClassA` has no attribute `id4`. -qualifiers_final_annotation.py:65:8 Invalid assignment [41]: Cannot reassign final attribute `self.ID7`. -qualifiers_final_annotation.py:67:8 Invalid assignment [41]: Cannot reassign final attribute `self.ID7`. -qualifiers_final_annotation.py:71:0 Invalid assignment [41]: Cannot reassign final attribute `RATE`. -qualifiers_final_annotation.py:81:0 Invalid assignment [41]: Cannot reassign final attribute `ClassB.DEFAULT_ID`. -qualifiers_final_annotation.py:94:4 Invalid assignment [41]: Cannot reassign final attribute `BORDER_WIDTH`. -qualifiers_final_annotation.py:107:4 Incompatible attribute type [8]: Attribute `VALUE2` declared in class `ClassD` has type `Final` but is used as type `int`. -qualifiers_final_annotation.py:107:4 Invalid type [31]: Expression `Final` is not a valid type. Final cannot be nested. -qualifiers_final_annotation.py:118:0 Invalid type [31]: Expression `typing.List[Final[int]]` is not a valid type. Final cannot be nested. -qualifiers_final_annotation.py:121:10 Invalid type [31]: Parameter `x` cannot be annotated with Final. -qualifiers_final_annotation.py:131:0 Uninitialized attribute [13]: Attribute `($local_qualifiers_final_annotation$X, int)` is declared in class `N` to have type `typing.Any` but is never initialized. -qualifiers_final_annotation.py:131:0 Uninitialized attribute [13]: Attribute `($local_qualifiers_final_annotation$Y, int)` is declared in class `N` to have type `typing.Any` but is never initialized. -qualifiers_final_annotation.py:133:0 Unexpected keyword [28]: Unexpected keyword argument `x` to call `N.__init__`. -qualifiers_final_annotation.py:134:0 Unexpected keyword [28]: Unexpected keyword argument `a` to call `N.__init__`. -qualifiers_final_annotation.py:135:0 Unexpected keyword [28]: Unexpected keyword argument `x` to call `N.__init__`. -qualifiers_final_annotation.py:141:4 Invalid assignment [41]: Cannot reassign final attribute `ID1`. -qualifiers_final_annotation.py:145:4 Invalid assignment [41]: Cannot reassign final attribute `x`. -qualifiers_final_annotation.py:147:9 Invalid assignment [41]: Cannot reassign final attribute `x`. -qualifiers_final_annotation.py:149:8 Invalid assignment [41]: Cannot reassign final attribute `x`. -qualifiers_final_annotation.py:152:29 Invalid assignment [41]: Cannot reassign final attribute `x`. -qualifiers_final_annotation.py:155:8 Invalid assignment [41]: Cannot reassign final attribute `x`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 16: Expected 1 errors -Line 38: Expected 1 errors -Line 108: Expected 1 errors -Line 28: Unexpected errors ['qualifiers_final_annotation.py:28:0 Uninitialized attribute [13]: Attribute `ID3` is declared in class `ClassA` to have type `int` but is never initialized.'] -Line 131: Unexpected errors ['qualifiers_final_annotation.py:131:0 Uninitialized attribute [13]: Attribute `($local_qualifiers_final_annotation$X, int)` is declared in class `N` to have type `typing.Any` but is never initialized.', 'qualifiers_final_annotation.py:131:0 Uninitialized attribute [13]: Attribute `($local_qualifiers_final_annotation$Y, int)` is declared in class `N` to have type `typing.Any` but is never initialized.'] -Line 133: Unexpected errors ['qualifiers_final_annotation.py:133:0 Unexpected keyword [28]: Unexpected keyword argument `x` to call `N.__init__`.'] -""" diff --git a/conformance/results/pyre/qualifiers_final_decorator.toml b/conformance/results/pyre/qualifiers_final_decorator.toml deleted file mode 100644 index ef5be734e..000000000 --- a/conformance/results/pyre/qualifiers_final_decorator.toml +++ /dev/null @@ -1,24 +0,0 @@ -conformant = "Partial" -notes = """ -Reports error for overloaded method implementation marked @final if its overloads do not. -Does not report error for overloaded @final method defined in stub file. -Reports misleading error when overload is marked @final but implementation is not. -""" -output = """ -qualifiers_final_decorator.py:21:0 Invalid inheritance [39]: Cannot inherit from final class `Base1`. -qualifiers_final_decorator.py:51:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s). -qualifiers_final_decorator.py:56:4 Invalid override [40]: `qualifiers_final_decorator.Derived2.method1` cannot override final method defined in `Base2`. -qualifiers_final_decorator.py:60:4 Invalid override [40]: `qualifiers_final_decorator.Derived2.method2` cannot override final method defined in `Base2`. -qualifiers_final_decorator.py:64:4 Invalid override [40]: `qualifiers_final_decorator.Derived2.method3` cannot override final method defined in `Base2`. -qualifiers_final_decorator.py:75:4 Invalid override [40]: `qualifiers_final_decorator.Derived2.method4` cannot override final method defined in `Base2`. -qualifiers_final_decorator.py:86:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s). -qualifiers_final_decorator.py:118:4 Inconsistent override [14]: `qualifiers_final_decorator.Derived5.method` overrides method defined in `Base5_2` inconsistently. Could not find parameter `v` in overriding signature. -qualifiers_final_decorator.py:118:4 Invalid override [40]: `qualifiers_final_decorator.Derived5.method` cannot override final method defined in `Base5_2`. -qualifiers_final_decorator.py:126:0 Invalid inheritance [39]: `final` cannot be used with non-method functions. -""" -conformance_automated = "Fail" -errors_diff = """ -Lines 80, 89: Expected error (tag 'Derived3') -Lines 94, 102: Expected error (tag 'Derived4') -Line 51: Unexpected errors ['qualifiers_final_decorator.py:51:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).'] -""" diff --git a/conformance/results/pyre/specialtypes_any.toml b/conformance/results/pyre/specialtypes_any.toml deleted file mode 100644 index b3b83ddee..000000000 --- a/conformance/results/pyre/specialtypes_any.toml +++ /dev/null @@ -1,15 +0,0 @@ -conformant = "Partial" -notes = """ -Does not support Any as a base class. -""" -output = """ -specialtypes_any.py:81:13 Invalid inheritance [39]: `typing.Any` is not a valid parent class. -specialtypes_any.py:87:12 Undefined attribute [16]: `ClassA` has no attribute `method2`. -specialtypes_any.py:88:12 Undefined attribute [16]: `ClassA` has no attribute `method3`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 81: Unexpected errors ['specialtypes_any.py:81:13 Invalid inheritance [39]: `typing.Any` is not a valid parent class.'] -Line 87: Unexpected errors ['specialtypes_any.py:87:12 Undefined attribute [16]: `ClassA` has no attribute `method2`.'] -Line 88: Unexpected errors ['specialtypes_any.py:88:12 Undefined attribute [16]: `ClassA` has no attribute `method3`.'] -""" diff --git a/conformance/results/pyre/specialtypes_never.toml b/conformance/results/pyre/specialtypes_never.toml deleted file mode 100644 index 61b1c2673..000000000 --- a/conformance/results/pyre/specialtypes_never.toml +++ /dev/null @@ -1,27 +0,0 @@ -conformant = "Partial" -notes = """ -Does not treat Never as compatible with all other types. -""" -output = """ -specialtypes_never.py:21:8 Incompatible return type [7]: Function declared non-returnable, but got `None`. -specialtypes_never.py:55:0 Uninitialized attribute [13]: Attribute `x` is declared in class `ClassA` to have type `NoReturn` but is never initialized. -specialtypes_never.py:55:0 Uninitialized attribute [13]: Attribute `y` is declared in class `ClassA` to have type `typing.List[NoReturn]` but is never initialized. -specialtypes_never.py:64:4 Incompatible variable type [9]: v1 is declared to have type `int` but is used as type `Never`. -specialtypes_never.py:65:4 Incompatible variable type [9]: v2 is declared to have type `str` but is used as type `Never`. -specialtypes_never.py:66:4 Incompatible variable type [9]: v3 is declared to have type `List[str]` but is used as type `Never`. -specialtypes_never.py:82:4 Incompatible variable type [9]: v3 is declared to have type `List[int]` but is used as type `List[Never]`. -specialtypes_never.py:83:4 Incompatible variable type [9]: v4 is declared to have type `Never` but is used as type `NoReturn`. -specialtypes_never.py:92:4 Incompatible return type [7]: Expected `ClassB[Variable[U]]` but got `ClassB[Never]`. -specialtypes_never.py:101:4 Incompatible return type [7]: Expected `ClassC[Variable[U]]` but got `ClassC[Never]`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 19: Expected 1 errors -Line 21: Unexpected errors ['specialtypes_never.py:21:8 Incompatible return type [7]: Function declared non-returnable, but got `None`.'] -Line 55: Unexpected errors ['specialtypes_never.py:55:0 Uninitialized attribute [13]: Attribute `x` is declared in class `ClassA` to have type `NoReturn` but is never initialized.', 'specialtypes_never.py:55:0 Uninitialized attribute [13]: Attribute `y` is declared in class `ClassA` to have type `typing.List[NoReturn]` but is never initialized.'] -Line 64: Unexpected errors ['specialtypes_never.py:64:4 Incompatible variable type [9]: v1 is declared to have type `int` but is used as type `Never`.'] -Line 65: Unexpected errors ['specialtypes_never.py:65:4 Incompatible variable type [9]: v2 is declared to have type `str` but is used as type `Never`.'] -Line 66: Unexpected errors ['specialtypes_never.py:66:4 Incompatible variable type [9]: v3 is declared to have type `List[str]` but is used as type `Never`.'] -Line 83: Unexpected errors ['specialtypes_never.py:83:4 Incompatible variable type [9]: v4 is declared to have type `Never` but is used as type `NoReturn`.'] -Line 92: Unexpected errors ['specialtypes_never.py:92:4 Incompatible return type [7]: Expected `ClassB[Variable[U]]` but got `ClassB[Never]`.'] -""" diff --git a/conformance/results/pyre/specialtypes_none.toml b/conformance/results/pyre/specialtypes_none.toml deleted file mode 100644 index a9c3b0913..000000000 --- a/conformance/results/pyre/specialtypes_none.toml +++ /dev/null @@ -1,9 +0,0 @@ -conformant = "Pass" -output = """ -specialtypes_none.py:21:6 Incompatible parameter type [6]: In call `func1`, for 1st positional argument, expected `None` but got `Type[None]`. -specialtypes_none.py:27:0 Incompatible variable type [9]: none2 is declared to have type `Iterable[typing.Any]` but is used as type `None`. -specialtypes_none.py:41:6 Incompatible parameter type [6]: In call `func2`, for 1st positional argument, expected `Type[None]` but got `None`. -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pyre/specialtypes_promotions.toml b/conformance/results/pyre/specialtypes_promotions.toml deleted file mode 100644 index fb9055fb6..000000000 --- a/conformance/results/pyre/specialtypes_promotions.toml +++ /dev/null @@ -1,10 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject use of attribute that is compatible only with float. -""" -output = """ -""" -conformance_automated = "Fail" -errors_diff = """ -Line 13: Expected 1 errors -""" diff --git a/conformance/results/pyre/specialtypes_type.toml b/conformance/results/pyre/specialtypes_type.toml deleted file mode 100644 index 78343fa29..000000000 --- a/conformance/results/pyre/specialtypes_type.toml +++ /dev/null @@ -1,26 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject Callable when passed to type[T]. -Does not treat `type` same as `type[Any]` for assert_type. -Does not allow access to unknown attributes from object of type `type[Any]`. -Does not reject access to unknown attributes from object of type `Type[object]`. -Reports type incompatibility between `type` and `Callable[..., Any]`. -""" -output = """ -specialtypes_type.py:56:6 Incompatible parameter type [6]: In call `func4`, for 1st positional argument, expected `Type[Union[BasicUser, ProUser]]` but got `Type[TeamUser]`. -specialtypes_type.py:76:11 Invalid type parameters [24]: Generic type `type` expects 1 type parameter, received 2, use `typing.Type[]` to avoid runtime subscripting errors. -specialtypes_type.py:117:4 Undefined attribute [16]: `object` has no attribute `unknown`. -specialtypes_type.py:143:0 Undefined attribute [16]: `TypeAlias` has no attribute `unknown`. -specialtypes_type.py:165:4 Incompatible variable type [9]: x1 is declared to have type `typing.Callable[..., typing.Any]` but is used as type `Type[typing.Any]`. -specialtypes_type.py:166:4 Incompatible variable type [9]: x2 is declared to have type `typing.Callable[[int, int], int]` but is used as type `Type[typing.Any]`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 70: Expected 1 errors -Line 120: Expected 1 errors -Line 144: Expected 1 errors -Line 145: Expected 1 errors -Line 146: Expected 1 errors -Line 165: Unexpected errors ['specialtypes_type.py:165:4 Incompatible variable type [9]: x1 is declared to have type `typing.Callable[..., typing.Any]` but is used as type `Type[typing.Any]`.'] -Line 166: Unexpected errors ['specialtypes_type.py:166:4 Incompatible variable type [9]: x2 is declared to have type `typing.Callable[[int, int], int]` but is used as type `Type[typing.Any]`.'] -""" diff --git a/conformance/results/pyre/tuples_type_compat.toml b/conformance/results/pyre/tuples_type_compat.toml deleted file mode 100644 index 3d3a35787..000000000 --- a/conformance/results/pyre/tuples_type_compat.toml +++ /dev/null @@ -1,97 +0,0 @@ -conformant = "Partial" -notes = """ -Does not support some unpacked tuple forms. -Does not report type violation when assigning `tuple[int, ...]` to `tuple[int]`. -Does not support tuple narrowing based on `len()` type guard (optional). -Does not correctly evaluate `Sequence[Never]` for `tuple[()]`. -""" -output = """ -tuples_type_compat.py:15:4 Incompatible variable type [9]: v2 is declared to have type `Tuple[int, int]` but is used as type `Tuple[float, complex]`. -tuples_type_compat.py:22:30 Invalid type [31]: Expression `tuple[(int, *tuple[(int, ...)])]` is not a valid type. -tuples_type_compat.py:27:8 Invalid type [31]: Expression `tuple[(int, *tuple[(int, ...)])]` is not a valid type. -tuples_type_compat.py:47:8 Invalid type [31]: Expression `tuple[(int, *tuple[(str, ...)])]` is not a valid type. -tuples_type_compat.py:55:21 Undefined or invalid type [11]: Annotation `SomeType` is not defined as a type. -tuples_type_compat.py:71:15 Invalid type [31]: Expression `typing.Union[(tuple[int], tuple[(str, str)], tuple[(int, *tuple[(str, ...)], int)])]` is not a valid type. -tuples_type_compat.py:91:15 Invalid type [31]: Expression `typing.Union[(tuple[int], tuple[(str, str)], tuple[(int, *tuple[(str, ...)], int)])]` is not a valid type. -tuples_type_compat.py:95:12 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Tuple[int]` but got `Union[Tuple[int], Tuple[str, str]]`. -tuples_type_compat.py:99:12 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Union[Tuple[int, int], Tuple[str, str]]` but got `Union[Tuple[int], Tuple[str, str]]`. -tuples_type_compat.py:103:12 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Tuple[int, str, int]` but got `Union[Tuple[int], Tuple[str, str]]`. -tuples_type_compat.py:115:12 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Tuple[Union[int, str], str]` but got `Tuple[Union[int, str], Union[int, str]]`. -tuples_type_compat.py:117:12 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Tuple[Union[int, str], int]` but got `Tuple[Union[int, str], Union[int, str]]`. -tuples_type_compat.py:134:39 Invalid type [31]: Expression `tuple[(int, *tuple[(str, ...)])]` is not a valid type. -tuples_type_compat.py:139:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Sequence[Union[int, str]]` but got `Sequence[Variable[T]]`. -tuples_type_compat.py:140:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Sequence[Never]` but got `Sequence[Variable[T]]`. -tuples_type_compat.py:143:4 Invalid type [31]: Expression `tuple[(int, *tuple[str])]` is not a valid type. -tuples_type_compat.py:144:0 Incompatible variable type [9]: t1 is declared to have type `Tuple[typing_extensions.Literal[1], typing_extensions.Literal['']]` but is used as type `Tuple[typing_extensions.Literal[1], typing_extensions.Literal[''], typing_extensions.Literal['']]`. -tuples_type_compat.py:146:0 Incompatible variable type [9]: t2 is declared to have type `Tuple[int, unknown]` but is used as type `Tuple[int]`. -tuples_type_compat.py:146:4 Invalid type [31]: Expression `tuple[(int, *tuple[(str, ...)])]` is not a valid type. -tuples_type_compat.py:147:0 Incompatible variable type [9]: t2 is declared to have type `Tuple[typing_extensions.Literal[1]]` but is used as type `Tuple[typing_extensions.Literal[1], typing_extensions.Literal['']]`. -tuples_type_compat.py:148:0 Incompatible variable type [9]: t2 is declared to have type `Tuple[typing_extensions.Literal[1]]` but is used as type `Tuple[typing_extensions.Literal[1], typing_extensions.Literal[''], typing_extensions.Literal['']]`. -tuples_type_compat.py:149:0 Incompatible variable type [9]: t2 is declared to have type `Tuple[typing_extensions.Literal[1]]` but is used as type `Tuple[typing_extensions.Literal[1], typing_extensions.Literal[1], typing_extensions.Literal['']]`. -tuples_type_compat.py:150:0 Incompatible variable type [9]: t2 is declared to have type `Tuple[typing_extensions.Literal[1]]` but is used as type `Tuple[typing_extensions.Literal[1], typing_extensions.Literal[''], typing_extensions.Literal[1]]`. -tuples_type_compat.py:153:0 Incompatible variable type [9]: t3 is declared to have type `Tuple[int, unknown, int]` but is used as type `Tuple[int, int]`. -tuples_type_compat.py:153:4 Invalid type [31]: Expression `tuple[(int, *tuple[(str, ...)], int)]` is not a valid type. -tuples_type_compat.py:154:0 Incompatible variable type [9]: t3 is declared to have type `Tuple[typing_extensions.Literal[1], typing_extensions.Literal[2]]` but is used as type `Tuple[typing_extensions.Literal[1], typing_extensions.Literal[''], typing_extensions.Literal[2]]`. -tuples_type_compat.py:155:0 Incompatible variable type [9]: t3 is declared to have type `Tuple[typing_extensions.Literal[1], typing_extensions.Literal[2]]` but is used as type `Tuple[typing_extensions.Literal[1], typing_extensions.Literal[''], typing_extensions.Literal[''], typing_extensions.Literal[2]]`. -tuples_type_compat.py:156:0 Incompatible variable type [9]: t3 is declared to have type `Tuple[typing_extensions.Literal[1], typing_extensions.Literal[2]]` but is used as type `Tuple[typing_extensions.Literal[1], typing_extensions.Literal[''], typing_extensions.Literal['']]`. -tuples_type_compat.py:157:0 Incompatible variable type [9]: t3 is declared to have type `Tuple[typing_extensions.Literal[1], typing_extensions.Literal[2]]` but is used as type `Tuple[typing_extensions.Literal[1], typing_extensions.Literal[''], typing_extensions.Literal[''], float]`. -tuples_type_compat.py:159:0 Incompatible variable type [9]: t4 is declared to have type `Tuple[unknown, int]` but is used as type `Tuple[int]`. -tuples_type_compat.py:159:4 Invalid type [31]: Expression `tuple[(*tuple[(str, ...)], int)]` is not a valid type. -tuples_type_compat.py:160:0 Incompatible variable type [9]: t4 is declared to have type `Tuple[typing_extensions.Literal[1]]` but is used as type `Tuple[typing_extensions.Literal[''], typing_extensions.Literal[1]]`. -tuples_type_compat.py:161:0 Incompatible variable type [9]: t4 is declared to have type `Tuple[typing_extensions.Literal[1]]` but is used as type `Tuple[typing_extensions.Literal[''], typing_extensions.Literal[''], typing_extensions.Literal[1]]`. -tuples_type_compat.py:162:0 Incompatible variable type [9]: t4 is declared to have type `Tuple[typing_extensions.Literal[1]]` but is used as type `Tuple[typing_extensions.Literal[1], typing_extensions.Literal[''], typing_extensions.Literal[1]]`. -tuples_type_compat.py:163:0 Incompatible variable type [9]: t4 is declared to have type `Tuple[typing_extensions.Literal[1]]` but is used as type `Tuple[typing_extensions.Literal[''], typing_extensions.Literal[''], float]`. -tuples_type_compat.py:167:4 Incompatible variable type [9]: t1 is declared to have type `Tuple[str, str, unknown]` but is used as type `Tuple[str, str]`. -tuples_type_compat.py:167:8 Invalid type [31]: Expression `tuple[(str, str, *tuple[(int, ...)])]` is not a valid type. -tuples_type_compat.py:168:4 Incompatible variable type [9]: t2 is declared to have type `Tuple[str, str, unknown]` but is used as type `Tuple[str, str]`. -tuples_type_compat.py:168:8 Invalid type [31]: Expression `tuple[(str, str, *tuple[int])]` is not a valid type. -tuples_type_compat.py:169:8 Invalid type [31]: Expression `tuple[(str, *tuple[(str, ...)])]` is not a valid type. -tuples_type_compat.py:170:4 Incompatible variable type [9]: t4 is declared to have type `Tuple[str, str, unknown]` but is used as type `Tuple[str, str]`. -tuples_type_compat.py:170:8 Invalid type [31]: Expression `tuple[(str, str, *tuple[(str, ...)])]` is not a valid type. -tuples_type_compat.py:171:4 Incompatible variable type [9]: t5 is declared to have type `Tuple[str, str, str, unknown]` but is used as type `Tuple[str, str]`. -tuples_type_compat.py:171:8 Invalid type [31]: Expression `tuple[(str, str, str, *tuple[(str, ...)])]` is not a valid type. -tuples_type_compat.py:172:4 Incompatible variable type [9]: t6 is declared to have type `Tuple[str, unknown, str]` but is used as type `Tuple[str, str]`. -tuples_type_compat.py:172:8 Invalid type [31]: Expression `tuple[(str, *tuple[(int, ...)], str)]` is not a valid type. -tuples_type_compat.py:173:8 Invalid type [31]: Expression `tuple[(*tuple[(str, ...)], str)]` is not a valid type. -tuples_type_compat.py:174:8 Invalid type [31]: Expression `tuple[(*tuple[(str, ...)], str)]` is not a valid type. -tuples_type_compat.py:175:4 Incompatible variable type [9]: t9 is declared to have type `Tuple[unknown, str, str, str]` but is used as type `Tuple[str, str]`. -tuples_type_compat.py:175:8 Invalid type [31]: Expression `tuple[(*tuple[(str, ...)], str, str, str)]` is not a valid type. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 29: Expected 1 errors -Line 32: Expected 1 errors -Line 33: Expected 1 errors -Line 43: Expected 1 errors -Line 62: Expected 1 errors -Line 22: Unexpected errors ['tuples_type_compat.py:22:30 Invalid type [31]: Expression `tuple[(int, *tuple[(int, ...)])]` is not a valid type.'] -Line 27: Unexpected errors ['tuples_type_compat.py:27:8 Invalid type [31]: Expression `tuple[(int, *tuple[(int, ...)])]` is not a valid type.'] -Line 47: Unexpected errors ['tuples_type_compat.py:47:8 Invalid type [31]: Expression `tuple[(int, *tuple[(str, ...)])]` is not a valid type.'] -Line 55: Unexpected errors ['tuples_type_compat.py:55:21 Undefined or invalid type [11]: Annotation `SomeType` is not defined as a type.'] -Line 71: Unexpected errors ['tuples_type_compat.py:71:15 Invalid type [31]: Expression `typing.Union[(tuple[int], tuple[(str, str)], tuple[(int, *tuple[(str, ...)], int)])]` is not a valid type.'] -Line 91: Unexpected errors ['tuples_type_compat.py:91:15 Invalid type [31]: Expression `typing.Union[(tuple[int], tuple[(str, str)], tuple[(int, *tuple[(str, ...)], int)])]` is not a valid type.'] -Line 95: Unexpected errors ['tuples_type_compat.py:95:12 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Tuple[int]` but got `Union[Tuple[int], Tuple[str, str]]`.'] -Line 99: Unexpected errors ['tuples_type_compat.py:99:12 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Union[Tuple[int, int], Tuple[str, str]]` but got `Union[Tuple[int], Tuple[str, str]]`.'] -Line 103: Unexpected errors ['tuples_type_compat.py:103:12 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Tuple[int, str, int]` but got `Union[Tuple[int], Tuple[str, str]]`.'] -Line 115: Unexpected errors ['tuples_type_compat.py:115:12 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Tuple[Union[int, str], str]` but got `Tuple[Union[int, str], Union[int, str]]`.'] -Line 117: Unexpected errors ['tuples_type_compat.py:117:12 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Tuple[Union[int, str], int]` but got `Tuple[Union[int, str], Union[int, str]]`.'] -Line 134: Unexpected errors ['tuples_type_compat.py:134:39 Invalid type [31]: Expression `tuple[(int, *tuple[(str, ...)])]` is not a valid type.'] -Line 139: Unexpected errors ['tuples_type_compat.py:139:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Sequence[Union[int, str]]` but got `Sequence[Variable[T]]`.'] -Line 140: Unexpected errors ['tuples_type_compat.py:140:4 Incompatible parameter type [6]: In call `assert_type`, for 1st positional argument, expected `Sequence[Never]` but got `Sequence[Variable[T]]`.'] -Line 143: Unexpected errors ['tuples_type_compat.py:143:4 Invalid type [31]: Expression `tuple[(int, *tuple[str])]` is not a valid type.'] -Line 146: Unexpected errors ['tuples_type_compat.py:146:0 Incompatible variable type [9]: t2 is declared to have type `Tuple[int, unknown]` but is used as type `Tuple[int]`.', 'tuples_type_compat.py:146:4 Invalid type [31]: Expression `tuple[(int, *tuple[(str, ...)])]` is not a valid type.'] -Line 147: Unexpected errors ["tuples_type_compat.py:147:0 Incompatible variable type [9]: t2 is declared to have type `Tuple[typing_extensions.Literal[1]]` but is used as type `Tuple[typing_extensions.Literal[1], typing_extensions.Literal['']]`."] -Line 148: Unexpected errors ["tuples_type_compat.py:148:0 Incompatible variable type [9]: t2 is declared to have type `Tuple[typing_extensions.Literal[1]]` but is used as type `Tuple[typing_extensions.Literal[1], typing_extensions.Literal[''], typing_extensions.Literal['']]`."] -Line 153: Unexpected errors ['tuples_type_compat.py:153:0 Incompatible variable type [9]: t3 is declared to have type `Tuple[int, unknown, int]` but is used as type `Tuple[int, int]`.', 'tuples_type_compat.py:153:4 Invalid type [31]: Expression `tuple[(int, *tuple[(str, ...)], int)]` is not a valid type.'] -Line 154: Unexpected errors ["tuples_type_compat.py:154:0 Incompatible variable type [9]: t3 is declared to have type `Tuple[typing_extensions.Literal[1], typing_extensions.Literal[2]]` but is used as type `Tuple[typing_extensions.Literal[1], typing_extensions.Literal[''], typing_extensions.Literal[2]]`."] -Line 155: Unexpected errors ["tuples_type_compat.py:155:0 Incompatible variable type [9]: t3 is declared to have type `Tuple[typing_extensions.Literal[1], typing_extensions.Literal[2]]` but is used as type `Tuple[typing_extensions.Literal[1], typing_extensions.Literal[''], typing_extensions.Literal[''], typing_extensions.Literal[2]]`."] -Line 159: Unexpected errors ['tuples_type_compat.py:159:0 Incompatible variable type [9]: t4 is declared to have type `Tuple[unknown, int]` but is used as type `Tuple[int]`.', 'tuples_type_compat.py:159:4 Invalid type [31]: Expression `tuple[(*tuple[(str, ...)], int)]` is not a valid type.'] -Line 160: Unexpected errors ["tuples_type_compat.py:160:0 Incompatible variable type [9]: t4 is declared to have type `Tuple[typing_extensions.Literal[1]]` but is used as type `Tuple[typing_extensions.Literal[''], typing_extensions.Literal[1]]`."] -Line 161: Unexpected errors ["tuples_type_compat.py:161:0 Incompatible variable type [9]: t4 is declared to have type `Tuple[typing_extensions.Literal[1]]` but is used as type `Tuple[typing_extensions.Literal[''], typing_extensions.Literal[''], typing_extensions.Literal[1]]`."] -Line 167: Unexpected errors ['tuples_type_compat.py:167:4 Incompatible variable type [9]: t1 is declared to have type `Tuple[str, str, unknown]` but is used as type `Tuple[str, str]`.', 'tuples_type_compat.py:167:8 Invalid type [31]: Expression `tuple[(str, str, *tuple[(int, ...)])]` is not a valid type.'] -Line 169: Unexpected errors ['tuples_type_compat.py:169:8 Invalid type [31]: Expression `tuple[(str, *tuple[(str, ...)])]` is not a valid type.'] -Line 170: Unexpected errors ['tuples_type_compat.py:170:4 Incompatible variable type [9]: t4 is declared to have type `Tuple[str, str, unknown]` but is used as type `Tuple[str, str]`.', 'tuples_type_compat.py:170:8 Invalid type [31]: Expression `tuple[(str, str, *tuple[(str, ...)])]` is not a valid type.'] -Line 172: Unexpected errors ['tuples_type_compat.py:172:4 Incompatible variable type [9]: t6 is declared to have type `Tuple[str, unknown, str]` but is used as type `Tuple[str, str]`.', 'tuples_type_compat.py:172:8 Invalid type [31]: Expression `tuple[(str, *tuple[(int, ...)], str)]` is not a valid type.'] -Line 173: Unexpected errors ['tuples_type_compat.py:173:8 Invalid type [31]: Expression `tuple[(*tuple[(str, ...)], str)]` is not a valid type.'] -Line 174: Unexpected errors ['tuples_type_compat.py:174:8 Invalid type [31]: Expression `tuple[(*tuple[(str, ...)], str)]` is not a valid type.'] -""" diff --git a/conformance/results/pyre/tuples_type_form.toml b/conformance/results/pyre/tuples_type_form.toml deleted file mode 100644 index 18b7d89ad..000000000 --- a/conformance/results/pyre/tuples_type_form.toml +++ /dev/null @@ -1,20 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject some invalid tuple forms involving ellipsis. -""" -output = """ -tuples_type_form.py:12:0 Incompatible variable type [9]: t1 is declared to have type `Tuple[int]` but is used as type `Tuple[int, int]`. -tuples_type_form.py:14:0 Incompatible variable type [9]: t2 is declared to have type `Tuple[int, int]` but is used as type `Tuple[int]`. -tuples_type_form.py:15:0 Incompatible variable type [9]: t2 is declared to have type `Tuple[int, int]` but is used as type `Tuple[int, str]`. -tuples_type_form.py:25:0 Incompatible variable type [9]: t10 is declared to have type `Tuple[]` but is used as type `Tuple[int]`. -tuples_type_form.py:36:0 Incompatible variable type [9]: t20 is declared to have type `typing.Tuple[int, ...]` but is used as type `Tuple[int, int, int, str]`. -tuples_type_form.py:40:5 Undefined or invalid type [11]: Annotation `...` is not defined as a type. -tuples_type_form.py:44:5 Invalid type [31]: Expression `tuple[(*tuple[str], ...)]` is not a valid type. -tuples_type_form.py:45:5 Invalid type [31]: Expression `tuple[(*tuple[(str, ...)], ...)]` is not a valid type. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 41: Expected 1 errors -Line 42: Expected 1 errors -Line 43: Expected 1 errors -""" diff --git a/conformance/results/pyre/tuples_unpacked.toml b/conformance/results/pyre/tuples_unpacked.toml deleted file mode 100644 index 521b8b9a7..000000000 --- a/conformance/results/pyre/tuples_unpacked.toml +++ /dev/null @@ -1,36 +0,0 @@ -conformant = "Partial" -notes = """ -Does not understand star syntax for `Unpack`. -""" -output = """ -tuples_unpacked.py:16:13 Invalid type [31]: Expression `tuple[(int, *tuple[(bool, bool)], str)]` is not a valid type. -tuples_unpacked.py:18:19 Invalid type [31]: Expression `tuple[(*tuple[(int, bool)], bool, str)]` is not a valid type. -tuples_unpacked.py:19:19 Invalid type [31]: Expression `tuple[(int, bool, *tuple[(bool, str)])]` is not a valid type. -tuples_unpacked.py:25:13 Invalid type [31]: Expression `tuple[(int, *tuple[(bool, ...)], str)]` is not a valid type. -tuples_unpacked.py:31:4 Invalid type [31]: Expression `tuple[(*tuple[int], *tuple[int])]` is not a valid type. -tuples_unpacked.py:33:4 Invalid type [31]: Expression `tuple[(*tuple[(int, ...)], *tuple[int])]` is not a valid type. -tuples_unpacked.py:38:4 Invalid type [31]: Expression `tuple[(*tuple[str], *tuple[str])]` is not a valid type. -tuples_unpacked.py:39:4 Invalid type [31]: Expression `tuple[(*tuple[(str, *tuple[(str, ...)])])]` is not a valid type. -tuples_unpacked.py:40:4 Invalid type [31]: Expression `tuple[(*tuple[(str, ...)], *tuple[(int, ...)])]` is not a valid type. -tuples_unpacked.py:41:4 Invalid type [31]: Expression `tuple[(*tuple[(str, *tuple[(str, ...)])], *tuple[(int, ...)])]` is not a valid type. -tuples_unpacked.py:49:13 Invalid type [31]: Expression `tuple[(*$local_tuples_unpacked$Ts)]` is not a valid type. -tuples_unpacked.py:50:8 Invalid type [31]: Expression `tuple[(*tuple[str], *$local_tuples_unpacked$Ts)]` is not a valid type. -tuples_unpacked.py:51:8 Invalid type [31]: Expression `tuple[(*tuple[(str, ...)], *$local_tuples_unpacked$Ts)]` is not a valid type. -tuples_unpacked.py:59:5 Invalid type [31]: Expression `tuple[(typing.Unpack[tuple[(str, ...)]], typing.Unpack[tuple[(int, ...)]])]` is not a valid type. -tuples_unpacked.py:60:5 Invalid type [31]: Expression `tuple[(typing.Unpack[tuple[(str, typing.Unpack[tuple[(str, ...)]])]], typing.Unpack[tuple[(int, ...)]])]` is not a valid type. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 61: Expected 1 errors -Line 16: Unexpected errors ['tuples_unpacked.py:16:13 Invalid type [31]: Expression `tuple[(int, *tuple[(bool, bool)], str)]` is not a valid type.'] -Line 18: Unexpected errors ['tuples_unpacked.py:18:19 Invalid type [31]: Expression `tuple[(*tuple[(int, bool)], bool, str)]` is not a valid type.'] -Line 19: Unexpected errors ['tuples_unpacked.py:19:19 Invalid type [31]: Expression `tuple[(int, bool, *tuple[(bool, str)])]` is not a valid type.'] -Line 25: Unexpected errors ['tuples_unpacked.py:25:13 Invalid type [31]: Expression `tuple[(int, *tuple[(bool, ...)], str)]` is not a valid type.'] -Line 31: Unexpected errors ['tuples_unpacked.py:31:4 Invalid type [31]: Expression `tuple[(*tuple[int], *tuple[int])]` is not a valid type.'] -Line 33: Unexpected errors ['tuples_unpacked.py:33:4 Invalid type [31]: Expression `tuple[(*tuple[(int, ...)], *tuple[int])]` is not a valid type.'] -Line 38: Unexpected errors ['tuples_unpacked.py:38:4 Invalid type [31]: Expression `tuple[(*tuple[str], *tuple[str])]` is not a valid type.'] -Line 39: Unexpected errors ['tuples_unpacked.py:39:4 Invalid type [31]: Expression `tuple[(*tuple[(str, *tuple[(str, ...)])])]` is not a valid type.'] -Line 49: Unexpected errors ['tuples_unpacked.py:49:13 Invalid type [31]: Expression `tuple[(*$local_tuples_unpacked$Ts)]` is not a valid type.'] -Line 50: Unexpected errors ['tuples_unpacked.py:50:8 Invalid type [31]: Expression `tuple[(*tuple[str], *$local_tuples_unpacked$Ts)]` is not a valid type.'] -Line 60: Unexpected errors ['tuples_unpacked.py:60:5 Invalid type [31]: Expression `tuple[(typing.Unpack[tuple[(str, typing.Unpack[tuple[(str, ...)]])]], typing.Unpack[tuple[(int, ...)]])]` is not a valid type.'] -""" diff --git a/conformance/results/pyre/typeddicts_alt_syntax.toml b/conformance/results/pyre/typeddicts_alt_syntax.toml deleted file mode 100644 index c172f19d5..000000000 --- a/conformance/results/pyre/typeddicts_alt_syntax.toml +++ /dev/null @@ -1,18 +0,0 @@ -conformant = "Partial" -notes = """ -Does not report when name of TypedDict doesn't match assigned identifier name. -Does not support keyword-argument form of alternative syntax (deprecated in 3.11). -""" -output = """ -typeddicts_alt_syntax.py:23:16 Call error [29]: `object` is not a function. -typeddicts_alt_syntax.py:41:9 Call error [29]: `object` is not a function. -typeddicts_alt_syntax.py:43:8 Undefined or invalid type [11]: Annotation `Movie2` is not defined as a type. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 27: Expected 1 errors -Line 31: Expected 1 errors -Line 35: Expected 1 errors -Line 45: Expected 1 errors -Line 43: Unexpected errors ['typeddicts_alt_syntax.py:43:8 Undefined or invalid type [11]: Annotation `Movie2` is not defined as a type.'] -""" diff --git a/conformance/results/pyre/typeddicts_class_syntax.toml b/conformance/results/pyre/typeddicts_class_syntax.toml deleted file mode 100644 index 213091bcc..000000000 --- a/conformance/results/pyre/typeddicts_class_syntax.toml +++ /dev/null @@ -1,20 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject methods within TypedDict class. -Does not report when metaclass is provided. -Does not report when other keyword argument is provided. -Does not support generic TypedDict class. -""" -output = """ -typeddicts_class_syntax.py:57:0 Uninitialized attribute [13]: Attribute `name` is declared in class `GenericTypedDict` to have type `str` but is never initialized. -typeddicts_class_syntax.py:57:0 Uninitialized attribute [13]: Attribute `value` is declared in class `GenericTypedDict` to have type `Variable[T]` but is never initialized. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 29: Expected 1 errors -Line 33: Expected 1 errors -Line 38: Expected 1 errors -Line 44: Expected 1 errors -Line 49: Expected 1 errors -Line 57: Unexpected errors ['typeddicts_class_syntax.py:57:0 Uninitialized attribute [13]: Attribute `name` is declared in class `GenericTypedDict` to have type `str` but is never initialized.', 'typeddicts_class_syntax.py:57:0 Uninitialized attribute [13]: Attribute `value` is declared in class `GenericTypedDict` to have type `Variable[T]` but is never initialized.'] -""" diff --git a/conformance/results/pyre/typeddicts_final.toml b/conformance/results/pyre/typeddicts_final.toml deleted file mode 100644 index 499949307..000000000 --- a/conformance/results/pyre/typeddicts_final.toml +++ /dev/null @@ -1,11 +0,0 @@ -conformant = "Partial" -notes = """ -Does not handle value with literal type as index to TypedDict object. -""" -output = """ -typeddicts_final.py:26:17 Incompatible parameter type [6]: In call `TypedDictionary.__getitem__`, for 1st positional argument, expected `typing_extensions.Literal['name']` but got `Union[typing_extensions.Literal['name'], typing_extensions.Literal['year']]`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 26: Unexpected errors ["typeddicts_final.py:26:17 Incompatible parameter type [6]: In call `TypedDictionary.__getitem__`, for 1st positional argument, expected `typing_extensions.Literal['name']` but got `Union[typing_extensions.Literal['name'], typing_extensions.Literal['year']]`."] -""" diff --git a/conformance/results/pyre/typeddicts_inheritance.toml b/conformance/results/pyre/typeddicts_inheritance.toml deleted file mode 100644 index 3e91f5b67..000000000 --- a/conformance/results/pyre/typeddicts_inheritance.toml +++ /dev/null @@ -1,12 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject TypedDict class that inherits from non-TypedDict class. -""" -output = """ -typeddicts_inheritance.py:54:0 Inconsistent override [15]: `x` overrides attribute defined in `X1` inconsistently. Type `int` is not a subtype of the overridden attribute `str`. -typeddicts_inheritance.py:65:0 Invalid inheritance [39]: Field `x` has type `int` in base class `X2` and type `str` in base class `Y2`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 44: Expected 1 errors -""" diff --git a/conformance/results/pyre/typeddicts_operations.toml b/conformance/results/pyre/typeddicts_operations.toml deleted file mode 100644 index 14ebfde95..000000000 --- a/conformance/results/pyre/typeddicts_operations.toml +++ /dev/null @@ -1,21 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject `del` of required key. -""" -output = """ -typeddicts_operations.py:22:16 Invalid TypedDict operation [54]: Expected `str` to be assigned to `Movie` field `name` but got `int`. -typeddicts_operations.py:23:16 Invalid TypedDict operation [54]: Expected `int` to be assigned to `Movie` field `year` but got `str`. -typeddicts_operations.py:24:6 TypedDict accessed with a missing key [27]: TypedDict `Movie` has no key `other`. -typeddicts_operations.py:26:12 TypedDict accessed with a missing key [27]: TypedDict `Movie` has no key `other`. -typeddicts_operations.py:28:8 TypedDict initialization error [55]: Missing required field `year` for TypedDict `Movie`. -typeddicts_operations.py:29:8 TypedDict initialization error [55]: Expected type `int` for `Movie` field `year` but got `float`. -typeddicts_operations.py:32:8 TypedDict initialization error [55]: TypedDict `Movie` has no field `other`. -typeddicts_operations.py:37:4 Incompatible variable type [9]: movie is declared to have type `Movie` but is used as type `Dict[str, Union[int, str]]`. -typeddicts_operations.py:44:10 TypedDict accessed with a missing key [27]: TypedDict `Movie` has no key `other`. -typeddicts_operations.py:47:0 Undefined attribute [16]: `Movie` has no attribute `clear`. -typeddicts_operations.py:62:0 Undefined attribute [16]: `MovieOptional` has no attribute `clear`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 49: Expected 1 errors -""" diff --git a/conformance/results/pyre/typeddicts_readonly.toml b/conformance/results/pyre/typeddicts_readonly.toml deleted file mode 100644 index 70380b51f..000000000 --- a/conformance/results/pyre/typeddicts_readonly.toml +++ /dev/null @@ -1,14 +0,0 @@ -conformant = "Unsupported" -output = """ -typeddicts_readonly.py:18:13 Undefined or invalid type [11]: Annotation `ReadOnly` is not defined as a type. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 24: Expected 1 errors -Line 36: Expected 1 errors -Line 50: Expected 1 errors -Line 51: Expected 1 errors -Line 60: Expected 1 errors -Line 61: Expected 1 errors -Line 18: Unexpected errors ['typeddicts_readonly.py:18:13 Undefined or invalid type [11]: Annotation `ReadOnly` is not defined as a type.'] -""" diff --git a/conformance/results/pyre/typeddicts_readonly_consistency.toml b/conformance/results/pyre/typeddicts_readonly_consistency.toml deleted file mode 100644 index a13a44a5c..000000000 --- a/conformance/results/pyre/typeddicts_readonly_consistency.toml +++ /dev/null @@ -1,21 +0,0 @@ -conformant = "Unsupported" -output = """ -typeddicts_readonly_consistency.py:30:7 Undefined or invalid type [11]: Annotation `ReadOnly` is not defined as a type. -typeddicts_readonly_consistency.py:37:4 Incompatible variable type [9]: v3 is declared to have type `B1` but is used as type `A1`. -typeddicts_readonly_consistency.py:38:4 Incompatible variable type [9]: v4 is declared to have type `B1` but is used as type `C1`. -typeddicts_readonly_consistency.py:40:4 Incompatible variable type [9]: v5 is declared to have type `C1` but is used as type `A1`. -typeddicts_readonly_consistency.py:41:4 Incompatible variable type [9]: v6 is declared to have type `C1` but is used as type `B1`. -typeddicts_readonly_consistency.py:78:4 Incompatible variable type [9]: v1 is declared to have type `A2` but is used as type `B2`. -typeddicts_readonly_consistency.py:79:4 Incompatible variable type [9]: v2 is declared to have type `A2` but is used as type `C2`. -typeddicts_readonly_consistency.py:81:4 Incompatible variable type [9]: v3 is declared to have type `B2` but is used as type `A2`. -typeddicts_readonly_consistency.py:82:4 Incompatible variable type [9]: v4 is declared to have type `B2` but is used as type `C2`. -typeddicts_readonly_consistency.py:84:4 Incompatible variable type [9]: v5 is declared to have type `C2` but is used as type `A2`. -typeddicts_readonly_consistency.py:85:4 Incompatible variable type [9]: v6 is declared to have type `C2` but is used as type `B2`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 30: Unexpected errors ['typeddicts_readonly_consistency.py:30:7 Undefined or invalid type [11]: Annotation `ReadOnly` is not defined as a type.'] -Line 41: Unexpected errors ['typeddicts_readonly_consistency.py:41:4 Incompatible variable type [9]: v6 is declared to have type `C1` but is used as type `B1`.'] -Line 78: Unexpected errors ['typeddicts_readonly_consistency.py:78:4 Incompatible variable type [9]: v1 is declared to have type `A2` but is used as type `B2`.'] -Line 79: Unexpected errors ['typeddicts_readonly_consistency.py:79:4 Incompatible variable type [9]: v2 is declared to have type `A2` but is used as type `C2`.'] -""" diff --git a/conformance/results/pyre/typeddicts_readonly_inheritance.toml b/conformance/results/pyre/typeddicts_readonly_inheritance.toml deleted file mode 100644 index 8bcacffd1..000000000 --- a/conformance/results/pyre/typeddicts_readonly_inheritance.toml +++ /dev/null @@ -1,27 +0,0 @@ -conformant = "Unsupported" -output = """ -typeddicts_readonly_inheritance.py:15:10 Undefined or invalid type [11]: Annotation `ReadOnly` is not defined as a type. -typeddicts_readonly_inheritance.py:18:0 Inconsistent override [15]: `name` overrides attribute defined in `NamedDict` inconsistently. Type `str` is not a subtype of the overridden attribute `unknown`. -typeddicts_readonly_inheritance.py:65:18 TypedDict initialization error [55]: Missing required field `name` for TypedDict `RequiredName`. -typeddicts_readonly_inheritance.py:75:0 Inconsistent override [15]: `ident` overrides attribute defined in `OptionalIdent` inconsistently. Type `str` is not a subtype of the overridden attribute `unknown`. -typeddicts_readonly_inheritance.py:82:13 Invalid TypedDict operation [54]: Expected `str` to be assigned to `User` field `ident` but got `int`. -typeddicts_readonly_inheritance.py:83:4 TypedDict initialization error [55]: Expected type `str` for `User` field `ident` but got `int`. -typeddicts_readonly_inheritance.py:84:4 TypedDict initialization error [55]: Missing required field `ident` for TypedDict `User`. -typeddicts_readonly_inheritance.py:93:0 Inconsistent override [15]: `a` overrides attribute defined in `F1` inconsistently. Type `unknown` is not a subtype of the overridden attribute `int`. -typeddicts_readonly_inheritance.py:97:0 Inconsistent override [15]: `a` overrides attribute defined in `F1` inconsistently. Type `int` is not a subtype of the overridden attribute `int`. -typeddicts_readonly_inheritance.py:119:0 Invalid inheritance [39]: Field `x` has type `int` in base class `TD_A1` and type `float` in base class `TD_A2`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 36: Expected 1 errors -Line 50: Expected 1 errors -Line 94: Expected 1 errors -Line 98: Expected 1 errors -Line 106: Expected 1 errors -Line 132: Expected 1 errors -Line 15: Unexpected errors ['typeddicts_readonly_inheritance.py:15:10 Undefined or invalid type [11]: Annotation `ReadOnly` is not defined as a type.'] -Line 18: Unexpected errors ['typeddicts_readonly_inheritance.py:18:0 Inconsistent override [15]: `name` overrides attribute defined in `NamedDict` inconsistently. Type `str` is not a subtype of the overridden attribute `unknown`.'] -Line 75: Unexpected errors ['typeddicts_readonly_inheritance.py:75:0 Inconsistent override [15]: `ident` overrides attribute defined in `OptionalIdent` inconsistently. Type `str` is not a subtype of the overridden attribute `unknown`.'] -Line 93: Unexpected errors ['typeddicts_readonly_inheritance.py:93:0 Inconsistent override [15]: `a` overrides attribute defined in `F1` inconsistently. Type `unknown` is not a subtype of the overridden attribute `int`.'] -Line 97: Unexpected errors ['typeddicts_readonly_inheritance.py:97:0 Inconsistent override [15]: `a` overrides attribute defined in `F1` inconsistently. Type `int` is not a subtype of the overridden attribute `int`.'] -""" diff --git a/conformance/results/pyre/typeddicts_readonly_kwargs.toml b/conformance/results/pyre/typeddicts_readonly_kwargs.toml deleted file mode 100644 index 911a969a2..000000000 --- a/conformance/results/pyre/typeddicts_readonly_kwargs.toml +++ /dev/null @@ -1,11 +0,0 @@ -conformant = "Unsupported" -output = """ -typeddicts_readonly_kwargs.py:24:10 Undefined or invalid type [11]: Annotation `ReadOnly` is not defined as a type. -typeddicts_readonly_kwargs.py:29:33 Undefined or invalid type [11]: Annotation `Unpack` is not defined as a type. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 33: Expected 1 errors -Line 24: Unexpected errors ['typeddicts_readonly_kwargs.py:24:10 Undefined or invalid type [11]: Annotation `ReadOnly` is not defined as a type.'] -Line 29: Unexpected errors ['typeddicts_readonly_kwargs.py:29:33 Undefined or invalid type [11]: Annotation `Unpack` is not defined as a type.'] -""" diff --git a/conformance/results/pyre/typeddicts_readonly_update.toml b/conformance/results/pyre/typeddicts_readonly_update.toml deleted file mode 100644 index 6f271f647..000000000 --- a/conformance/results/pyre/typeddicts_readonly_update.toml +++ /dev/null @@ -1,11 +0,0 @@ -conformant = "Unsupported" -output = """ -typeddicts_readonly_update.py:17:7 Undefined or invalid type [11]: Annotation `ReadOnly` is not defined as a type. -typeddicts_readonly_update.py:34:13 Incompatible parameter type [6]: In call `TypedDictionary.update`, for 1st positional argument, expected `A` but got `B`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 23: Expected 1 errors -Line 17: Unexpected errors ['typeddicts_readonly_update.py:17:7 Undefined or invalid type [11]: Annotation `ReadOnly` is not defined as a type.'] -Line 34: Unexpected errors ['typeddicts_readonly_update.py:34:13 Incompatible parameter type [6]: In call `TypedDictionary.update`, for 1st positional argument, expected `A` but got `B`.'] -""" diff --git a/conformance/results/pyre/typeddicts_required.toml b/conformance/results/pyre/typeddicts_required.toml deleted file mode 100644 index f8d3d4cc8..000000000 --- a/conformance/results/pyre/typeddicts_required.toml +++ /dev/null @@ -1,22 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject use of `Required` in function parameter annotation. -Does not reject nested use of `Required` in type annotation. -Does not support recursive TypedDict definitions. -Incorrectly complains about uninitialized attributes on TypedDict definitions. -""" -output = """ -typeddicts_required.py:11:0 Uninitialized attribute [13]: Attribute `x` is declared in class `NotTypedDict` to have type `Required[int]` but is never initialized. -typeddicts_required.py:71:62 Undefined or invalid type [11]: Annotation `RecursiveMovie` is not defined as a type. -typeddicts_required.py:74:24 TypedDict initialization error [55]: Expected type `unknown` for `RecursiveMovie` field `predecessor` but got `typing.Dict[str, str]`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 12: Expected 1 errors -Line 16: Expected 1 errors -Line 59: Expected 1 errors -Line 60: Expected 1 errors -Line 11: Unexpected errors ['typeddicts_required.py:11:0 Uninitialized attribute [13]: Attribute `x` is declared in class `NotTypedDict` to have type `Required[int]` but is never initialized.'] -Line 71: Unexpected errors ['typeddicts_required.py:71:62 Undefined or invalid type [11]: Annotation `RecursiveMovie` is not defined as a type.'] -Line 74: Unexpected errors ['typeddicts_required.py:74:24 TypedDict initialization error [55]: Expected type `unknown` for `RecursiveMovie` field `predecessor` but got `typing.Dict[str, str]`.'] -""" diff --git a/conformance/results/pyre/typeddicts_type_consistency.toml b/conformance/results/pyre/typeddicts_type_consistency.toml deleted file mode 100644 index 124f691f9..000000000 --- a/conformance/results/pyre/typeddicts_type_consistency.toml +++ /dev/null @@ -1,24 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject assignment of TypedDict with missing key. -Does not return non-Optional value from `get` method for required key. -Does not properly handle nested TypedDicts. -""" -output = """ -typeddicts_type_consistency.py:21:0 Incompatible variable type [9]: a1 is declared to have type `A1` but is used as type `B1`. -typeddicts_type_consistency.py:38:0 Incompatible variable type [9]: a2 is declared to have type `A2` but is used as type `B2`. -typeddicts_type_consistency.py:69:11 TypedDict initialization error [55]: TypedDict `A3` has no field `y`. -typeddicts_type_consistency.py:76:0 Incompatible variable type [9]: d1 is declared to have type `Dict[str, int]` but is used as type `B3`. -typeddicts_type_consistency.py:77:0 Incompatible variable type [9]: d2 is declared to have type `Dict[str, object]` but is used as type `B3`. -typeddicts_type_consistency.py:78:0 Incompatible variable type [9]: d3 is declared to have type `Dict[typing.Any, typing.Any]` but is used as type `B3`. -typeddicts_type_consistency.py:82:0 Incompatible variable type [9]: m1 is declared to have type `Mapping[str, int]` but is used as type `B3`. -typeddicts_type_consistency.py:101:0 Incompatible variable type [9]: name3 is declared to have type `str` but is used as type `Optional[str]`. -typeddicts_type_consistency.py:107:0 Incompatible variable type [9]: age4 is declared to have type `int` but is used as type `Union[str, int]`. -typeddicts_type_consistency.py:126:41 TypedDict initialization error [55]: Expected type `str` for `Inner1` field `inner_key` but got `int`. -typeddicts_type_consistency.py:152:0 Incompatible variable type [9]: o4 is declared to have type `Outer3` but is used as type `Outer2`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 65: Expected 1 errors -Line 152: Unexpected errors ['typeddicts_type_consistency.py:152:0 Incompatible variable type [9]: o4 is declared to have type `Outer3` but is used as type `Outer2`.'] -""" diff --git a/conformance/results/pyre/typeddicts_usage.toml b/conformance/results/pyre/typeddicts_usage.toml deleted file mode 100644 index 029675407..000000000 --- a/conformance/results/pyre/typeddicts_usage.toml +++ /dev/null @@ -1,15 +0,0 @@ -conformant = "Partial" -notes = """ -Does not report errant use of TypedDict in `isinstance` call. -Does not reject use of TypedDict as TypeVar bound. -""" -output = """ -typeddicts_usage.py:23:6 TypedDict accessed with a missing key [27]: TypedDict `Movie` has no key `director`. -typeddicts_usage.py:24:16 Invalid TypedDict operation [54]: Expected `int` to be assigned to `Movie` field `year` but got `str`. -typeddicts_usage.py:28:16 TypedDict initialization error [55]: Missing required field `name` for TypedDict `Movie`. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 35: Expected 1 errors -Line 40: Expected 1 errors -""" diff --git a/conformance/results/pyre/version.toml b/conformance/results/pyre/version.toml deleted file mode 100644 index 57ed5696a..000000000 --- a/conformance/results/pyre/version.toml +++ /dev/null @@ -1,2 +0,0 @@ -version = "pyre 0.9.21" -test_duration = 3.4 diff --git a/conformance/results/pyrefly/aliases_explicit.toml b/conformance/results/pyrefly/aliases_explicit.toml new file mode 100644 index 000000000..9edd1350a --- /dev/null +++ b/conformance/results/pyrefly/aliases_explicit.toml @@ -0,0 +1,29 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR aliases_explicit.py:67:9-28: `TypeAlias[GoodTypeAlias2, type[int | None]]` is not subscriptable [unsupported-operation] +ERROR aliases_explicit.py:68:9-28: `TypeAlias[GoodTypeAlias3, type[list[int | None]]]` is not subscriptable [unsupported-operation] +ERROR aliases_explicit.py:69:9-33: Expected 1 type argument for `GoodTypeAlias4`, got 2 [bad-specialization] +ERROR aliases_explicit.py:70:9-33: Expected 1 type argument for `GoodTypeAlias8`, got 2 [bad-specialization] +ERROR aliases_explicit.py:71:9-33: Expected a valid ParamSpec expression, got `int` [invalid-param-spec] +ERROR aliases_explicit.py:79:21-61: Function call cannot be used in annotations [invalid-annotation] +ERROR aliases_explicit.py:80:21-31: List literal cannot be used in annotations [invalid-annotation] +ERROR aliases_explicit.py:81:21-34: Tuple literal cannot be used in annotations [invalid-annotation] +ERROR aliases_explicit.py:82:21-44: List comprehension cannot be used in annotations [invalid-annotation] +ERROR aliases_explicit.py:83:21-31: Dict literal cannot be used in annotations [invalid-annotation] +ERROR aliases_explicit.py:83:23-24: Could not find name `a` [unknown-name] +ERROR aliases_explicit.py:83:28-29: Could not find name `b` [unknown-name] +ERROR aliases_explicit.py:84:21-36: Function call cannot be used in annotations [invalid-annotation] +ERROR aliases_explicit.py:85:21-29: Invalid subscript expression cannot be used in annotations [invalid-annotation] +ERROR aliases_explicit.py:86:21-42: If expression cannot be used in annotations [invalid-annotation] +ERROR aliases_explicit.py:87:21-25: Expected `BadTypeAlias9` to be a type alias, got `Literal[3]` [invalid-type-alias] +ERROR aliases_explicit.py:88:22-26: Bool literal cannot be used in annotations [invalid-annotation] +ERROR aliases_explicit.py:89:22-23: Number literal cannot be used in annotations [invalid-annotation] +ERROR aliases_explicit.py:90:22-33: Boolean operation cannot be used in annotations [invalid-annotation] +ERROR aliases_explicit.py:91:22-32: F-string cannot be used in annotations [invalid-annotation] +ERROR aliases_explicit.py:100:5-19: `TypeAlias[ListAlias, type[list[Unknown]]]` is not subscriptable [unsupported-operation] +ERROR aliases_explicit.py:101:6-20: Expected a callable, got `TypeAlias[ListOrSetAlias, type[list[Unknown] | set[Unknown]]]` [not-callable] +ERROR aliases_explicit.py:102:5-24: `TypeAlias[ListOrSetAlias, type[list[Unknown] | set[Unknown]]]` is not subscriptable [unsupported-operation] +""" diff --git a/conformance/results/pyrefly/aliases_implicit.toml b/conformance/results/pyrefly/aliases_implicit.toml new file mode 100644 index 000000000..66c1e8324 --- /dev/null +++ b/conformance/results/pyrefly/aliases_implicit.toml @@ -0,0 +1,34 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR aliases_implicit.py:76:9-28: `type[int | None]` is not subscriptable [unsupported-operation] +ERROR aliases_implicit.py:77:9-28: `type[list[GoodTypeAlias2]]` is not subscriptable [unsupported-operation] +ERROR aliases_implicit.py:78:9-33: Expected 1 type argument for `GoodTypeAlias4`, got 2 [bad-specialization] +ERROR aliases_implicit.py:79:9-33: Expected 1 type argument for `GoodTypeAlias8`, got 2 [bad-specialization] +ERROR aliases_implicit.py:80:9-33: Expected a valid ParamSpec expression, got `int` [invalid-param-spec] +ERROR aliases_implicit.py:81:9-29: `str` is not assignable to upper bound `float` of type variable `TFloat` [bad-specialization] +ERROR aliases_implicit.py:106:9-22: `BadTypeAlias1` is not a valid type alias: Function call cannot be used in annotations [invalid-annotation] +ERROR aliases_implicit.py:107:9-22: Expected a type form, got instance of `list[type[int] | type[str]]` [not-a-type] +ERROR aliases_implicit.py:107:9-22: `BadTypeAlias2` is not a valid type alias: List literal cannot be used in annotations [invalid-annotation] +ERROR aliases_implicit.py:108:9-22: Expected a type form, got instance of `tuple[tuple[type[int], type[str]]]` [not-a-type] +ERROR aliases_implicit.py:108:9-22: `BadTypeAlias3` is not a valid type alias: Tuple literal cannot be used in annotations [invalid-annotation] +ERROR aliases_implicit.py:109:9-22: Expected a type form, got instance of `list[type[int]]` [not-a-type] +ERROR aliases_implicit.py:109:9-22: `BadTypeAlias4` is not a valid type alias: List comprehension cannot be used in annotations [invalid-annotation] +ERROR aliases_implicit.py:110:9-22: Expected a type form, got instance of `dict[str, str]` [not-a-type] +ERROR aliases_implicit.py:110:9-22: `BadTypeAlias5` is not a valid type alias: Dict literal cannot be used in annotations [invalid-annotation] +ERROR aliases_implicit.py:111:9-22: `BadTypeAlias6` is not a valid type alias: Function call cannot be used in annotations [invalid-annotation] +ERROR aliases_implicit.py:112:9-22: `BadTypeAlias7` is not a valid type alias: Invalid subscript expression cannot be used in annotations [invalid-annotation] +ERROR aliases_implicit.py:113:9-22: `BadTypeAlias8` is not a valid type alias: If expression cannot be used in annotations [invalid-annotation] +ERROR aliases_implicit.py:114:9-22: Expected a type form, got instance of `Literal[3]` [not-a-type] +ERROR aliases_implicit.py:115:10-24: Expected a type form, got instance of `Literal[True]` [not-a-type] +ERROR aliases_implicit.py:115:10-24: `BadTypeAlias10` is not a valid type alias: Bool literal cannot be used in annotations [invalid-annotation] +ERROR aliases_implicit.py:116:10-24: Expected a type form, got instance of `Literal[1]` [not-a-type] +ERROR aliases_implicit.py:116:10-24: `BadTypeAlias11` is not a valid type alias: Number literal cannot be used in annotations [invalid-annotation] +ERROR aliases_implicit.py:117:10-24: `BadTypeAlias12` is not a valid type alias: Boolean operation cannot be used in annotations [invalid-annotation] +ERROR aliases_implicit.py:118:10-24: Expected a type form, got instance of `Literal['int']` [not-a-type] +ERROR aliases_implicit.py:118:10-24: `BadTypeAlias13` is not a valid type alias: F-string cannot be used in annotations [invalid-annotation] +ERROR aliases_implicit.py:119:10-24: Expected a type form, got instance of `Literal['int | str']` [not-a-type] +ERROR aliases_implicit.py:133:6-20: Expected a callable, got `type[list[Unknown] | set[Unknown]]` [not-callable] +ERROR aliases_implicit.py:135:5-24: `type[list[Unknown] | set[Unknown]]` is not subscriptable [unsupported-operation] +""" diff --git a/conformance/results/pyrefly/aliases_newtype.toml b/conformance/results/pyrefly/aliases_newtype.toml new file mode 100644 index 000000000..27291ca76 --- /dev/null +++ b/conformance/results/pyrefly/aliases_newtype.toml @@ -0,0 +1,20 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR aliases_newtype.py:11:8-14: Argument `Literal['user']` is not assignable to parameter `_x` with type `int` in function `UserId.__new__` [bad-argument-type] +ERROR aliases_newtype.py:12:14-16: `Literal[42]` is not assignable to `UserId` [bad-assignment] +ERROR aliases_newtype.py:18:11-17: `type[UserId]` is not assignable to `type[Any]` [bad-assignment] +ERROR aliases_newtype.py:23:16-22: NewType `UserId` not allowed in isinstance() [invalid-argument] +ERROR aliases_newtype.py:26:21-27: Subclassing a NewType not allowed [invalid-inheritance] +ERROR aliases_newtype.py:35:20-29: Expected string literal "GoodName" [invalid-argument] +ERROR aliases_newtype.py:41:6-23: Expected 0 type arguments for `GoodNewType1`, got 1 [bad-specialization] +ERROR aliases_newtype.py:47:38-47: Second argument to NewType is invalid [invalid-argument] +ERROR aliases_newtype.py:50:38-45: Second argument to NewType cannot be an unbound generic [invalid-argument] +ERROR aliases_newtype.py:52:38-46: Second argument to NewType cannot be a protocol [invalid-argument] +ERROR aliases_newtype.py:54:38-48: Second argument to NewType is invalid [invalid-argument] +ERROR aliases_newtype.py:61:38-41: Second argument to NewType is invalid [invalid-argument] +ERROR aliases_newtype.py:63:43-46: Expected 2 positional arguments, got 3 in function `typing.NewType.__init__` [bad-argument-count] +ERROR aliases_newtype.py:65:38-41: Second argument to NewType is invalid [invalid-argument] +""" diff --git a/conformance/results/pyrefly/aliases_recursive.toml b/conformance/results/pyrefly/aliases_recursive.toml new file mode 100644 index 000000000..0cbfc4e60 --- /dev/null +++ b/conformance/results/pyrefly/aliases_recursive.toml @@ -0,0 +1,18 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR aliases_recursive.py:19:26-28: `complex` is not assignable to dict value type `Json` [bad-assignment] +ERROR aliases_recursive.py:20:12-19: `list[complex | int]` is not assignable to `dict[str, Json] | float | int | list[Json] | str | None` [bad-assignment] +ERROR aliases_recursive.py:38:22-50: `tuple[Literal[1], tuple[Literal['1'], Literal[1]], tuple[Literal[1], tuple[Literal[1], list[int]]]]` is not assignable to `int | str | tuple[RecursiveTuple, ...]` [bad-assignment] +ERROR aliases_recursive.py:39:22-30: `tuple[Literal[1], list[int]]` is not assignable to `int | str | tuple[RecursiveTuple, ...]` [bad-assignment] +ERROR aliases_recursive.py:50:30-33: `list[int]` is not assignable to dict value type `RecursiveMapping` [bad-assignment] +ERROR aliases_recursive.py:51:48-54: `list[int]` is not assignable to dict value type `RecursiveMapping` [bad-assignment] +ERROR aliases_recursive.py:52:72-81: `list[int]` is not assignable to dict value type `RecursiveMapping` [bad-assignment] +ERROR aliases_recursive.py:63:30-43: `list[list[float] | str]` is not assignable to `list[str | GenericTypeAlias1[str]]` [bad-assignment] +ERROR aliases_recursive.py:69:35-64: `list[list[int | list[int | list[float] | str]] | str]` is not assignable to `list[int | str | GenericTypeAlias2[str, int]]` [bad-assignment] +ERROR aliases_recursive.py:72:29-57: Found cyclic self-reference in `RecursiveUnion` [invalid-type-alias] +ERROR aliases_recursive.py:75:31-61: Found cyclic self-reference in `MutualReference1` [invalid-type-alias] +ERROR aliases_recursive.py:75:93-123: Found cyclic self-reference in `MutualReference2` [invalid-type-alias] +""" diff --git a/conformance/results/pyrefly/aliases_type_statement.toml b/conformance/results/pyrefly/aliases_type_statement.toml new file mode 100644 index 000000000..2feb71761 --- /dev/null +++ b/conformance/results/pyrefly/aliases_type_statement.toml @@ -0,0 +1,34 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR aliases_type_statement.py:17:1-21: Object of class `TypeAliasType` has no attribute `bit_count` [missing-attribute] +ERROR aliases_type_statement.py:19:1-11: Expected a callable, got `TypeAlias[GoodAlias1, type[int]]` [not-callable] +ERROR aliases_type_statement.py:23:7-30: Object of class `TypeAliasType` has no attribute `other_attrib` [missing-attribute] +ERROR aliases_type_statement.py:26:18-28: Cannot use scoped type alias `GoodAlias1` as a base class. Use a legacy type alias instead: `GoodAlias1: TypeAlias = type[int]` [invalid-inheritance] +ERROR aliases_type_statement.py:31:22-32: Expected class object, got `TypeAliasType` [invalid-argument] +ERROR aliases_type_statement.py:37:22-62: Function call cannot be used in annotations [invalid-annotation] +ERROR aliases_type_statement.py:38:22-32: List literal cannot be used in annotations [invalid-annotation] +ERROR aliases_type_statement.py:39:22-35: Tuple literal cannot be used in annotations [invalid-annotation] +ERROR aliases_type_statement.py:40:22-45: List comprehension cannot be used in annotations [invalid-annotation] +ERROR aliases_type_statement.py:41:22-32: Dict literal cannot be used in annotations [invalid-annotation] +ERROR aliases_type_statement.py:41:24-25: Could not find name `a` [unknown-name] +ERROR aliases_type_statement.py:41:29-30: Could not find name `b` [unknown-name] +ERROR aliases_type_statement.py:42:22-37: Function call cannot be used in annotations [invalid-annotation] +ERROR aliases_type_statement.py:43:22-30: Invalid subscript expression cannot be used in annotations [invalid-annotation] +ERROR aliases_type_statement.py:44:22-43: If expression cannot be used in annotations [invalid-annotation] +ERROR aliases_type_statement.py:45:22-26: Expected `BadTypeAlias9` to be a type alias, got `Literal[1]` [invalid-type-alias] +ERROR aliases_type_statement.py:46:23-27: Bool literal cannot be used in annotations [invalid-annotation] +ERROR aliases_type_statement.py:47:23-24: Number literal cannot be used in annotations [invalid-annotation] +ERROR aliases_type_statement.py:48:23-34: Boolean operation cannot be used in annotations [invalid-annotation] +ERROR aliases_type_statement.py:49:23-33: F-string cannot be used in annotations [invalid-annotation] +ERROR aliases_type_statement.py:53:15-25: Type parameters used in `TA1` but not declared [invalid-type-var] +ERROR aliases_type_statement.py:58:12-20: Type parameters used in `TA2` but not declared [invalid-type-var] +ERROR aliases_type_statement.py:68:7-41: `str` is not assignable to upper bound `int` of type variable `S` [bad-specialization] +ERROR aliases_type_statement.py:70:7-41: `int` is not assignable to upper bound `str` of type variable `T` [bad-specialization] +ERROR aliases_type_statement.py:73:28-47: Found cyclic self-reference in `RecursiveTypeAlias3` [invalid-type-alias] +ERROR aliases_type_statement.py:75:31-59: Found cyclic self-reference in `RecursiveTypeAlias4` [invalid-type-alias] +ERROR aliases_type_statement.py:79:28-47: Found cyclic self-reference in `RecursiveTypeAlias6` [invalid-type-alias] +ERROR aliases_type_statement.py:80:28-47: Found cyclic self-reference in `RecursiveTypeAlias7` [invalid-type-alias] +""" diff --git a/conformance/results/pyrefly/aliases_typealiastype.toml b/conformance/results/pyrefly/aliases_typealiastype.toml new file mode 100644 index 000000000..d6ec8ac8e --- /dev/null +++ b/conformance/results/pyrefly/aliases_typealiastype.toml @@ -0,0 +1,31 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR aliases_typealiastype.py:32:7-30: Object of class `TypeAliasType` has no attribute `other_attrib` [missing-attribute] +ERROR aliases_typealiastype.py:40:5-30: `int` is not assignable to upper bound `str` of type variable `TStr` [bad-specialization] +ERROR aliases_typealiastype.py:43:13-66: Type variable `S` is out of scope for this `TypeAliasType` [invalid-type-alias] +ERROR aliases_typealiastype.py:44:13-48: Type variable `S` is out of scope for this `TypeAliasType` [invalid-type-alias] +ERROR aliases_typealiastype.py:45:45-65: Value for argument `type_params` must be a tuple literal [invalid-type-alias] +ERROR aliases_typealiastype.py:46:13-52: Found cyclic self-reference in `BadAlias4` [invalid-type-alias] +ERROR aliases_typealiastype.py:47:13-79: Found cyclic self-reference in `BadAlias5` [invalid-type-alias] +ERROR aliases_typealiastype.py:48:13-52: Found cyclic self-reference in `BadAlias6` [invalid-type-alias] +ERROR aliases_typealiastype.py:49:13-50: Found cyclic self-reference in `BadAlias7` [invalid-type-alias] +ERROR aliases_typealiastype.py:52:40-80: Function call cannot be used in annotations [invalid-annotation] +ERROR aliases_typealiastype.py:53:40-50: List literal cannot be used in annotations [invalid-annotation] +ERROR aliases_typealiastype.py:54:42-55: Tuple literal cannot be used in annotations [invalid-annotation] +ERROR aliases_typealiastype.py:55:42-65: List comprehension cannot be used in annotations [invalid-annotation] +ERROR aliases_typealiastype.py:56:42-52: Dict literal cannot be used in annotations [invalid-annotation] +ERROR aliases_typealiastype.py:56:44-45: Could not find name `a` [unknown-name] +ERROR aliases_typealiastype.py:56:49-50: Could not find name `b` [unknown-name] +ERROR aliases_typealiastype.py:57:42-57: Function call cannot be used in annotations [invalid-annotation] +ERROR aliases_typealiastype.py:58:42-50: Invalid subscript expression cannot be used in annotations [invalid-annotation] +ERROR aliases_typealiastype.py:59:42-63: If expression cannot be used in annotations [invalid-annotation] +ERROR aliases_typealiastype.py:60:42-46: Expected `BadAlias16` to be a type alias, got `Literal[3]` [invalid-type-alias] +ERROR aliases_typealiastype.py:61:42-46: Bool literal cannot be used in annotations [invalid-annotation] +ERROR aliases_typealiastype.py:62:42-43: Number literal cannot be used in annotations [invalid-annotation] +ERROR aliases_typealiastype.py:63:42-53: Boolean operation cannot be used in annotations [invalid-annotation] +ERROR aliases_typealiastype.py:64:42-52: F-string cannot be used in annotations [invalid-annotation] +ERROR aliases_typealiastype.py:66:14-59: Found cyclic self-reference in `BadAlias21` [invalid-type-alias] +""" diff --git a/conformance/results/pyrefly/aliases_variance.toml b/conformance/results/pyrefly/aliases_variance.toml new file mode 100644 index 000000000..7cfcd6ebc --- /dev/null +++ b/conformance/results/pyrefly/aliases_variance.toml @@ -0,0 +1,10 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR aliases_variance.py:24:16-28: Type variable `T_co` is covariant but is used in invariant position [invalid-variance] +ERROR aliases_variance.py:28:16-31: Type variable `T_co` is covariant but is used in invariant position [invalid-variance] +ERROR aliases_variance.py:32:16-31: Type variable `T_co` is covariant but is used in invariant position [invalid-variance] +ERROR aliases_variance.py:44:16-41: Type variable `T_contra` is contravariant but is used in invariant position [invalid-variance] +""" diff --git a/conformance/results/pyrefly/annotations_coroutines.toml b/conformance/results/pyrefly/annotations_coroutines.toml new file mode 100644 index 000000000..be211bd5b --- /dev/null +++ b/conformance/results/pyrefly/annotations_coroutines.toml @@ -0,0 +1,6 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pyrefly/annotations_forward_refs.toml b/conformance/results/pyrefly/annotations_forward_refs.toml new file mode 100644 index 000000000..bf7260c92 --- /dev/null +++ b/conformance/results/pyrefly/annotations_forward_refs.toml @@ -0,0 +1,36 @@ +conformant = "Partial" +notes = """ +Resolves forward references in type annotations in classes at the point of definition instead of end-of-scope +Fails to resolve a forward reference to a nested class +""" +conformance_automated = "Fail" +errors_diff = """ +Line 94: Expected 1 errors +Line 96: Expected 1 errors +""" +output = """ +ERROR annotations_forward_refs.py:23:12-18: `ClassA` is uninitialized [unbound-name] +ERROR annotations_forward_refs.py:24:7-21: `|` union syntax does not work with string literals [invalid-annotation] +ERROR annotations_forward_refs.py:25:7-21: `|` union syntax does not work with string literals [invalid-annotation] +ERROR annotations_forward_refs.py:41:10-50: Function call cannot be used in annotations [invalid-annotation] +ERROR annotations_forward_refs.py:42:10-20: List literal cannot be used in annotations [invalid-annotation] +ERROR annotations_forward_refs.py:43:10-20: Tuple literal cannot be used in annotations [invalid-annotation] +ERROR annotations_forward_refs.py:44:10-33: List comprehension cannot be used in annotations [invalid-annotation] +ERROR annotations_forward_refs.py:45:10-12: Dict literal cannot be used in annotations [invalid-annotation] +ERROR annotations_forward_refs.py:46:10-26: Function call cannot be used in annotations [invalid-annotation] +ERROR annotations_forward_refs.py:47:10-18: Invalid subscript expression cannot be used in annotations [invalid-annotation] +ERROR annotations_forward_refs.py:48:10-31: If expression cannot be used in annotations [invalid-annotation] +ERROR annotations_forward_refs.py:49:10-14: Expected a type form, got instance of `Literal[1]` [not-a-type] +ERROR annotations_forward_refs.py:49:10-14: `var1` is not a valid type alias: Number literal cannot be used in annotations [invalid-annotation] +ERROR annotations_forward_refs.py:50:11-15: Bool literal cannot be used in annotations [invalid-annotation] +ERROR annotations_forward_refs.py:51:11-12: Number literal cannot be used in annotations [invalid-annotation] +ERROR annotations_forward_refs.py:52:11-13: Unary operation cannot be used in annotations [invalid-annotation] +ERROR annotations_forward_refs.py:53:11-21: Boolean operation cannot be used in annotations [invalid-annotation] +ERROR annotations_forward_refs.py:54:11-17: F-string cannot be used in annotations [invalid-annotation] +ERROR annotations_forward_refs.py:55:11-16: Expected a type form, got instance of `Module[types]` [not-a-type] +ERROR annotations_forward_refs.py:83:13-23: Could not find name `ClassInner` [unknown-name] +ERROR annotations_forward_refs.py:92:14-20: Could not find name `ClassF` [unknown-name] +ERROR annotations_forward_refs.py:101:8-11: Expected a type form, got instance of `(self: Self@ClassD) -> None` [not-a-type] +ERROR annotations_forward_refs.py:103:9-12: Expected a type form, got instance of `(self: Self@ClassD) -> None` [not-a-type] +ERROR annotations_forward_refs.py:111:16-45: assert_type(Unknown, ClassD.ClassInner) failed [assert-type] +""" diff --git a/conformance/results/pyrefly/annotations_future_import.toml b/conformance/results/pyrefly/annotations_future_import.toml new file mode 100644 index 000000000..f0ba60aec --- /dev/null +++ b/conformance/results/pyrefly/annotations_future_import.toml @@ -0,0 +1,14 @@ +conformant = "Partial" +notes = """ +Forward references to nested classes are not resolved +Resolves forward references in type annotations in classes at the point of definition instead of end-of-scope +""" +conformance_automated = "Fail" +errors_diff = """ +Line 37: Expected 1 errors +Line 39: Expected 1 errors +""" +output = """ +ERROR annotations_future_import.py:44:8-11: Expected a type form, got instance of `(self: Self@ClassB) -> None` [not-a-type] +ERROR annotations_future_import.py:46:9-12: Expected a type form, got instance of `(self: Self@ClassB) -> None` [not-a-type] +""" diff --git a/conformance/results/pyrefly/annotations_generators.toml b/conformance/results/pyrefly/annotations_generators.toml new file mode 100644 index 000000000..744cf383f --- /dev/null +++ b/conformance/results/pyrefly/annotations_generators.toml @@ -0,0 +1,16 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR annotations_generators.py:51:21-39: Function declared to return `C`, but one or more paths are missing an explicit `return` [bad-return] +ERROR annotations_generators.py:54:16-21: Returned type `Literal[False]` is not assignable to declared return type `C` [bad-return] +ERROR annotations_generators.py:57:15-16: Yielded type `Literal[3]` is not assignable to declared yield type `A` [invalid-yield] +ERROR annotations_generators.py:66:15-16: Yielded type `Literal[3]` is not assignable to declared yield type `A` [invalid-yield] +ERROR annotations_generators.py:75:11-14: Yielded type `B` is not assignable to declared yield type `A` [invalid-yield] +ERROR annotations_generators.py:86:21-24: Generator function should return `Generator` [bad-return] +ERROR annotations_generators.py:91:27-30: Async generator function should return `AsyncGenerator` [bad-return] +ERROR annotations_generators.py:118:5-29: Cannot yield from `Generator[A]`, which is not assignable to declared return type `Generator[B, None, Unknown]` [invalid-yield] +ERROR annotations_generators.py:119:5-19: Cannot yield from `Generator[int]`, which is not assignable to declared return type `Generator[B, None, Unknown]` [invalid-yield] +ERROR annotations_generators.py:135:5-29: Cannot yield from `Generator[None, int]`, which is not assignable to declared return type `Generator[None, str, Unknown]` [invalid-yield] +""" diff --git a/conformance/results/pyrefly/annotations_methods.toml b/conformance/results/pyrefly/annotations_methods.toml new file mode 100644 index 000000000..06e3f82f9 --- /dev/null +++ b/conformance/results/pyrefly/annotations_methods.toml @@ -0,0 +1,7 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR annotations_methods.py:42:12-28: assert_type(B, A) failed [assert-type] +""" diff --git a/conformance/results/pyrefly/annotations_typeexpr.toml b/conformance/results/pyrefly/annotations_typeexpr.toml new file mode 100644 index 000000000..47a5ef99e --- /dev/null +++ b/conformance/results/pyrefly/annotations_typeexpr.toml @@ -0,0 +1,22 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR annotations_typeexpr.py:88:9-49: Function call cannot be used in annotations [invalid-annotation] +ERROR annotations_typeexpr.py:89:9-19: List literal cannot be used in annotations [invalid-annotation] +ERROR annotations_typeexpr.py:90:9-19: Tuple literal cannot be used in annotations [invalid-annotation] +ERROR annotations_typeexpr.py:91:9-32: List comprehension cannot be used in annotations [invalid-annotation] +ERROR annotations_typeexpr.py:92:9-11: Dict literal cannot be used in annotations [invalid-annotation] +ERROR annotations_typeexpr.py:93:9-24: Function call cannot be used in annotations [invalid-annotation] +ERROR annotations_typeexpr.py:94:9-17: Invalid subscript expression cannot be used in annotations [invalid-annotation] +ERROR annotations_typeexpr.py:95:9-30: If expression cannot be used in annotations [invalid-annotation] +ERROR annotations_typeexpr.py:96:9-13: Expected a type form, got instance of `Literal[3]` [not-a-type] +ERROR annotations_typeexpr.py:96:9-13: `var1` is not a valid type alias: Number literal cannot be used in annotations [invalid-annotation] +ERROR annotations_typeexpr.py:97:10-14: Bool literal cannot be used in annotations [invalid-annotation] +ERROR annotations_typeexpr.py:98:10-11: Number literal cannot be used in annotations [invalid-annotation] +ERROR annotations_typeexpr.py:99:10-12: Unary operation cannot be used in annotations [invalid-annotation] +ERROR annotations_typeexpr.py:100:10-20: Boolean operation cannot be used in annotations [invalid-annotation] +ERROR annotations_typeexpr.py:101:10-16: F-string cannot be used in annotations [invalid-annotation] +ERROR annotations_typeexpr.py:102:10-15: Expected a type form, got instance of `Module[types]` [not-a-type] +""" diff --git a/conformance/results/pyrefly/callables_annotation.toml b/conformance/results/pyrefly/callables_annotation.toml new file mode 100644 index 000000000..dd27d4f3e --- /dev/null +++ b/conformance/results/pyrefly/callables_annotation.toml @@ -0,0 +1,24 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR callables_annotation.py:25:7-10: Expected 1 more positional argument [bad-argument-count] +ERROR callables_annotation.py:26:11-12: Argument `Literal[2]` is not assignable to parameter with type `str` [bad-argument-type] +ERROR callables_annotation.py:27:15-16: Expected 2 positional arguments, got 3 [bad-argument-count] +ERROR callables_annotation.py:29:8-9: Unexpected keyword argument `a` [unexpected-keyword] +ERROR callables_annotation.py:29:8-11: Expected 2 more positional arguments [bad-argument-count] +ERROR callables_annotation.py:29:13-14: Unexpected keyword argument `b` [unexpected-keyword] +ERROR callables_annotation.py:35:8-9: Expected 0 positional arguments, got 1 [bad-argument-count] +ERROR callables_annotation.py:55:5-18: Expected 2 arguments for `Callable`, got 1 [bad-specialization] +ERROR callables_annotation.py:56:14-17: Callable types can only have `ParamSpec` in this position, got `int` [bad-specialization] +ERROR callables_annotation.py:57:18-23: Expected a type form, got instance of `list[type[int]]` [not-a-type] +ERROR callables_annotation.py:58:5-28: Expected 2 arguments for `Callable`, got 3 [bad-specialization] +ERROR callables_annotation.py:59:15-18: Invalid position for `...` [invalid-argument] +ERROR callables_annotation.py:91:7-15: `() -> str` is not assignable to variable `cb3` with type `(int, ...) -> str` [bad-assignment] +ERROR callables_annotation.py:93:7-15: `(*, a: int) -> str` is not assignable to variable `cb3` with type `(int, ...) -> str` [bad-assignment] +ERROR callables_annotation.py:159:25-27: `Proto8` is not assignable to `Proto5[Any]` [bad-assignment] +ERROR callables_annotation.py:172:26-29: `() -> str` is not assignable to `(int, ...) -> str` [bad-assignment] +ERROR callables_annotation.py:187:48-50: `(int, str) -> str` is not assignable to `(str, ...) -> str` [bad-assignment] +ERROR callables_annotation.py:189:32-34: `(int, str) -> str` is not assignable to `(str, ...) -> str` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/callables_kwargs.toml b/conformance/results/pyrefly/callables_kwargs.toml new file mode 100644 index 000000000..d37554ce3 --- /dev/null +++ b/conformance/results/pyrefly/callables_kwargs.toml @@ -0,0 +1,23 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR callables_kwargs.py:46:10-12: Missing argument `v1` in function `func1` [missing-argument] +ERROR callables_kwargs.py:46:10-12: Missing argument `v3` in function `func1` [missing-argument] +ERROR callables_kwargs.py:51:32-34: Unexpected keyword argument `v4` in function `func1` [unexpected-keyword] +ERROR callables_kwargs.py:52:11-12: Expected argument `v1` to be passed by name in function `func1` [unexpected-positional-argument] +ERROR callables_kwargs.py:52:11-12: Expected 0 positional arguments, got 3 in function `func1` [bad-argument-count] +ERROR callables_kwargs.py:52:14-16: Expected argument `v3` to be passed by name in function `func1` [unexpected-positional-argument] +ERROR callables_kwargs.py:58:11-20: Unpacked keyword argument `str` is not assignable to parameter `v1` with type `int` in function `func1` [bad-argument-type] +ERROR callables_kwargs.py:63:17-22: Multiple values for argument `v1` in function `func1` [bad-keyword-argument] +ERROR callables_kwargs.py:64:11-12: Argument `Literal[1]` is not assignable to parameter `v3` with type `str` in function `func2` [bad-argument-type] +ERROR callables_kwargs.py:64:14-19: Multiple values for argument `v3` in function `func2` [bad-keyword-argument] +ERROR callables_kwargs.py:65:17-22: Multiple values for argument `v1` in function `func2` [bad-keyword-argument] +ERROR callables_kwargs.py:101:19-24: `(**kwargs: Unpack[TD2]) -> None` is not assignable to `TDProtocol3` [bad-assignment] +ERROR callables_kwargs.py:102:19-24: `(**kwargs: Unpack[TD2]) -> None` is not assignable to `TDProtocol4` [bad-assignment] +ERROR callables_kwargs.py:103:19-24: `(**kwargs: Unpack[TD2]) -> None` is not assignable to `TDProtocol5` [bad-assignment] +ERROR callables_kwargs.py:111:20-41: TypedDict key 'v1' in **kwargs overlaps with parameter 'v1' [bad-function-definition] +ERROR callables_kwargs.py:122:21-30: `Unpack` in **kwargs annotation must be used only with a `TypedDict` [invalid-annotation] +ERROR callables_kwargs.py:134:19-24: `(*, v1: int, v3: str, v2: str = '') -> None` is not assignable to `TDProtocol6` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/callables_protocol.toml b/conformance/results/pyrefly/callables_protocol.toml new file mode 100644 index 000000000..3bdc990b0 --- /dev/null +++ b/conformance/results/pyrefly/callables_protocol.toml @@ -0,0 +1,23 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR callables_protocol.py:35:7-15: `(*vals: bytes, *, max_items: int | None) -> list[bytes]` is not assignable to variable `cb1` with type `Proto1` [bad-assignment] +ERROR callables_protocol.py:36:7-15: `(*vals: bytes) -> list[bytes]` is not assignable to variable `cb1` with type `Proto1` [bad-assignment] +ERROR callables_protocol.py:37:7-15: `(*vals: bytes, *, max_len: str | None) -> list[bytes]` is not assignable to variable `cb1` with type `Proto1` [bad-assignment] +ERROR callables_protocol.py:67:7-15: `(*a: bytes) -> None` is not assignable to variable `cb2` with type `Proto2` [bad-assignment] +ERROR callables_protocol.py:68:7-15: `(*a: str, **b: str) -> None` is not assignable to variable `cb2` with type `Proto2` [bad-assignment] +ERROR callables_protocol.py:69:7-15: `(*a: bytes, **b: bytes) -> None` is not assignable to variable `cb2` with type `Proto2` [bad-assignment] +ERROR callables_protocol.py:70:7-15: `(**b: str) -> None` is not assignable to variable `cb2` with type `Proto2` [bad-assignment] +ERROR callables_protocol.py:97:16-24: `(x: int) -> None` is not assignable to `Proto4` [bad-assignment] +ERROR callables_protocol.py:121:18-26: `(*vals: bytes, *, max_len: int | None = None) -> list[bytes]` is not assignable to `NotProto6` [bad-assignment] +ERROR callables_protocol.py:169:7-15: `(x: int) -> Any` is not assignable to variable `cb8` with type `Proto8` [bad-assignment] +ERROR callables_protocol.py:186:33-38: `Literal['str']` is not assignable to attribute `other_attribute` with type `int` [bad-assignment] +ERROR callables_protocol.py:187:5-18: Object of class `Proto9` has no attribute `xxx` [missing-attribute] +ERROR callables_protocol.py:197:7-32: Object of class `Proto9` has no attribute `other_attribute2` [missing-attribute] +ERROR callables_protocol.py:238:8-17: `(x: int, y: str, /) -> Any` is not assignable to variable `cb11` with type `Proto11` [bad-assignment] +ERROR callables_protocol.py:260:8-17: `(*args: Any, *, kwarg0: Any) -> None` is not assignable to variable `cb12` with type `Proto12` [bad-assignment] +ERROR callables_protocol.py:284:27-42: `(path: str) -> str` is not assignable to `Proto13_Default` [bad-assignment] +ERROR callables_protocol.py:311:27-42: `(*, path: str) -> str` is not assignable to `Proto14_Default` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/callables_subtyping.toml b/conformance/results/pyrefly/callables_subtyping.toml new file mode 100644 index 000000000..3a332c8c8 --- /dev/null +++ b/conformance/results/pyrefly/callables_subtyping.toml @@ -0,0 +1,38 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR callables_subtyping.py:26:36-39: `(int) -> int` is not assignable to `(float) -> float` [bad-assignment] +ERROR callables_subtyping.py:29:32-35: `(float) -> float` is not assignable to `(int) -> int` [bad-assignment] +ERROR callables_subtyping.py:51:21-29: `PosOnly2` is not assignable to `Standard2` [bad-assignment] +ERROR callables_subtyping.py:52:21-28: `KwOnly2` is not assignable to `Standard2` [bad-assignment] +ERROR callables_subtyping.py:55:20-27: `KwOnly2` is not assignable to `PosOnly2` [bad-assignment] +ERROR callables_subtyping.py:58:19-27: `PosOnly2` is not assignable to `KwOnly2` [bad-assignment] +ERROR callables_subtyping.py:82:20-27: `NoArgs3` is not assignable to `IntArgs3` [bad-assignment] +ERROR callables_subtyping.py:85:22-29: `NoArgs3` is not assignable to `FloatArgs3` [bad-assignment] +ERROR callables_subtyping.py:86:22-30: `IntArgs3` is not assignable to `FloatArgs3` [bad-assignment] +ERROR callables_subtyping.py:116:20-28: `IntArgs4` is not assignable to `PosOnly4` [bad-assignment] +ERROR callables_subtyping.py:119:23-31: `StrArgs4` is not assignable to `IntStrArgs4` [bad-assignment] +ERROR callables_subtyping.py:120:23-31: `IntArgs4` is not assignable to `IntStrArgs4` [bad-assignment] +ERROR callables_subtyping.py:122:20-28: `IntArgs4` is not assignable to `StrArgs4` [bad-assignment] +ERROR callables_subtyping.py:124:20-28: `StrArgs4` is not assignable to `IntArgs4` [bad-assignment] +ERROR callables_subtyping.py:125:22-34: `IntStrArgs4` is not assignable to `Standard4` [bad-assignment] +ERROR callables_subtyping.py:126:22-30: `StrArgs4` is not assignable to `Standard4` [bad-assignment] +ERROR callables_subtyping.py:151:22-31: `NoKwargs5` is not assignable to `IntKwargs5` [bad-assignment] +ERROR callables_subtyping.py:154:24-33: `NoKwargs5` is not assignable to `FloatKwargs5` [bad-assignment] +ERROR callables_subtyping.py:155:24-34: `IntKwargs5` is not assignable to `FloatKwargs5` [bad-assignment] +ERROR callables_subtyping.py:187:19-29: `IntKwargs6` is not assignable to `KwOnly6` [bad-assignment] +ERROR callables_subtyping.py:190:25-35: `StrKwargs6` is not assignable to `IntStrKwargs6` [bad-assignment] +ERROR callables_subtyping.py:191:25-35: `IntKwargs6` is not assignable to `IntStrKwargs6` [bad-assignment] +ERROR callables_subtyping.py:193:22-32: `IntKwargs6` is not assignable to `StrKwargs6` [bad-assignment] +ERROR callables_subtyping.py:195:22-32: `StrKwargs6` is not assignable to `IntKwargs6` [bad-assignment] +ERROR callables_subtyping.py:196:22-36: `IntStrKwargs6` is not assignable to `Standard6` [bad-assignment] +ERROR callables_subtyping.py:197:22-32: `StrKwargs6` is not assignable to `Standard6` [bad-assignment] +ERROR callables_subtyping.py:236:23-37: `NoDefaultArg8` is not assignable to `DefaultArg8` [bad-assignment] +ERROR callables_subtyping.py:237:23-27: `NoX8` is not assignable to `DefaultArg8` [bad-assignment] +ERROR callables_subtyping.py:240:25-29: `NoX8` is not assignable to `NoDefaultArg8` [bad-assignment] +ERROR callables_subtyping.py:243:16-30: `NoDefaultArg8` is not assignable to `NoX8` [bad-assignment] +ERROR callables_subtyping.py:273:21-31: `Overloaded9` is not assignable to `FloatArg9` [bad-assignment] +ERROR callables_subtyping.py:297:24-31: `StrArg10` is not assignable to `Overloaded10` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/classes_classvar.toml b/conformance/results/pyrefly/classes_classvar.toml new file mode 100644 index 000000000..92c5a5257 --- /dev/null +++ b/conformance/results/pyrefly/classes_classvar.toml @@ -0,0 +1,29 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR classes_classvar.py:40:11-29: Expected 1 type argument for `ClassVar`, got 2 [invalid-annotation] +ERROR classes_classvar.py:41:14-15: Number literal cannot be used in annotations [invalid-annotation] +ERROR classes_classvar.py:42:14-17: Could not find name `var` [unknown-name] +ERROR classes_classvar.py:47:20-21: `ClassVar` arguments may not contain any type variables [invalid-annotation] +ERROR classes_classvar.py:48:20-27: `ClassVar` arguments may not contain any type variables [invalid-annotation] +ERROR classes_classvar.py:49:20-36: `ClassVar` arguments may not contain any type variables [invalid-annotation] +ERROR classes_classvar.py:54:33-35: `dict[@_, @_]` is not assignable to `list[str]` [bad-assignment] +ERROR classes_classvar.py:56:17-30: `ClassVar` may not be nested inside `Final` [invalid-annotation] +ERROR classes_classvar.py:57:17-30: `ClassVar` is not allowed in this context [invalid-annotation] +ERROR classes_classvar.py:71:26-34: `ClassVar` is only allowed inside a class body [invalid-annotation] +ERROR classes_classvar.py:71:26-39: `ClassVar` is not allowed in this context [invalid-annotation] +ERROR classes_classvar.py:72:12-20: `ClassVar` is only allowed inside a class body [invalid-annotation] +ERROR classes_classvar.py:72:12-25: `ClassVar` is not allowed in this context [invalid-annotation] +ERROR classes_classvar.py:73:9-16: Cannot set field `xx` [read-only] +ERROR classes_classvar.py:75:26-34: `ClassVar` is only allowed inside a class body [invalid-annotation] +ERROR classes_classvar.py:75:26-39: `ClassVar` is not allowed in this context [invalid-annotation] +ERROR classes_classvar.py:79:8-16: `ClassVar` is only allowed inside a class body [invalid-annotation] +ERROR classes_classvar.py:79:8-21: `ClassVar` is not allowed in this context [invalid-annotation] +ERROR classes_classvar.py:80:20-33: `ClassVar` is not allowed in this context [invalid-annotation] +ERROR classes_classvar.py:89:5-6: `ClassVar` may not be used for TypedDict members [invalid-annotation] +ERROR classes_classvar.py:94:5-6: `ClassVar` may not be used for NamedTuple members [invalid-annotation] +ERROR classes_classvar.py:127:1-19: Cannot set field `stats` [read-only] +ERROR classes_classvar.py:156:13-25: `ProtoAImpl` is not assignable to `ProtoA` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/classes_override.toml b/conformance/results/pyrefly/classes_override.toml new file mode 100644 index 000000000..bfb18ccfd --- /dev/null +++ b/conformance/results/pyrefly/classes_override.toml @@ -0,0 +1,13 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR classes_override.py:53:9-16: Class member `ChildA.method3` is marked as an override, but no parent class has a matching attribute [bad-override] +ERROR classes_override.py:57:9-16: Class member `ChildA.method4` is marked as an override, but no parent class has a matching attribute [bad-override] +ERROR classes_override.py:79:9-23: Class member `ChildA.static_method1` is marked as an override, but no parent class has a matching attribute [bad-override] +ERROR classes_override.py:84:9-22: Class member `ChildA.class_method1` is marked as an override, but no parent class has a matching attribute [bad-override] +ERROR classes_override.py:89:9-18: Class member `ChildA.property1` is marked as an override, but no parent class has a matching attribute [bad-override] +ERROR classes_override.py:135:9-17: Class member `ChildC2.__init__` overrides parent class `ParentC` in an inconsistent manner [bad-override] +ERROR classes_override.py:138:9-16: Class member `ChildC2.__new__` overrides parent class `ParentC` in an inconsistent manner [bad-override] +""" diff --git a/conformance/results/pyrefly/constructors_call_init.toml b/conformance/results/pyrefly/constructors_call_init.toml new file mode 100644 index 000000000..05593e0a0 --- /dev/null +++ b/conformance/results/pyrefly/constructors_call_init.toml @@ -0,0 +1,11 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR constructors_call_init.py:21:13-16: Argument `float` is not assignable to parameter `x` with type `int` in function `Class1.__init__` [bad-argument-type] +ERROR constructors_call_init.py:42:8-20: Argument `Class2[@_]` is not assignable to parameter `x` with type `Class3 | None` in function `Class2.__init__` [bad-argument-type] +ERROR constructors_call_init.py:56:12-14: Argument `Class4[str]` is not assignable to parameter `self` with type `Class4[int]` in function `Class4.__init__` [bad-argument-type] +ERROR constructors_call_init.py:107:9-17: `__init__` method self type cannot reference class type parameters `T2`, `T1` [invalid-annotation] +ERROR constructors_call_init.py:130:9-10: Expected 0 positional arguments, got 1 in function `object.__init__` [bad-argument-count] +""" diff --git a/conformance/results/pyrefly/constructors_call_metaclass.toml b/conformance/results/pyrefly/constructors_call_metaclass.toml new file mode 100644 index 000000000..5471a7404 --- /dev/null +++ b/conformance/results/pyrefly/constructors_call_metaclass.toml @@ -0,0 +1,8 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR constructors_call_metaclass.py:54:7-9: Missing argument `x` in function `Class3.__new__` [missing-argument] +ERROR constructors_call_metaclass.py:68:7-9: Missing argument `x` in function `Class4.__new__` [missing-argument] +""" diff --git a/conformance/results/pyrefly/constructors_call_new.toml b/conformance/results/pyrefly/constructors_call_new.toml new file mode 100644 index 000000000..edef6e5e5 --- /dev/null +++ b/conformance/results/pyrefly/constructors_call_new.toml @@ -0,0 +1,8 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR constructors_call_new.py:21:13-16: Argument `float` is not assignable to parameter `x` with type `int` in function `Class1.__new__` [bad-argument-type] +ERROR constructors_call_new.py:148:13-15: Argument `type[Class11[str]]` is not assignable to parameter `cls` with type `type[Class11[int]]` in function `Class11.__new__` [bad-argument-type] +""" diff --git a/conformance/results/pyrefly/constructors_call_type.toml b/conformance/results/pyrefly/constructors_call_type.toml new file mode 100644 index 000000000..fd4d14c64 --- /dev/null +++ b/conformance/results/pyrefly/constructors_call_type.toml @@ -0,0 +1,18 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR constructors_call_type.py:30:8-10: Missing argument `x` in function `Meta1.__call__` [missing-argument] +ERROR constructors_call_type.py:30:8-10: Missing argument `y` in function `Meta1.__call__` [missing-argument] +ERROR constructors_call_type.py:40:8-10: Missing argument `x` in function `Class2.__new__` [missing-argument] +ERROR constructors_call_type.py:40:8-10: Missing argument `y` in function `Class2.__new__` [missing-argument] +ERROR constructors_call_type.py:50:8-10: Missing argument `x` in function `Class3.__init__` [missing-argument] +ERROR constructors_call_type.py:50:8-10: Missing argument `y` in function `Class3.__init__` [missing-argument] +ERROR constructors_call_type.py:59:9-10: Expected 0 positional arguments, got 1 in function `object.__init__` [bad-argument-count] +ERROR constructors_call_type.py:64:9-10: Expected 0 positional arguments, got 1 [bad-argument-count] +ERROR constructors_call_type.py:72:8-10: Missing argument `x` in function `Meta1.__call__` [missing-argument] +ERROR constructors_call_type.py:72:8-10: Missing argument `y` in function `Meta1.__call__` [missing-argument] +ERROR constructors_call_type.py:81:8-11: Missing argument `y` in function `Class2.__new__` [missing-argument] +ERROR constructors_call_type.py:82:12-13: Argument `Literal[2]` is not assignable to parameter `y` with type `str` in function `Class2.__new__` [bad-argument-type] +""" diff --git a/conformance/results/pyrefly/constructors_callable.toml b/conformance/results/pyrefly/constructors_callable.toml new file mode 100644 index 000000000..e89288ee3 --- /dev/null +++ b/conformance/results/pyrefly/constructors_callable.toml @@ -0,0 +1,23 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR constructors_callable.py:38:3-5: Missing argument `x` [missing-argument] +ERROR constructors_callable.py:39:3-8: Missing argument `x` [missing-argument] +ERROR constructors_callable.py:39:4-5: Unexpected keyword argument `y` [unexpected-keyword] +ERROR constructors_callable.py:51:4-5: Expected 0 positional arguments, got 1 [bad-argument-count] +ERROR constructors_callable.py:66:3-5: Missing argument `x` [missing-argument] +ERROR constructors_callable.py:67:3-8: Missing argument `x` [missing-argument] +ERROR constructors_callable.py:67:4-5: Unexpected keyword argument `y` [unexpected-keyword] +ERROR constructors_callable.py:68:7-8: Expected 1 positional argument, got 2 [bad-argument-count] +ERROR constructors_callable.py:81:3-5: Missing argument `x` [missing-argument] +ERROR constructors_callable.py:82:3-8: Missing argument `x` [missing-argument] +ERROR constructors_callable.py:82:4-5: Unexpected keyword argument `y` [unexpected-keyword] +ERROR constructors_callable.py:129:4-5: Expected 0 positional arguments, got 1 [bad-argument-count] +ERROR constructors_callable.py:146:8-9: Expected 0 positional arguments, got 1 [bad-argument-count] +ERROR constructors_callable.py:185:10-22: Argument `Literal['not a list']` is not assignable to parameter `y` with type `list[str]` [bad-argument-type] +ERROR constructors_callable.py:187:9-13: Argument `list[str]` is not assignable to parameter `y` with type `list[int]` [bad-argument-type] +ERROR constructors_callable.py:197:10-22: Argument `Literal['not a list']` is not assignable to parameter `y` with type `list[str]` [bad-argument-type] +ERROR constructors_callable.py:199:9-13: Argument `list[str]` is not assignable to parameter `y` with type `list[int]` [bad-argument-type] +""" diff --git a/conformance/results/pyrefly/constructors_consistency.toml b/conformance/results/pyrefly/constructors_consistency.toml new file mode 100644 index 000000000..be211bd5b --- /dev/null +++ b/conformance/results/pyrefly/constructors_consistency.toml @@ -0,0 +1,6 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pyrefly/dataclasses_descriptors.toml b/conformance/results/pyrefly/dataclasses_descriptors.toml new file mode 100644 index 000000000..21e34e3c3 --- /dev/null +++ b/conformance/results/pyrefly/dataclasses_descriptors.toml @@ -0,0 +1,12 @@ +conformant = "Partial" +notes = """ +Assumes descriptor behavior only when field is assigned in class body +Doesn't allow non-data descriptors or data descriptors with differing `__get__` and `__set__` types +""" +conformance_automated = "Fail" +errors_diff = """ +Line 58: Unexpected errors ['Cannot set field `z` to non-data descriptor `Desc2` [bad-dataclass-descriptor]'] +""" +output = """ +ERROR dataclasses_descriptors.py:58:5-6: Cannot set field `z` to non-data descriptor `Desc2` [bad-dataclass-descriptor] +""" diff --git a/conformance/results/pyrefly/dataclasses_final.toml b/conformance/results/pyrefly/dataclasses_final.toml new file mode 100644 index 000000000..144be4b17 --- /dev/null +++ b/conformance/results/pyrefly/dataclasses_final.toml @@ -0,0 +1,11 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR dataclasses_final.py:27:1-17: Cannot set field `final_classvar` [read-only] +ERROR dataclasses_final.py:35:1-19: Cannot set field `final_no_default` [read-only] +ERROR dataclasses_final.py:36:1-21: Cannot set field `final_with_default` [read-only] +ERROR dataclasses_final.py:37:1-19: Cannot set field `final_no_default` [read-only] +ERROR dataclasses_final.py:38:1-21: Cannot set field `final_with_default` [read-only] +""" diff --git a/conformance/results/pyrefly/dataclasses_frozen.toml b/conformance/results/pyrefly/dataclasses_frozen.toml new file mode 100644 index 000000000..4fd80f44f --- /dev/null +++ b/conformance/results/pyrefly/dataclasses_frozen.toml @@ -0,0 +1,10 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR dataclasses_frozen.py:16:1-6: Cannot set field `a` [read-only] +ERROR dataclasses_frozen.py:17:1-6: Cannot set field `b` [read-only] +ERROR dataclasses_frozen.py:23:7-10: Cannot inherit non-frozen dataclass `DC2` from frozen dataclass `DC1` [invalid-inheritance] +ERROR dataclasses_frozen.py:33:7-10: Cannot inherit frozen dataclass `DC4` from non-frozen dataclass `DC3` [invalid-inheritance] +""" diff --git a/conformance/results/pyrefly/dataclasses_hash.toml b/conformance/results/pyrefly/dataclasses_hash.toml new file mode 100644 index 000000000..4c89ed9cf --- /dev/null +++ b/conformance/results/pyrefly/dataclasses_hash.toml @@ -0,0 +1,10 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR dataclasses_hash.py:17:1-16: Expected a callable, got `None` [not-callable] +ERROR dataclasses_hash.py:18:16-22: `DC1` is not assignable to `Hashable` [bad-assignment] +ERROR dataclasses_hash.py:39:1-16: Expected a callable, got `None` [not-callable] +ERROR dataclasses_hash.py:40:16-22: `DC3` is not assignable to `Hashable` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/dataclasses_inheritance.toml b/conformance/results/pyrefly/dataclasses_inheritance.toml new file mode 100644 index 000000000..0b64d63ad --- /dev/null +++ b/conformance/results/pyrefly/dataclasses_inheritance.toml @@ -0,0 +1,8 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR dataclasses_inheritance.py:62:5-6: ClassVar `DC7.x` overrides instance variable of the same name in parent class `DC6` [bad-override] +ERROR dataclasses_inheritance.py:66:5-6: Instance variable `DC7.y` overrides ClassVar of the same name in parent class `DC6` [bad-override] +""" diff --git a/conformance/results/pyrefly/dataclasses_kwonly.toml b/conformance/results/pyrefly/dataclasses_kwonly.toml new file mode 100644 index 000000000..aebe69eb9 --- /dev/null +++ b/conformance/results/pyrefly/dataclasses_kwonly.toml @@ -0,0 +1,9 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR dataclasses_kwonly.py:23:11-12: Expected 1 positional argument, got 2 in function `DC1.__init__` [bad-argument-count] +ERROR dataclasses_kwonly.py:38:11-12: Expected 1 positional argument, got 2 in function `DC2.__init__` [bad-argument-count] +ERROR dataclasses_kwonly.py:53:11-12: Expected 1 positional argument, got 2 in function `DC3.__init__` [bad-argument-count] +""" diff --git a/conformance/results/pyrefly/dataclasses_match_args.toml b/conformance/results/pyrefly/dataclasses_match_args.toml new file mode 100644 index 000000000..16221354f --- /dev/null +++ b/conformance/results/pyrefly/dataclasses_match_args.toml @@ -0,0 +1,7 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR dataclasses_match_args.py:42:1-19: Class `DC4` has no class attribute `__match_args__` [missing-attribute] +""" diff --git a/conformance/results/pyrefly/dataclasses_order.toml b/conformance/results/pyrefly/dataclasses_order.toml new file mode 100644 index 000000000..65b34aec2 --- /dev/null +++ b/conformance/results/pyrefly/dataclasses_order.toml @@ -0,0 +1,7 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR dataclasses_order.py:50:4-17: `<` is not supported between `DC1` and `DC2` [unsupported-operation] +""" diff --git a/conformance/results/pyrefly/dataclasses_postinit.toml b/conformance/results/pyrefly/dataclasses_postinit.toml new file mode 100644 index 000000000..8098f3ab8 --- /dev/null +++ b/conformance/results/pyrefly/dataclasses_postinit.toml @@ -0,0 +1,10 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR dataclasses_postinit.py:19:9-22: `__post_init__` type `(x: int, y: int) -> None` is not assignable to expected type `(x: int, y: str) -> object` generated from the dataclass's `InitVar` fields [bad-function-definition] +ERROR dataclasses_postinit.py:28:7-12: Object of class `DC1` has no attribute `x` [missing-attribute] +ERROR dataclasses_postinit.py:29:7-12: Object of class `DC1` has no attribute `y` [missing-attribute] +ERROR dataclasses_postinit.py:36:9-22: `__post_init__` type `(x: int) -> None` is not assignable to expected type `(x: int, y: str) -> object` generated from the dataclass's `InitVar` fields [bad-function-definition] +""" diff --git a/conformance/results/pyrefly/dataclasses_slots.toml b/conformance/results/pyrefly/dataclasses_slots.toml new file mode 100644 index 000000000..33af4406b --- /dev/null +++ b/conformance/results/pyrefly/dataclasses_slots.toml @@ -0,0 +1,11 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR dataclasses_slots.py:11:7-10: Cannot specify both `slots=True` and `__slots__` [bad-class-definition] +ERROR dataclasses_slots.py:25:14-15: Object of class `DC2` has no attribute `y` (not declared in `__slots__`) [missing-attribute] +ERROR dataclasses_slots.py:38:14-15: Object of class `DC3` has no attribute `y` (not declared in `__slots__`) [missing-attribute] +ERROR dataclasses_slots.py:66:1-14: Class `DC6` has no class attribute `__slots__` [missing-attribute] +ERROR dataclasses_slots.py:69:1-17: Object of class `DC6` has no attribute `__slots__` [missing-attribute] +""" diff --git a/conformance/results/pyrefly/dataclasses_transform_class.toml b/conformance/results/pyrefly/dataclasses_transform_class.toml new file mode 100644 index 000000000..31fc9270f --- /dev/null +++ b/conformance/results/pyrefly/dataclasses_transform_class.toml @@ -0,0 +1,14 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR dataclasses_transform_class.py:51:7-24: Cannot inherit non-frozen dataclass `Customer1Subclass` from frozen dataclass `Customer1` [invalid-inheritance] +ERROR dataclasses_transform_class.py:63:1-8: Cannot set field `id` [read-only] +ERROR dataclasses_transform_class.py:66:18-19: Expected argument `id` to be passed by name in function `Customer1.__init__` [unexpected-positional-argument] +ERROR dataclasses_transform_class.py:66:21-26: Expected argument `name` to be passed by name in function `Customer1.__init__` [unexpected-positional-argument] +ERROR dataclasses_transform_class.py:72:6-17: `<` is not supported between `Customer1` and `Customer1` [unsupported-operation] +ERROR dataclasses_transform_class.py:82:18-19: Expected argument `id` to be passed by name in function `Customer2.__init__` [unexpected-positional-argument] +ERROR dataclasses_transform_class.py:82:18-19: Expected 0 positional arguments, got 2 in function `Customer2.__init__` [bad-argument-count] +ERROR dataclasses_transform_class.py:122:1-8: Cannot set field `id` [read-only] +""" diff --git a/conformance/results/pyrefly/dataclasses_transform_converter.toml b/conformance/results/pyrefly/dataclasses_transform_converter.toml new file mode 100644 index 000000000..f49dd73da --- /dev/null +++ b/conformance/results/pyrefly/dataclasses_transform_converter.toml @@ -0,0 +1,15 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR dataclasses_transform_converter.py:48:41-55: Argument `() -> int` is not assignable to parameter `converter` with type `(@_) -> @_` in function `model_field` [bad-argument-type] +ERROR dataclasses_transform_converter.py:49:41-55: Argument `(*, x: int) -> int` is not assignable to parameter `converter` with type `(@_) -> @_` in function `model_field` [bad-argument-type] +ERROR dataclasses_transform_converter.py:107:5-6: Argument `Literal[1]` is not assignable to parameter `field0` with type `str` in function `DC2.__init__` [bad-argument-type] +ERROR dataclasses_transform_converter.py:108:23-24: Argument `Literal[1]` is not assignable to parameter `field3` with type `bytes | str` in function `DC2.__init__` [bad-argument-type] +ERROR dataclasses_transform_converter.py:109:29-31: Argument `complex` is not assignable to parameter `field4` with type `list[str] | str` in function `DC2.__init__` [bad-argument-type] +ERROR dataclasses_transform_converter.py:118:14-15: `Literal[1]` is not assignable to attribute `field0` with type `str` [bad-assignment] +ERROR dataclasses_transform_converter.py:119:14-15: `Literal[1]` is not assignable to attribute `field3` with type `bytes | str` [bad-assignment] +ERROR dataclasses_transform_converter.py:130:67-68: Argument `Literal[1]` is not assignable to parameter `default` with type `str | None` in function `model_field` [bad-argument-type] +ERROR dataclasses_transform_converter.py:133:75-78: Argument `type[int]` is not assignable to parameter `default_factory` with type `(() -> str) | None` in function `model_field` [bad-argument-type] +""" diff --git a/conformance/results/pyrefly/dataclasses_transform_field.toml b/conformance/results/pyrefly/dataclasses_transform_field.toml new file mode 100644 index 000000000..df3d09509 --- /dev/null +++ b/conformance/results/pyrefly/dataclasses_transform_field.toml @@ -0,0 +1,8 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR dataclasses_transform_field.py:64:16-18: Unexpected keyword argument `id` in function `CustomerModel1.__init__` [unexpected-keyword] +ERROR dataclasses_transform_field.py:75:16-17: Expected argument `name` to be passed by name in function `CustomerModel2.__init__` [unexpected-positional-argument] +""" diff --git a/conformance/results/pyrefly/dataclasses_transform_func.toml b/conformance/results/pyrefly/dataclasses_transform_func.toml new file mode 100644 index 000000000..1d8c11fc8 --- /dev/null +++ b/conformance/results/pyrefly/dataclasses_transform_func.toml @@ -0,0 +1,13 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR dataclasses_transform_func.py:56:13-14: `Literal[3]` is not assignable to attribute `name` with type `str` [bad-assignment] +ERROR dataclasses_transform_func.py:60:6-17: `<` is not supported between `Customer1` and `Customer1` [unsupported-operation] +ERROR dataclasses_transform_func.py:64:36-42: Unexpected keyword argument `salary` in function `Customer1.__init__` [unexpected-keyword] +ERROR dataclasses_transform_func.py:70:18-19: Expected argument `id` to be passed by name in function `Customer2.__init__` [unexpected-positional-argument] +ERROR dataclasses_transform_func.py:70:21-27: Expected argument `name` to be passed by name in function `Customer2.__init__` [unexpected-positional-argument] +ERROR dataclasses_transform_func.py:89:7-24: Cannot inherit non-frozen dataclass `Customer3Subclass` from frozen dataclass `Customer3` [invalid-inheritance] +ERROR dataclasses_transform_func.py:96:1-8: Cannot set field `id` [read-only] +""" diff --git a/conformance/results/pyrefly/dataclasses_transform_meta.toml b/conformance/results/pyrefly/dataclasses_transform_meta.toml new file mode 100644 index 000000000..8af862f41 --- /dev/null +++ b/conformance/results/pyrefly/dataclasses_transform_meta.toml @@ -0,0 +1,14 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR dataclasses_transform_meta.py:51:7-24: Cannot inherit non-frozen dataclass `Customer1Subclass` from frozen dataclass `Customer1` [invalid-inheritance] +ERROR dataclasses_transform_meta.py:63:1-8: Cannot set field `id` [read-only] +ERROR dataclasses_transform_meta.py:66:18-19: Expected argument `id` to be passed by name in function `Customer1.__init__` [unexpected-positional-argument] +ERROR dataclasses_transform_meta.py:66:21-26: Expected argument `name` to be passed by name in function `Customer1.__init__` [unexpected-positional-argument] +ERROR dataclasses_transform_meta.py:73:6-17: `<` is not supported between `Customer1` and `Customer1` [unsupported-operation] +ERROR dataclasses_transform_meta.py:83:18-19: Expected argument `id` to be passed by name in function `Customer2.__init__` [unexpected-positional-argument] +ERROR dataclasses_transform_meta.py:83:18-19: Expected 0 positional arguments, got 2 in function `Customer2.__init__` [bad-argument-count] +ERROR dataclasses_transform_meta.py:103:1-8: Cannot set field `id` [read-only] +""" diff --git a/conformance/results/pyrefly/dataclasses_usage.toml b/conformance/results/pyrefly/dataclasses_usage.toml new file mode 100644 index 000000000..471ce6829 --- /dev/null +++ b/conformance/results/pyrefly/dataclasses_usage.toml @@ -0,0 +1,19 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR dataclasses_usage.py:51:19-27: Missing argument `unit_price` in function `InventoryItem.__init__` [missing-argument] +ERROR dataclasses_usage.py:52:28-35: Argument `Literal['price']` is not assignable to parameter `unit_price` with type `float` in function `InventoryItem.__init__` [bad-argument-type] +ERROR dataclasses_usage.py:53:36-37: Expected 3 positional arguments, got 4 in function `InventoryItem.__init__` [bad-argument-count] +ERROR dataclasses_usage.py:62:5-6: Dataclass field `b` without a default may not follow dataclass field with a default [bad-class-definition] +ERROR dataclasses_usage.py:68:5-6: Dataclass field `b` without a default may not follow dataclass field with a default [bad-class-definition] +ERROR dataclasses_usage.py:74:5-6: Dataclass field `b` without a default may not follow dataclass field with a default [bad-class-definition] +ERROR dataclasses_usage.py:84:13-14: Expected 1 positional argument, got 2 in function `DC4.__init__` [bad-argument-count] +ERROR dataclasses_usage.py:89:14-40: `str` is not assignable to `int` [bad-assignment] +ERROR dataclasses_usage.py:128:8-9: Expected 1 positional argument, got 2 in function `DC7.__init__` [bad-argument-count] +ERROR dataclasses_usage.py:131:4-7: Missing argument `y` in function `DC8.__init__` [missing-argument] +ERROR dataclasses_usage.py:180:6-7: Expected 0 positional arguments, got 1 in function `object.__init__` [bad-argument-count] +ERROR dataclasses_usage.py:229:5-6: `y` is a dataclass field but has no type annotation [bad-class-definition] +ERROR dataclasses_usage.py:246:12-13: Expected 2 positional arguments, got 3 in function `DC19.__init__` [bad-argument-count] +""" diff --git a/conformance/results/pyrefly/directives_assert_type.toml b/conformance/results/pyrefly/directives_assert_type.toml new file mode 100644 index 000000000..bafeb7409 --- /dev/null +++ b/conformance/results/pyrefly/directives_assert_type.toml @@ -0,0 +1,13 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR directives_assert_type.py:27:16-24: assert_type(int | str, int) failed [assert-type] +ERROR directives_assert_type.py:28:16-24: assert_type(int | str, Any) failed [assert-type] +ERROR directives_assert_type.py:29:16-24: assert_type(Any, int) failed [assert-type] +ERROR directives_assert_type.py:30:16-24: assert_type(Literal[4], int) failed [assert-type] +ERROR directives_assert_type.py:32:16-18: assert_type needs 2 positional arguments, got 0 [bad-argument-count] +ERROR directives_assert_type.py:33:16-25: assert_type(Literal[''], int) failed [assert-type] +ERROR directives_assert_type.py:34:16-33: assert_type needs 2 positional arguments, got 3 [bad-argument-count] +""" diff --git a/conformance/results/pyrefly/directives_cast.toml b/conformance/results/pyrefly/directives_cast.toml new file mode 100644 index 000000000..e4e745aef --- /dev/null +++ b/conformance/results/pyrefly/directives_cast.toml @@ -0,0 +1,10 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR directives_cast.py:15:12-14: `typing.cast` missing required argument `typ` [missing-argument] +ERROR directives_cast.py:15:12-14: `typing.cast` missing required argument `val` [missing-argument] +ERROR directives_cast.py:16:12-19: First argument to `typing.cast` must be a type [bad-argument-type] +ERROR directives_cast.py:17:12-25: `typing.cast` expected 2 arguments, got 3 [bad-argument-count] +""" diff --git a/conformance/results/pyrefly/directives_deprecated.toml b/conformance/results/pyrefly/directives_deprecated.toml new file mode 100644 index 000000000..9373c54f4 --- /dev/null +++ b/conformance/results/pyrefly/directives_deprecated.toml @@ -0,0 +1,18 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ + WARN directives_deprecated.py:18:44-47: `Ham` is deprecated [deprecated] + WARN directives_deprecated.py:24:1-23: `_directives_deprecated_library.norwegian_blue` is deprecated [deprecated] + WARN directives_deprecated.py:25:5-27: `_directives_deprecated_library.norwegian_blue` is deprecated [deprecated] + WARN directives_deprecated.py:30:12-15: Call to deprecated overload `_directives_deprecated_library.foo` [deprecated] + WARN directives_deprecated.py:41:5-13: `+` is not supported between `Spam` and `Literal[1]` [deprecated] + WARN directives_deprecated.py:42:1-10: `+=` is not supported between `Spam` and `Literal[1]` [deprecated] + WARN directives_deprecated.py:44:1-12: `_directives_deprecated_library.Spam.greasy` is deprecated [deprecated] + WARN directives_deprecated.py:47:1-11: `_directives_deprecated_library.Spam.shape` is deprecated [deprecated] + WARN directives_deprecated.py:48:1-11: `_directives_deprecated_library.Spam.shape` is deprecated [deprecated] + WARN directives_deprecated.py:58:1-10: `Invocable.__call__` is deprecated [deprecated] + WARN directives_deprecated.py:69:1-6: `lorem` is deprecated [deprecated] + WARN directives_deprecated.py:98:5-10: `SupportsFoo1.foo` is deprecated [deprecated] +""" diff --git a/conformance/results/pyrefly/directives_disjoint_base.toml b/conformance/results/pyrefly/directives_disjoint_base.toml new file mode 100644 index 000000000..fd781b2d4 --- /dev/null +++ b/conformance/results/pyrefly/directives_disjoint_base.toml @@ -0,0 +1,13 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR directives_disjoint_base.py:69:7-19: Class `LeftAndRight` inherits from incompatible disjoint bases `Left`, `Right` [invalid-inheritance] +ERROR directives_disjoint_base.py:73:7-24: Class `LeftChildAndRight` inherits from incompatible disjoint bases `LeftChild`, `Right` [invalid-inheritance] +ERROR directives_disjoint_base.py:77:7-27: Class `LeftAndRightViaChild` inherits from incompatible disjoint bases `Left`, `Right` [invalid-inheritance] +ERROR directives_disjoint_base.py:81:7-17: Class `LeftRecord` inherits from incompatible disjoint bases `Left`, `Record` [invalid-inheritance] +ERROR directives_disjoint_base.py:105:7-24: Class `IncompatibleSlots` inherits from incompatible disjoint bases `SlotBase1`, `SlotBase2` [invalid-inheritance] +ERROR directives_disjoint_base.py:113:1-15: `@disjoint_base` cannot be applied to a function [bad-function-definition] +ERROR directives_disjoint_base.py:118:1-15: `@disjoint_base` cannot be applied to a TypedDict [bad-class-definition] +ERROR directives_disjoint_base.py:123:1-15: `@disjoint_base` cannot be applied to a Protocol [bad-class-definition] +""" diff --git a/conformance/results/pyrefly/directives_no_type_check.toml b/conformance/results/pyrefly/directives_no_type_check.toml new file mode 100644 index 000000000..52623ac35 --- /dev/null +++ b/conformance/results/pyrefly/directives_no_type_check.toml @@ -0,0 +1,9 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR directives_no_type_check.py:15:14-16: `Literal['']` is not assignable to `int` [bad-assignment] +ERROR directives_no_type_check.py:32:6-8: Missing argument `a` in function `func1` [missing-argument] +ERROR directives_no_type_check.py:32:6-8: Missing argument `b` in function `func1` [missing-argument] +""" diff --git a/conformance/results/pyrefly/directives_reveal_type.toml b/conformance/results/pyrefly/directives_reveal_type.toml new file mode 100644 index 000000000..5cd063da4 --- /dev/null +++ b/conformance/results/pyrefly/directives_reveal_type.toml @@ -0,0 +1,8 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR directives_reveal_type.py:19:16-18: reveal_type needs 1 positional argument, got 0 [bad-argument-count] +ERROR directives_reveal_type.py:20:16-22: reveal_type needs 1 positional argument, got 2 [bad-argument-count] +""" diff --git a/conformance/results/pyrefly/directives_type_checking.toml b/conformance/results/pyrefly/directives_type_checking.toml new file mode 100644 index 000000000..be211bd5b --- /dev/null +++ b/conformance/results/pyrefly/directives_type_checking.toml @@ -0,0 +1,6 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pyrefly/directives_type_ignore.toml b/conformance/results/pyrefly/directives_type_ignore.toml new file mode 100644 index 000000000..be211bd5b --- /dev/null +++ b/conformance/results/pyrefly/directives_type_ignore.toml @@ -0,0 +1,6 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pyrefly/directives_type_ignore_file1.toml b/conformance/results/pyrefly/directives_type_ignore_file1.toml new file mode 100644 index 000000000..be211bd5b --- /dev/null +++ b/conformance/results/pyrefly/directives_type_ignore_file1.toml @@ -0,0 +1,6 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pyrefly/directives_type_ignore_file2.toml b/conformance/results/pyrefly/directives_type_ignore_file2.toml new file mode 100644 index 000000000..ae2a41fdc --- /dev/null +++ b/conformance/results/pyrefly/directives_type_ignore_file2.toml @@ -0,0 +1,7 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR directives_type_ignore_file2.py:14:10-12: `Literal['']` is not assignable to `int` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/directives_version_platform.toml b/conformance/results/pyrefly/directives_version_platform.toml new file mode 100644 index 000000000..562bdae49 --- /dev/null +++ b/conformance/results/pyrefly/directives_version_platform.toml @@ -0,0 +1,11 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR directives_version_platform.py:33:19-23: Could not find name `val3` [unknown-name] +ERROR directives_version_platform.py:50:19-23: Could not find name `val6` [unknown-name] +ERROR directives_version_platform.py:59:19-23: Could not find name `val9` [unknown-name] +ERROR directives_version_platform.py:66:19-24: Could not find name `val10` [unknown-name] +ERROR directives_version_platform.py:75:19-24: Could not find name `val13` [unknown-name] +""" diff --git a/conformance/results/pyrefly/enums_behaviors.toml b/conformance/results/pyrefly/enums_behaviors.toml new file mode 100644 index 000000000..150f59c2c --- /dev/null +++ b/conformance/results/pyrefly/enums_behaviors.toml @@ -0,0 +1,9 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR enums_behaviors.py:27:12-33: assert_type(Literal[Color.RED], Color) failed [assert-type] +ERROR enums_behaviors.py:32:12-43: assert_type(Color, Literal[Color.BLUE]) failed [assert-type] +ERROR enums_behaviors.py:44:21-26: Cannot extend final class `Shape` [invalid-inheritance] +""" diff --git a/conformance/results/pyrefly/enums_definition.toml b/conformance/results/pyrefly/enums_definition.toml new file mode 100644 index 000000000..22ed73f5d --- /dev/null +++ b/conformance/results/pyrefly/enums_definition.toml @@ -0,0 +1,7 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR enums_definition.py:92:1-13: Class `Color12` has no class attribute `BLUE` [missing-attribute] +""" diff --git a/conformance/results/pyrefly/enums_expansion.toml b/conformance/results/pyrefly/enums_expansion.toml new file mode 100644 index 000000000..7c27606f9 --- /dev/null +++ b/conformance/results/pyrefly/enums_expansion.toml @@ -0,0 +1,7 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR enums_expansion.py:56:20-51: assert_type(CustomFlags, Literal[CustomFlags.FLAG3]) failed [assert-type] +""" diff --git a/conformance/results/pyrefly/enums_member_names.toml b/conformance/results/pyrefly/enums_member_names.toml new file mode 100644 index 000000000..f0f464fe6 --- /dev/null +++ b/conformance/results/pyrefly/enums_member_names.toml @@ -0,0 +1,7 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR enums_member_names.py:30:16-65: assert_type(str, Literal['BLUE', 'GREEN', 'RED']) failed [assert-type] +""" diff --git a/conformance/results/pyrefly/enums_member_values.toml b/conformance/results/pyrefly/enums_member_values.toml new file mode 100644 index 000000000..93bdb61fb --- /dev/null +++ b/conformance/results/pyrefly/enums_member_values.toml @@ -0,0 +1,10 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR enums_member_values.py:54:12-46: assert_type(Any, Literal[1]) failed [assert-type] +ERROR enums_member_values.py:68:12-42: assert_type(int, Literal[1]) failed [assert-type] +ERROR enums_member_values.py:78:5-10: Enum member `GREEN` has type `Literal['green']`, must match the `_value_` attribute annotation of `int` [bad-assignment] +ERROR enums_member_values.py:85:24-29: `int` is not assignable to attribute `_value_` with type `str` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/enums_members.toml b/conformance/results/pyrefly/enums_members.toml new file mode 100644 index 000000000..4b81e579b --- /dev/null +++ b/conformance/results/pyrefly/enums_members.toml @@ -0,0 +1,15 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR enums_members.py:54:5-8: Enum member `DOG` may not be annotated directly. Instead, annotate the `_value_` attribute. [invalid-annotation] +ERROR enums_members.py:86:20-34: `Pet4.converter` is not a valid enum member [invalid-literal] +ERROR enums_members.py:87:20-34: `Pet4.transform` is not a valid enum member [invalid-literal] +ERROR enums_members.py:88:18-30: `Pet4.species` is not a valid enum member [invalid-literal] +ERROR enums_members.py:89:16-26: `Pet4.speak` is not a valid enum member [invalid-literal] +ERROR enums_members.py:120:32-41: `Example.b` is not a valid enum member [invalid-literal] +ERROR enums_members.py:133:43-55: `Example2.__B` is not a valid enum member [invalid-literal] +ERROR enums_members.py:150:12-27: assert_type(Literal[Pet5.DOG], int) failed [assert-type] +ERROR enums_members.py:151:12-28: assert_type(Literal[Pet5.FISH], int) failed [assert-type] +""" diff --git a/conformance/results/pyrefly/exceptions_context_managers.toml b/conformance/results/pyrefly/exceptions_context_managers.toml new file mode 100644 index 000000000..be211bd5b --- /dev/null +++ b/conformance/results/pyrefly/exceptions_context_managers.toml @@ -0,0 +1,6 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pyrefly/generics_base_class.toml b/conformance/results/pyrefly/generics_base_class.toml new file mode 100644 index 000000000..b1434372f --- /dev/null +++ b/conformance/results/pyrefly/generics_base_class.toml @@ -0,0 +1,13 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_base_class.py:26:26-27: Argument `SymbolTable` is not assignable to parameter `x` with type `dict[str, list[object]]` in function `takes_dict_incorrect` [bad-argument-type] +ERROR generics_base_class.py:29:14-24: `Generic` is not allowed in this context [invalid-annotation] +ERROR generics_base_class.py:30:8-15: Expected a type argument for `Generic` [invalid-annotation] +ERROR generics_base_class.py:49:22-42: Expected 1 type argument for `LinkedList`, got 2 [bad-specialization] +ERROR generics_base_class.py:61:18-34: Expected 1 type argument for `MyDict`, got 2 [bad-specialization] +ERROR generics_base_class.py:68:28-29: Duplicated type parameter declaration `T` [invalid-inheritance] +ERROR generics_base_class.py:98:7-15: Class `BadChild` has inconsistent type arguments for base class `Grandparent`: `Grandparent[T1, T2]` and `Grandparent[T2, T1]` [invalid-inheritance] +""" diff --git a/conformance/results/pyrefly/generics_basic.toml b/conformance/results/pyrefly/generics_basic.toml new file mode 100644 index 000000000..91d67475f --- /dev/null +++ b/conformance/results/pyrefly/generics_basic.toml @@ -0,0 +1,25 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_basic.py:40:15-16: Argument `bytes` is not assignable to parameter `y` with type `str` in function `concat` [bad-argument-type] +ERROR generics_basic.py:41:15-16: Argument `str` is not assignable to parameter `y` with type `bytes` in function `concat` [bad-argument-type] +ERROR generics_basic.py:49:18-48: Expected at least 2 constraints in TypeVar `BadConstraint1`, got 1 [invalid-type-var] +ERROR generics_basic.py:55:53-60: Type variable bounds and constraints must be concrete [invalid-annotation] +ERROR generics_basic.py:69:15-16: Argument `bytes` is not assignable to parameter `y` with type `str` in function `concat` [bad-argument-type] +ERROR generics_basic.py:121:24-25: Duplicated type parameter declaration `T` [invalid-inheritance] +ERROR generics_basic.py:157:8-9: Cannot index into `MyMap1[str, int]` [bad-index] +ERROR generics_basic.py:158:8-9: Cannot index into `MyMap2[int, str]` [bad-index] +ERROR generics_basic.py:162:7-11: Expected a type variable, got `int` [invalid-type-var] +ERROR generics_basic.py:163:7-11: Expected a type variable, got `int` [invalid-type-var] +ERROR generics_basic.py:171:7-11: Class `Bad3` uses type variables not specified in `Generic` or `Protocol` base [invalid-type-var] +ERROR generics_basic.py:172:7-11: Class `Bad4` uses type variables not specified in `Generic` or `Protocol` base [invalid-type-var] +ERROR generics_basic.py:208:7-26: Metaclass may not be an unbound generic [invalid-inheritance] +ERROR generics_basic.py:223:22-34: Argument `Literal['not a list']` is not assignable to parameter `y` with type `list[int]` in function `takes_two_lists` [bad-argument-type] +ERROR generics_basic.py:225:22-26: Argument `list[str]` is not assignable to parameter `y` with type `list[int]` in function `takes_two_lists` [bad-argument-type] +ERROR generics_basic.py:232:24-25: Argument `list[str]` is not assignable to parameter `y` with type `list[int]` in function `takes_two_lists` [bad-argument-type] +ERROR generics_basic.py:240:26-38: Argument `Literal['not a list']` is not assignable to parameter `y` with type `list[int]` in function `takes_two_int_lists` [bad-argument-type] +ERROR generics_basic.py:241:20-31: `str` is not assignable to upper bound `int` of type variable `T_int` [bad-specialization] +ERROR generics_basic.py:241:26-30: Argument `list[str]` is not assignable to parameter `y` with type `list[int]` in function `takes_two_int_lists` [bad-argument-type] +ERROR generics_basic.py:251:28-29: Argument `list[bool]` is not assignable to parameter `y` with type `list[int]` in function `takes_two_int_lists` [bad-argument-type] +""" diff --git a/conformance/results/pyrefly/generics_defaults.toml b/conformance/results/pyrefly/generics_defaults.toml new file mode 100644 index 000000000..5570f83ca --- /dev/null +++ b/conformance/results/pyrefly/generics_defaults.toml @@ -0,0 +1,12 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_defaults.py:24:7-31: Type parameter `T` without a default cannot follow type parameter `DefaultStrT` with a default [invalid-type-var] +ERROR generics_defaults.py:66:8-27: Expected 5 type arguments for `AllTheDefaults`, got 1 [bad-specialization] +ERROR generics_defaults.py:152:51-54: Expected default `int` of `Invalid1` to be assignable to the upper bound of `str` [invalid-type-var] +ERROR generics_defaults.py:159:52-55: Expected default `int` of `Invalid2` to be one of the following constraints: `float`, `str` [invalid-type-var] +ERROR generics_defaults.py:177:12-27: assert_type(int, Any) failed [assert-type] +ERROR generics_defaults.py:188:7-11: TypeVar `T5` with a default cannot follow TypeVarTuple `Ts` [invalid-type-var] +""" diff --git a/conformance/results/pyrefly/generics_defaults_referential.toml b/conformance/results/pyrefly/generics_defaults_referential.toml new file mode 100644 index 000000000..d4c867f4f --- /dev/null +++ b/conformance/results/pyrefly/generics_defaults_referential.toml @@ -0,0 +1,13 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_defaults_referential.py:36:17-18: Argument `str` is not assignable to parameter `b` with type `int` in function `Foo.__init__` [bad-argument-type] +ERROR generics_defaults_referential.py:37:14-15: Argument `str` is not assignable to parameter `a` with type `int` in function `Foo.__init__` [bad-argument-type] +ERROR generics_defaults_referential.py:53:7-13: Default of type parameter `Start2T` refers to out-of-scope type parameter `StopT` [invalid-type-var] +ERROR generics_defaults_referential.py:60:11-15: Default of type parameter `S2` refers to out-of-scope type parameter `S1` [invalid-type-var] +ERROR generics_defaults_referential.py:68:40-42: Expected default `TypeVar[X1]` of `Invalid1` to be assignable to the upper bound of `str` [invalid-type-var] +ERROR generics_defaults_referential.py:74:52-54: Expected default `TypeVar[Y1]` of `Invalid2` to be one of the following constraints: `float`, `str` [invalid-type-var] +ERROR generics_defaults_referential.py:78:63-65: Expected default `TypeVar[Y2]` of `AlsoInvalid2` to be one of the following constraints: `bool`, `complex` [invalid-type-var] +""" diff --git a/conformance/results/pyrefly/generics_defaults_specialization.toml b/conformance/results/pyrefly/generics_defaults_specialization.toml new file mode 100644 index 000000000..c0783e881 --- /dev/null +++ b/conformance/results/pyrefly/generics_defaults_specialization.toml @@ -0,0 +1,9 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_defaults_specialization.py:30:1-19: Expected 1 type argument for `MyAlias`, got 2 [bad-specialization] +ERROR generics_defaults_specialization.py:48:22-25: `type[Bar]` is not assignable to `type[Bar[int]]` [bad-assignment] +ERROR generics_defaults_specialization.py:58:1-9: Expected 0 type arguments for `Foo`, got 1 [bad-specialization] +""" diff --git a/conformance/results/pyrefly/generics_mixed_variance_inference.toml b/conformance/results/pyrefly/generics_mixed_variance_inference.toml new file mode 100644 index 000000000..910830561 --- /dev/null +++ b/conformance/results/pyrefly/generics_mixed_variance_inference.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_mixed_variance_inference.py:13:22-39: `Mixed[bool, *tuple[()], []]` is not assignable to `Mixed[int, *tuple[()], []]` [bad-assignment] +ERROR generics_mixed_variance_inference.py:16:27-51: `Mixed[int, object, []]` is not assignable to `Mixed[int, int, []]` [bad-assignment] +ERROR generics_mixed_variance_inference.py:21:25-45: `Mixed[int, *tuple[()], [bool]]` is not assignable to `Mixed[int, *tuple[()], [int]]` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/generics_paramspec_basic.toml b/conformance/results/pyrefly/generics_paramspec_basic.toml new file mode 100644 index 000000000..75c9f9bb1 --- /dev/null +++ b/conformance/results/pyrefly/generics_paramspec_basic.toml @@ -0,0 +1,15 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_paramspec_basic.py:10:13-31: ParamSpec must be assigned to a variable named `NotIt` [invalid-param-spec] +ERROR generics_paramspec_basic.py:15:18-19: `P` is not allowed in this context [invalid-annotation] +ERROR generics_paramspec_basic.py:23:14-15: `P` is not allowed in this context [invalid-annotation] +ERROR generics_paramspec_basic.py:23:20-21: `P` is not allowed in this context [invalid-annotation] +ERROR generics_paramspec_basic.py:27:14-33: `Concatenate[int, P]` is not allowed in this context [invalid-annotation] +ERROR generics_paramspec_basic.py:31:14-21: `ParamSpec` cannot be used for type parameter [invalid-param-spec] +ERROR generics_paramspec_basic.py:35:35-36: `P` is not allowed in this context [invalid-annotation] +ERROR generics_paramspec_basic.py:39:18-19: `P` is not allowed in this context [invalid-annotation] +ERROR generics_paramspec_basic.py:39:31-32: `P` is not allowed in this context [invalid-annotation] +""" diff --git a/conformance/results/pyrefly/generics_paramspec_components.toml b/conformance/results/pyrefly/generics_paramspec_components.toml new file mode 100644 index 000000000..03d98dbde --- /dev/null +++ b/conformance/results/pyrefly/generics_paramspec_components.toml @@ -0,0 +1,25 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_paramspec_components.py:17:25-33: `ParamSpec` **kwargs is only allowed in a **kwargs annotation [invalid-annotation] +ERROR generics_paramspec_components.py:17:45-51: `ParamSpec` *args is only allowed in an *args annotation [invalid-annotation] +ERROR generics_paramspec_components.py:20:23-29: `ParamSpec` *args is only allowed in an *args annotation [invalid-annotation] +ERROR generics_paramspec_components.py:23:5-24:13: `ParamSpec` *args and **kwargs must be used together [invalid-param-spec] +ERROR generics_paramspec_components.py:23:46-52: `ParamSpec` *args is only allowed in an *args annotation [invalid-annotation] +ERROR generics_paramspec_components.py:26:5-27:13: `ParamSpec` *args and **kwargs must be used together [invalid-param-spec] +ERROR generics_paramspec_components.py:30:25-31: Expected a type form, got instance of `ParamSpecArgs` [not-a-type] +ERROR generics_paramspec_components.py:30:43-51: Expected a type form, got instance of `ParamSpecKwargs` [not-a-type] +ERROR generics_paramspec_components.py:35:18-24: `ParamSpec` *args is only allowed in an *args annotation [invalid-annotation] +ERROR generics_paramspec_components.py:36:20-28: `ParamSpec` **kwargs is only allowed in a **kwargs annotation [invalid-annotation] +ERROR generics_paramspec_components.py:38:5-39:13: `ParamSpec` *args and **kwargs must be used together [invalid-param-spec] +ERROR generics_paramspec_components.py:41:5-42:13: `ParamSpec` *args and **kwargs must be used together [invalid-param-spec] +ERROR generics_paramspec_components.py:49:10-27: Expected *-unpacked P.args and **-unpacked P.kwargs [invalid-param-spec] +ERROR generics_paramspec_components.py:51:11-12: Expected 0 positional arguments, got 1 [bad-argument-count] +ERROR generics_paramspec_components.py:60:28-34: Keyword-only parameter `s` may not appear after ParamSpec args parameter [bad-function-definition] +ERROR generics_paramspec_components.py:70:10-30: Expected *-unpacked P.args and **-unpacked P.kwargs [invalid-param-spec] +ERROR generics_paramspec_components.py:72:10-27: Expected 1 more positional argument [bad-argument-count] +ERROR generics_paramspec_components.py:83:13-14: Expected argument `x` to be positional in function `foo` [unexpected-keyword] +ERROR generics_paramspec_components.py:98:20-23: Argument `Literal['A']` is not assignable to parameter `a` with type `int` in function `twice` [bad-argument-type] +ERROR generics_paramspec_components.py:98:25-26: Argument `Literal[1]` is not assignable to parameter `b` with type `str` in function `twice` [bad-argument-type] +""" diff --git a/conformance/results/pyrefly/generics_paramspec_semantics.toml b/conformance/results/pyrefly/generics_paramspec_semantics.toml new file mode 100644 index 000000000..a62bb475d --- /dev/null +++ b/conformance/results/pyrefly/generics_paramspec_semantics.toml @@ -0,0 +1,17 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_paramspec_semantics.py:26:4-5: Expected argument `a` to be positional [unexpected-keyword] +ERROR generics_paramspec_semantics.py:26:11-12: Expected argument `b` to be positional [unexpected-keyword] +ERROR generics_paramspec_semantics.py:27:9-12: Argument `Literal['A']` is not assignable to parameter `b` with type `bool` [bad-argument-type] +ERROR generics_paramspec_semantics.py:46:17-20: Argument `(y: int, x: str) -> int` is not assignable to parameter `y` with type `(x: int, y: str) -> int` in function `func1` [bad-argument-type] +ERROR generics_paramspec_semantics.py:61:23-37: Argument `(*, y: int) -> int` is not assignable to parameter `y` with type `(*, x: int) -> int` in function `func1` [bad-argument-type] +ERROR generics_paramspec_semantics.py:98:4-5: Argument `Literal[1]` is not assignable to parameter with type `str` [bad-argument-type] +ERROR generics_paramspec_semantics.py:108:4-5: Argument `Literal[1]` is not assignable to parameter `*args` with type `bool` [bad-argument-type] +ERROR generics_paramspec_semantics.py:120:4-5: Argument `Literal[1]` is not assignable to parameter with type `str` [bad-argument-type] +ERROR generics_paramspec_semantics.py:127:1-19: Argument `(x: str) -> int` is not assignable to parameter `x` with type `(int, ParamSpec(@_)) -> int` in function `expects_int_first` [bad-argument-type] +ERROR generics_paramspec_semantics.py:132:1-19: Argument `(*, x: int) -> int` is not assignable to parameter `x` with type `(int, ParamSpec(@_)) -> int` in function `expects_int_first` [bad-argument-type] +ERROR generics_paramspec_semantics.py:137:1-19: Argument `(**kwargs: int) -> int` is not assignable to parameter `x` with type `(int, ParamSpec(@_)) -> int` in function `expects_int_first` [bad-argument-type] +""" diff --git a/conformance/results/pyrefly/generics_paramspec_specialization.toml b/conformance/results/pyrefly/generics_paramspec_specialization.toml new file mode 100644 index 000000000..a835b8d19 --- /dev/null +++ b/conformance/results/pyrefly/generics_paramspec_specialization.toml @@ -0,0 +1,11 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_paramspec_specialization.py:44:15-31: Expected a valid ParamSpec expression, got `int` [invalid-param-spec] +ERROR generics_paramspec_specialization.py:54:9-11: Argument `Literal['']` is not assignable to parameter with type `int` [bad-argument-type] +ERROR generics_paramspec_specialization.py:55:16-18: Argument `Literal['']` is not assignable to parameter with type `bool` [bad-argument-type] +ERROR generics_paramspec_specialization.py:60:9-11: Argument `Literal['']` is not assignable to parameter with type `int` [bad-argument-type] +ERROR generics_paramspec_specialization.py:61:16-18: Argument `Literal['']` is not assignable to parameter with type `bool` [bad-argument-type] +""" diff --git a/conformance/results/pyrefly/generics_paramspec_variance.toml b/conformance/results/pyrefly/generics_paramspec_variance.toml new file mode 100644 index 000000000..71f24512f --- /dev/null +++ b/conformance/results/pyrefly/generics_paramspec_variance.toml @@ -0,0 +1,45 @@ +conformant = "Unsupported" +conformance_automated = "Fail" +errors_diff = """ +Line 117: Expected 1 errors +Line 126: Expected 1 errors +Line 97: Unexpected errors ['Unexpected keyword argument `contravariant` to ParamSpec [invalid-param-spec]'] +Line 98: Unexpected errors ['Unexpected keyword argument `covariant` to ParamSpec [invalid-param-spec]'] +Line 99: Unexpected errors ['Unexpected keyword argument `infer_variance` to ParamSpec [invalid-param-spec]'] +Line 122: Unexpected errors ['`ContravariantParamSpecOld[[object]]` is not assignable to `ContravariantParamSpecOld[[int]]` [bad-assignment]'] +Line 133: Unexpected errors ['`CovariantParamSpecOld[[int]]` is not assignable to `CovariantParamSpecOld[[object]]` [bad-assignment]'] +Line 143: Unexpected errors ['`InferredContravariantParamSpecOld[[object]]` is not assignable to `InferredContravariantParamSpecOld[[int]]` [bad-assignment]'] +Line 152: Unexpected errors ['`InferredCovariantParamSpecOld[[int]]` is not assignable to `InferredCovariantParamSpecOld[[object]]` [bad-assignment]'] +""" +output = """ +ERROR generics_paramspec_variance.py:14:42-67: `InvariantParamSpec[[int]]` is not assignable to `InvariantParamSpec[[object]]` [bad-assignment] +ERROR generics_paramspec_variance.py:15:39-67: `InvariantParamSpec[[object]]` is not assignable to `InvariantParamSpec[[int]]` [bad-assignment] +ERROR generics_paramspec_variance.py:21:42-71: `ContravariantParamSpec[[int]]` is not assignable to `ContravariantParamSpec[[object]]` [bad-assignment] +ERROR generics_paramspec_variance.py:30:36-64: `CovariantParamSpec[[object]]` is not assignable to `CovariantParamSpec[[int]]` [bad-assignment] +ERROR generics_paramspec_variance.py:61:12-19: `InitP[[*, a: int]]` is not assignable to attribute `t` with type `InitP[[a: int]]` [bad-assignment] +ERROR generics_paramspec_variance.py:63:12-20: `InitP[[a: int, /]]` is not assignable to attribute `t` with type `InitP[[a: int]]` [bad-assignment] +ERROR generics_paramspec_variance.py:65:12-22: `InitP[[b: int]]` is not assignable to attribute `t` with type `InitP[[a: int]]` [bad-assignment] +ERROR generics_paramspec_variance.py:69:12-22: `InitP[[a: int, b: str]]` is not assignable to attribute `t` with type `InitP[[a: int]]` [bad-assignment] +ERROR generics_paramspec_variance.py:88:13-24: `OutitP[[b: int]]` is not assignable to attribute `t` with type `OutitP[[a: int]]` [bad-assignment] +ERROR generics_paramspec_variance.py:90:13-26: `OutitP[[a: int = 1]]` is not assignable to attribute `t` with type `OutitP[[a: int]]` [bad-assignment] +ERROR generics_paramspec_variance.py:92:13-24: `OutitP[[a: int, b: str]]` is not assignable to attribute `t` with type `OutitP[[a: int]]` [bad-assignment] +ERROR generics_paramspec_variance.py:97:24-42: Unexpected keyword argument `contravariant` to ParamSpec [invalid-param-spec] +ERROR generics_paramspec_variance.py:98:26-40: Unexpected keyword argument `covariant` to ParamSpec [invalid-param-spec] +ERROR generics_paramspec_variance.py:99:30-49: Unexpected keyword argument `infer_variance` to ParamSpec [invalid-param-spec] +ERROR generics_paramspec_variance.py:100:28-42: Unexpected keyword argument `covariant` to ParamSpec [invalid-param-spec] +ERROR generics_paramspec_variance.py:100:44-62: Unexpected keyword argument `contravariant` to ParamSpec [invalid-param-spec] +ERROR generics_paramspec_variance.py:101:28-42: Unexpected keyword argument `covariant` to ParamSpec [invalid-param-spec] +ERROR generics_paramspec_variance.py:101:44-63: Unexpected keyword argument `infer_variance` to ParamSpec [invalid-param-spec] +ERROR generics_paramspec_variance.py:102:28-46: Unexpected keyword argument `contravariant` to ParamSpec [invalid-param-spec] +ERROR generics_paramspec_variance.py:102:48-67: Unexpected keyword argument `infer_variance` to ParamSpec [invalid-param-spec] +ERROR generics_paramspec_variance.py:110:14-43: `InvariantParamSpecOld[[bool]]` is not assignable to variable `in_out_old` with type `InvariantParamSpecOld[[int]]` [bad-assignment] +ERROR generics_paramspec_variance.py:111:14-45: `InvariantParamSpecOld[[object]]` is not assignable to variable `in_out_old` with type `InvariantParamSpecOld[[int]]` [bad-assignment] +ERROR generics_paramspec_variance.py:121:49-81: `ContravariantParamSpecOld[[int]]` is not assignable to `ContravariantParamSpecOld[[object]]` [bad-assignment] +ERROR generics_paramspec_variance.py:122:46-81: `ContravariantParamSpecOld[[object]]` is not assignable to `ContravariantParamSpecOld[[int]]` [bad-assignment] +ERROR generics_paramspec_variance.py:132:43-74: `CovariantParamSpecOld[[object]]` is not assignable to `CovariantParamSpecOld[[int]]` [bad-assignment] +ERROR generics_paramspec_variance.py:133:46-74: `CovariantParamSpecOld[[int]]` is not assignable to `CovariantParamSpecOld[[object]]` [bad-assignment] +ERROR generics_paramspec_variance.py:142:63-103: `InferredContravariantParamSpecOld[[int]]` is not assignable to `InferredContravariantParamSpecOld[[object]]` [bad-assignment] +ERROR generics_paramspec_variance.py:143:60-103: `InferredContravariantParamSpecOld[[object]]` is not assignable to `InferredContravariantParamSpecOld[[int]]` [bad-assignment] +ERROR generics_paramspec_variance.py:151:57-96: `InferredCovariantParamSpecOld[[object]]` is not assignable to `InferredCovariantParamSpecOld[[int]]` [bad-assignment] +ERROR generics_paramspec_variance.py:152:60-96: `InferredCovariantParamSpecOld[[int]]` is not assignable to `InferredCovariantParamSpecOld[[object]]` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/generics_scoping.toml b/conformance/results/pyrefly/generics_scoping.toml new file mode 100644 index 000000000..151b2f8e5 --- /dev/null +++ b/conformance/results/pyrefly/generics_scoping.toml @@ -0,0 +1,21 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_scoping.py:16:12-34: assert_type(int, Literal[1]) failed [assert-type] +ERROR generics_scoping.py:20:12-38: assert_type(str, Literal['a']) failed [assert-type] +ERROR generics_scoping.py:34:10-13: Argument `Literal['a']` is not assignable to parameter `x` with type `int` in function `MyClass.meth_2` [bad-argument-type] +ERROR generics_scoping.py:50:12-48: assert_type(str, Literal['abc']) failed [assert-type] +ERROR generics_scoping.py:54:12-50: assert_type(bytes, Literal[b'abc']) failed [assert-type] +ERROR generics_scoping.py:61:8-15: Type variable `S` is not in scope [invalid-type-var] +ERROR generics_scoping.py:65:14-21: Type variable `S` is not in scope [invalid-type-var] +ERROR generics_scoping.py:76:29-30: Type parameter `T` shadows a type parameter of the same name from an enclosing scope [invalid-type-var] +ERROR generics_scoping.py:86:24-25: Type parameter `T` shadows a type parameter of the same name from an enclosing scope [invalid-type-var] +ERROR generics_scoping.py:89:12-19: Type variable `T` is not in scope [invalid-type-var] +ERROR generics_scoping.py:91:36-37: Type parameter `T` shadows a type parameter of the same name from an enclosing scope [invalid-type-var] +ERROR generics_scoping.py:98:24-31: Type variable `T` is not in scope [invalid-type-var] +ERROR generics_scoping.py:105:14-15: Type variable `T` is not in scope [invalid-type-var] +ERROR generics_scoping.py:106:14-21: Type variable `T` is not in scope [invalid-type-var] +ERROR generics_scoping.py:107:1-8: Type variable `T` is not in scope [invalid-type-var] +""" diff --git a/conformance/results/pyrefly/generics_self_advanced.toml b/conformance/results/pyrefly/generics_self_advanced.toml new file mode 100644 index 000000000..797430280 --- /dev/null +++ b/conformance/results/pyrefly/generics_self_advanced.toml @@ -0,0 +1,9 @@ +conformant = "Pass" +notes = """ +Treats attributes not initialized on the class as instance-only. +""" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pyrefly/generics_self_attributes.toml b/conformance/results/pyrefly/generics_self_attributes.toml new file mode 100644 index 000000000..d1b89fa7c --- /dev/null +++ b/conformance/results/pyrefly/generics_self_attributes.toml @@ -0,0 +1,8 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_self_attributes.py:26:38-62: Argument `LinkedList[int]` is not assignable to parameter `next` with type `OrdinalLinkedList | None` in function `OrdinalLinkedList.__init__` [bad-argument-type] +ERROR generics_self_attributes.py:32:15-50: `LinkedList[int]` is not assignable to attribute `next` with type `OrdinalLinkedList | None` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/generics_self_basic.toml b/conformance/results/pyrefly/generics_self_basic.toml new file mode 100644 index 000000000..4d20a9e48 --- /dev/null +++ b/conformance/results/pyrefly/generics_self_basic.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_self_basic.py:20:16-23: Returned type `Shape` is not assignable to declared return type `Self@Shape` [bad-return] +ERROR generics_self_basic.py:33:16-23: Returned type `Shape` is not assignable to declared return type `Self@Shape` [bad-return] +ERROR generics_self_basic.py:68:26-35: `Self` may not be subscripted [invalid-annotation] +""" diff --git a/conformance/results/pyrefly/generics_self_protocols.toml b/conformance/results/pyrefly/generics_self_protocols.toml new file mode 100644 index 000000000..75aead9ff --- /dev/null +++ b/conformance/results/pyrefly/generics_self_protocols.toml @@ -0,0 +1,8 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_self_protocols.py:61:19-34: Argument `BadReturnType` is not assignable to parameter `shape` with type `ShapeProtocol` in function `accepts_shape` [bad-argument-type] +ERROR generics_self_protocols.py:64:19-41: Argument `ReturnDifferentClass` is not assignable to parameter `shape` with type `ShapeProtocol` in function `accepts_shape` [bad-argument-type] +""" diff --git a/conformance/results/pyrefly/generics_self_usage.toml b/conformance/results/pyrefly/generics_self_usage.toml new file mode 100644 index 000000000..ea9b7b8b2 --- /dev/null +++ b/conformance/results/pyrefly/generics_self_usage.toml @@ -0,0 +1,18 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_self_usage.py:73:14-18: `Self` must appear within a class [invalid-annotation] +ERROR generics_self_usage.py:73:23-27: `Self` must appear within a class [invalid-annotation] +ERROR generics_self_usage.py:76:6-10: `Self` must appear within a class [invalid-annotation] +ERROR generics_self_usage.py:82:9-37: `Self` cannot be used when `self` has an explicit TypeVar annotation [invalid-annotation] +ERROR generics_self_usage.py:87:16-22: Returned type `Foo3` is not assignable to declared return type `Self@Foo3` [bad-return] +ERROR generics_self_usage.py:103:15-19: `Self` must appear within a class [invalid-annotation] +ERROR generics_self_usage.py:105:12-16: `Self` must appear within a class [invalid-annotation] +ERROR generics_self_usage.py:105:12-16: Invalid base class: `Self` [invalid-inheritance] +ERROR generics_self_usage.py:108:30-34: `Self` must appear within a class [invalid-annotation] +ERROR generics_self_usage.py:113:9-13: `Self` cannot be used in a static method [invalid-annotation] +ERROR generics_self_usage.py:118:9-25: `Self` cannot be used in a static method [invalid-annotation] +ERROR generics_self_usage.py:123:37-41: `Self` cannot be used in a metaclass [invalid-annotation] +ERROR generics_self_usage.py:127:42-46: `Self` cannot be used in a metaclass [invalid-annotation] +""" diff --git a/conformance/results/pyrefly/generics_syntax_compatibility.toml b/conformance/results/pyrefly/generics_syntax_compatibility.toml new file mode 100644 index 000000000..6dba07458 --- /dev/null +++ b/conformance/results/pyrefly/generics_syntax_compatibility.toml @@ -0,0 +1,9 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_syntax_compatibility.py:14:7-13: Class `ClassA` uses type variables not specified in `Generic` or `Protocol` base [invalid-type-var] +ERROR generics_syntax_compatibility.py:14:22-23: Type parameter `K` is not included in the type parameter list [invalid-type-var] +ERROR generics_syntax_compatibility.py:26:35-36: Type parameter `K` is not included in the type parameter list [invalid-type-var] +""" diff --git a/conformance/results/pyrefly/generics_syntax_declarations.toml b/conformance/results/pyrefly/generics_syntax_declarations.toml new file mode 100644 index 000000000..def48a460 --- /dev/null +++ b/conformance/results/pyrefly/generics_syntax_declarations.toml @@ -0,0 +1,16 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_syntax_declarations.py:17:7-13: Redundant type parameter declaration [invalid-type-var] +ERROR generics_syntax_declarations.py:25:7-13: Redundant type parameter declaration [invalid-type-var] +ERROR generics_syntax_declarations.py:32:9-21: Object of class `str` has no attribute `is_integer` [missing-attribute] +ERROR generics_syntax_declarations.py:44:31-32: Type variable `V` is not in scope [invalid-type-var] +ERROR generics_syntax_declarations.py:48:17-27: Expected a type form, got instance of `list[type[int] | type[str]]` [not-a-type] +ERROR generics_syntax_declarations.py:60:17-19: Expected at least 2 constraints in TypeVar `T`, got 0 [invalid-type-var] +ERROR generics_syntax_declarations.py:64:17-23: Expected at least 2 constraints in TypeVar `T`, got 1 [invalid-type-var] +ERROR generics_syntax_declarations.py:71:17-19: Expected a type form, got instance of `tuple[type[bytes], type[str]]` [not-a-type] +ERROR generics_syntax_declarations.py:75:18-19: Expected a type form, got instance of `Literal[3]` [not-a-type] +ERROR generics_syntax_declarations.py:79:23-24: Could not find name `S` [unknown-name] +""" diff --git a/conformance/results/pyrefly/generics_syntax_infer_variance.toml b/conformance/results/pyrefly/generics_syntax_infer_variance.toml new file mode 100644 index 000000000..422d6031b --- /dev/null +++ b/conformance/results/pyrefly/generics_syntax_infer_variance.toml @@ -0,0 +1,24 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_syntax_infer_variance.py:15:36-55: Contradictory variance specifications [invalid-type-var] +ERROR generics_syntax_infer_variance.py:17:40-59: Contradictory variance specifications [invalid-type-var] +ERROR generics_syntax_infer_variance.py:29:35-62: `ShouldBeCovariant1[float]` is not assignable to `ShouldBeCovariant1[int]` [bad-assignment] +ERROR generics_syntax_infer_variance.py:47:35-62: `ShouldBeCovariant2[float]` is not assignable to `ShouldBeCovariant2[int]` [bad-assignment] +ERROR generics_syntax_infer_variance.py:56:35-62: `ShouldBeCovariant3[float]` is not assignable to `ShouldBeCovariant3[int]` [bad-assignment] +ERROR generics_syntax_infer_variance.py:85:34-64: `ShouldBeCovariant5[float]` is not assignable to `ShouldBeCovariant5[int]` [bad-assignment] +ERROR generics_syntax_infer_variance.py:96:34-64: `ShouldBeCovariant6[float]` is not assignable to `ShouldBeCovariant6[int]` [bad-assignment] +ERROR generics_syntax_infer_variance.py:112:38-64: `ShouldBeInvariant1[int]` is not assignable to `ShouldBeInvariant1[float]` [bad-assignment] +ERROR generics_syntax_infer_variance.py:113:36-66: `ShouldBeInvariant1[float]` is not assignable to `ShouldBeInvariant1[int]` [bad-assignment] +ERROR generics_syntax_infer_variance.py:127:38-64: `ShouldBeInvariant2[int]` is not assignable to `ShouldBeInvariant2[float]` [bad-assignment] +ERROR generics_syntax_infer_variance.py:128:36-66: `ShouldBeInvariant2[float]` is not assignable to `ShouldBeInvariant2[int]` [bad-assignment] +ERROR generics_syntax_infer_variance.py:135:43-73: `ShouldBeInvariant3[int, str]` is not assignable to `ShouldBeInvariant3[float, str]` [bad-assignment] +ERROR generics_syntax_infer_variance.py:136:41-73: `ShouldBeInvariant3[float, str]` is not assignable to `ShouldBeInvariant3[int, str]` [bad-assignment] +ERROR generics_syntax_infer_variance.py:137:43-73: `ShouldBeInvariant3[str, int]` is not assignable to `ShouldBeInvariant3[str, float]` [bad-assignment] +ERROR generics_syntax_infer_variance.py:138:41-73: `ShouldBeInvariant3[str, float]` is not assignable to `ShouldBeInvariant3[str, int]` [bad-assignment] +ERROR generics_syntax_infer_variance.py:146:38-64: `ShouldBeInvariant4[int]` is not assignable to `ShouldBeInvariant4[float]` [bad-assignment] +ERROR generics_syntax_infer_variance.py:154:38-64: `ShouldBeInvariant5[int]` is not assignable to `ShouldBeInvariant5[float]` [bad-assignment] +ERROR generics_syntax_infer_variance.py:165:45-75: `ShouldBeContravariant1[int]` is not assignable to `ShouldBeContravariant1[float]` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/generics_syntax_scoping.toml b/conformance/results/pyrefly/generics_syntax_scoping.toml new file mode 100644 index 000000000..2034cb3ed --- /dev/null +++ b/conformance/results/pyrefly/generics_syntax_scoping.toml @@ -0,0 +1,13 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_syntax_scoping.py:14:20-31: Type variable bounds and constraints must be concrete [invalid-annotation] +ERROR generics_syntax_scoping.py:18:26-27: Expected a type form, got instance of `int` [not-a-type] +ERROR generics_syntax_scoping.py:26:7-8: `T` is uninitialized [unbound-name] +ERROR generics_syntax_scoping.py:35:17-18: Expected a type form, got instance of `int` [not-a-type] +ERROR generics_syntax_scoping.py:83:17-18: Type parameter `T` shadows a type parameter of the same name from an enclosing scope [invalid-type-var] +ERROR generics_syntax_scoping.py:86:17-18: Type parameter `T` shadows a type parameter of the same name from an enclosing scope [invalid-type-var] +ERROR generics_syntax_scoping.py:89:17-18: Type parameter `T` shadows a type parameter of the same name from an enclosing scope [invalid-type-var] +""" diff --git a/conformance/results/pyrefly/generics_type_erasure.toml b/conformance/results/pyrefly/generics_type_erasure.toml new file mode 100644 index 000000000..efb957387 --- /dev/null +++ b/conformance/results/pyrefly/generics_type_erasure.toml @@ -0,0 +1,13 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_type_erasure.py:38:16-18: Argument `Literal['']` is not assignable to parameter `label` with type `int | None` in function `Node.__init__` [bad-argument-type] +ERROR generics_type_erasure.py:40:16-17: Argument `Literal[0]` is not assignable to parameter `label` with type `str | None` in function `Node.__init__` [bad-argument-type] +ERROR generics_type_erasure.py:42:1-16: Generic attribute `label` of class `Node` is not visible on the class [no-access] +ERROR generics_type_erasure.py:43:1-16: Generic attribute `label` of class `Node` is not visible on the class [missing-attribute] +ERROR generics_type_erasure.py:44:1-11: Generic attribute `label` of class `Node` is not visible on the class [no-access] +ERROR generics_type_erasure.py:45:1-11: Generic attribute `label` of class `Node` is not visible on the class [missing-attribute] +ERROR generics_type_erasure.py:46:1-15: Generic attribute `label` of class `Node` is not visible on the class [missing-attribute] +""" diff --git a/conformance/results/pyrefly/generics_typevartuple_args.toml b/conformance/results/pyrefly/generics_typevartuple_args.toml new file mode 100644 index 000000000..9db9ebae3 --- /dev/null +++ b/conformance/results/pyrefly/generics_typevartuple_args.toml @@ -0,0 +1,14 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_typevartuple_args.py:33:12-23: Unpacked argument `tuple[Literal[0], Literal['']]` is not assignable to parameter `*args` with type `tuple[*@_, Env]` in function `exec_le` [bad-argument-type] +ERROR generics_typevartuple_args.py:34:12-34: Unpacked argument `tuple[Literal[0], Literal['']]` is not assignable to parameter `*args` with type `tuple[*@_, Env]` in function `exec_le` [bad-argument-type] +ERROR generics_typevartuple_args.py:48:6-17: Unpacked argument `tuple[Literal[1], Literal['2'], Literal[3]]` is not assignable to parameter `*args` with type `tuple[int, ...]` in function `func1` [bad-argument-type] +ERROR generics_typevartuple_args.py:57:6-16: Unpacked argument `tuple[Literal[1], Literal[1], Literal['']]` is not assignable to parameter `*args` with type `tuple[int, *tuple[str, ...], str]` in function `func2` [bad-argument-type] +ERROR generics_typevartuple_args.py:58:6-9: Unpacked argument `tuple[Literal[1]]` is not assignable to parameter `*args` with type `tuple[int, *tuple[str, ...], str]` in function `func2` [bad-argument-type] +ERROR generics_typevartuple_args.py:59:6-10: Unpacked argument `tuple[Literal['']]` is not assignable to parameter `*args` with type `tuple[int, *tuple[str, ...], str]` in function `func2` [bad-argument-type] +ERROR generics_typevartuple_args.py:67:6-9: Expected 1 more positional argument in function `func3` [bad-argument-count] +ERROR generics_typevartuple_args.py:75:13-19: Argument `tuple[Literal[1], Literal[2]]` is not assignable to parameter `*args` with type `tuple[int]` in function `func4` [bad-argument-type] +""" diff --git a/conformance/results/pyrefly/generics_typevartuple_basic.toml b/conformance/results/pyrefly/generics_typevartuple_basic.toml new file mode 100644 index 000000000..df28e1648 --- /dev/null +++ b/conformance/results/pyrefly/generics_typevartuple_basic.toml @@ -0,0 +1,20 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_typevartuple_basic.py:43:34-43: Argument `Height` is not assignable to parameter `shape` with type `tuple[*@_]` in function `Array.__init__` [bad-argument-type] +ERROR generics_typevartuple_basic.py:44:35-62: `Array[Batch, Width]` is not assignable to `Array[Batch, Height, Width]` [bad-assignment] +ERROR generics_typevartuple_basic.py:45:41-47:2: `Array[Time, Batch, Width, Height]` is not assignable to `Array[Time, Batch, Height, Width]` [bad-assignment] +ERROR generics_typevartuple_basic.py:53:22-27: `TypeVarTuple` must be unpacked [invalid-annotation] +ERROR generics_typevartuple_basic.py:54:37-42: `TypeVarTuple` must be unpacked [invalid-type-var-tuple] +ERROR generics_typevartuple_basic.py:57:34-39: `TypeVarTuple` must be unpacked [invalid-type-var-tuple] +ERROR generics_typevartuple_basic.py:60:24-29: `TypeVarTuple` must be unpacked [invalid-annotation] +ERROR generics_typevartuple_basic.py:66:27-30: Unexpected positional argument to TypeVarTuple [invalid-type-var-tuple] +ERROR generics_typevartuple_basic.py:67:27-36: Unexpected keyword argument `bound` to TypeVarTuple [invalid-type-var-tuple] +ERROR generics_typevartuple_basic.py:91:15-19: Argument `tuple[Literal[0]]` is not assignable to parameter `arg2` with type `tuple[int, int]` in function `func2` [bad-argument-type] +ERROR generics_typevartuple_basic.py:100:17-18: Argument `Array[Width]` is not assignable to parameter `y` with type `Array[Height]` in function `multiply` [bad-argument-type] +ERROR generics_typevartuple_basic.py:101:17-18: Argument `Array[Height, Width]` is not assignable to parameter `y` with type `Array[Height]` in function `multiply` [bad-argument-type] +ERROR generics_typevartuple_basic.py:107:7-13: Type parameters for class may not have more than one TypeVarTuple [invalid-type-var-tuple] +ERROR generics_typevartuple_basic.py:111:7-13: Type parameters for class may not have more than one TypeVarTuple [invalid-type-var-tuple] +""" diff --git a/conformance/results/pyrefly/generics_typevartuple_callable.toml b/conformance/results/pyrefly/generics_typevartuple_callable.toml new file mode 100644 index 000000000..4c3a32c03 --- /dev/null +++ b/conformance/results/pyrefly/generics_typevartuple_callable.toml @@ -0,0 +1,7 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_typevartuple_callable.py:26:28-35: Argument `tuple[Literal[''], Literal[0]]` is not assignable to parameter `args` with type `tuple[int, str]` in function `Process.__init__` [bad-argument-type] +""" diff --git a/conformance/results/pyrefly/generics_typevartuple_concat.toml b/conformance/results/pyrefly/generics_typevartuple_concat.toml new file mode 100644 index 000000000..be211bd5b --- /dev/null +++ b/conformance/results/pyrefly/generics_typevartuple_concat.toml @@ -0,0 +1,6 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pyrefly/generics_typevartuple_overloads.toml b/conformance/results/pyrefly/generics_typevartuple_overloads.toml new file mode 100644 index 000000000..be211bd5b --- /dev/null +++ b/conformance/results/pyrefly/generics_typevartuple_overloads.toml @@ -0,0 +1,6 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pyrefly/generics_typevartuple_specialization.toml b/conformance/results/pyrefly/generics_typevartuple_specialization.toml new file mode 100644 index 000000000..e5dcdaff5 --- /dev/null +++ b/conformance/results/pyrefly/generics_typevartuple_specialization.toml @@ -0,0 +1,12 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_typevartuple_specialization.py:109:1-21: Unpacked argument cannot be used for type parameter T [bad-unpacking] +ERROR generics_typevartuple_specialization.py:110:1-36: Unpacked argument cannot be used for type parameter T [bad-unpacking] +ERROR generics_typevartuple_specialization.py:121:26-29: Only one unbounded type is allowed to be unpacked [bad-unpacking] +ERROR generics_typevartuple_specialization.py:122:26-42: Only one unbounded type is allowed to be unpacked [bad-unpacking] +ERROR generics_typevartuple_specialization.py:127:5-13: Expected 3 type arguments for `TA7`, got 1 [bad-specialization] +ERROR generics_typevartuple_specialization.py:163:8-18: Unpacked argument cannot be used for type parameter T [bad-unpacking] +""" diff --git a/conformance/results/pyrefly/generics_typevartuple_unpack.toml b/conformance/results/pyrefly/generics_typevartuple_unpack.toml new file mode 100644 index 000000000..300385ff4 --- /dev/null +++ b/conformance/results/pyrefly/generics_typevartuple_unpack.toml @@ -0,0 +1,7 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_typevartuple_unpack.py:30:28-29: Argument `Array[Batch]` is not assignable to parameter `x` with type `Array[Batch, *tuple[Any, ...], Channels]` in function `process_batch_channels` [bad-argument-type] +""" diff --git a/conformance/results/pyrefly/generics_typevartuple_variance.toml b/conformance/results/pyrefly/generics_typevartuple_variance.toml new file mode 100644 index 000000000..67528a194 --- /dev/null +++ b/conformance/results/pyrefly/generics_typevartuple_variance.toml @@ -0,0 +1,49 @@ +conformant = "Unsupported" +conformance_automated = "Fail" +errors_diff = """ +Line 79: Expected 1 errors +Line 90: Expected 1 errors +Line 55: Unexpected errors ['Unexpected keyword argument `infer_variance` to TypeVarTuple [invalid-type-var-tuple]'] +Line 73: Unexpected errors ['Unexpected keyword argument `contravariant` to TypeVarTuple [invalid-type-var-tuple]'] +Line 84: Unexpected errors ['`ContravariantTypeVarTupleOld[object]` is not assignable to `ContravariantTypeVarTupleOld[int]` [bad-assignment]'] +Line 87: Unexpected errors ['Unexpected keyword argument `covariant` to TypeVarTuple [invalid-type-var-tuple]'] +Line 98: Unexpected errors ['`CovariantTypeVarTupleOld[int]` is not assignable to `CovariantTypeVarTupleOld[object]` [bad-assignment]'] +Line 108: Unexpected errors ['`InferredContravariantTypeVarTupleOld[object]` is not assignable to `InferredContravariantTypeVarTupleOld[int]` [bad-assignment]'] +Line 117: Unexpected errors ['`InferredCovariantTypeVarTupleOld[int]` is not assignable to `InferredCovariantTypeVarTupleOld[object]` [bad-assignment]'] +""" +output = """ +ERROR generics_typevartuple_variance.py:14:45-73: `InvariantTypeVarTuple[int]` is not assignable to `InvariantTypeVarTuple[object]` [bad-assignment] +ERROR generics_typevartuple_variance.py:15:42-73: `InvariantTypeVarTuple[object]` is not assignable to `InvariantTypeVarTuple[int]` [bad-assignment] +ERROR generics_typevartuple_variance.py:17:64-108: `InvariantTypeVarTuple[*tuple[object, ...]]` is not assignable to `InvariantTypeVarTuple[*tuple[int, ...]]` [bad-assignment] +ERROR generics_typevartuple_variance.py:18:70-111: `InvariantTypeVarTuple[*tuple[int, ...]]` is not assignable to `InvariantTypeVarTuple[*tuple[object, ...]]` [bad-assignment] +ERROR generics_typevartuple_variance.py:20:58-99: `InvariantTypeVarTuple[*tuple[int, ...]]` is not assignable to `InvariantTypeVarTuple[int]` [bad-assignment] +ERROR generics_typevartuple_variance.py:21:71-99: `InvariantTypeVarTuple[int]` is not assignable to `InvariantTypeVarTuple[*tuple[int, ...]]` [bad-assignment] +ERROR generics_typevartuple_variance.py:28:53-93: `ContravariantTypeVarTuple[object, int]` is not assignable to `ContravariantTypeVarTuple[object, object]` [bad-assignment] +ERROR generics_typevartuple_variance.py:31:70-115: `ContravariantTypeVarTuple[*tuple[int, ...]]` is not assignable to `ContravariantTypeVarTuple[*tuple[object, ...]]` [bad-assignment] +ERROR generics_typevartuple_variance.py:34:71-103: `ContravariantTypeVarTuple[int]` is not assignable to `ContravariantTypeVarTuple[*tuple[int, ...]]` [bad-assignment] +ERROR generics_typevartuple_variance.py:42:39-70: `CovariantTypeVarTuple[object]` is not assignable to `CovariantTypeVarTuple[int]` [bad-assignment] +ERROR generics_typevartuple_variance.py:45:50-88: `CovariantTypeVarTuple[bool, object]` is not assignable to `CovariantTypeVarTuple[int, int]` [bad-assignment] +ERROR generics_typevartuple_variance.py:46:50-88: `CovariantTypeVarTuple[object, bool]` is not assignable to `CovariantTypeVarTuple[int, int]` [bad-assignment] +ERROR generics_typevartuple_variance.py:47:50-90: `CovariantTypeVarTuple[object, object]` is not assignable to `CovariantTypeVarTuple[int, int]` [bad-assignment] +ERROR generics_typevartuple_variance.py:48:61-105: `CovariantTypeVarTuple[*tuple[object, ...]]` is not assignable to `CovariantTypeVarTuple[*tuple[int, ...]]` [bad-assignment] +ERROR generics_typevartuple_variance.py:51:55-96: `CovariantTypeVarTuple[*tuple[int, ...]]` is not assignable to `CovariantTypeVarTuple[int]` [bad-assignment] +ERROR generics_typevartuple_variance.py:55:35-54: Unexpected keyword argument `infer_variance` to TypeVarTuple [invalid-type-var-tuple] +ERROR generics_typevartuple_variance.py:56:33-47: Unexpected keyword argument `covariant` to TypeVarTuple [invalid-type-var-tuple] +ERROR generics_typevartuple_variance.py:56:49-67: Unexpected keyword argument `contravariant` to TypeVarTuple [invalid-type-var-tuple] +ERROR generics_typevartuple_variance.py:57:33-47: Unexpected keyword argument `covariant` to TypeVarTuple [invalid-type-var-tuple] +ERROR generics_typevartuple_variance.py:57:49-68: Unexpected keyword argument `infer_variance` to TypeVarTuple [invalid-type-var-tuple] +ERROR generics_typevartuple_variance.py:58:33-51: Unexpected keyword argument `contravariant` to TypeVarTuple [invalid-type-var-tuple] +ERROR generics_typevartuple_variance.py:58:53-72: Unexpected keyword argument `infer_variance` to TypeVarTuple [invalid-type-var-tuple] +ERROR generics_typevartuple_variance.py:68:45-76: `InvariantTypeVarTupleOld[int]` is not assignable to `InvariantTypeVarTupleOld[object]` [bad-assignment] +ERROR generics_typevartuple_variance.py:69:42-76: `InvariantTypeVarTupleOld[object]` is not assignable to `InvariantTypeVarTupleOld[int]` [bad-assignment] +ERROR generics_typevartuple_variance.py:73:29-47: Unexpected keyword argument `contravariant` to TypeVarTuple [invalid-type-var-tuple] +ERROR generics_typevartuple_variance.py:83:52-87: `ContravariantTypeVarTupleOld[int]` is not assignable to `ContravariantTypeVarTupleOld[object]` [bad-assignment] +ERROR generics_typevartuple_variance.py:84:49-87: `ContravariantTypeVarTupleOld[object]` is not assignable to `ContravariantTypeVarTupleOld[int]` [bad-assignment] +ERROR generics_typevartuple_variance.py:87:31-45: Unexpected keyword argument `covariant` to TypeVarTuple [invalid-type-var-tuple] +ERROR generics_typevartuple_variance.py:97:46-80: `CovariantTypeVarTupleOld[object]` is not assignable to `CovariantTypeVarTupleOld[int]` [bad-assignment] +ERROR generics_typevartuple_variance.py:98:49-80: `CovariantTypeVarTupleOld[int]` is not assignable to `CovariantTypeVarTupleOld[object]` [bad-assignment] +ERROR generics_typevartuple_variance.py:107:66-109: `InferredContravariantTypeVarTupleOld[int]` is not assignable to `InferredContravariantTypeVarTupleOld[object]` [bad-assignment] +ERROR generics_typevartuple_variance.py:108:63-109: `InferredContravariantTypeVarTupleOld[object]` is not assignable to `InferredContravariantTypeVarTupleOld[int]` [bad-assignment] +ERROR generics_typevartuple_variance.py:116:60-102: `InferredCovariantTypeVarTupleOld[object]` is not assignable to `InferredCovariantTypeVarTupleOld[int]` [bad-assignment] +ERROR generics_typevartuple_variance.py:117:63-102: `InferredCovariantTypeVarTupleOld[int]` is not assignable to `InferredCovariantTypeVarTupleOld[object]` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/generics_upper_bound.toml b/conformance/results/pyrefly/generics_upper_bound.toml new file mode 100644 index 000000000..58dd424cd --- /dev/null +++ b/conformance/results/pyrefly/generics_upper_bound.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +conformant = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_upper_bound.py:24:38-45: Type variable bounds and constraints must be concrete [invalid-annotation] +ERROR generics_upper_bound.py:44:16-54: assert_type(list[int] | set[int], Collection[int]) failed [assert-type] +ERROR generics_upper_bound.py:52:7-13: `int` is not assignable to upper bound `Sized` of type variable `ST` [bad-specialization] +ERROR generics_upper_bound.py:57:38-49: TypeVar cannot have both constraints and bound [invalid-type-var] +""" diff --git a/conformance/results/pyrefly/generics_variance.toml b/conformance/results/pyrefly/generics_variance.toml new file mode 100644 index 000000000..ea219502b --- /dev/null +++ b/conformance/results/pyrefly/generics_variance.toml @@ -0,0 +1,19 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_variance.py:14:36-54: Contradictory variance specifications [invalid-type-var] +ERROR generics_variance.py:77:14-23: Type variable `T_co` is covariant but is used in invariant position [invalid-variance] +ERROR generics_variance.py:81:14-27: Type variable `T_contra` is contravariant but is used in invariant position [invalid-variance] +ERROR generics_variance.py:93:17-29: Type variable `T_contra` is contravariant but is used in covariant position [invalid-variance] +ERROR generics_variance.py:105:21-33: Type variable `T_co` is covariant but is used in contravariant position [invalid-variance] +ERROR generics_variance.py:113:21-37: Type variable `T_co` is covariant but is used in contravariant position [invalid-variance] +ERROR generics_variance.py:126:5-25: Type variable `T_co` is covariant but is used in contravariant position [invalid-variance] +ERROR generics_variance.py:132:5-33: Type variable `T_contra` is contravariant but is used in covariant position [invalid-variance] +ERROR generics_variance.py:142:5-33: Type variable `T_co` is covariant but is used in contravariant position [invalid-variance] +ERROR generics_variance.py:163:26-54: Type variable `T_contra` is contravariant but is used in covariant position [invalid-variance] +ERROR generics_variance.py:167:30-58: Type variable `T_co` is covariant but is used in contravariant position [invalid-variance] +ERROR generics_variance.py:191:33-70: Type variable `T_contra` is contravariant but is used in covariant position [invalid-variance] +ERROR generics_variance.py:196:5-42: Type variable `T_co` is covariant but is used in contravariant position [invalid-variance] +""" diff --git a/conformance/results/pyrefly/generics_variance_inference.toml b/conformance/results/pyrefly/generics_variance_inference.toml new file mode 100644 index 000000000..612ceca73 --- /dev/null +++ b/conformance/results/pyrefly/generics_variance_inference.toml @@ -0,0 +1,30 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR generics_variance_inference.py:24:33-35: `ClassA[float, int, int]` is not assignable to `ClassA[int, int, int]` [bad-assignment] +ERROR generics_variance_inference.py:25:37-39: `ClassA[float, int, int]` is not assignable to `ClassA[float, float, int]` [bad-assignment] +ERROR generics_variance_inference.py:28:33-35: `ClassA[int, float, float]` is not assignable to `ClassA[int, int, int]` [bad-assignment] +ERROR generics_variance_inference.py:41:35-62: `ShouldBeCovariant1[float]` is not assignable to `ShouldBeCovariant1[int]` [bad-assignment] +ERROR generics_variance_inference.py:49:35-62: `ShouldBeCovariant2[float]` is not assignable to `ShouldBeCovariant2[int]` [bad-assignment] +ERROR generics_variance_inference.py:58:35-62: `ShouldBeCovariant3[float]` is not assignable to `ShouldBeCovariant3[int]` [bad-assignment] +ERROR generics_variance_inference.py:67:34-62: `ShouldBeCovariant4[float]` is not assignable to `ShouldBeCovariant4[int]` [bad-assignment] +ERROR generics_variance_inference.py:80:34-62: `ShouldBeCovariant5[float]` is not assignable to `ShouldBeCovariant5[int]` [bad-assignment] +ERROR generics_variance_inference.py:96:38-64: `ShouldBeInvariant1[int]` is not assignable to `ShouldBeInvariant1[float]` [bad-assignment] +ERROR generics_variance_inference.py:97:36-66: `ShouldBeInvariant1[float]` is not assignable to `ShouldBeInvariant1[int]` [bad-assignment] +ERROR generics_variance_inference.py:111:38-64: `ShouldBeInvariant2[int]` is not assignable to `ShouldBeInvariant2[float]` [bad-assignment] +ERROR generics_variance_inference.py:112:36-66: `ShouldBeInvariant2[float]` is not assignable to `ShouldBeInvariant2[int]` [bad-assignment] +ERROR generics_variance_inference.py:119:43-73: `ShouldBeInvariant3[int, str]` is not assignable to `ShouldBeInvariant3[float, str]` [bad-assignment] +ERROR generics_variance_inference.py:120:41-73: `ShouldBeInvariant3[float, str]` is not assignable to `ShouldBeInvariant3[int, str]` [bad-assignment] +ERROR generics_variance_inference.py:121:43-73: `ShouldBeInvariant3[str, int]` is not assignable to `ShouldBeInvariant3[str, float]` [bad-assignment] +ERROR generics_variance_inference.py:122:41-73: `ShouldBeInvariant3[str, float]` is not assignable to `ShouldBeInvariant3[str, int]` [bad-assignment] +ERROR generics_variance_inference.py:130:38-64: `ShouldBeInvariant4[int]` is not assignable to `ShouldBeInvariant4[float]` [bad-assignment] +ERROR generics_variance_inference.py:138:38-64: `ShouldBeInvariant5[int]` is not assignable to `ShouldBeInvariant5[float]` [bad-assignment] +ERROR generics_variance_inference.py:149:45-75: `ShouldBeContravariant1[int]` is not assignable to `ShouldBeContravariant1[float]` [bad-assignment] +ERROR generics_variance_inference.py:169:31-58: `ShouldBeInvariant6[float]` is not assignable to `ShouldBeInvariant6[int]` [bad-assignment] +ERROR generics_variance_inference.py:170:33-58: `ShouldBeInvariant6[int]` is not assignable to `ShouldBeInvariant6[float]` [bad-assignment] +ERROR generics_variance_inference.py:181:31-58: `ShouldBeCovariant6[float]` is not assignable to `ShouldBeCovariant6[int]` [bad-assignment] +ERROR generics_variance_inference.py:194:37-66: `ShouldBeContravariant2[int]` is not assignable to `ShouldBeContravariant2[float]` [bad-assignment] +ERROR generics_variance_inference.py:205:31-59: `ShouldBeCovariant7[object]` is not assignable to `ShouldBeCovariant7[int]` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/historical_positional.toml b/conformance/results/pyrefly/historical_positional.toml new file mode 100644 index 000000000..3242ab5da --- /dev/null +++ b/conformance/results/pyrefly/historical_positional.toml @@ -0,0 +1,10 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR historical_positional.py:18:4-7: Expected argument `__x` to be positional in function `f1` [unexpected-keyword] +ERROR historical_positional.py:26:16-19: Positional-only parameter `__y` cannot appear after keyword parameters [bad-function-definition] +ERROR historical_positional.py:54:26-29: Positional-only parameter `__y` cannot appear after keyword parameters [bad-function-definition] +ERROR historical_positional.py:59:6-9: Expected argument `__x` to be positional in function `A.m1` [unexpected-keyword] +""" diff --git a/conformance/results/pyrefly/literals_interactions.toml b/conformance/results/pyrefly/literals_interactions.toml new file mode 100644 index 000000000..451fa2d4b --- /dev/null +++ b/conformance/results/pyrefly/literals_interactions.toml @@ -0,0 +1,10 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR literals_interactions.py:14:7-8: Index 5 out of range for tuple with 3 elements [bad-index] +ERROR literals_interactions.py:15:7-8: Index -5 out of range for tuple with 3 elements [bad-index] +ERROR literals_interactions.py:16:7-8: Index 4 out of range for tuple with 3 elements [bad-index] +ERROR literals_interactions.py:17:7-9: Index -4 out of range for tuple with 3 elements [bad-index] +""" diff --git a/conformance/results/pyrefly/literals_literalstring.toml b/conformance/results/pyrefly/literals_literalstring.toml new file mode 100644 index 000000000..201849395 --- /dev/null +++ b/conformance/results/pyrefly/literals_literalstring.toml @@ -0,0 +1,16 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR literals_literalstring.py:36:29-42: Invalid type inside literal, `LiteralString` [invalid-literal] +ERROR literals_literalstring.py:37:22-35: Invalid type inside literal, `LiteralString` [invalid-literal] +ERROR literals_literalstring.py:43:23-24: `Literal['two']` is not assignable to `Literal['']` [bad-assignment] +ERROR literals_literalstring.py:65:25-45: `str` is not assignable to `LiteralString` [bad-assignment] +ERROR literals_literalstring.py:73:25-26: `Literal[3]` is not assignable to `LiteralString` [bad-assignment] +ERROR literals_literalstring.py:74:25-32: `Literal[b'test']` is not assignable to `LiteralString` [bad-assignment] +ERROR literals_literalstring.py:119:21-24: `str` is not assignable to upper bound `LiteralString` of type variable `TLiteral` [bad-specialization] +ERROR literals_literalstring.py:133:41-53: `Container[str]` is not assignable to `Container[LiteralString]` [bad-assignment] +ERROR literals_literalstring.py:133:50-53: `str` is not assignable to upper bound `LiteralString` of type variable `T` [bad-specialization] +ERROR literals_literalstring.py:171:21-24: `list[LiteralString]` is not assignable to `list[str]` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/literals_parameterizations.toml b/conformance/results/pyrefly/literals_parameterizations.toml new file mode 100644 index 000000000..e31da9df2 --- /dev/null +++ b/conformance/results/pyrefly/literals_parameterizations.toml @@ -0,0 +1,23 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR literals_parameterizations.py:41:15-20: Invalid literal expression [invalid-literal] +ERROR literals_parameterizations.py:42:15-38: Invalid literal expression [invalid-literal] +ERROR literals_parameterizations.py:43:15-21: Invalid literal expression [invalid-literal] +ERROR literals_parameterizations.py:44:15-17: Invalid literal expression [invalid-literal] +ERROR literals_parameterizations.py:45:15-24: Invalid literal expression [invalid-literal] +ERROR literals_parameterizations.py:46:7-33: `Literal` arguments cannot be parenthesized [invalid-literal] +ERROR literals_parameterizations.py:47:15-35: Invalid literal expression [invalid-literal] +ERROR literals_parameterizations.py:48:15-18: Invalid type inside literal, `int` [invalid-literal] +ERROR literals_parameterizations.py:49:15-23: Expected a type form, got instance of `Literal[3]` [not-a-type] +ERROR literals_parameterizations.py:50:16-17: Invalid type inside literal, `TypeVar[T]` [invalid-literal] +ERROR literals_parameterizations.py:51:16-20: Invalid literal expression [invalid-literal] +ERROR literals_parameterizations.py:52:16-19: Invalid type inside literal, `Any` [invalid-literal] +ERROR literals_parameterizations.py:53:16-19: Invalid literal expression [invalid-literal] +ERROR literals_parameterizations.py:56:28-33: Invalid literal expression [invalid-literal] +ERROR literals_parameterizations.py:60:4-11: Expected a type argument for `Literal` [invalid-annotation] +ERROR literals_parameterizations.py:61:12-23: Expected a type form, got instance of `(x: Unknown) -> int` [not-a-type] +ERROR literals_parameterizations.py:65:32-33: `Literal[Color.RED]` is not assignable to `Literal['Color.RED']` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/literals_semantics.toml b/conformance/results/pyrefly/literals_semantics.toml new file mode 100644 index 000000000..89fc09ba8 --- /dev/null +++ b/conformance/results/pyrefly/literals_semantics.toml @@ -0,0 +1,10 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR literals_semantics.py:10:18-19: `Literal[4]` is not assignable to `Literal[3]` [bad-assignment] +ERROR literals_semantics.py:24:26-27: `Literal[0]` is not assignable to `Literal[False]` [bad-assignment] +ERROR literals_semantics.py:25:22-23: `Literal[False]` is not assignable to `Literal[0]` [bad-assignment] +ERROR literals_semantics.py:33:5-11: Augmented assignment result `int` is not assignable to `Literal[3, 4, 5]` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/namedtuples_define_class.toml b/conformance/results/pyrefly/namedtuples_define_class.toml new file mode 100644 index 000000000..e98b6c716 --- /dev/null +++ b/conformance/results/pyrefly/namedtuples_define_class.toml @@ -0,0 +1,21 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR namedtuples_define_class.py:33:10-11: Index 3 out of range for tuple with 3 elements [bad-index] +ERROR namedtuples_define_class.py:34:10-12: Index -4 out of range for tuple with 3 elements [bad-index] +ERROR namedtuples_define_class.py:45:11-14: Missing argument `y` in function `Point.__new__` [missing-argument] +ERROR namedtuples_define_class.py:46:11-16: Missing argument `y` in function `Point.__new__` [missing-argument] +ERROR namedtuples_define_class.py:47:15-17: Argument `Literal['']` is not assignable to parameter `y` with type `int` in function `Point.__new__` [bad-argument-type] +ERROR namedtuples_define_class.py:48:24-25: Argument `Literal[3]` is not assignable to parameter `units` with type `str` in function `Point.__new__` [bad-argument-type] +ERROR namedtuples_define_class.py:49:22-24: Expected 3 positional arguments, got 4 in function `Point.__new__` [bad-argument-count] +ERROR namedtuples_define_class.py:50:23-28: Unexpected keyword argument `other` in function `Point.__new__` [unexpected-keyword] +ERROR namedtuples_define_class.py:70:20-22: Expected 2 positional arguments, got 3 in function `Point2.__new__` [bad-argument-count] +ERROR namedtuples_define_class.py:77:5-7: NamedTuple field name may not start with an underscore: `_y` [bad-class-definition] +ERROR namedtuples_define_class.py:87:5-13: NamedTuple field 'latitude' without a default may not follow NamedTuple field with a default [bad-class-definition] +ERROR namedtuples_define_class.py:107:5-6: Cannot override named tuple element `x` [bad-override] +ERROR namedtuples_define_class.py:121:24-25: Expected 2 positional arguments, got 3 in function `ConditionalField.__new__` [bad-argument-count] +ERROR namedtuples_define_class.py:140:19-22: Argument `float` is not assignable to parameter `value` with type `str` in function `Property.__new__` [bad-argument-type] +ERROR namedtuples_define_class.py:147:7-11: Named tuples do not support multiple inheritance [invalid-inheritance] +""" diff --git a/conformance/results/pyrefly/namedtuples_define_functional.toml b/conformance/results/pyrefly/namedtuples_define_functional.toml new file mode 100644 index 000000000..40c47f739 --- /dev/null +++ b/conformance/results/pyrefly/namedtuples_define_functional.toml @@ -0,0 +1,21 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR namedtuples_define_functional.py:16:14-19: Missing argument `y` in function `Point1.__new__` [missing-argument] +ERROR namedtuples_define_functional.py:21:14-16: Missing argument `x` in function `Point2.__new__` [missing-argument] +ERROR namedtuples_define_functional.py:21:14-16: Missing argument `y` in function `Point2.__new__` [missing-argument] +ERROR namedtuples_define_functional.py:26:21-22: Expected 2 positional arguments, got 3 in function `Point3.__new__` [bad-argument-count] +ERROR namedtuples_define_functional.py:31:14-22: Missing argument `y` in function `Point4.__new__` [missing-argument] +ERROR namedtuples_define_functional.py:31:18-19: Unexpected keyword argument `z` in function `Point4.__new__` [unexpected-keyword] +ERROR namedtuples_define_functional.py:36:18-21: Argument `Literal['1']` is not assignable to parameter `y` with type `int` in function `Point5.__new__` [bad-argument-type] +ERROR namedtuples_define_functional.py:37:21-22: Expected 2 positional arguments, got 3 in function `Point5.__new__` [bad-argument-count] +ERROR namedtuples_define_functional.py:42:18-21: Argument `Literal['1']` is not assignable to parameter `y` with type `int` in function `Point6.__new__` [bad-argument-type] +ERROR namedtuples_define_functional.py:43:17-20: Argument `float` is not assignable to parameter `x` with type `int` in function `Point6.__new__` [bad-argument-type] +ERROR namedtuples_define_functional.py:52:31-34: Duplicate field `a` [bad-class-definition] +ERROR namedtuples_define_functional.py:53:33-38: `def` is not a valid identifier [bad-class-definition] +ERROR namedtuples_define_functional.py:54:33-38: `def` is not a valid identifier [bad-class-definition] +ERROR namedtuples_define_functional.py:55:33-37: NamedTuple field name may not start with an underscore: `_d` [bad-class-definition] +ERROR namedtuples_define_functional.py:69:4-6: Missing argument `a` in function `NT7.__new__` [missing-argument] +""" diff --git a/conformance/results/pyrefly/namedtuples_type_compat.toml b/conformance/results/pyrefly/namedtuples_type_compat.toml new file mode 100644 index 000000000..83282a96f --- /dev/null +++ b/conformance/results/pyrefly/namedtuples_type_compat.toml @@ -0,0 +1,8 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR namedtuples_type_compat.py:22:23-24: `Point` is not assignable to `tuple[int, int]` [bad-assignment] +ERROR namedtuples_type_compat.py:23:28-29: `Point` is not assignable to `tuple[int, str, str]` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/namedtuples_usage.toml b/conformance/results/pyrefly/namedtuples_usage.toml new file mode 100644 index 000000000..fb3a165ad --- /dev/null +++ b/conformance/results/pyrefly/namedtuples_usage.toml @@ -0,0 +1,14 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR namedtuples_usage.py:34:9-10: Index 3 out of range for tuple with 3 elements [bad-index] +ERROR namedtuples_usage.py:35:9-11: Index -4 out of range for tuple with 3 elements [bad-index] +ERROR namedtuples_usage.py:40:1-4: Cannot set field `x` [read-only] +ERROR namedtuples_usage.py:41:1-5: Cannot set item in `Point` [unsupported-operation] +ERROR namedtuples_usage.py:42:5-8: Cannot delete field `x` [read-only] +ERROR namedtuples_usage.py:43:5-9: Cannot delete item in `Point` [unsupported-operation] +ERROR namedtuples_usage.py:52:1-7: Cannot unpack Point (of size 3) into 2 values [bad-unpacking] +ERROR namedtuples_usage.py:53:1-21: Cannot unpack Point (of size 3) into 4 values [bad-unpacking] +""" diff --git a/conformance/results/pyrefly/narrowing_typeguard.toml b/conformance/results/pyrefly/narrowing_typeguard.toml new file mode 100644 index 000000000..be07b9006 --- /dev/null +++ b/conformance/results/pyrefly/narrowing_typeguard.toml @@ -0,0 +1,10 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR narrowing_typeguard.py:102:9-13: Type guard functions must accept at least one positional argument [bad-function-definition] +ERROR narrowing_typeguard.py:107:9-13: Type guard functions must accept at least one positional argument [bad-function-definition] +ERROR narrowing_typeguard.py:128:20-36: Argument `(val: object) -> TypeGuard[int]` is not assignable to parameter `f` with type `(object) -> str` in function `takes_callable_str` [bad-argument-type] +ERROR narrowing_typeguard.py:148:26-42: Argument `(val: object) -> TypeGuard[int]` is not assignable to parameter `f` with type `CallableStrProto` in function `takes_callable_str_proto` [bad-argument-type] +""" diff --git a/conformance/results/pyrefly/narrowing_typeis.toml b/conformance/results/pyrefly/narrowing_typeis.toml new file mode 100644 index 000000000..008c5b417 --- /dev/null +++ b/conformance/results/pyrefly/narrowing_typeis.toml @@ -0,0 +1,15 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR narrowing_typeis.py:110:9-13: Type guard functions must accept at least one positional argument [bad-function-definition] +ERROR narrowing_typeis.py:115:9-13: Type guard functions must accept at least one positional argument [bad-function-definition] +ERROR narrowing_typeis.py:137:20-36: Argument `(val: object) -> TypeIs[int]` is not assignable to parameter `f` with type `(object) -> str` in function `takes_callable_str` [bad-argument-type] +ERROR narrowing_typeis.py:157:26-42: Argument `(val: object) -> TypeIs[int]` is not assignable to parameter `f` with type `CallableStrProto` in function `takes_callable_str_proto` [bad-argument-type] +ERROR narrowing_typeis.py:174:17-30: Argument `(val: object) -> TypeIs[int]` is not assignable to parameter `f` with type `(object) -> TypeGuard[int]` in function `takes_typeguard` [bad-argument-type] +ERROR narrowing_typeis.py:175:14-30: Argument `(val: object) -> TypeGuard[int]` is not assignable to parameter `f` with type `(object) -> TypeIs[int]` in function `takes_typeis` [bad-argument-type] +ERROR narrowing_typeis.py:196:18-29: Argument `(val: object) -> TypeIs[bool]` is not assignable to parameter `f` with type `(object) -> TypeIs[int]` in function `takes_int_typeis` [bad-argument-type] +ERROR narrowing_typeis.py:200:5-15: Return type `str` must be assignable to the first argument type `int` [bad-function-definition] +ERROR narrowing_typeis.py:204:5-24: Return type `list[int]` must be assignable to the first argument type `list[object]` [bad-function-definition] +""" diff --git a/conformance/results/pyrefly/overloads_basic.toml b/conformance/results/pyrefly/overloads_basic.toml new file mode 100644 index 000000000..9dd079a23 --- /dev/null +++ b/conformance/results/pyrefly/overloads_basic.toml @@ -0,0 +1,7 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR overloads_basic.py:39:1-6: Cannot index into `Bytes` [bad-index] +""" diff --git a/conformance/results/pyrefly/overloads_consistency.toml b/conformance/results/pyrefly/overloads_consistency.toml new file mode 100644 index 000000000..da6c71193 --- /dev/null +++ b/conformance/results/pyrefly/overloads_consistency.toml @@ -0,0 +1,8 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR overloads_consistency.py:25:5-16: Overload return type `str` is not assignable to implementation return type `int` [inconsistent-overload] +ERROR overloads_consistency.py:41:5-19: Implementation signature `(x: int) -> int | str` does not accept all arguments that overload signature `(x: str) -> str` accepts [inconsistent-overload] +""" diff --git a/conformance/results/pyrefly/overloads_definitions.toml b/conformance/results/pyrefly/overloads_definitions.toml new file mode 100644 index 000000000..31182ffd5 --- /dev/null +++ b/conformance/results/pyrefly/overloads_definitions.toml @@ -0,0 +1,18 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR overloads_definitions.py:16:5-10: Overloaded function needs at least two @overload declarations [invalid-overload] +ERROR overloads_definitions.py:28:5-10: Overloaded function must have an implementation [invalid-overload] +ERROR overloads_definitions.py:59:9-21: Overloaded function must have an implementation [invalid-overload] +ERROR overloads_definitions.py:81:9-14: If `@staticmethod` is present on any overload or the implementation, it should be on every overload and the implementation. [invalid-overload] +ERROR overloads_definitions.py:90:9-14: If `@classmethod` is present on any overload or the implementation, it should be on every overload and the implementation. [invalid-overload] +ERROR overloads_definitions.py:124:9-22: `@final` should only be applied to the implementation of an overloaded function. [invalid-overload] +ERROR overloads_definitions.py:139:9-24: `@final` should only be applied to the implementation of an overloaded function. [invalid-overload] +ERROR overloads_definitions.py:144:9-24: `@final` should only be applied to the implementation of an overloaded function. [invalid-overload] +ERROR overloads_definitions.py:181:9-21: `final_method` is declared as final in parent class `Base` [bad-override] +ERROR overloads_definitions.py:196:9-21: Class member `Child.bad_override` is marked as an override, but no parent class has a matching attribute [bad-override] +ERROR overloads_definitions.py:228:9-20: `@override` should only be applied to the implementation of an overloaded function. [invalid-overload] +ERROR overloads_definitions.py:232:9-20: `@override` should only be applied to the implementation of an overloaded function. [invalid-overload] +""" diff --git a/conformance/results/pyrefly/overloads_definitions_stub.toml b/conformance/results/pyrefly/overloads_definitions_stub.toml new file mode 100644 index 000000000..983ac42fb --- /dev/null +++ b/conformance/results/pyrefly/overloads_definitions_stub.toml @@ -0,0 +1,14 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR overloads_definitions_stub.pyi:14:5-10: Overloaded function needs at least two @overload declarations [invalid-overload] +ERROR overloads_definitions_stub.pyi:33:9-14: If `@staticmethod` is present on one overload, all overloads must have that decorator. [invalid-overload] +ERROR overloads_definitions_stub.pyi:44:9-14: If `@classmethod` is present on one overload, all overloads must have that decorator. [invalid-overload] +ERROR overloads_definitions_stub.pyi:73:9-22: If an overloaded function has no implementation, `@final` should be applied to the first overload only. [invalid-overload] +ERROR overloads_definitions_stub.pyi:86:9-24: If an overloaded function has no implementation, `@final` should be applied to the first overload only. [invalid-overload] +ERROR overloads_definitions_stub.pyi:108:9-21: `final_method` is declared as final in parent class `Base` [bad-override] +ERROR overloads_definitions_stub.pyi:122:9-21: Class member `Child.bad_override` is marked as an override, but no parent class has a matching attribute [bad-override] +ERROR overloads_definitions_stub.pyi:147:9-20: If an overloaded function has no implementation, `@override` should be applied to the first overload only. [invalid-overload] +""" diff --git a/conformance/results/pyrefly/overloads_evaluation.toml b/conformance/results/pyrefly/overloads_evaluation.toml new file mode 100644 index 000000000..6b60e3f4a --- /dev/null +++ b/conformance/results/pyrefly/overloads_evaluation.toml @@ -0,0 +1,10 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR overloads_evaluation.py:38:11-13: No matching overload found for function `example1_1` called with arguments: () [no-matching-overload] +ERROR overloads_evaluation.py:46:15-16: Argument `Literal[1]` is not assignable to parameter `y` with type `str` in function `example1_1` [bad-argument-type] +ERROR overloads_evaluation.py:51:12-13: Argument `Literal[1]` is not assignable to parameter `x` with type `str` in function `example1_1` [bad-argument-type] +ERROR overloads_evaluation.py:116:13-22: No matching overload found for function `example2` called with arguments: (int | str, int | str, Literal[1]) [no-matching-overload] +""" diff --git a/conformance/results/pyrefly/protocols_class_objects.toml b/conformance/results/pyrefly/protocols_class_objects.toml new file mode 100644 index 000000000..1dc760acf --- /dev/null +++ b/conformance/results/pyrefly/protocols_class_objects.toml @@ -0,0 +1,14 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR protocols_class_objects.py:29:5-10: Argument `type[Proto]` is not assignable to parameter `cls` with type `type[Proto]` in function `fun` [bad-argument-type] +ERROR protocols_class_objects.py:34:7-12: `type[Proto]` is not assignable to variable `var` with type `type[Proto]` [bad-assignment] +ERROR protocols_class_objects.py:58:16-25: `type[ConcreteA]` is not assignable to `ProtoA1` [bad-assignment] +ERROR protocols_class_objects.py:74:16-25: `type[ConcreteB]` is not assignable to `ProtoB1` [bad-assignment] +ERROR protocols_class_objects.py:104:16-26: `type[ConcreteC1]` is not assignable to `ProtoC1` [bad-assignment] +ERROR protocols_class_objects.py:106:16-26: `type[ConcreteC2]` is not assignable to `ProtoC1` [bad-assignment] +ERROR protocols_class_objects.py:107:16-26: `type[ConcreteC2]` is not assignable to `ProtoC2` [bad-assignment] +ERROR protocols_class_objects.py:108:16-26: `type[ConcreteC3]` is not assignable to `ProtoC1` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/protocols_definition.toml b/conformance/results/pyrefly/protocols_definition.toml new file mode 100644 index 000000000..a02940d9b --- /dev/null +++ b/conformance/results/pyrefly/protocols_definition.toml @@ -0,0 +1,29 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR protocols_definition.py:30:11-14: Argument `list[int]` is not assignable to parameter `things` with type `Iterable[SupportsClose]` in function `close_all` [bad-argument-type] +ERROR protocols_definition.py:67:14-18: Protocol variables must be explicitly declared in the class body [protocol-implicitly-defined-attribute] +ERROR protocols_definition.py:114:22-38: `Concrete2_Bad1` is not assignable to `Template2` [bad-assignment] +ERROR protocols_definition.py:115:22-38: `Concrete2_Bad2` is not assignable to `Template2` [bad-assignment] +ERROR protocols_definition.py:116:22-38: `Concrete2_Bad3` is not assignable to `Template2` [bad-assignment] +ERROR protocols_definition.py:117:22-38: `Concrete2_Bad4` is not assignable to `Template2` [bad-assignment] +ERROR protocols_definition.py:156:22-38: `Concrete3_Bad1` is not assignable to `Template3` [bad-assignment] +ERROR protocols_definition.py:157:22-38: `Concrete3_Bad2` is not assignable to `Template3` [bad-assignment] +ERROR protocols_definition.py:158:22-38: `Concrete3_Bad3` is not assignable to `Template3` [bad-assignment] +ERROR protocols_definition.py:159:22-38: `Concrete3_Bad4` is not assignable to `Template3` [bad-assignment] +ERROR protocols_definition.py:160:22-38: `Concrete3_Bad5` is not assignable to `Template3` [bad-assignment] +ERROR protocols_definition.py:218:22-38: `Concrete4_Bad1` is not assignable to `Template4` [bad-assignment] +ERROR protocols_definition.py:219:22-38: `Concrete4_Bad2` is not assignable to `Template4` [bad-assignment] +ERROR protocols_definition.py:285:22-38: `Concrete5_Bad1` is not assignable to `Template5` [bad-assignment] +ERROR protocols_definition.py:286:22-38: `Concrete5_Bad2` is not assignable to `Template5` [bad-assignment] +ERROR protocols_definition.py:287:22-38: `Concrete5_Bad3` is not assignable to `Template5` [bad-assignment] +ERROR protocols_definition.py:288:22-38: `Concrete5_Bad4` is not assignable to `Template5` [bad-assignment] +ERROR protocols_definition.py:289:22-38: `Concrete5_Bad5` is not assignable to `Template5` [bad-assignment] +ERROR protocols_definition.py:339:22-38: `Concrete6_Bad1` is not assignable to `Template6` [bad-assignment] +ERROR protocols_definition.py:340:22-38: `Concrete6_Bad2` is not assignable to `Template6` [bad-assignment] +ERROR protocols_definition.py:341:22-38: `Concrete6_Bad3` is not assignable to `Template6` [bad-assignment] +ERROR protocols_definition.py:369:22-38: `Concrete7_Bad1` is not assignable to `Template7` [bad-assignment] +ERROR protocols_definition.py:370:22-38: `Concrete7_Bad2` is not assignable to `Template7` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/protocols_explicit.toml b/conformance/results/pyrefly/protocols_explicit.toml new file mode 100644 index 000000000..0ce752b0b --- /dev/null +++ b/conformance/results/pyrefly/protocols_explicit.toml @@ -0,0 +1,12 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR protocols_explicit.py:27:16-28: Method `draw` inherited from class `PColor` has no implementation and cannot be accessed via `super()` [missing-attribute] +ERROR protocols_explicit.py:56:20-36: `tuple[int, int, str]` is not assignable to attribute `rgb` with type `tuple[int, int, int]` [bad-assignment] +ERROR protocols_explicit.py:60:10-20: Cannot instantiate `Point` because the following members are abstract: `intensity`, `transparency` [bad-instantiation] +ERROR protocols_explicit.py:89:15-17: Cannot instantiate `Concrete1` because the following members are abstract: `cm1` [bad-instantiation] +ERROR protocols_explicit.py:134:15-17: Cannot instantiate `Concrete5` because the following members are abstract: `method1` [bad-instantiation] +ERROR protocols_explicit.py:164:17-19: Cannot instantiate `Concrete7A` because the following members are abstract: `method1` [bad-instantiation] +""" diff --git a/conformance/results/pyrefly/protocols_generic.toml b/conformance/results/pyrefly/protocols_generic.toml new file mode 100644 index 000000000..f4344e4ff --- /dev/null +++ b/conformance/results/pyrefly/protocols_generic.toml @@ -0,0 +1,15 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR protocols_generic.py:40:24-35: `Concrete1` is not assignable to `Proto1[int, str]` [bad-assignment] +ERROR protocols_generic.py:44:7-13: Class `Proto2` specifies type parameters in both `Generic` and `Protocol` bases [invalid-inheritance] +ERROR protocols_generic.py:56:20-29: `Box[float]` is not assignable to `Box[int]` [bad-assignment] +ERROR protocols_generic.py:66:25-35: `Sender[int]` is not assignable to `Sender[float]` [bad-assignment] +ERROR protocols_generic.py:74:28-36: `AttrProto[int]` is not assignable to `AttrProto[float]` [bad-assignment] +ERROR protocols_generic.py:75:26-36: `AttrProto[float]` is not assignable to `AttrProto[int]` [bad-assignment] +ERROR protocols_generic.py:133:26-49: `InvalidParentProperty` is not assignable to `HasParentProperty` [bad-assignment] +ERROR protocols_generic.py:153:18-36: `InvalidHasMethod` is not assignable to `HasMethod` [bad-assignment] +ERROR protocols_generic.py:185:23-43: `InvalidGreaterThan` is not assignable to `HasGreaterThan` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/protocols_merging.toml b/conformance/results/pyrefly/protocols_merging.toml new file mode 100644 index 000000000..0819adc23 --- /dev/null +++ b/conformance/results/pyrefly/protocols_merging.toml @@ -0,0 +1,12 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR protocols_merging.py:52:25-38: `SCConcrete2` is not assignable to `SizedAndClosable1` [bad-assignment] +ERROR protocols_merging.py:53:25-38: `SCConcrete2` is not assignable to `SizedAndClosable2` [bad-assignment] +ERROR protocols_merging.py:54:25-38: `SCConcrete2` is not assignable to `SizedAndClosable3` [bad-assignment] +ERROR protocols_merging.py:67:16-33: If `Protocol` is included as a base class, all other bases must be protocols [invalid-inheritance] +ERROR protocols_merging.py:82:22-24: Cannot instantiate `SizedAndClosable4` because the following members are abstract: `close` [bad-instantiation] +ERROR protocols_merging.py:83:24-37: `SCConcrete1` is not assignable to `SizedAndClosable4` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/protocols_modules.toml b/conformance/results/pyrefly/protocols_modules.toml new file mode 100644 index 000000000..08e55a351 --- /dev/null +++ b/conformance/results/pyrefly/protocols_modules.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR protocols_modules.py:26:17-36: `Module[_protocols_modules1]` is not assignable to `Options2` [bad-assignment] +ERROR protocols_modules.py:48:18-37: `Module[_protocols_modules2]` is not assignable to `Reporter2` [bad-assignment] +ERROR protocols_modules.py:49:18-37: `Module[_protocols_modules2]` is not assignable to `Reporter3` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/protocols_recursive.toml b/conformance/results/pyrefly/protocols_recursive.toml new file mode 100644 index 000000000..be211bd5b --- /dev/null +++ b/conformance/results/pyrefly/protocols_recursive.toml @@ -0,0 +1,6 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pyrefly/protocols_runtime_checkable.toml b/conformance/results/pyrefly/protocols_runtime_checkable.toml new file mode 100644 index 000000000..f794b975d --- /dev/null +++ b/conformance/results/pyrefly/protocols_runtime_checkable.toml @@ -0,0 +1,14 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR protocols_runtime_checkable.py:23:22-28: Protocol `Proto1` is not decorated with @runtime_checkable and cannot be used with isinstance() [invalid-argument] +ERROR protocols_runtime_checkable.py:55:22-34: Protocol `DataProtocol` has non-method members and cannot be used with issubclass() [invalid-argument] +ERROR protocols_runtime_checkable.py:61:22-53: Protocol `DataProtocol` has non-method members and cannot be used with issubclass() [invalid-argument] +ERROR protocols_runtime_checkable.py:88:33-39: Runtime checkable protocol `Proto3` has an unsafe overlap with type `Concrete3A` [unsafe-overlap] +ERROR protocols_runtime_checkable.py:91:33-58: Runtime checkable protocol `Proto3` has an unsafe overlap with type `Concrete3B` [unsafe-overlap] +ERROR protocols_runtime_checkable.py:91:33-58: Runtime checkable protocol `NonDataProtocol` has an unsafe overlap with type `Concrete3B` [unsafe-overlap] +ERROR protocols_runtime_checkable.py:94:31-56: Runtime checkable protocol `Proto3` has an unsafe overlap with type `Concrete3A` [unsafe-overlap] +ERROR protocols_runtime_checkable.py:94:31-56: Runtime checkable protocol `NonDataProtocol` has an unsafe overlap with type `Concrete3A` [unsafe-overlap] +""" diff --git a/conformance/results/pyrefly/protocols_self.toml b/conformance/results/pyrefly/protocols_self.toml new file mode 100644 index 000000000..be211bd5b --- /dev/null +++ b/conformance/results/pyrefly/protocols_self.toml @@ -0,0 +1,6 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pyrefly/protocols_subtyping.toml b/conformance/results/pyrefly/protocols_subtyping.toml new file mode 100644 index 000000000..ab7a89280 --- /dev/null +++ b/conformance/results/pyrefly/protocols_subtyping.toml @@ -0,0 +1,13 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR protocols_subtyping.py:16:12-14: Cannot instantiate `Proto1` because it is a protocol [bad-instantiation] +ERROR protocols_subtyping.py:38:21-23: `Proto2` is not assignable to `Concrete2` [bad-assignment] +ERROR protocols_subtyping.py:55:18-20: `Proto2` is not assignable to `Proto3` [bad-assignment] +ERROR protocols_subtyping.py:79:30-36: `Proto5[int]` is not assignable to `Proto4[int, float]` [bad-assignment] +ERROR protocols_subtyping.py:80:25-31: `Proto4[int, int]` is not assignable to `Proto5[float]` [bad-assignment] +ERROR protocols_subtyping.py:102:30-32: `Proto6[float, float]` is not assignable to `Proto7[int, float]` [bad-assignment] +ERROR protocols_subtyping.py:103:33-35: `Proto6[float, float]` is not assignable to `Proto7[float, object]` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/protocols_variance.toml b/conformance/results/pyrefly/protocols_variance.toml new file mode 100644 index 000000000..f6836baf9 --- /dev/null +++ b/conformance/results/pyrefly/protocols_variance.toml @@ -0,0 +1,18 @@ +conformant = "Partial" +conformance_automated = "Fail" +notes = """ +Doesn't support variance keywords to ParamSpec +""" +errors_diff = """ +Line 15: Unexpected errors ['Unexpected keyword argument `contravariant` to ParamSpec [invalid-param-spec]'] +""" +output = """ +ERROR protocols_variance.py:15:20-38: Unexpected keyword argument `contravariant` to ParamSpec [invalid-param-spec] + WARN protocols_variance.py:22:7-17: Type variable `T1` in class `AnotherBox` is declared as invariant, but could be covariant based on its usage [variance-mismatch] + WARN protocols_variance.py:41:7-16: Type variable `T3` in class `Protocol2` is declared as invariant, but could be contravariant based on its usage [variance-mismatch] + WARN protocols_variance.py:57:7-16: Type variable `T1` in class `Protocol4` is declared as invariant, but could be contravariant based on its usage [variance-mismatch] +ERROR protocols_variance.py:63:9-11: Type variable `T1_co` is covariant but is used in contravariant position [invalid-variance] + WARN protocols_variance.py:67:7-16: Type variable `T1` in class `Protocol6` is declared as invariant, but could be covariant based on its usage [variance-mismatch] +ERROR protocols_variance.py:73:9-11: Type variable `T1_contra` is contravariant but is used in covariant position [invalid-variance] + WARN protocols_variance.py:105:7-17: Type variable `T1` in class `Protocol12` is declared as invariant, but could be covariant based on its usage [variance-mismatch] +""" diff --git a/conformance/results/pyrefly/qualifiers_annotated.toml b/conformance/results/pyrefly/qualifiers_annotated.toml new file mode 100644 index 000000000..cf976cd2f --- /dev/null +++ b/conformance/results/pyrefly/qualifiers_annotated.toml @@ -0,0 +1,28 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR qualifiers_annotated.py:38:17-27: List literal cannot be used in annotations [invalid-annotation] +ERROR qualifiers_annotated.py:39:17-30: Tuple literal cannot be used in annotations [invalid-annotation] +ERROR qualifiers_annotated.py:40:17-40: List comprehension cannot be used in annotations [invalid-annotation] +ERROR qualifiers_annotated.py:41:17-27: Dict literal cannot be used in annotations [invalid-annotation] +ERROR qualifiers_annotated.py:41:19-20: Could not find name `a` [unknown-name] +ERROR qualifiers_annotated.py:41:24-25: Could not find name `b` [unknown-name] +ERROR qualifiers_annotated.py:42:17-32: Function call cannot be used in annotations [invalid-annotation] +ERROR qualifiers_annotated.py:43:17-25: Invalid subscript expression cannot be used in annotations [invalid-annotation] +ERROR qualifiers_annotated.py:44:17-38: If expression cannot be used in annotations [invalid-annotation] +ERROR qualifiers_annotated.py:45:17-21: Could not find name `var1` [unknown-name] +ERROR qualifiers_annotated.py:46:17-21: Bool literal cannot be used in annotations [invalid-annotation] +ERROR qualifiers_annotated.py:47:18-19: Number literal cannot be used in annotations [invalid-annotation] +ERROR qualifiers_annotated.py:48:18-29: Boolean operation cannot be used in annotations [invalid-annotation] +ERROR qualifiers_annotated.py:49:18-28: F-string cannot be used in annotations [invalid-annotation] +ERROR qualifiers_annotated.py:59:8-22: `Annotated` needs at least one piece of metadata in addition to the type [invalid-annotation] +ERROR qualifiers_annotated.py:71:24-42: `Annotated[int]` is not assignable to `type[Any]` [bad-assignment] +ERROR qualifiers_annotated.py:72:24-32: `TypeAlias[SmallInt, Annotated[int]]` is not assignable to `type[Any]` [bad-assignment] +ERROR qualifiers_annotated.py:79:7-25: Argument `Annotated[str]` is not assignable to parameter `x` with type `type[@_]` in function `func4` [bad-argument-type] +ERROR qualifiers_annotated.py:80:7-15: Argument `TypeAlias[SmallInt, Annotated[int]]` is not assignable to parameter `x` with type `type[@_]` in function `func4` [bad-argument-type] +ERROR qualifiers_annotated.py:86:1-10: Expected a callable, got `type[Annotated]` [not-callable] +ERROR qualifiers_annotated.py:87:1-19: Expected a callable, got `Annotated[int]` [not-callable] +ERROR qualifiers_annotated.py:88:1-9: Expected a callable, got `TypeAlias[SmallInt, Annotated[int]]` [not-callable] +""" diff --git a/conformance/results/pyrefly/qualifiers_final_annotation.toml b/conformance/results/pyrefly/qualifiers_final_annotation.toml new file mode 100644 index 000000000..4da0650c7 --- /dev/null +++ b/conformance/results/pyrefly/qualifiers_final_annotation.toml @@ -0,0 +1,37 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR qualifiers_final_annotation.py:16:7-12: Expected a type argument for `Final` [invalid-annotation] +ERROR qualifiers_final_annotation.py:18:7-22: Expected 1 type argument for `Final`, got 2 [invalid-annotation] +ERROR qualifiers_final_annotation.py:34:5-8: Final attribute declared in class body must be initialized with a value or in `__init__` [invalid-annotation] +ERROR qualifiers_final_annotation.py:38:5-8: Final attribute declared in class body must be initialized with a value or in `__init__` [invalid-annotation] +ERROR qualifiers_final_annotation.py:54:9-17: Cannot set field `ID5` [read-only] +ERROR qualifiers_final_annotation.py:62:9-17: Cannot set field `id3` [read-only] +ERROR qualifiers_final_annotation.py:63:9-17: Cannot set field `id4` [read-only] +ERROR qualifiers_final_annotation.py:65:9-17: Cannot set field `ID7` [read-only] +ERROR qualifiers_final_annotation.py:67:9-17: Cannot set field `ID7` [read-only] +ERROR qualifiers_final_annotation.py:71:8-11: Cannot assign to variable `RATE` because it is marked final [bad-assignment] +ERROR qualifiers_final_annotation.py:81:1-18: Cannot set field `DEFAULT_ID` [read-only] +ERROR qualifiers_final_annotation.py:94:5-17: `BORDER_WIDTH` is declared as final in parent class `ClassC` [bad-override] +ERROR qualifiers_final_annotation.py:107:5-11: `Final` may not be nested inside `ClassVar` [invalid-annotation] +ERROR qualifiers_final_annotation.py:108:19-27: `ClassVar` may not be nested inside `Final` [invalid-annotation] +ERROR qualifiers_final_annotation.py:118:9-19: `Final` is not allowed in this context [invalid-annotation] +ERROR qualifiers_final_annotation.py:121:14-19: `Final` is only allowed on a class or local variable annotation [invalid-annotation] +ERROR qualifiers_final_annotation.py:121:14-30: `Final` is not allowed in this context [invalid-annotation] +ERROR qualifiers_final_annotation.py:131:5-6: `Final` may not be used for TypedDict members [invalid-annotation] +ERROR qualifiers_final_annotation.py:136:5-6: `Final` may not be used for NamedTuple members [invalid-annotation] +ERROR qualifiers_final_annotation.py:148:2-7: Missing argument `x` in function `N.__new__` [missing-argument] +ERROR qualifiers_final_annotation.py:148:2-7: Missing argument `y` in function `N.__new__` [missing-argument] +ERROR qualifiers_final_annotation.py:148:3-4: Unexpected keyword argument `a` in function `N.__new__` [unexpected-keyword] +ERROR qualifiers_final_annotation.py:149:5-7: Argument `Literal['']` is not assignable to parameter `x` with type `int` in function `N.__new__` [bad-argument-type] +ERROR qualifiers_final_annotation.py:149:11-13: Argument `Literal['']` is not assignable to parameter `y` with type `int` in function `N.__new__` [bad-argument-type] +ERROR qualifiers_final_annotation.py:155:11-12: Cannot assign to variable `ID1` because it is marked final [bad-assignment] +ERROR qualifiers_final_annotation.py:159:5-11: Cannot assign to variable `x` because it is marked final [bad-assignment] +ERROR qualifiers_final_annotation.py:161:15-16: Cannot assign to variable `x` because it is marked final [bad-assignment] +ERROR qualifiers_final_annotation.py:163:14-23: Cannot assign to variable `x` because it is marked final [bad-assignment] +ERROR qualifiers_final_annotation.py:166:10-26: Cannot assign to variable `x` because it is marked final [bad-assignment] +ERROR qualifiers_final_annotation.py:169:5-11: Cannot assign to variable `x` because it is marked final [bad-assignment] +ERROR qualifiers_final_annotation.py:180:1-4: Cannot assign to `TEN` because it is imported as final [bad-assignment] +ERROR qualifiers_final_annotation.py:184:1-3: Cannot assign to `PI` because it is imported as final [bad-assignment] +""" diff --git a/conformance/results/pyrefly/qualifiers_final_decorator.toml b/conformance/results/pyrefly/qualifiers_final_decorator.toml new file mode 100644 index 000000000..381d74150 --- /dev/null +++ b/conformance/results/pyrefly/qualifiers_final_decorator.toml @@ -0,0 +1,16 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR qualifiers_final_decorator.py:21:16-21: Cannot extend final class `Base1` [invalid-inheritance] +ERROR qualifiers_final_decorator.py:56:9-16: `method1` is declared as final in parent class `Base2` [bad-override] +ERROR qualifiers_final_decorator.py:60:9-16: `method2` is declared as final in parent class `Base2` [bad-override] +ERROR qualifiers_final_decorator.py:64:9-16: `method3` is declared as final in parent class `Base2` [bad-override] +ERROR qualifiers_final_decorator.py:68:9-16: `method4` is declared as final in parent class `Base2` [bad-override] +ERROR qualifiers_final_decorator.py:81:9-15: `method` is declared as final in parent class `Base3` [bad-override] +ERROR qualifiers_final_decorator.py:86:9-15: `@final` should only be applied to the implementation of an overloaded function. [invalid-overload] +ERROR qualifiers_final_decorator.py:95:9-15: `method` is declared as final in parent class `Base4` [bad-override] +ERROR qualifiers_final_decorator.py:118:9-15: `method` is declared as final in parent class `Base5_2` [bad-override] + WARN qualifiers_final_decorator.py:125:1-7: Decorator `@final` can only be used on methods. [invalid-decorator] +""" diff --git a/conformance/results/pyrefly/specialtypes_any.toml b/conformance/results/pyrefly/specialtypes_any.toml new file mode 100644 index 000000000..be211bd5b --- /dev/null +++ b/conformance/results/pyrefly/specialtypes_any.toml @@ -0,0 +1,6 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pyrefly/specialtypes_never.toml b/conformance/results/pyrefly/specialtypes_never.toml new file mode 100644 index 000000000..251ce6ae0 --- /dev/null +++ b/conformance/results/pyrefly/specialtypes_never.toml @@ -0,0 +1,9 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR specialtypes_never.py:19:22-30: Function declared to return `NoReturn` but is missing an explicit `return` [bad-return] +ERROR specialtypes_never.py:85:21-22: `list[Never]` is not assignable to `list[int]` [bad-assignment] +ERROR specialtypes_never.py:104:12-27: Returned type `ClassC[Never]` is not assignable to declared return type `ClassC[U]` [bad-return] +""" diff --git a/conformance/results/pyrefly/specialtypes_none.toml b/conformance/results/pyrefly/specialtypes_none.toml new file mode 100644 index 000000000..6d4c240e0 --- /dev/null +++ b/conformance/results/pyrefly/specialtypes_none.toml @@ -0,0 +1,9 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR specialtypes_none.py:21:7-17: Argument `type[NoneType]` is not assignable to parameter `val1` with type `None` in function `func1` [bad-argument-type] +ERROR specialtypes_none.py:27:19-23: `None` is not assignable to `Iterable[Unknown]` [bad-assignment] +ERROR specialtypes_none.py:41:7-11: Argument `None` is not assignable to parameter `val1` with type `type[None]` in function `func2` [bad-argument-type] +""" diff --git a/conformance/results/pyrefly/specialtypes_promotions.toml b/conformance/results/pyrefly/specialtypes_promotions.toml new file mode 100644 index 000000000..6b038e892 --- /dev/null +++ b/conformance/results/pyrefly/specialtypes_promotions.toml @@ -0,0 +1,7 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR specialtypes_promotions.py:13:5-16: Object of class `float` has no attribute `numerator` [missing-attribute] +""" diff --git a/conformance/results/pyrefly/specialtypes_sentinels.toml b/conformance/results/pyrefly/specialtypes_sentinels.toml new file mode 100644 index 000000000..0366c5785 --- /dev/null +++ b/conformance/results/pyrefly/specialtypes_sentinels.toml @@ -0,0 +1,9 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR specialtypes_sentinels.py:14:20-27: Default `` is not assignable to parameter `x` with type `int` [bad-function-definition] +ERROR specialtypes_sentinels.py:36:7-19: Argument `Cls.Cls.IN_CLASS` is not assignable to parameter `x` with type `int | | SPECIAL` in function `func2` [bad-argument-type] +ERROR specialtypes_sentinels.py:39:7-14: Argument `` is not assignable to parameter `x` with type `int | Cls.Cls.IN_CLASS` in function `func3` [bad-argument-type] +""" diff --git a/conformance/results/pyrefly/specialtypes_type.toml b/conformance/results/pyrefly/specialtypes_type.toml new file mode 100644 index 000000000..e5bf63e0c --- /dev/null +++ b/conformance/results/pyrefly/specialtypes_type.toml @@ -0,0 +1,15 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR specialtypes_type.py:56:7-15: Argument `type[TeamUser]` is not assignable to parameter `user_class` with type `type[BasicUser | ProUser]` in function `func4` [bad-argument-type] +ERROR specialtypes_type.py:70:7-15: Argument `type[Callable]` is not assignable to parameter `x` with type `type[@_]` in function `func5` [bad-argument-type] +ERROR specialtypes_type.py:76:12-26: Expected 1 type argument for `type`, got 2 [bad-specialization] +ERROR specialtypes_type.py:117:5-14: Class `object` has no class attribute `unknown` [missing-attribute] +ERROR specialtypes_type.py:120:5-14: Class `object` has no class attribute `unknown` [missing-attribute] +ERROR specialtypes_type.py:143:1-12: Class `type` has no class attribute `unknown` [missing-attribute] +ERROR specialtypes_type.py:144:1-12: Class `type` has no class attribute `unknown` [missing-attribute] +ERROR specialtypes_type.py:145:1-12: Class `type` has no class attribute `unknown` [missing-attribute] +ERROR specialtypes_type.py:146:1-12: Class `type` has no class attribute `unknown` [missing-attribute] +""" diff --git a/conformance/results/pyrefly/tuples_type_compat.toml b/conformance/results/pyrefly/tuples_type_compat.toml new file mode 100644 index 000000000..c85896b78 --- /dev/null +++ b/conformance/results/pyrefly/tuples_type_compat.toml @@ -0,0 +1,30 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR tuples_type_compat.py:15:27-29: `tuple[float, complex]` is not assignable to `tuple[int, int]` [bad-assignment] +ERROR tuples_type_compat.py:29:10-12: `tuple[int, ...]` is not assignable to variable `v2` with type `tuple[int, *tuple[int, ...]]` [bad-assignment] +ERROR tuples_type_compat.py:32:10-12: `tuple[int, *tuple[int, ...]]` is not assignable to variable `v3` with type `tuple[int]` [bad-assignment] +ERROR tuples_type_compat.py:33:10-12: `tuple[int, ...]` is not assignable to variable `v3` with type `tuple[int]` [bad-assignment] +ERROR tuples_type_compat.py:43:22-24: `tuple[int, ...]` is not assignable to `tuple[int]` [bad-assignment] +ERROR tuples_type_compat.py:62:26-35: `tuple[int, ...]` is not assignable to `tuple[int, int]` [bad-assignment] +ERROR tuples_type_compat.py:76:20-37: assert_type(tuple[int], tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]) failed [assert-type] +ERROR tuples_type_compat.py:81:20-37: assert_type(tuple[int, int] | tuple[str, str], tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]) failed [assert-type] +ERROR tuples_type_compat.py:86:20-37: assert_type(tuple[int, str, int], tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]) failed [assert-type] +ERROR tuples_type_compat.py:102:24-41: assert_type(tuple[int], tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]) failed [assert-type] +ERROR tuples_type_compat.py:107:24-41: assert_type(tuple[int, int] | tuple[str, str], tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]) failed [assert-type] +ERROR tuples_type_compat.py:112:24-41: assert_type(tuple[int, str, int], tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]) failed [assert-type] +ERROR tuples_type_compat.py:126:24-53: assert_type(tuple[int | str, int | str], tuple[int | str, str]) failed [assert-type] +ERROR tuples_type_compat.py:129:24-53: assert_type(tuple[int | str, int | str], tuple[int | str, int]) failed [assert-type] +ERROR tuples_type_compat.py:157:6-17: `tuple[Literal[1], Literal[''], Literal['']]` is not assignable to variable `t1` with type `tuple[int, str]` [bad-assignment] +ERROR tuples_type_compat.py:162:6-16: `tuple[Literal[1], Literal[1], Literal['']]` is not assignable to variable `t2` with type `tuple[int, *tuple[str, ...]]` [bad-assignment] +ERROR tuples_type_compat.py:163:6-16: `tuple[Literal[1], Literal[''], Literal[1]]` is not assignable to variable `t2` with type `tuple[int, *tuple[str, ...]]` [bad-assignment] +ERROR tuples_type_compat.py:169:6-17: `tuple[Literal[1], Literal[''], Literal['']]` is not assignable to variable `t3` with type `tuple[int, *tuple[str, ...], int]` [bad-assignment] +ERROR tuples_type_compat.py:170:6-22: `tuple[Literal[1], Literal[''], Literal[''], float]` is not assignable to variable `t3` with type `tuple[int, *tuple[str, ...], int]` [bad-assignment] +ERROR tuples_type_compat.py:175:6-16: `tuple[Literal[1], Literal[''], Literal[1]]` is not assignable to variable `t4` with type `tuple[*tuple[str, ...], int]` [bad-assignment] +ERROR tuples_type_compat.py:176:6-19: `tuple[Literal[''], Literal[''], float]` is not assignable to variable `t4` with type `tuple[*tuple[str, ...], int]` [bad-assignment] +ERROR tuples_type_compat.py:181:40-41: `tuple[str, str]` is not assignable to `tuple[str, str, int]` [bad-assignment] +ERROR tuples_type_compat.py:184:50-51: `tuple[str, str]` is not assignable to `tuple[str, str, str, *tuple[str, ...]]` [bad-assignment] +ERROR tuples_type_compat.py:188:50-51: `tuple[str, str]` is not assignable to `tuple[*tuple[str, ...], str, str, str]` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/tuples_type_form.toml b/conformance/results/pyrefly/tuples_type_form.toml new file mode 100644 index 000000000..7a9c92c85 --- /dev/null +++ b/conformance/results/pyrefly/tuples_type_form.toml @@ -0,0 +1,17 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR tuples_type_form.py:12:6-12: `tuple[Literal[1], Literal[2]]` is not assignable to variable `t1` with type `tuple[int]` [bad-assignment] +ERROR tuples_type_form.py:14:6-10: `tuple[Literal[1]]` is not assignable to variable `t2` with type `tuple[int, int]` [bad-assignment] +ERROR tuples_type_form.py:15:6-13: `tuple[Literal[1], Literal['']]` is not assignable to variable `t2` with type `tuple[int, int]` [bad-assignment] +ERROR tuples_type_form.py:25:7-11: `tuple[Literal[1]]` is not assignable to variable `t10` with type `tuple[()]` [bad-assignment] +ERROR tuples_type_form.py:36:7-20: `tuple[Literal[1], Literal[2], Literal[3], Literal['']]` is not assignable to variable `t20` with type `tuple[int, ...]` [bad-assignment] +ERROR tuples_type_form.py:40:22-25: Invalid position for `...` [invalid-argument] +ERROR tuples_type_form.py:41:12-15: Invalid position for `...` [invalid-argument] +ERROR tuples_type_form.py:42:12-15: Invalid position for `...` [invalid-argument] +ERROR tuples_type_form.py:43:17-20: Invalid position for `...` [invalid-argument] +ERROR tuples_type_form.py:44:25-28: `...` cannot be used with an unpacked `TypeVarTuple` or tuple [invalid-argument] +ERROR tuples_type_form.py:45:30-33: Invalid position for `...` [invalid-argument] +""" diff --git a/conformance/results/pyrefly/tuples_unpacked.toml b/conformance/results/pyrefly/tuples_unpacked.toml new file mode 100644 index 000000000..8792b4535 --- /dev/null +++ b/conformance/results/pyrefly/tuples_unpacked.toml @@ -0,0 +1,11 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR tuples_unpacked.py:40:29-45: Only one unbounded type is allowed to be unpacked [bad-unpacking] +ERROR tuples_unpacked.py:41:42-58: Only one unbounded type is allowed to be unpacked [bad-unpacking] +ERROR tuples_unpacked.py:51:33-36: Only one unbounded type is allowed to be unpacked [bad-unpacking] +ERROR tuples_unpacked.py:59:37-60: Only one unbounded type is allowed to be unpacked [bad-unpacking] +ERROR tuples_unpacked.py:61:50-73: Only one unbounded type is allowed to be unpacked [bad-unpacking] +""" diff --git a/conformance/results/pyrefly/typeddicts_alt_syntax.toml b/conformance/results/pyrefly/typeddicts_alt_syntax.toml new file mode 100644 index 000000000..ab8a7e821 --- /dev/null +++ b/conformance/results/pyrefly/typeddicts_alt_syntax.toml @@ -0,0 +1,17 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR typeddicts_alt_syntax.py:23:1-14: Expected valid functional typed dictionary definition [invalid-argument] +ERROR typeddicts_alt_syntax.py:27:45-46: Expected first item to be a string literal [invalid-argument] + WARN typeddicts_alt_syntax.py:31:27-38: Expected string literal "BadTypedDict3" [name-mismatch] +ERROR typeddicts_alt_syntax.py:35:72-83: Unrecognized keyword argument `other` in typed dictionary definition [invalid-argument] +ERROR typeddicts_alt_syntax.py:41:1-7: Expected valid functional typed dictionary definition [invalid-argument] +ERROR typeddicts_alt_syntax.py:41:30-38: Unrecognized keyword argument `name` in typed dictionary definition [invalid-argument] +ERROR typeddicts_alt_syntax.py:41:40-48: Unrecognized keyword argument `year` in typed dictionary definition [invalid-argument] +ERROR typeddicts_alt_syntax.py:44:11-17: Key `name` is not defined in TypedDict `Movie2` [bad-typed-dict-key] +ERROR typeddicts_alt_syntax.py:44:35-41: Key `year` is not defined in TypedDict `Movie2` [bad-typed-dict-key] +ERROR typeddicts_alt_syntax.py:45:11-17: Key `name` is not defined in TypedDict `Movie2` [bad-typed-dict-key] +ERROR typeddicts_alt_syntax.py:45:35-41: Key `year` is not defined in TypedDict `Movie2` [bad-typed-dict-key] +""" diff --git a/conformance/results/pyrefly/typeddicts_class_syntax.toml b/conformance/results/pyrefly/typeddicts_class_syntax.toml new file mode 100644 index 000000000..abea056d9 --- /dev/null +++ b/conformance/results/pyrefly/typeddicts_class_syntax.toml @@ -0,0 +1,12 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR typeddicts_class_syntax.py:30:9-16: TypedDict members must be declared in the form `field: Annotation` with no assignment [bad-class-definition] +ERROR typeddicts_class_syntax.py:35:9-16: TypedDict members must be declared in the form `field: Annotation` with no assignment [bad-class-definition] +ERROR typeddicts_class_syntax.py:40:9-16: TypedDict members must be declared in the form `field: Annotation` with no assignment [bad-class-definition] +ERROR typeddicts_class_syntax.py:49:7-20: Typed dictionary definitions may not specify a metaclass [invalid-inheritance] +ERROR typeddicts_class_syntax.py:54:7-20: TypedDict does not support keyword argument `other` [bad-typed-dict] +ERROR typeddicts_class_syntax.py:69:17-32: No matching overload found for function `ConditionalField.__init__` called with arguments: (x=Literal[1], y=Literal[2], z=Literal[3]) [no-matching-overload] +""" diff --git a/conformance/results/pyrefly/typeddicts_extra_items.toml b/conformance/results/pyrefly/typeddicts_extra_items.toml new file mode 100644 index 000000000..c85f4c008 --- /dev/null +++ b/conformance/results/pyrefly/typeddicts_extra_items.toml @@ -0,0 +1,34 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR typeddicts_extra_items.py:15:45-49: `Literal[1982]` is not assignable to TypedDict key with type `bool` [bad-assignment] +ERROR typeddicts_extra_items.py:22:55-59: `Literal[1982]` is not assignable to TypedDict key with type `bool` [bad-assignment] +ERROR typeddicts_extra_items.py:39:54-58: `None` is not assignable to TypedDict key `year` with type `int` [bad-assignment] +ERROR typeddicts_extra_items.py:49:7-16: Expected literal True or False for keyword `closed`, got instance of `bool` [bad-typed-dict] +ERROR typeddicts_extra_items.py:67:7-20: Non-closed TypedDict cannot inherit from closed TypedDict `ClosedBase` [bad-typed-dict] +ERROR typeddicts_extra_items.py:73:7-20: Non-closed TypedDict cannot inherit from TypedDict `ExtraItemsBase` with extra items [bad-typed-dict] +ERROR typeddicts_extra_items.py:92:5-8: Cannot extend closed TypedDict `MovieA` with extra item `age` [bad-typed-dict-key] +ERROR typeddicts_extra_items.py:95:5-8: Cannot extend closed TypedDict `MovieB` with extra item `age` [bad-typed-dict-key] +ERROR typeddicts_extra_items.py:109:7-30: Closed TypedDict cannot inherit from TypedDict `ExtraItemsBase` with non-read-only extra items [bad-typed-dict] +ERROR typeddicts_extra_items.py:114:50-63: `Required` is not allowed in this context [invalid-annotation] +ERROR typeddicts_extra_items.py:117:57-73: `NotRequired` is not allowed in this context [invalid-annotation] +ERROR typeddicts_extra_items.py:128:15-21: Key `name` in TypedDict `MovieEI` may not be deleted [unsupported-delete] +ERROR typeddicts_extra_items.py:143:48-52: Unexpected keyword argument `year` in function `unpack_no_extra` [unexpected-keyword] +ERROR typeddicts_extra_items.py:174:7-12: Cannot change the non-read-only extra items type of TypedDict `Parent` [bad-typed-dict] +ERROR typeddicts_extra_items.py:185:5-9: Cannot add required field `year` to TypedDict `MovieBase2` with non-read-only `extra_items` [bad-typed-dict-key] +ERROR typeddicts_extra_items.py:188:5-9: `int` is not consistent with `extra_items` type `int | None` of TypedDict `MovieBase2` [bad-typed-dict-key] +ERROR typeddicts_extra_items.py:197:5-14: `str` is not assignable to `extra_items` type `int | None` of TypedDict `BookBase` [bad-typed-dict-key] +ERROR typeddicts_extra_items.py:215:22-30: `MovieDetails` is not assignable to `MovieBase2` [bad-assignment] +ERROR typeddicts_extra_items.py:222:22-30: `MovieWithYear2` is not assignable to `MovieBase2` [bad-assignment] +ERROR typeddicts_extra_items.py:242:19-27: `MovieDetails5` is not assignable to `MovieSI` [bad-assignment] +ERROR typeddicts_extra_items.py:256:13-22: `MovieExtraStr` is not assignable to variable `extra_int` with type `MovieExtraInt` [bad-assignment] +ERROR typeddicts_extra_items.py:257:13-22: `MovieExtraInt` is not assignable to variable `extra_str` with type `MovieExtraStr` [bad-assignment] +ERROR typeddicts_extra_items.py:268:14-24: `MovieNotClosed` is not assignable to variable `extra_int2` with type `MovieExtraInt` [bad-assignment] +ERROR typeddicts_extra_items.py:278:15-57: No matching overload found for function `NonClosedMovie.__init__` called with arguments: (name=Literal['No Country for Old Men'], year=Literal[2007]) [no-matching-overload] +ERROR typeddicts_extra_items.py:285:52-61: Keyword argument `language` with type `Literal['English']` is not assignable to kwargs type `int` in function `ExtraMovie.__init__` [bad-argument-type] +ERROR typeddicts_extra_items.py:293:12-54: No matching overload found for function `ClosedMovie.__init__` called with arguments: (name=Literal['No Country for Old Men'], year=Literal[2007]) [no-matching-overload] +ERROR typeddicts_extra_items.py:303:34-44: `MovieExtraInt` is not assignable to `Mapping[str, int]` [bad-assignment] +ERROR typeddicts_extra_items.py:352:25-52: `dict[str, int]` is not assignable to `IntDict` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/typeddicts_final.toml b/conformance/results/pyrefly/typeddicts_final.toml new file mode 100644 index 000000000..be211bd5b --- /dev/null +++ b/conformance/results/pyrefly/typeddicts_final.toml @@ -0,0 +1,6 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pyrefly/typeddicts_inheritance.toml b/conformance/results/pyrefly/typeddicts_inheritance.toml new file mode 100644 index 000000000..621a115e8 --- /dev/null +++ b/conformance/results/pyrefly/typeddicts_inheritance.toml @@ -0,0 +1,9 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR typeddicts_inheritance.py:44:7-19: `NonTypedDict` is not a typed dictionary. Typed dictionary definitions may only extend other typed dictionaries. [invalid-inheritance] +ERROR typeddicts_inheritance.py:55:4-5: Class member `Y1.x` overrides parent class `X1` in an inconsistent manner [bad-override-mutable-attribute] +ERROR typeddicts_inheritance.py:65:7-11: Field `x` has inconsistent types inherited from multiple base classes [inconsistent-inheritance] +""" diff --git a/conformance/results/pyrefly/typeddicts_operations.toml b/conformance/results/pyrefly/typeddicts_operations.toml new file mode 100644 index 000000000..d7b4e31aa --- /dev/null +++ b/conformance/results/pyrefly/typeddicts_operations.toml @@ -0,0 +1,18 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR typeddicts_operations.py:22:17-21: `Literal[1982]` is not assignable to TypedDict key `name` with type `str` [bad-assignment] +ERROR typeddicts_operations.py:23:17-19: `Literal['']` is not assignable to TypedDict key `year` with type `int` [bad-assignment] +ERROR typeddicts_operations.py:24:7-14: TypedDict `Movie` does not have key `other` [bad-typed-dict-key] +ERROR typeddicts_operations.py:26:13-20: TypedDict `Movie` does not have key `other` [bad-typed-dict-key] +ERROR typeddicts_operations.py:28:9-33: Missing required key `year` for TypedDict `Movie` [bad-typed-dict-key] +ERROR typeddicts_operations.py:29:42-48: `float` is not assignable to TypedDict key `year` with type `int` [bad-assignment] +ERROR typeddicts_operations.py:32:36-43: Key `other` is not defined in TypedDict `Movie` [bad-typed-dict-key] +ERROR typeddicts_operations.py:37:20-52: Missing required key `name` for TypedDict `Movie` [bad-typed-dict-key] +ERROR typeddicts_operations.py:37:21-33: Expected string literal key, got `str` [bad-typed-dict-key] +ERROR typeddicts_operations.py:47:1-12: Object of class `Movie` has no attribute `clear` [missing-attribute] +ERROR typeddicts_operations.py:49:11-17: Key `name` in TypedDict `Movie` may not be deleted [unsupported-delete] +ERROR typeddicts_operations.py:62:1-21: Object of class `MovieOptional` has no attribute `clear` [missing-attribute] +""" diff --git a/conformance/results/pyrefly/typeddicts_readonly.toml b/conformance/results/pyrefly/typeddicts_readonly.toml new file mode 100644 index 000000000..08517495c --- /dev/null +++ b/conformance/results/pyrefly/typeddicts_readonly.toml @@ -0,0 +1,12 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR typeddicts_readonly.py:24:4-13: Key `members` in TypedDict `Band` is read-only [read-only] +ERROR typeddicts_readonly.py:36:4-13: Key `members` in TypedDict `Band2` is read-only [read-only] +ERROR typeddicts_readonly.py:50:4-11: Key `title` in TypedDict `Movie1` is read-only [read-only] +ERROR typeddicts_readonly.py:51:4-10: Key `year` in TypedDict `Movie1` is read-only [read-only] +ERROR typeddicts_readonly.py:60:4-11: Key `title` in TypedDict `Movie2` is read-only [read-only] +ERROR typeddicts_readonly.py:61:4-10: Key `year` in TypedDict `Movie2` is read-only [read-only] +""" diff --git a/conformance/results/pyrefly/typeddicts_readonly_consistency.toml b/conformance/results/pyrefly/typeddicts_readonly_consistency.toml new file mode 100644 index 000000000..9f8e01d85 --- /dev/null +++ b/conformance/results/pyrefly/typeddicts_readonly_consistency.toml @@ -0,0 +1,13 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR typeddicts_readonly_consistency.py:37:14-15: `A1` is not assignable to `B1` [bad-assignment] +ERROR typeddicts_readonly_consistency.py:38:14-15: `C1` is not assignable to `B1` [bad-assignment] +ERROR typeddicts_readonly_consistency.py:40:14-15: `A1` is not assignable to `C1` [bad-assignment] +ERROR typeddicts_readonly_consistency.py:81:14-15: `A2` is not assignable to `B2` [bad-assignment] +ERROR typeddicts_readonly_consistency.py:82:14-15: `C2` is not assignable to `B2` [bad-assignment] +ERROR typeddicts_readonly_consistency.py:84:14-15: `A2` is not assignable to `C2` [bad-assignment] +ERROR typeddicts_readonly_consistency.py:85:14-15: `B2` is not assignable to `C2` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/typeddicts_readonly_inheritance.toml b/conformance/results/pyrefly/typeddicts_readonly_inheritance.toml new file mode 100644 index 000000000..e2eb106eb --- /dev/null +++ b/conformance/results/pyrefly/typeddicts_readonly_inheritance.toml @@ -0,0 +1,17 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR typeddicts_readonly_inheritance.py:36:4-10: Key `name` in TypedDict `Album2` is read-only [read-only] +ERROR typeddicts_readonly_inheritance.py:50:5-8: Class member `RecordShop.alt` overrides parent class `AlbumCollection` in an inconsistent manner [bad-override] +ERROR typeddicts_readonly_inheritance.py:65:19-21: Missing required key `name` for TypedDict `RequiredName` [bad-typed-dict-key] +ERROR typeddicts_readonly_inheritance.py:82:14-15: `Literal[3]` is not assignable to TypedDict key `ident` with type `str` [bad-assignment] +ERROR typeddicts_readonly_inheritance.py:83:15-16: `Literal[3]` is not assignable to TypedDict key `ident` with type `str` [bad-assignment] +ERROR typeddicts_readonly_inheritance.py:84:5-7: Missing required key `ident` for TypedDict `User` [bad-typed-dict-key] +ERROR typeddicts_readonly_inheritance.py:94:5-6: TypedDict field `a` in `F3` cannot be marked read-only; parent TypedDict `F1` defines it as mutable [bad-typed-dict-key] +ERROR typeddicts_readonly_inheritance.py:98:5-6: TypedDict field `a` in `F4` must remain required because parent TypedDict `F1` defines it as required [bad-typed-dict-key] +ERROR typeddicts_readonly_inheritance.py:106:5-6: TypedDict field `c` in `F6` cannot be made non-required; parent TypedDict `F1` defines it as required [bad-typed-dict-key] +ERROR typeddicts_readonly_inheritance.py:119:7-11: Field `x` is declared `float` in ancestor `class TD_A2: ... `, which is not assignable to the type `int` implied by multiple inheritance [inconsistent-inheritance] +ERROR typeddicts_readonly_inheritance.py:132:7-11: TypedDict field `x` in `TD_B` cannot be made non-required; parent TypedDict `TD_B2` defines it as required [bad-typed-dict-key] +""" diff --git a/conformance/results/pyrefly/typeddicts_readonly_kwargs.toml b/conformance/results/pyrefly/typeddicts_readonly_kwargs.toml new file mode 100644 index 000000000..0be703f17 --- /dev/null +++ b/conformance/results/pyrefly/typeddicts_readonly_kwargs.toml @@ -0,0 +1,7 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR typeddicts_readonly_kwargs.py:33:12-18: Key `key1` in TypedDict `ReadOnlyArgs` is read-only [read-only] +""" diff --git a/conformance/results/pyrefly/typeddicts_readonly_update.toml b/conformance/results/pyrefly/typeddicts_readonly_update.toml new file mode 100644 index 000000000..44bc14874 --- /dev/null +++ b/conformance/results/pyrefly/typeddicts_readonly_update.toml @@ -0,0 +1,7 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR typeddicts_readonly_update.py:23:10-14: No matching overload found for function `A.update` called with arguments: (A) [no-matching-overload] +""" diff --git a/conformance/results/pyrefly/typeddicts_required.toml b/conformance/results/pyrefly/typeddicts_required.toml new file mode 100644 index 000000000..765286b13 --- /dev/null +++ b/conformance/results/pyrefly/typeddicts_required.toml @@ -0,0 +1,11 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR typeddicts_required.py:12:5-6: `Required` may only be used for TypedDict members [invalid-annotation] +ERROR typeddicts_required.py:16:8-19: `NotRequired` is only allowed inside a class body [invalid-annotation] +ERROR typeddicts_required.py:16:8-24: `NotRequired` is not allowed in this context [invalid-annotation] +ERROR typeddicts_required.py:60:8-31: Duplicate qualifier `Required` [invalid-annotation] +ERROR typeddicts_required.py:61:8-34: Cannot combine `Required` and `NotRequired` for a TypedDict field [invalid-annotation] +""" diff --git a/conformance/results/pyrefly/typeddicts_type_consistency.toml b/conformance/results/pyrefly/typeddicts_type_consistency.toml new file mode 100644 index 000000000..fa29b2f84 --- /dev/null +++ b/conformance/results/pyrefly/typeddicts_type_consistency.toml @@ -0,0 +1,15 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR typeddicts_type_consistency.py:21:10-12: `B1` is not assignable to `A1` [bad-assignment] +ERROR typeddicts_type_consistency.py:38:10-12: `B2` is not assignable to `A2` [bad-assignment] +ERROR typeddicts_type_consistency.py:65:6-8: `A3` is not assignable to variable `b3` with type `B3` [bad-assignment] +ERROR typeddicts_type_consistency.py:69:21-24: Key `y` is not defined in TypedDict `A3` [bad-typed-dict-key] +ERROR typeddicts_type_consistency.py:76:22-24: `B3` is not assignable to `dict[str, int]` [bad-assignment] +ERROR typeddicts_type_consistency.py:77:25-27: `B3` is not assignable to `dict[str, object]` [bad-assignment] +ERROR typeddicts_type_consistency.py:78:22-24: `B3` is not assignable to `dict[Any, Any]` [bad-assignment] +ERROR typeddicts_type_consistency.py:82:25-27: `B3` is not assignable to `Mapping[str, int]` [bad-assignment] +ERROR typeddicts_type_consistency.py:126:56-57: `Literal[1]` is not assignable to TypedDict key `inner_key` with type `str` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/typeddicts_usage.toml b/conformance/results/pyrefly/typeddicts_usage.toml new file mode 100644 index 000000000..7406846f5 --- /dev/null +++ b/conformance/results/pyrefly/typeddicts_usage.toml @@ -0,0 +1,12 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR typeddicts_usage.py:23:7-17: TypedDict `Movie` does not have key `director` [bad-typed-dict-key] +ERROR typeddicts_usage.py:24:17-23: `Literal['1982']` is not assignable to TypedDict key `year` with type `int` [bad-assignment] +ERROR typeddicts_usage.py:28:17-56: Missing required key `name` for TypedDict `Movie` [bad-typed-dict-key] +ERROR typeddicts_usage.py:28:18-25: Key `title` is not defined in TypedDict `Movie` [bad-typed-dict-key] +ERROR typeddicts_usage.py:35:22-27: TypedDict `Movie` not allowed as second argument to isinstance() [invalid-argument] +ERROR typeddicts_usage.py:40:24-33: `TypedDict` is not allowed in this context [invalid-annotation] +""" diff --git a/conformance/results/pyrefly/typeforms_typeform.toml b/conformance/results/pyrefly/typeforms_typeform.toml new file mode 100644 index 000000000..53ea18bed --- /dev/null +++ b/conformance/results/pyrefly/typeforms_typeform.toml @@ -0,0 +1,21 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +ERROR typeforms_typeform.py:23:30-39: `type[int | str]` is not assignable to `TypeForm[str | None]` [bad-assignment] +ERROR typeforms_typeform.py:24:30-46: `type[list[str | None]]` is not assignable to `TypeForm[str | None]` [bad-assignment] +ERROR typeforms_typeform.py:59:7-19: Argument `Literal['not a type']` is not assignable to parameter `x` with type `TypeForm[Any]` in function `func1` [bad-argument-type] +ERROR typeforms_typeform.py:67:18-25: `tuple[Unknown, ...]` is not assignable to `TypeForm[Any]` [bad-assignment] +ERROR typeforms_typeform.py:68:18-24: `tuple[Literal[1], Literal[2]]` is not assignable to `TypeForm[Any]` [bad-assignment] +ERROR typeforms_typeform.py:69:18-19: `Literal[1]` is not assignable to `TypeForm[Any]` [bad-assignment] +ERROR typeforms_typeform.py:70:18-22: `type[Self]` is not assignable to `TypeForm[Any]` [bad-assignment] +ERROR typeforms_typeform.py:71:18-31: `ClassVar` is not allowed in this context [invalid-annotation] +ERROR typeforms_typeform.py:72:18-28: `Final` is not allowed in this context [invalid-annotation] +ERROR typeforms_typeform.py:73:18-28: `type[*TypeVarTuple[Ts]]` is not assignable to `TypeForm[Any]` [bad-assignment] +ERROR typeforms_typeform.py:74:18-26: `type[Optional]` is not assignable to `TypeForm[Any]` [bad-assignment] +ERROR typeforms_typeform.py:75:19-28: `+` is not supported between `type[int]` and `type[str]` [unsupported-operation] +ERROR typeforms_typeform.py:86:16-23: Function call cannot be used in annotations [invalid-annotation] +ERROR typeforms_typeform.py:88:15-22: Function call cannot be used in annotations [invalid-annotation] +ERROR typeforms_typeform.py:98:21-36: `TypeForm[int]` is not assignable to `TypeForm[str]` [bad-assignment] +ERROR typeforms_typeform.py:108:21-31: `type[int]` is not assignable to `TypeForm[str]` [bad-assignment] +""" diff --git a/conformance/results/pyrefly/version.toml b/conformance/results/pyrefly/version.toml new file mode 100644 index 000000000..017c55769 --- /dev/null +++ b/conformance/results/pyrefly/version.toml @@ -0,0 +1 @@ +version = "pyrefly 1.4.0" diff --git a/conformance/results/pyright/aliases_explicit.toml b/conformance/results/pyright/aliases_explicit.toml index c52150393..5948d8aba 100644 --- a/conformance/results/pyright/aliases_explicit.toml +++ b/conformance/results/pyright/aliases_explicit.toml @@ -3,41 +3,44 @@ output = """ aliases_explicit.py:67:24 - error: Expected no type arguments for class "int" (reportInvalidTypeArguments) aliases_explicit.py:67:24 - error: Expected no type arguments for class "NoneType" (reportInvalidTypeArguments) aliases_explicit.py:68:9 - error: Type "list[int | None]" is already specialized (reportInvalidTypeArguments) -aliases_explicit.py:69:29 - error: Too many type arguments provided for "GoodTypeAlias4[T@GoodTypeAlias4]"; expected 1 but received 2 -aliases_explicit.py:70:29 - error: Too many type arguments provided for "GoodTypeAlias8[T@GoodTypeAlias8]"; expected 1 but received 2 -aliases_explicit.py:71:24 - error: Expected ParamSpec, ellipsis, or list of types +aliases_explicit.py:69:29 - error: Too many type arguments provided for "GoodTypeAlias4[T@GoodTypeAlias4]"; expected 1 but received 2 (reportInvalidTypeForm) +aliases_explicit.py:70:29 - error: Too many type arguments provided for "GoodTypeAlias8[T@GoodTypeAlias8]"; expected 1 but received 2 (reportInvalidTypeForm) +aliases_explicit.py:71:24 - error: Expected ParamSpec, ellipsis, or list of types (reportInvalidTypeForm) aliases_explicit.py:79:21 - error: Invalid expression form for type alias definition (reportInvalidTypeForm) aliases_explicit.py:79:21 - error: Call expression not allowed in type expression (reportInvalidTypeForm) aliases_explicit.py:80:21 - error: Invalid expression form for type alias definition (reportInvalidTypeForm) -aliases_explicit.py:80:21 - error: List expression not allowed in type annotation -  Use List[T] to indicate a list type or Union[T1, T2] to indicate a union type (reportInvalidTypeForm) -aliases_explicit.py:80:21 - error: Expected type expression but received "list[Unknown]" (reportGeneralTypeIssues) +aliases_explicit.py:80:21 - error: List expression not allowed in type expression +  Use list[T] to indicate a list type or T1 | T2 to indicate a union type (reportInvalidTypeForm) +aliases_explicit.py:80:21 - error: Expected class but received "list[Unknown]" (reportGeneralTypeIssues) aliases_explicit.py:81:21 - error: Invalid expression form for type alias definition (reportInvalidTypeForm) -aliases_explicit.py:81:21 - error: Tuple expression not allowed in type annotation -  Use tuple[T1, ..., Tn] to indicate a tuple type or Union[T1, T2] to indicate a union type (reportInvalidTypeForm) +aliases_explicit.py:81:21 - error: Tuple expression not allowed in type expression +  Use tuple[T1, ..., Tn] to indicate a tuple type or T1 | T2 to indicate a union type (reportInvalidTypeForm) aliases_explicit.py:82:21 - error: Invalid expression form for type alias definition (reportInvalidTypeForm) -aliases_explicit.py:82:21 - error: List expression not allowed in type annotation -  Use List[T] to indicate a list type or Union[T1, T2] to indicate a union type (reportInvalidTypeForm) -aliases_explicit.py:82:21 - error: Expected type expression but received "list[type[int]]" (reportGeneralTypeIssues) +aliases_explicit.py:82:21 - error: List expression not allowed in type expression +  Use list[T] to indicate a list type or T1 | T2 to indicate a union type (reportInvalidTypeForm) +aliases_explicit.py:82:21 - error: Expected class but received "list[type[int]]" (reportGeneralTypeIssues) aliases_explicit.py:83:21 - error: Invalid expression form for type alias definition (reportInvalidTypeForm) -aliases_explicit.py:83:21 - error: Dictionary expression not allowed in type annotation -  Use Dict[T1, T2] to indicate a dictionary type (reportInvalidTypeForm) -aliases_explicit.py:83:21 - error: Expected type expression but received "dict[str, str]" (reportGeneralTypeIssues) +aliases_explicit.py:83:21 - error: Dictionary expression not allowed in type expression +  Use dict[T1, T2] to indicate a dictionary type (reportInvalidTypeForm) +aliases_explicit.py:83:21 - error: Expected class but received "dict[str, Unknown]" (reportGeneralTypeIssues) +aliases_explicit.py:83:28 - error: "b" is not defined (reportUndefinedVariable) aliases_explicit.py:84:21 - error: Invalid expression form for type alias definition (reportInvalidTypeForm) aliases_explicit.py:84:21 - error: Call expression not allowed in type expression (reportInvalidTypeForm) aliases_explicit.py:85:21 - error: Invalid expression form for type alias definition (reportInvalidTypeForm) -aliases_explicit.py:85:21 - error: List expression not allowed in type annotation -  Use List[T] to indicate a list type or Union[T1, T2] to indicate a union type (reportInvalidTypeForm) -aliases_explicit.py:85:21 - error: Expected type expression but received "list[type[int]]" (reportGeneralTypeIssues) +aliases_explicit.py:85:21 - error: List expression not allowed in type expression +  Use list[T] to indicate a list type or T1 | T2 to indicate a union type (reportInvalidTypeForm) +aliases_explicit.py:85:21 - error: Expected class but received "list[type[int]]" (reportGeneralTypeIssues) +aliases_explicit.py:85:27 - error: Expected class but received "Literal[0]" (reportGeneralTypeIssues) aliases_explicit.py:86:21 - error: Invalid expression form for type alias definition (reportInvalidTypeForm) -aliases_explicit.py:86:21 - error: Ternary expression not allowed in type annotation (reportInvalidTypeForm) +aliases_explicit.py:86:21 - error: Ternary expression not allowed in type expression (reportInvalidTypeForm) aliases_explicit.py:87:21 - error: Variable not allowed in type expression (reportInvalidTypeForm) -aliases_explicit.py:88:22 - error: Expected type expression but received "Literal[True]" (reportGeneralTypeIssues) +aliases_explicit.py:88:22 - error: Invalid expression form for type alias definition (reportInvalidTypeForm) +aliases_explicit.py:88:22 - error: Expected class but received "Literal[True]" (reportGeneralTypeIssues) aliases_explicit.py:89:22 - error: Invalid expression form for type alias definition (reportInvalidTypeForm) -aliases_explicit.py:89:22 - error: Expected type expression but received "Literal[1]" (reportGeneralTypeIssues) +aliases_explicit.py:89:22 - error: Expected class but received "Literal[1]" (reportGeneralTypeIssues) aliases_explicit.py:90:22 - error: Invalid expression form for type alias definition (reportInvalidTypeForm) -aliases_explicit.py:90:22 - error: Binary operator not allowed in type annotation (reportInvalidTypeForm) -aliases_explicit.py:91:22 - error: Type annotations cannot use format string literals (f-strings) (reportGeneralTypeIssues) +aliases_explicit.py:90:22 - error: Binary operator not allowed in type expression (reportInvalidTypeForm) +aliases_explicit.py:91:22 - error: Type expressions cannot use format string literals (f-strings) (reportGeneralTypeIssues) aliases_explicit.py:100:5 - error: Type "list[Unknown]" is already specialized (reportInvalidTypeArguments) aliases_explicit.py:101:6 - error: Object of type "UnionType" is not callable (reportCallIssue) aliases_explicit.py:102:5 - error: Type "list[Unknown]" is already specialized (reportInvalidTypeArguments) diff --git a/conformance/results/pyright/aliases_implicit.toml b/conformance/results/pyright/aliases_implicit.toml index bc3199966..32f2b7be2 100644 --- a/conformance/results/pyright/aliases_implicit.toml +++ b/conformance/results/pyright/aliases_implicit.toml @@ -3,12 +3,12 @@ output = """ aliases_implicit.py:76:24 - error: Expected no type arguments for class "int" (reportInvalidTypeArguments) aliases_implicit.py:76:24 - error: Expected no type arguments for class "NoneType" (reportInvalidTypeArguments) aliases_implicit.py:77:9 - error: Type "list[int | None]" is already specialized (reportInvalidTypeArguments) -aliases_implicit.py:78:29 - error: Too many type arguments provided for "GoodTypeAlias4[T@GoodTypeAlias4]"; expected 1 but received 2 -aliases_implicit.py:79:29 - error: Too many type arguments provided for "GoodTypeAlias8[T@GoodTypeAlias8]"; expected 1 but received 2 -aliases_implicit.py:80:24 - error: Expected ParamSpec, ellipsis, or list of types +aliases_implicit.py:78:29 - error: Too many type arguments provided for "GoodTypeAlias4[T@GoodTypeAlias4]"; expected 1 but received 2 (reportInvalidTypeForm) +aliases_implicit.py:79:29 - error: Too many type arguments provided for "GoodTypeAlias8[T@GoodTypeAlias8]"; expected 1 but received 2 (reportInvalidTypeForm) +aliases_implicit.py:80:24 - error: Expected ParamSpec, ellipsis, or list of types (reportInvalidTypeForm) aliases_implicit.py:81:9 - error: Could not specialize type "GoodTypeAlias12[TFloat@GoodTypeAlias12]" -  Type "str" is incompatible with type "float" -    "str" is incompatible with "float" +  Type "str" is not assignable to type "float" +    "str" is not assignable to "float" (reportInvalidTypeForm) aliases_implicit.py:106:9 - error: Variable not allowed in type expression (reportInvalidTypeForm) aliases_implicit.py:107:9 - error: Variable not allowed in type expression (reportInvalidTypeForm) aliases_implicit.py:108:9 - error: Variable not allowed in type expression (reportInvalidTypeForm) diff --git a/conformance/results/pyright/aliases_newtype.toml b/conformance/results/pyright/aliases_newtype.toml index e95cb8ad3..4e70b6d53 100644 --- a/conformance/results/pyright/aliases_newtype.toml +++ b/conformance/results/pyright/aliases_newtype.toml @@ -1,21 +1,28 @@ conformant = "Pass" output = """ aliases_newtype.py:11:8 - error: Argument of type "Literal['user']" cannot be assigned to parameter "_x" of type "int" in function "__init__" -  "Literal['user']" is incompatible with "int" (reportArgumentType) -aliases_newtype.py:12:14 - error: Expression of type "Literal[42]" is incompatible with declared type "UserId" -  "Literal[42]" is incompatible with "UserId" (reportAssignmentType) -aliases_newtype.py:20:16 - error: Second argument to "isinstance" must be a class or tuple of classes -  Class created with NewType cannot be used with instance and class checks (reportArgumentType) -aliases_newtype.py:23:21 - error: Base class "UserId" is marked final and cannot be subclassed -aliases_newtype.py:32:1 - error: NewType must be assigned to a variable with the same name (reportGeneralTypeIssues) -aliases_newtype.py:38:19 - error: Expected no type arguments for class "GoodNewType1" (reportInvalidTypeArguments) -aliases_newtype.py:44:38 - error: Expected class as second argument to NewType (reportGeneralTypeIssues) -aliases_newtype.py:47:43 - error: Type variable "T" has no meaning in this context (reportGeneralTypeIssues) -aliases_newtype.py:49:38 - error: NewType cannot be used with structural type (a protocol or TypedDict class) (reportGeneralTypeIssues) -aliases_newtype.py:51:38 - error: NewType cannot be used with Literal type (reportGeneralTypeIssues) -aliases_newtype.py:58:38 - error: NewType cannot be used with structural type (a protocol or TypedDict class) (reportGeneralTypeIssues) -aliases_newtype.py:60:15 - error: NewType requires two positional arguments (reportCallIssue) -aliases_newtype.py:62:38 - error: The second argument to NewType must be a known class, not Any or Unknown (reportGeneralTypeIssues) +  "Literal['user']" is not assignable to "int" (reportArgumentType) +aliases_newtype.py:12:14 - error: Type "Literal[42]" is not assignable to declared type "UserId" +  "Literal[42]" is not assignable to "UserId" (reportAssignmentType) +aliases_newtype.py:18:11 - error: Type "type[UserId]" is not assignable to declared type "type" +  "FunctionType" is not assignable to "type" (reportAssignmentType) +aliases_newtype.py:23:16 - error: Argument of type "type[UserId]" cannot be assigned to parameter "class_or_tuple" of type "_ClassInfo" in function "isinstance" +  Type "FunctionType" is not assignable to type "_ClassInfo" +    "FunctionType" is not assignable to "type" +    "FunctionType" is not assignable to "UnionType" +    "FunctionType" is not assignable to "tuple[_ClassInfo, ...]" (reportArgumentType) +aliases_newtype.py:23:16 - error: Second argument to "isinstance" must be a class or tuple of classes +  Type created with NewType cannot be used with instance and class checks (reportArgumentType) +aliases_newtype.py:26:21 - error: Base class "UserId" is marked final and cannot be subclassed (reportGeneralTypeIssues) +aliases_newtype.py:35:1 - error: NewType must be assigned to a variable with the same name (reportGeneralTypeIssues) +aliases_newtype.py:41:19 - error: Expected no type arguments for class "GoodNewType1" (reportInvalidTypeArguments) +aliases_newtype.py:47:38 - error: Expected class as second argument to NewType (reportGeneralTypeIssues) +aliases_newtype.py:50:43 - error: Type variable "T" has no meaning in this context (reportGeneralTypeIssues) +aliases_newtype.py:52:38 - error: NewType cannot be used with structural type (a Protocol or TypedDict class) (reportGeneralTypeIssues) +aliases_newtype.py:54:38 - error: NewType cannot be used with Literal type (reportGeneralTypeIssues) +aliases_newtype.py:61:38 - error: NewType cannot be used with structural type (a Protocol or TypedDict class) (reportGeneralTypeIssues) +aliases_newtype.py:63:15 - error: NewType requires two positional arguments (reportCallIssue) +aliases_newtype.py:65:38 - error: The second argument to NewType must be a known class, not Any or Unknown (reportGeneralTypeIssues) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/aliases_recursive.toml b/conformance/results/pyright/aliases_recursive.toml index 47830d168..dd135ac2b 100644 --- a/conformance/results/pyright/aliases_recursive.toml +++ b/conformance/results/pyright/aliases_recursive.toml @@ -1,66 +1,74 @@ conformant = "Pass" output = """ -aliases_recursive.py:19:12 - error: Expression of type "dict[str, int | complex]" is incompatible with declared type "Json" -  Type "dict[str, int | complex]" is incompatible with type "Json" -    "dict[str, int | complex]" is incompatible with "None" -    "dict[str, int | complex]" is incompatible with "int" -    "dict[str, int | complex]" is incompatible with "str" -    "dict[str, int | complex]" is incompatible with "float" -    "dict[str, int | complex]" is incompatible with "list[Json]" -    "dict[str, int | complex]" is incompatible with "dict[str, Json]" +aliases_recursive.py:19:12 - error: Type "dict[str, int | complex]" is not assignable to declared type "Json" +  Type "dict[str, int | complex]" is not assignable to type "Json" +    "dict[str, int | complex]" is not assignable to "None" +    "dict[str, int | complex]" is not assignable to "int" +    "dict[str, int | complex]" is not assignable to "str" +    "dict[str, int | complex]" is not assignable to "float" +    "dict[str, int | complex]" is not assignable to "list[Json]" +    "dict[str, int | complex]" is not assignable to "dict[str, Json]"       Type parameter "_VT@dict" is invariant, but "int | complex" is not the same as "Json" ... (reportAssignmentType) -aliases_recursive.py:20:16 - error: Expression of type "list[int | complex]" is incompatible with declared type "Json" -  Type "complex" is incompatible with type "Json" -    "complex" is incompatible with "None" -    "complex" is incompatible with "int" -    "complex" is incompatible with "str" -    "complex" is incompatible with "float" -    "complex" is incompatible with "list[Json]" -    "complex" is incompatible with "dict[str, Json]" (reportAssignmentType) -aliases_recursive.py:38:22 - error: Expression of type "tuple[Literal[1], tuple[Literal['1'], Literal[1]], tuple[Literal[1], tuple[Literal[1], list[int]]]]" is incompatible with declared type "RecursiveTuple" -  Type "tuple[Literal[1], tuple[Literal['1'], Literal[1]], tuple[Literal[1], tuple[Literal[1], list[int]]]]" is incompatible with type "RecursiveTuple" -    "tuple[Literal[1], tuple[Literal['1'], Literal[1]], tuple[Literal[1], tuple[Literal[1], list[int]]]]" is incompatible with "str" -    "tuple[Literal[1], tuple[Literal['1'], Literal[1]], tuple[Literal[1], tuple[Literal[1], list[int]]]]" is incompatible with "int" -    "tuple[Literal[1], tuple[Literal['1'], Literal[1]], tuple[Literal[1], tuple[Literal[1], list[int]]]]" is incompatible with "tuple[RecursiveTuple, ...]" -      Tuple entry 1 is incorrect type (reportAssignmentType) -aliases_recursive.py:39:22 - error: Expression of type "tuple[Literal[1], list[int]]" is incompatible with declared type "RecursiveTuple" -  Type "tuple[Literal[1], list[int]]" is incompatible with type "RecursiveTuple" -    "tuple[Literal[1], list[int]]" is incompatible with "str" -    "tuple[Literal[1], list[int]]" is incompatible with "int" -    "tuple[Literal[1], list[int]]" is incompatible with "tuple[RecursiveTuple, ...]" -      Tuple entry 1 is incorrect type (reportAssignmentType) -aliases_recursive.py:50:24 - error: Expression of type "dict[str, list[int]]" is incompatible with declared type "RecursiveMapping" -  Type "dict[str, list[int]]" is incompatible with type "RecursiveMapping" -    "dict[str, list[int]]" is incompatible with "str" -    "dict[str, list[int]]" is incompatible with "int" -    "dict[str, list[int]]" is incompatible with "Mapping[str, RecursiveMapping]" +aliases_recursive.py:20:16 - error: Type "list[int | complex]" is not assignable to declared type "Json" +  Type "complex" is not assignable to type "Json" +    "complex" is not assignable to "None" +    "complex" is not assignable to "int" +    "complex" is not assignable to "str" +    "complex" is not assignable to "float" +    "complex" is not assignable to "list[Json]" +    "complex" is not assignable to "dict[str, Json]" (reportAssignmentType) +aliases_recursive.py:38:22 - error: Type "tuple[Literal[1], tuple[str, int], tuple[int, tuple[int, list[int]]]]" is not assignable to declared type "RecursiveTuple" +  Type "tuple[Literal[1], tuple[str, int], tuple[int, tuple[int, list[int]]]]" is not assignable to type "RecursiveTuple" +    "tuple[Literal[1], tuple[str, int], tuple[int, tuple[int, list[int]]]]" is not assignable to "str" +    "tuple[Literal[1], tuple[str, int], tuple[int, tuple[int, list[int]]]]" is not assignable to "int" +    "tuple[Literal[1], tuple[str, int], tuple[int, tuple[int, list[int]]]]" is not assignable to "tuple[RecursiveTuple, ...]" +      Tuple entry 1 is incorrect type +        Type "tuple[str, int] | tuple[int, tuple[int, list[int]]] | Literal[1]" is not assignable to type "RecursiveTuple" +          Type "tuple[int, tuple[int, list[int]]]" is not assignable to type "RecursiveTuple" (reportAssignmentType) +aliases_recursive.py:39:22 - error: Type "tuple[Literal[1], list[int]]" is not assignable to declared type "RecursiveTuple" +  Type "tuple[Literal[1], list[int]]" is not assignable to type "RecursiveTuple" +    "tuple[Literal[1], list[int]]" is not assignable to "str" +    "tuple[Literal[1], list[int]]" is not assignable to "int" +    "tuple[Literal[1], list[int]]" is not assignable to "tuple[RecursiveTuple, ...]" +      Tuple entry 1 is incorrect type +        Type "list[int] | Literal[1]" is not assignable to type "RecursiveTuple" +          Type "list[int]" is not assignable to type "RecursiveTuple" (reportAssignmentType) +aliases_recursive.py:50:24 - error: Type "dict[str, list[int]]" is not assignable to declared type "RecursiveMapping" +  Type "dict[str, list[int]]" is not assignable to type "RecursiveMapping" +    "dict[str, list[int]]" is not assignable to "str" +    "dict[str, list[int]]" is not assignable to "int" +    "dict[str, list[int]]" is not assignable to "Mapping[str, RecursiveMapping]"       Type parameter "_VT_co@Mapping" is covariant, but "list[int]" is not a subtype of "RecursiveMapping" -        Type "list[int]" is incompatible with type "RecursiveMapping" -          "list[int]" is incompatible with "str" -          "list[int]" is incompatible with "int" +        Type "list[int]" is not assignable to type "RecursiveMapping" +          "list[int]" is not assignable to "str" +          "list[int]" is not assignable to "int" ... (reportAssignmentType) -aliases_recursive.py:51:24 - error: Expression of type "dict[str, str | int | list[int]]" is incompatible with declared type "RecursiveMapping" -  Type "dict[str, str | int | list[int]]" is incompatible with type "RecursiveMapping" -    "dict[str, str | int | list[int]]" is incompatible with "str" -    "dict[str, str | int | list[int]]" is incompatible with "int" -    "dict[str, str | int | list[int]]" is incompatible with "Mapping[str, RecursiveMapping]" -      Type parameter "_VT_co@Mapping" is covariant, but "str | int | list[int]" is not a subtype of "RecursiveMapping" (reportAssignmentType) -aliases_recursive.py:52:24 - error: Expression of type "dict[str, str | int | dict[str, str | int | list[int]]]" is incompatible with declared type "RecursiveMapping" -  Type "dict[str, str | int | dict[str, str | int | list[int]]]" is incompatible with type "RecursiveMapping" -    "dict[str, str | int | dict[str, str | int | list[int]]]" is incompatible with "str" -    "dict[str, str | int | dict[str, str | int | list[int]]]" is incompatible with "int" -    "dict[str, str | int | dict[str, str | int | list[int]]]" is incompatible with "Mapping[str, RecursiveMapping]" -      Type parameter "_VT_co@Mapping" is covariant, but "str | int | dict[str, str | int | list[int]]" is not a subtype of "RecursiveMapping" (reportAssignmentType) -aliases_recursive.py:63:38 - error: Expression of type "list[str | list[float]]" is incompatible with declared type "GenericTypeAlias1[str]" -  Type "float" is incompatible with type "GenericTypeAlias1[T1@GenericTypeAlias1] | str" -    "float" is incompatible with "list[GenericTypeAlias1 | str]" -    "float" is incompatible with "str" (reportAssignmentType) -aliases_recursive.py:69:51 - error: Expression of type "list[list[int | list[str | int | list[float]]] | str]" is incompatible with declared type "GenericTypeAlias2[str, int]" -  Type "float" is incompatible with type "GenericTypeAlias2[T1@GenericTypeAlias2, T2@GenericTypeAlias2] | str | int" -    "float" is incompatible with "list[GenericTypeAlias2 | str | int]" -    "float" is incompatible with "str" -    "float" is incompatible with "int" (reportAssignmentType) +aliases_recursive.py:51:24 - error: Type "dict[str, str | int | list[int]]" is not assignable to declared type "RecursiveMapping" +  Type "dict[str, str | int | list[int]]" is not assignable to type "RecursiveMapping" +    "dict[str, str | int | list[int]]" is not assignable to "str" +    "dict[str, str | int | list[int]]" is not assignable to "int" +    "dict[str, str | int | list[int]]" is not assignable to "Mapping[str, RecursiveMapping]" +      Type parameter "_VT_co@Mapping" is covariant, but "str | int | list[int]" is not a subtype of "RecursiveMapping" +        Type "str | int | list[int]" is not assignable to type "RecursiveMapping" +          Type "list[int]" is not assignable to type "RecursiveMapping" (reportAssignmentType) +aliases_recursive.py:52:24 - error: Type "dict[str, str | int | dict[str, str | int | list[int]]]" is not assignable to declared type "RecursiveMapping" +  Type "dict[str, str | int | dict[str, str | int | list[int]]]" is not assignable to type "RecursiveMapping" +    "dict[str, str | int | dict[str, str | int | list[int]]]" is not assignable to "str" +    "dict[str, str | int | dict[str, str | int | list[int]]]" is not assignable to "int" +    "dict[str, str | int | dict[str, str | int | list[int]]]" is not assignable to "Mapping[str, RecursiveMapping]" +      Type parameter "_VT_co@Mapping" is covariant, but "str | int | dict[str, str | int | list[int]]" is not a subtype of "RecursiveMapping" +        Type "str | int | dict[str, str | int | list[int]]" is not assignable to type "RecursiveMapping" +          Type "dict[str, str | int | list[int]]" is not assignable to type "RecursiveMapping" (reportAssignmentType) +aliases_recursive.py:63:38 - error: Type "list[str | list[float]]" is not assignable to declared type "GenericTypeAlias1[str]" +  Type "float" is not assignable to type "GenericTypeAlias1[T1@GenericTypeAlias1] | str" +    "float" is not assignable to "list[GenericTypeAlias1 | str]" +    "float" is not assignable to "str" (reportAssignmentType) +aliases_recursive.py:69:51 - error: Type "list[list[int | list[str | int | list[float]]] | str]" is not assignable to declared type "GenericTypeAlias2[str, int]" +  Type "float" is not assignable to type "GenericTypeAlias2[T1@GenericTypeAlias2, T2@GenericTypeAlias2] | str | int" +    "float" is not assignable to "list[GenericTypeAlias2 | str | int]" +    "float" is not assignable to "str" +    "float" is not assignable to "int" (reportAssignmentType) aliases_recursive.py:72:29 - error: Type alias "RecursiveUnion" cannot use itself in its definition (reportGeneralTypeIssues) aliases_recursive.py:75:31 - error: Type alias "MutualReference1" cannot use itself in its definition (reportGeneralTypeIssues) """ diff --git a/conformance/results/pyright/aliases_type_statement.toml b/conformance/results/pyright/aliases_type_statement.toml index 63bd24874..407dbd082 100644 --- a/conformance/results/pyright/aliases_type_statement.toml +++ b/conformance/results/pyright/aliases_type_statement.toml @@ -2,52 +2,51 @@ conformant = "Pass" output = """ aliases_type_statement.py:17:12 - error: Cannot access attribute "bit_count" for class "TypeAliasType"   Attribute "bit_count" is unknown (reportAttributeAccessIssue) -aliases_type_statement.py:19:1 - error: Object of type "TypeAliasType" is not callable (reportCallIssue) +aliases_type_statement.py:19:1 - error: Object of type "TypeAliasType" is not callable +  Attribute "__call__" is unknown (reportCallIssue) aliases_type_statement.py:23:18 - error: Cannot access attribute "other_attrib" for class "TypeAliasType"   Attribute "other_attrib" is unknown (reportAttributeAccessIssue) -aliases_type_statement.py:26:18 - error: A type alias defined in a "type" statement cannot be used as a base class -aliases_type_statement.py:31:22 - error: Argument of type "GoodAlias1" cannot be assigned to parameter "class_or_tuple" of type "_ClassInfo" in function "isinstance" -  Type "TypeAliasType" is incompatible with type "_ClassInfo" -    "TypeAliasType" is incompatible with "type" -    "TypeAliasType" is incompatible with "UnionType" -    "TypeAliasType" is incompatible with "tuple[_ClassInfo, ...]" (reportArgumentType) -aliases_type_statement.py:31:22 - error: Second argument to "isinstance" must be a class or tuple of classes -  Type alias created with "type" statement cannot be used with instance and class checks (reportArgumentType) +aliases_type_statement.py:26:18 - error: A type alias defined in a "type" statement cannot be used as a base class (reportGeneralTypeIssues) +aliases_type_statement.py:31:22 - error: Argument of type "TypeAliasType" cannot be assigned to parameter "class_or_tuple" of type "_ClassInfo" in function "isinstance" +  Type "TypeAliasType" is not assignable to type "_ClassInfo" +    "TypeAliasType" is not assignable to "type" +    "TypeAliasType" is not assignable to "UnionType" +    "TypeAliasType" is not assignable to "tuple[_ClassInfo, ...]" (reportArgumentType) aliases_type_statement.py:37:22 - error: Call expression not allowed in type expression (reportInvalidTypeForm) -aliases_type_statement.py:38:22 - error: List expression not allowed in type annotation -  Use List[T] to indicate a list type or Union[T1, T2] to indicate a union type (reportInvalidTypeForm) -aliases_type_statement.py:38:22 - error: Expected type expression but received "list[Unknown]" (reportGeneralTypeIssues) -aliases_type_statement.py:39:22 - error: Tuple expression not allowed in type annotation -  Use tuple[T1, ..., Tn] to indicate a tuple type or Union[T1, T2] to indicate a union type (reportInvalidTypeForm) -aliases_type_statement.py:40:22 - error: List expression not allowed in type annotation -  Use List[T] to indicate a list type or Union[T1, T2] to indicate a union type (reportInvalidTypeForm) -aliases_type_statement.py:40:22 - error: Expected type expression but received "list[type[int]]" (reportGeneralTypeIssues) -aliases_type_statement.py:41:22 - error: Dictionary expression not allowed in type annotation -  Use Dict[T1, T2] to indicate a dictionary type (reportInvalidTypeForm) -aliases_type_statement.py:41:22 - error: Expected type expression but received "dict[str, str]" (reportGeneralTypeIssues) +aliases_type_statement.py:38:22 - error: List expression not allowed in type expression +  Use list[T] to indicate a list type or T1 | T2 to indicate a union type (reportInvalidTypeForm) +aliases_type_statement.py:38:22 - error: Expected class but received "list[Unknown]" (reportGeneralTypeIssues) +aliases_type_statement.py:39:22 - error: Tuple expression not allowed in type expression +  Use tuple[T1, ..., Tn] to indicate a tuple type or T1 | T2 to indicate a union type (reportInvalidTypeForm) +aliases_type_statement.py:40:22 - error: List expression not allowed in type expression +  Use list[T] to indicate a list type or T1 | T2 to indicate a union type (reportInvalidTypeForm) +aliases_type_statement.py:40:22 - error: Expected class but received "list[type[int]]" (reportGeneralTypeIssues) +aliases_type_statement.py:41:22 - error: Dictionary expression not allowed in type expression +  Use dict[T1, T2] to indicate a dictionary type (reportInvalidTypeForm) +aliases_type_statement.py:41:22 - error: Expected class but received "dict[str, Unknown]" (reportGeneralTypeIssues) +aliases_type_statement.py:41:29 - error: "b" is not defined (reportUndefinedVariable) aliases_type_statement.py:42:22 - error: Call expression not allowed in type expression (reportInvalidTypeForm) -aliases_type_statement.py:43:22 - error: List expression not allowed in type annotation -  Use List[T] to indicate a list type or Union[T1, T2] to indicate a union type (reportInvalidTypeForm) -aliases_type_statement.py:43:22 - error: Expected type expression but received "list[type[int]]" (reportGeneralTypeIssues) -aliases_type_statement.py:44:22 - error: Ternary expression not allowed in type annotation (reportInvalidTypeForm) +aliases_type_statement.py:43:22 - error: List expression not allowed in type expression +  Use list[T] to indicate a list type or T1 | T2 to indicate a union type (reportInvalidTypeForm) +aliases_type_statement.py:43:22 - error: Expected class but received "list[type[int]]" (reportGeneralTypeIssues) +aliases_type_statement.py:43:28 - error: Expected class but received "Literal[0]" (reportGeneralTypeIssues) +aliases_type_statement.py:44:22 - error: Ternary expression not allowed in type expression (reportInvalidTypeForm) aliases_type_statement.py:45:22 - error: Variable not allowed in type expression (reportInvalidTypeForm) -aliases_type_statement.py:46:23 - error: Expected type expression but received "Literal[True]" (reportGeneralTypeIssues) -aliases_type_statement.py:47:23 - error: Expected type expression but received "Literal[1]" (reportGeneralTypeIssues) -aliases_type_statement.py:48:23 - error: Binary operator not allowed in type annotation (reportInvalidTypeForm) -aliases_type_statement.py:49:23 - error: Type annotations cannot use format string literals (f-strings) (reportGeneralTypeIssues) -aliases_type_statement.py:52:10 - error: Type alias declaration "BadTypeAlias14" is obscured by a declaration of the same name (reportRedeclaration) -aliases_type_statement.py:58:10 - error: A type statement can be used only within a module or class scope (reportGeneralTypeIssues) -aliases_type_statement.py:64:23 - error: Type parameter "V" is not included in the type parameter list for "TA1" (reportGeneralTypeIssues) -aliases_type_statement.py:69:17 - error: Type parameter "T1" is not included in the type parameter list for "TA2" (reportGeneralTypeIssues) -aliases_type_statement.py:79:7 - error: Could not specialize type "RecursiveTypeAlias2[S@RecursiveTypeAlias2, T@RecursiveTypeAlias2, P@RecursiveTypeAlias2]" -  Type "str" is incompatible with type "int" -    "str" is incompatible with "int" -aliases_type_statement.py:81:7 - error: Could not specialize type "RecursiveTypeAlias2[S@RecursiveTypeAlias2, T@RecursiveTypeAlias2, P@RecursiveTypeAlias2]" -  Type "int" is incompatible with type "str" -    "int" is incompatible with "str" -aliases_type_statement.py:84:28 - error: Type alias "RecursiveTypeAlias3" cannot use itself in its definition (reportGeneralTypeIssues) -aliases_type_statement.py:86:31 - error: Type alias "RecursiveTypeAlias4" cannot use itself in its definition (reportGeneralTypeIssues) -aliases_type_statement.py:90:28 - error: Type alias "RecursiveTypeAlias6" cannot use itself in its definition (reportGeneralTypeIssues) +aliases_type_statement.py:46:23 - error: Expected class but received "Literal[True]" (reportGeneralTypeIssues) +aliases_type_statement.py:47:23 - error: Expected class but received "Literal[1]" (reportGeneralTypeIssues) +aliases_type_statement.py:48:23 - error: Binary operator not allowed in type expression (reportInvalidTypeForm) +aliases_type_statement.py:49:23 - error: Type expressions cannot use format string literals (f-strings) (reportGeneralTypeIssues) +aliases_type_statement.py:53:23 - error: Type parameter "V" is not included in the type parameter list for "TA1" (reportGeneralTypeIssues) +aliases_type_statement.py:58:17 - error: Type parameter "T1" is not included in the type parameter list for "TA2" (reportGeneralTypeIssues) +aliases_type_statement.py:68:7 - error: Could not specialize type "RecursiveTypeAlias2[S@RecursiveTypeAlias2, T@RecursiveTypeAlias2, P@RecursiveTypeAlias2]" +  Type "str" is not assignable to type "int" +    "str" is not assignable to "int" (reportInvalidTypeForm) +aliases_type_statement.py:70:7 - error: Could not specialize type "RecursiveTypeAlias2[S@RecursiveTypeAlias2, T@RecursiveTypeAlias2, P@RecursiveTypeAlias2]" +  Type "int" is not assignable to type "str" +    "int" is not assignable to "str" (reportInvalidTypeForm) +aliases_type_statement.py:73:28 - error: Type alias "RecursiveTypeAlias3" cannot use itself in its definition (reportGeneralTypeIssues) +aliases_type_statement.py:75:31 - error: Type alias "RecursiveTypeAlias4" cannot use itself in its definition (reportGeneralTypeIssues) +aliases_type_statement.py:79:28 - error: Type alias "RecursiveTypeAlias6" cannot use itself in its definition (reportGeneralTypeIssues) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/aliases_typealiastype.toml b/conformance/results/pyright/aliases_typealiastype.toml index 48ebb2a23..8bd8d47da 100644 --- a/conformance/results/pyright/aliases_typealiastype.toml +++ b/conformance/results/pyright/aliases_typealiastype.toml @@ -3,29 +3,32 @@ output = """ aliases_typealiastype.py:32:18 - error: Cannot access attribute "other_attrib" for class "TypeAliasType"   Attribute "other_attrib" is unknown (reportAttributeAccessIssue) aliases_typealiastype.py:40:5 - error: Could not specialize type "GoodAlias5[S@GoodAlias5, TStr@GoodAlias5, P@GoodAlias5, Ts@GoodAlias5]" -  Type "int" is incompatible with type "str" -    "int" is incompatible with "str" +  Type "int" is not assignable to type "str" +    "int" is not assignable to "str" (reportInvalidTypeForm) aliases_typealiastype.py:43:45 - error: Type variable "S" has no meaning in this context (reportGeneralTypeIssues) aliases_typealiastype.py:44:45 - error: Type variable "S" has no meaning in this context (reportGeneralTypeIssues) -aliases_typealiastype.py:45:57 - error: Type parameter list must be a tuple containing only TypeVar, TypeVarTuple, or ParamSpec +aliases_typealiastype.py:45:57 - error: Type parameter list must be a tuple containing only TypeVar, TypeVarTuple, or ParamSpec (reportGeneralTypeIssues) aliases_typealiastype.py:46:40 - error: Type alias "BadAlias4" cannot use itself in its definition (reportGeneralTypeIssues) aliases_typealiastype.py:47:40 - error: Type alias "BadAlias5" cannot use itself in its definition (reportGeneralTypeIssues) aliases_typealiastype.py:48:40 - error: Type alias "BadAlias6" cannot use itself in its definition (reportGeneralTypeIssues) aliases_typealiastype.py:52:40 - error: Call expression not allowed in type expression (reportInvalidTypeForm) -aliases_typealiastype.py:53:40 - error: Expected type expression but received "list[Unknown]" (reportGeneralTypeIssues) -aliases_typealiastype.py:54:42 - error: Expected type expression but received "tuple[tuple[type[int], type[str]]]" (reportGeneralTypeIssues) -aliases_typealiastype.py:55:42 - error: Expected type expression but received "list[type[int]]" (reportGeneralTypeIssues) -aliases_typealiastype.py:56:42 - error: Expected type expression but received "dict[str, str]" (reportGeneralTypeIssues) +aliases_typealiastype.py:53:40 - error: Expected class but received "list[Unknown]" (reportGeneralTypeIssues) +aliases_typealiastype.py:54:42 - error: Expected class but received "tuple[tuple[type[int], type[str]]]" (reportGeneralTypeIssues) +aliases_typealiastype.py:55:42 - error: Expected class but received "list[type[int]]" (reportGeneralTypeIssues) +aliases_typealiastype.py:56:42 - error: Expected class but received "dict[str, Unknown]" (reportGeneralTypeIssues) +aliases_typealiastype.py:56:49 - error: "b" is not defined (reportUndefinedVariable) aliases_typealiastype.py:57:42 - error: Call expression not allowed in type expression (reportInvalidTypeForm) -aliases_typealiastype.py:58:42 - error: List expression not allowed in type annotation -  Use List[T] to indicate a list type or Union[T1, T2] to indicate a union type (reportInvalidTypeForm) -aliases_typealiastype.py:58:42 - error: Expected type expression but received "list[type[int]]" (reportGeneralTypeIssues) -aliases_typealiastype.py:59:42 - error: Ternary expression not allowed in type annotation (reportInvalidTypeForm) +aliases_typealiastype.py:58:42 - error: List expression not allowed in type expression +  Use list[T] to indicate a list type or T1 | T2 to indicate a union type (reportInvalidTypeForm) +aliases_typealiastype.py:58:42 - error: Expected class but received "list[type[int]]" (reportGeneralTypeIssues) +aliases_typealiastype.py:58:48 - error: Expected class but received "Literal[0]" (reportGeneralTypeIssues) +aliases_typealiastype.py:59:42 - error: Ternary expression not allowed in type expression (reportInvalidTypeForm) aliases_typealiastype.py:60:42 - error: Variable not allowed in type expression (reportInvalidTypeForm) -aliases_typealiastype.py:61:42 - error: Expected type expression but received "Literal[True]" (reportGeneralTypeIssues) -aliases_typealiastype.py:62:42 - error: Expected type expression but received "Literal[1]" (reportGeneralTypeIssues) -aliases_typealiastype.py:63:42 - error: Binary operator not allowed in type annotation (reportInvalidTypeForm) -aliases_typealiastype.py:64:42 - error: Type annotations cannot use format string literals (f-strings) (reportGeneralTypeIssues) +aliases_typealiastype.py:61:42 - error: Expected class but received "Literal[True]" (reportGeneralTypeIssues) +aliases_typealiastype.py:62:42 - error: Expected class but received "Literal[1]" (reportGeneralTypeIssues) +aliases_typealiastype.py:63:42 - error: Binary operator not allowed in type expression (reportInvalidTypeForm) +aliases_typealiastype.py:64:42 - error: Type expressions cannot use format string literals (f-strings) (reportGeneralTypeIssues) +aliases_typealiastype.py:66:47 - error: "BadAlias21" is not defined (reportUndefinedVariable) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/aliases_variance.toml b/conformance/results/pyright/aliases_variance.toml index 4536540fb..b653968e9 100644 --- a/conformance/results/pyright/aliases_variance.toml +++ b/conformance/results/pyright/aliases_variance.toml @@ -3,11 +3,11 @@ output = """ aliases_variance.py:24:23 - error: Type "T_co@ClassA_1" cannot be assigned to type variable "T@ClassA"   Variance of type argument "T_co@ClassA_1" is incompatible with base class "ClassA" (reportInvalidTypeArguments) aliases_variance.py:28:26 - error: Could not specialize type "A_Alias_1[T_co@A_Alias_1]" -  Variance of type argument "T_co@ClassA_2" is incompatible with "T_co@A_Alias_1" +  Variance of type argument "T_co@ClassA_2" is incompatible with "T_co@A_Alias_1" (reportInvalidTypeForm) aliases_variance.py:32:26 - error: Could not specialize type "A_Alias_2[T_co@A_Alias_2]" -  Variance of type argument "T_co@ClassA_3" is incompatible with "T_co@A_Alias_2" +  Variance of type argument "T_co@ClassA_3" is incompatible with "T_co@A_Alias_2" (reportInvalidTypeForm) aliases_variance.py:44:26 - error: Could not specialize type "B_Alias_1[T_co@B_Alias_1, T_contra@B_Alias_1]" -  Variance of type argument "T_contra@ClassB_1" is incompatible with "T_co@B_Alias_1" +  Variance of type argument "T_contra@ClassB_1" is incompatible with "T_co@B_Alias_1" (reportInvalidTypeForm) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/annotations_forward_refs.toml b/conformance/results/pyright/annotations_forward_refs.toml index 4ddb40f39..cb4a1a727 100644 --- a/conformance/results/pyright/annotations_forward_refs.toml +++ b/conformance/results/pyright/annotations_forward_refs.toml @@ -1,38 +1,47 @@ -conformant = "Pass" +conformant = "Partial" +notes = """ +Prefers to resolve forward references in classes outside of the class instead of end-of-scope +""" +conformance_automated = "Fail" +errors_diff = """ +Line 94: Expected 1 errors +Line 96: Expected 1 errors +Line 103: Expected 1 errors +""" output = """ annotations_forward_refs.py:22:7 - error: "ClassA" is not defined (reportUndefinedVariable) annotations_forward_refs.py:23:12 - error: "ClassA" is not defined (reportUndefinedVariable) annotations_forward_refs.py:24:7 - error: Union syntax cannot be used with string operand; use quotes around entire expression (reportGeneralTypeIssues) annotations_forward_refs.py:25:13 - error: Union syntax cannot be used with string operand; use quotes around entire expression (reportGeneralTypeIssues) -annotations_forward_refs.py:41:9 - error: Expected type but received a string literal (reportGeneralTypeIssues) -annotations_forward_refs.py:42:10 - error: List expression not allowed in type annotation -  Use List[T] to indicate a list type or Union[T1, T2] to indicate a union type (reportInvalidTypeForm) -annotations_forward_refs.py:42:10 - error: Expected type expression but received "list[Unknown]" (reportGeneralTypeIssues) -annotations_forward_refs.py:43:10 - error: Tuple expression not allowed in type annotation -  Use tuple[T1, ..., Tn] to indicate a tuple type or Union[T1, T2] to indicate a union type (reportInvalidTypeForm) -annotations_forward_refs.py:44:10 - error: List expression not allowed in type annotation -  Use List[T] to indicate a list type or Union[T1, T2] to indicate a union type (reportInvalidTypeForm) -annotations_forward_refs.py:44:10 - error: Expected type expression but received "list[type[int]]" (reportGeneralTypeIssues) -annotations_forward_refs.py:45:10 - error: Dictionary expression not allowed in type annotation -  Use Dict[T1, T2] to indicate a dictionary type (reportInvalidTypeForm) -annotations_forward_refs.py:45:10 - error: Expected type expression but received "dict[Unknown, Unknown]" (reportGeneralTypeIssues) +annotations_forward_refs.py:41:10 - error: Call expression not allowed in type expression (reportInvalidTypeForm) +annotations_forward_refs.py:42:10 - error: List expression not allowed in type expression +  Use list[T] to indicate a list type or T1 | T2 to indicate a union type (reportInvalidTypeForm) +annotations_forward_refs.py:42:10 - error: Expected class but received "list[Unknown]" (reportGeneralTypeIssues) +annotations_forward_refs.py:43:10 - error: Tuple expression not allowed in type expression +  Use tuple[T1, ..., Tn] to indicate a tuple type or T1 | T2 to indicate a union type (reportInvalidTypeForm) +annotations_forward_refs.py:44:10 - error: List expression not allowed in type expression +  Use list[T] to indicate a list type or T1 | T2 to indicate a union type (reportInvalidTypeForm) +annotations_forward_refs.py:44:10 - error: Expected class but received "list[type[int]]" (reportGeneralTypeIssues) +annotations_forward_refs.py:45:10 - error: Dictionary expression not allowed in type expression +  Use dict[T1, T2] to indicate a dictionary type (reportInvalidTypeForm) +annotations_forward_refs.py:45:10 - error: Expected class but received "dict[Unknown, Unknown]" (reportGeneralTypeIssues) annotations_forward_refs.py:46:10 - error: Call expression not allowed in type expression (reportInvalidTypeForm) -annotations_forward_refs.py:47:10 - error: List expression not allowed in type annotation -  Use List[T] to indicate a list type or Union[T1, T2] to indicate a union type (reportInvalidTypeForm) -annotations_forward_refs.py:47:10 - error: Expected type expression but received "list[type[int]]" (reportGeneralTypeIssues) -annotations_forward_refs.py:48:10 - error: Ternary expression not allowed in type annotation (reportInvalidTypeForm) +annotations_forward_refs.py:47:10 - error: List expression not allowed in type expression +  Use list[T] to indicate a list type or T1 | T2 to indicate a union type (reportInvalidTypeForm) +annotations_forward_refs.py:47:10 - error: Expected class but received "list[type[int]]" (reportGeneralTypeIssues) +annotations_forward_refs.py:47:16 - error: Expected class but received "Literal[0]" (reportGeneralTypeIssues) +annotations_forward_refs.py:48:10 - error: Ternary expression not allowed in type expression (reportInvalidTypeForm) annotations_forward_refs.py:49:10 - error: Variable not allowed in type expression (reportInvalidTypeForm) -annotations_forward_refs.py:50:11 - error: Expected type expression but received "Literal[True]" (reportGeneralTypeIssues) -annotations_forward_refs.py:51:11 - error: Expected type expression but received "Literal[1]" (reportGeneralTypeIssues) -annotations_forward_refs.py:52:11 - error: Unary operator not allowed in type annotation (reportInvalidTypeForm) -annotations_forward_refs.py:53:11 - error: Binary operator not allowed in type annotation (reportInvalidTypeForm) -annotations_forward_refs.py:54:11 - error: Type annotations cannot use format string literals (f-strings) (reportGeneralTypeIssues) +annotations_forward_refs.py:50:11 - error: Expected class but received "Literal[True]" (reportGeneralTypeIssues) +annotations_forward_refs.py:51:11 - error: Expected class but received "Literal[1]" (reportGeneralTypeIssues) +annotations_forward_refs.py:52:11 - error: Unary operator not allowed in type expression (reportInvalidTypeForm) +annotations_forward_refs.py:53:11 - error: Binary operator not allowed in type expression (reportInvalidTypeForm) +annotations_forward_refs.py:54:11 - error: Type expressions cannot use format string literals (f-strings) (reportGeneralTypeIssues) annotations_forward_refs.py:55:10 - error: Module cannot be used as a type (reportGeneralTypeIssues) -annotations_forward_refs.py:66:26 - error: "ClassB" is not defined (reportUndefinedVariable) -annotations_forward_refs.py:80:14 - error: Type of "ClassF" could not be determined because it refers to itself (reportGeneralTypeIssues) -annotations_forward_refs.py:80:14 - error: Variable not allowed in type expression (reportInvalidTypeForm) -annotations_forward_refs.py:89:8 - error: Expected type expression but received "(self: Self@ClassD) -> None" (reportGeneralTypeIssues) -""" -conformance_automated = "Pass" -errors_diff = """ +annotations_forward_refs.py:65:26 - error: "ClassB" is not defined (reportUndefinedVariable) +annotations_forward_refs.py:83:13 - error: "ClassInner" is not defined (reportUndefinedVariable) +annotations_forward_refs.py:92:14 - error: Type of "ClassF" could not be determined because it refers to itself (reportGeneralTypeIssues) +annotations_forward_refs.py:92:14 - error: Variable not allowed in type expression (reportInvalidTypeForm) +annotations_forward_refs.py:101:8 - error: Expected class but received "(self: Self@ClassD) -> None" (reportGeneralTypeIssues) +annotations_forward_refs.py:111:17 - error: "assert_type" mismatch: expected "ClassInner" but received "Unknown" (reportAssertTypeFailure) """ diff --git a/conformance/results/pyright/annotations_future_import.toml b/conformance/results/pyright/annotations_future_import.toml new file mode 100644 index 000000000..baa4287eb --- /dev/null +++ b/conformance/results/pyright/annotations_future_import.toml @@ -0,0 +1,13 @@ +conformant = "Partial" +notes = """ +Prefers to resolve forward references in classes outside of the class instead of end-of-scope +""" +conformance_automated = "Fail" +errors_diff = """ +Line 37: Expected 1 errors +Line 39: Expected 1 errors +Line 44: Expected 1 errors +Line 46: Expected 1 errors +""" +output = """ +""" diff --git a/conformance/results/pyright/annotations_generators.toml b/conformance/results/pyright/annotations_generators.toml index 23081ff4f..84e2463d0 100644 --- a/conformance/results/pyright/annotations_generators.toml +++ b/conformance/results/pyright/annotations_generators.toml @@ -1,35 +1,41 @@ conformant = "Pass" output = """ annotations_generators.py:51:21 - error: Function with declared return type "C" must return value on all code paths -  "None" is incompatible with "C" (reportReturnType) -annotations_generators.py:54:16 - error: Expression of type "Literal[False]" is incompatible with return type "C" -  "Literal[False]" is incompatible with "C" (reportReturnType) +  "None" is not assignable to "C" (reportReturnType) +annotations_generators.py:54:16 - error: Type "Literal[False]" is not assignable to return type "C" +  "Literal[False]" is not assignable to "C" (reportReturnType) annotations_generators.py:57:15 - error: Return type of generator function must be compatible with "Generator[Literal[3], Any, Any]" -  "Literal[3]" is incompatible with "A" (reportReturnType) +  "Generator[Literal[3], Unknown, Unknown]" is not assignable to "Generator[A, B, C]" +    Type parameter "_YieldT_co@Generator" is covariant, but "Literal[3]" is not a subtype of "A" +      "Literal[3]" is not assignable to "A" (reportReturnType) annotations_generators.py:66:15 - error: Return type of generator function must be compatible with "Generator[Literal[3], Any, Any]" -  "Literal[3]" is incompatible with "A" (reportReturnType) +  "Generator[Literal[3], Unknown, Unknown]" is not assignable to "Generator[A, int, Any]" +    Type parameter "_YieldT_co@Generator" is covariant, but "Literal[3]" is not a subtype of "A" +      "Literal[3]" is not assignable to "A" (reportReturnType) annotations_generators.py:75:11 - error: Return type of generator function must be compatible with "Generator[B, Any, Any]" -  "B" is incompatible with "A" (reportReturnType) +  "Generator[B, Unknown, Unknown]" is not assignable to "Iterator[A]" +    Type parameter "_T_co@Iterator" is covariant, but "B" is not a subtype of "A" +      "B" is not assignable to "A" (reportReturnType) annotations_generators.py:86:21 - error: Return type of generator function must be compatible with "Generator[Any, Any, Any]" -  "Generator[Any, Any, Any]" is incompatible with "int" (reportInvalidTypeForm) +  "Generator[Any, Any, Any]" is not assignable to "int" (reportInvalidTypeForm) annotations_generators.py:87:11 - error: Return type of generator function must be compatible with "Generator[None, Any, Any]" -  "Generator[None, Unknown, Unknown]" is incompatible with "int" (reportReturnType) +  "Generator[None, Unknown, Unknown]" is not assignable to "int" (reportReturnType) annotations_generators.py:91:27 - error: Return type of async generator function must be compatible with "AsyncGenerator[Any, Any]" -  "AsyncGenerator[Any, Any, Any]" is incompatible with "int" (reportInvalidTypeForm) +  "AsyncGenerator[Any, Any, Any]" is not assignable to "int" (reportInvalidTypeForm) annotations_generators.py:92:11 - error: Return type of async generator function must be compatible with "AsyncGenerator[None, Any]" -  "AsyncGenerator[None, Unknown, Unknown]" is incompatible with "int" (reportReturnType) +  "AsyncGenerator[None, Unknown, Unknown]" is not assignable to "int" (reportReturnType) annotations_generators.py:118:16 - error: Return type of generator function must be compatible with "Generator[A, Any, Any]" -  "Generator[A, Unknown, Unknown]" is incompatible with "Iterator[B]" +  "Generator[A, Unknown, Unknown]" is not assignable to "Iterator[B]"     Type parameter "_T_co@Iterator" is covariant, but "A" is not a subtype of "B" -      "A" is incompatible with "B" (reportReturnType) +      "A" is not assignable to "B" (reportReturnType) annotations_generators.py:119:16 - error: Return type of generator function must be compatible with "Generator[int, Any, Any]" -  "Generator[int, Unknown, Unknown]" is incompatible with "Iterator[B]" +  "Generator[int, Unknown, Unknown]" is not assignable to "Iterator[B]"     Type parameter "_T_co@Iterator" is covariant, but "int" is not a subtype of "B" -      "int" is incompatible with "B" (reportReturnType) +      "int" is not assignable to "B" (reportReturnType) annotations_generators.py:135:16 - error: Return type of generator function must be compatible with "Generator[None, Any, Any]" -  "Generator[None, int, Unknown]" is incompatible with "Generator[None, str, None]" +  "Generator[None, int, Unknown]" is not assignable to "Generator[None, str, None]"     Type parameter "_SendT_contra@Generator" is contravariant, but "int" is not a supertype of "str" -      "str" is incompatible with "int" (reportReturnType) +      "str" is not assignable to "int" (reportReturnType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/annotations_methods.toml b/conformance/results/pyright/annotations_methods.toml index 120e85cae..27ff70b96 100644 --- a/conformance/results/pyright/annotations_methods.toml +++ b/conformance/results/pyright/annotations_methods.toml @@ -4,7 +4,7 @@ Type evaluation differs from other type checkers because of ambiguity in the spe """ output = """ annotations_methods.py:46:8 - error: Argument of type "A" cannot be assigned to parameter "self" of type "B" in function "copy" -  "A" is incompatible with "B" (reportArgumentType) +  "A" is not assignable to "B" (reportArgumentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/annotations_typeexpr.toml b/conformance/results/pyright/annotations_typeexpr.toml index 1afdc4e4a..e9e3fdca6 100644 --- a/conformance/results/pyright/annotations_typeexpr.toml +++ b/conformance/results/pyright/annotations_typeexpr.toml @@ -1,28 +1,29 @@ conformant = "Pass" output = """ annotations_typeexpr.py:88:9 - error: Call expression not allowed in type expression (reportInvalidTypeForm) -annotations_typeexpr.py:89:9 - error: List expression not allowed in type annotation -  Use List[T] to indicate a list type or Union[T1, T2] to indicate a union type (reportInvalidTypeForm) -annotations_typeexpr.py:89:9 - error: Expected type expression but received "list[Unknown]" (reportGeneralTypeIssues) -annotations_typeexpr.py:90:9 - error: Tuple expression not allowed in type annotation -  Use tuple[T1, ..., Tn] to indicate a tuple type or Union[T1, T2] to indicate a union type (reportInvalidTypeForm) -annotations_typeexpr.py:91:9 - error: List expression not allowed in type annotation -  Use List[T] to indicate a list type or Union[T1, T2] to indicate a union type (reportInvalidTypeForm) -annotations_typeexpr.py:91:9 - error: Expected type expression but received "list[type[int]]" (reportGeneralTypeIssues) -annotations_typeexpr.py:92:9 - error: Dictionary expression not allowed in type annotation -  Use Dict[T1, T2] to indicate a dictionary type (reportInvalidTypeForm) -annotations_typeexpr.py:92:9 - error: Expected type expression but received "dict[Unknown, Unknown]" (reportGeneralTypeIssues) +annotations_typeexpr.py:89:9 - error: List expression not allowed in type expression +  Use list[T] to indicate a list type or T1 | T2 to indicate a union type (reportInvalidTypeForm) +annotations_typeexpr.py:89:9 - error: Expected class but received "list[Unknown]" (reportGeneralTypeIssues) +annotations_typeexpr.py:90:9 - error: Tuple expression not allowed in type expression +  Use tuple[T1, ..., Tn] to indicate a tuple type or T1 | T2 to indicate a union type (reportInvalidTypeForm) +annotations_typeexpr.py:91:9 - error: List expression not allowed in type expression +  Use list[T] to indicate a list type or T1 | T2 to indicate a union type (reportInvalidTypeForm) +annotations_typeexpr.py:91:9 - error: Expected class but received "list[type[int]]" (reportGeneralTypeIssues) +annotations_typeexpr.py:92:9 - error: Dictionary expression not allowed in type expression +  Use dict[T1, T2] to indicate a dictionary type (reportInvalidTypeForm) +annotations_typeexpr.py:92:9 - error: Expected class but received "dict[Unknown, Unknown]" (reportGeneralTypeIssues) annotations_typeexpr.py:93:9 - error: Call expression not allowed in type expression (reportInvalidTypeForm) -annotations_typeexpr.py:94:9 - error: List expression not allowed in type annotation -  Use List[T] to indicate a list type or Union[T1, T2] to indicate a union type (reportInvalidTypeForm) -annotations_typeexpr.py:94:9 - error: Expected type expression but received "list[type[int]]" (reportGeneralTypeIssues) -annotations_typeexpr.py:95:9 - error: Ternary expression not allowed in type annotation (reportInvalidTypeForm) +annotations_typeexpr.py:94:9 - error: List expression not allowed in type expression +  Use list[T] to indicate a list type or T1 | T2 to indicate a union type (reportInvalidTypeForm) +annotations_typeexpr.py:94:9 - error: Expected class but received "list[type[int]]" (reportGeneralTypeIssues) +annotations_typeexpr.py:94:15 - error: Expected class but received "Literal[0]" (reportGeneralTypeIssues) +annotations_typeexpr.py:95:9 - error: Ternary expression not allowed in type expression (reportInvalidTypeForm) annotations_typeexpr.py:96:9 - error: Variable not allowed in type expression (reportInvalidTypeForm) -annotations_typeexpr.py:97:10 - error: Expected type expression but received "Literal[True]" (reportGeneralTypeIssues) -annotations_typeexpr.py:98:10 - error: Expected type expression but received "Literal[1]" (reportGeneralTypeIssues) -annotations_typeexpr.py:99:10 - error: Unary operator not allowed in type annotation (reportInvalidTypeForm) -annotations_typeexpr.py:100:10 - error: Binary operator not allowed in type annotation (reportInvalidTypeForm) -annotations_typeexpr.py:101:10 - error: Type annotations cannot use format string literals (f-strings) (reportGeneralTypeIssues) +annotations_typeexpr.py:97:10 - error: Expected class but received "Literal[True]" (reportGeneralTypeIssues) +annotations_typeexpr.py:98:10 - error: Expected class but received "Literal[1]" (reportGeneralTypeIssues) +annotations_typeexpr.py:99:10 - error: Unary operator not allowed in type expression (reportInvalidTypeForm) +annotations_typeexpr.py:100:10 - error: Binary operator not allowed in type expression (reportInvalidTypeForm) +annotations_typeexpr.py:101:10 - error: Type expressions cannot use format string literals (f-strings) (reportGeneralTypeIssues) annotations_typeexpr.py:102:10 - error: Module cannot be used as a type (reportGeneralTypeIssues) """ conformance_automated = "Pass" diff --git a/conformance/results/pyright/callables_annotation.toml b/conformance/results/pyright/callables_annotation.toml index b228ecf40..407d0e2b2 100644 --- a/conformance/results/pyright/callables_annotation.toml +++ b/conformance/results/pyright/callables_annotation.toml @@ -2,39 +2,39 @@ conformant = "Pass" output = """ callables_annotation.py:25:5 - error: Expected 1 more positional argument (reportCallIssue) callables_annotation.py:26:11 - error: Argument of type "Literal[2]" cannot be assigned to parameter of type "str" -  "Literal[2]" is incompatible with "str" (reportArgumentType) +  "Literal[2]" is not assignable to "str" (reportArgumentType) callables_annotation.py:27:15 - error: Expected 2 positional arguments (reportCallIssue) callables_annotation.py:29:10 - error: Expected 2 more positional arguments (reportCallIssue) callables_annotation.py:35:8 - error: Expected 0 positional arguments (reportCallIssue) -callables_annotation.py:55:14 - error: Expected parameter type list or "..." -callables_annotation.py:56:14 - error: Expected parameter type list or "..." -callables_annotation.py:57:18 - error: List expression not allowed for this type argument -callables_annotation.py:58:14 - error: Expected parameter type list or "..." -callables_annotation.py:58:24 - error: Expected only two type arguments to "Callable" -callables_annotation.py:59:15 - error: "..." is not allowed in this context -callables_annotation.py:91:7 - error: Expression of type "() -> str" is incompatible with declared type "(int, ...) -> str" -  Type "() -> str" is incompatible with type "(int, ...) -> str" -    Function accepts too many positional parameters; expected 0 but received 2 (reportAssignmentType) -callables_annotation.py:93:7 - error: Expression of type "(*, a: int) -> str" is incompatible with declared type "(int, ...) -> str" -  Type "(*, a: int) -> str" is incompatible with type "(int, ...) -> str" -    Function accepts too many positional parameters; expected 0 but received 2 (reportAssignmentType) -callables_annotation.py:159:25 - error: Expression of type "Proto8" is incompatible with declared type "Proto5[Any]" +callables_annotation.py:55:14 - error: Expected parameter type list or "..." (reportInvalidTypeForm) +callables_annotation.py:56:14 - error: Expected parameter type list or "..." (reportInvalidTypeForm) +callables_annotation.py:57:18 - error: List expression not allowed for this type argument (reportInvalidTypeForm) +callables_annotation.py:58:14 - error: Expected parameter type list or "..." (reportInvalidTypeForm) +callables_annotation.py:58:24 - error: Expected only two type arguments to "Callable" (reportInvalidTypeForm) +callables_annotation.py:59:15 - error: "..." is not allowed in this context (reportInvalidTypeForm) +callables_annotation.py:91:7 - error: Type "() -> str" is not assignable to declared type "(int, ...) -> str" +  Type "() -> str" is not assignable to type "(int, ...) -> str" +    Function accepts too few positional parameters; expected 1 but received 0 (reportAssignmentType) +callables_annotation.py:93:7 - error: Type "(*, a: int) -> str" is not assignable to declared type "(int, ...) -> str" +  Type "(*, a: int) -> str" is not assignable to type "(int, ...) -> str" +    Function accepts too few positional parameters; expected 1 but received 0 (reportAssignmentType) +callables_annotation.py:159:25 - error: Type "Proto8" is not assignable to declared type "Proto5[Any]"   "Proto8" is incompatible with protocol "Proto5[Any]"     "__call__" is an incompatible type -      Type "() -> None" is incompatible with type "(*args: T_contra@Proto5, **kwargs: T_contra@Proto5) -> None" +      Type "() -> None" is not assignable to type "(*args: T_contra@Proto5, **kwargs: T_contra@Proto5) -> None"         Parameter "*args" has no corresponding parameter         Parameter "**kwargs" has no corresponding parameter (reportAssignmentType) -callables_annotation.py:172:26 - error: Expression of type "() -> str" is incompatible with declared type "Callback2[...]" -  Type "() -> str" is incompatible with type "Callback2[...]" -    Function accepts too many positional parameters; expected 0 but received 2 (reportAssignmentType) -callables_annotation.py:187:48 - error: Expression of type "(int, str) -> str" is incompatible with declared type "(str, ...) -> str" -  Type "(int, str) -> str" is incompatible with type "(str, ...) -> str" +callables_annotation.py:172:26 - error: Type "() -> str" is not assignable to declared type "Callback2[...]" +  Type "() -> str" is not assignable to type "Callback2[...]" +    Function accepts too few positional parameters; expected 1 but received 0 (reportAssignmentType) +callables_annotation.py:187:48 - error: Type "(int, str) -> str" is not assignable to declared type "(str, ...) -> str" +  Type "(int, str) -> str" is not assignable to type "(str, ...) -> str"     Parameter 1: type "str" is incompatible with type "int" -      "str" is incompatible with "int" (reportAssignmentType) -callables_annotation.py:189:32 - error: Expression of type "(int, str) -> str" is incompatible with declared type "CallbackWithStr[...]" -  Type "(int, str) -> str" is incompatible with type "CallbackWithStr[...]" +      "str" is not assignable to "int" (reportAssignmentType) +callables_annotation.py:189:32 - error: Type "(int, str) -> str" is not assignable to declared type "CallbackWithStr[...]" +  Type "(int, str) -> str" is not assignable to type "CallbackWithStr[...]"     Parameter 1: type "str" is incompatible with type "int" -      "str" is incompatible with "int" (reportAssignmentType) +      "str" is not assignable to "int" (reportAssignmentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/callables_kwargs.toml b/conformance/results/pyright/callables_kwargs.toml index c82031c93..b04d6a66a 100644 --- a/conformance/results/pyright/callables_kwargs.toml +++ b/conformance/results/pyright/callables_kwargs.toml @@ -1,32 +1,35 @@ conformant = "Pass" output = """ callables_kwargs.py:28:5 - error: Could not access item in TypedDict -  "v2" is not a required key in "*TD2", so access may result in runtime exception (reportTypedDictNotRequiredAccess) +  "v2" is not a required key in "TD2", so access may result in runtime exception (reportTypedDictNotRequiredAccess) callables_kwargs.py:46:5 - error: Arguments missing for parameters "v1", "v3" (reportCallIssue) callables_kwargs.py:51:32 - error: No parameter named "v4" (reportCallIssue) callables_kwargs.py:52:11 - error: Expected 0 positional arguments (reportCallIssue) callables_kwargs.py:58:13 - error: Argument of type "str" cannot be assigned to parameter "v1" of type "int" in function "func1" -  "str" is incompatible with "int" (reportArgumentType) +  "str" is not assignable to "int" (reportArgumentType) callables_kwargs.py:63:19 - error: Unable to match unpacked TypedDict argument to parameters   Parameter "v1" is already assigned (reportCallIssue) callables_kwargs.py:64:16 - error: Unable to match unpacked TypedDict argument to parameters   Parameter "v3" is already assigned (reportCallIssue) callables_kwargs.py:65:19 - error: Unable to match unpacked TypedDict argument to parameters   Parameter "v1" is already assigned (reportCallIssue) -callables_kwargs.py:101:19 - error: Expression of type "(**kwargs: **TD2) -> None" is incompatible with declared type "TDProtocol3" -  Type "(**kwargs: **TD2) -> None" is incompatible with type "(*, v1: int, v2: int, v3: str) -> None" +callables_kwargs.py:101:19 - error: Type "(**kwargs: **TD2) -> None" is not assignable to declared type "TDProtocol3" +  Type "(**kwargs: **TD2) -> None" is not assignable to type "(*, v1: int, v2: int, v3: str) -> None"     Keyword parameter "v2" of type "int" is incompatible with type "str" -      "int" is incompatible with "str" (reportAssignmentType) -callables_kwargs.py:102:19 - error: Expression of type "(**kwargs: **TD2) -> None" is incompatible with declared type "TDProtocol4" -  Type "(**kwargs: **TD2) -> None" is incompatible with type "(*, v1: int) -> None" -    Keyword parameter "v3" is missing in destination (reportAssignmentType) -callables_kwargs.py:103:19 - error: Expression of type "(**kwargs: **TD2) -> None" is incompatible with declared type "TDProtocol5" -  Type "(**kwargs: **TD2) -> None" is incompatible with type "(v1: int, v3: str) -> None" -    Function accepts too many positional parameters; expected 0 but received 2 -      Keyword parameter "v1" is missing in destination -      Keyword parameter "v3" is missing in destination (reportAssignmentType) +      "int" is not assignable to "str" (reportAssignmentType) +callables_kwargs.py:102:19 - error: Type "(**kwargs: **TD2) -> None" is not assignable to declared type "TDProtocol4" +  Type "(**kwargs: **TD2) -> None" is not assignable to type "(*, v1: int) -> None" +    Extra parameter "v3" (reportAssignmentType) +callables_kwargs.py:103:19 - error: Type "(**kwargs: **TD2) -> None" is not assignable to declared type "TDProtocol5" +  Type "(**kwargs: **TD2) -> None" is not assignable to type "(v1: int, v3: str) -> None" +    Function accepts too few positional parameters; expected 2 but received 0 +      Parameter "v1" is missing default argument +      Parameter "v3" is missing default argument (reportAssignmentType) callables_kwargs.py:111:30 - error: Typed dictionary overlaps with keyword parameter: v1 (reportGeneralTypeIssues) callables_kwargs.py:122:21 - error: Expected TypedDict type argument for Unpack (reportGeneralTypeIssues) +callables_kwargs.py:134:19 - error: Type "(*, v1: int, v3: str, v2: str = "") -> None" is not assignable to declared type "TDProtocol6" +  Type "(*, v1: int, v3: str, v2: str = "") -> None" is not assignable to type "(**kwargs: **TD2) -> None" +    Parameter "**kwargs" has no corresponding parameter (reportAssignmentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/callables_protocol.toml b/conformance/results/pyright/callables_protocol.toml index 957091858..82afbb4c6 100644 --- a/conformance/results/pyright/callables_protocol.toml +++ b/conformance/results/pyright/callables_protocol.toml @@ -1,62 +1,65 @@ conformant = "Pass" output = """ -callables_protocol.py:35:7 - error: Expression of type "(*vals: bytes, max_items: int | None) -> list[bytes]" is incompatible with declared type "Proto1" -  Type "(*vals: bytes, max_items: int | None) -> list[bytes]" is incompatible with type "(*vals: bytes, max_len: int | None = None) -> list[bytes]" -    Keyword parameter "max_items" is missing in destination -    Keyword parameter "max_len" is missing in source (reportAssignmentType) -callables_protocol.py:36:7 - error: Expression of type "(*vals: bytes) -> list[bytes]" is incompatible with declared type "Proto1" -  Type "(*vals: bytes) -> list[bytes]" is incompatible with type "(*vals: bytes, max_len: int | None = None) -> list[bytes]" -    Keyword parameter "max_len" is missing in source (reportAssignmentType) -callables_protocol.py:37:7 - error: Expression of type "(*vals: bytes, max_len: str | None) -> list[bytes]" is incompatible with declared type "Proto1" -  Type "(*vals: bytes, max_len: str | None) -> list[bytes]" is incompatible with type "(*vals: bytes, max_len: int | None = None) -> list[bytes]" +callables_protocol.py:35:7 - error: Type "(*vals: bytes, max_items: int | None) -> list[bytes]" is not assignable to declared type "Proto1" +  Type "(*vals: bytes, max_items: int | None) -> list[bytes]" is not assignable to type "(*vals: bytes, max_len: int | None = None) -> list[bytes]" +    Extra parameter "max_items" +    Missing keyword parameter "max_len" (reportAssignmentType) +callables_protocol.py:36:7 - error: Type "(*vals: bytes) -> list[bytes]" is not assignable to declared type "Proto1" +  Type "(*vals: bytes) -> list[bytes]" is not assignable to type "(*vals: bytes, max_len: int | None = None) -> list[bytes]" +    Missing keyword parameter "max_len" (reportAssignmentType) +callables_protocol.py:37:7 - error: Type "(*vals: bytes, max_len: str | None) -> list[bytes]" is not assignable to declared type "Proto1" +  Type "(*vals: bytes, max_len: str | None) -> list[bytes]" is not assignable to type "(*vals: bytes, max_len: int | None = None) -> list[bytes]"     Keyword parameter "max_len" of type "int | None" is incompatible with type "str | None" +      Type "int | None" is not assignable to type "str | None" +        Type "int" is not assignable to type "str | None" +          "int" is not assignable to "str" +          "int" is not assignable to "None"     Parameter "max_len" is missing default argument (reportAssignmentType) -callables_protocol.py:67:7 - error: Expression of type "(*a: bytes) -> None" is incompatible with declared type "Proto2" -  Type "(*a: bytes) -> None" is incompatible with type "(*vals: bytes, **kwargs: str) -> None" +callables_protocol.py:67:7 - error: Type "(*a: bytes) -> None" is not assignable to declared type "Proto2" +  Type "(*a: bytes) -> None" is not assignable to type "(*vals: bytes, **kwargs: str) -> None"     Parameter "**kwargs" has no corresponding parameter (reportAssignmentType) -callables_protocol.py:68:7 - error: Expression of type "(*a: str, **b: str) -> None" is incompatible with declared type "Proto2" -  Type "(*a: str, **b: str) -> None" is incompatible with type "(*vals: bytes, **kwargs: str) -> None" +callables_protocol.py:68:7 - error: Type "(*a: str, **b: str) -> None" is not assignable to declared type "Proto2" +  Type "(*a: str, **b: str) -> None" is not assignable to type "(*vals: bytes, **kwargs: str) -> None"     Parameter 1: type "*tuple[bytes, ...]" is incompatible with type "*tuple[str, ...]" -      "*tuple[bytes, ...]" is incompatible with "*tuple[str, ...]" +      "*tuple[bytes, ...]" is not assignable to "*tuple[str, ...]"         Tuple entry 1 is incorrect type -          "bytes" is incompatible with "str" (reportAssignmentType) -callables_protocol.py:69:7 - error: Expression of type "(*a: bytes, **b: bytes) -> None" is incompatible with declared type "Proto2" -  Type "(*a: bytes, **b: bytes) -> None" is incompatible with type "(*vals: bytes, **kwargs: str) -> None" +          "bytes" is not assignable to "str" (reportAssignmentType) +callables_protocol.py:69:7 - error: Type "(*a: bytes, **b: bytes) -> None" is not assignable to declared type "Proto2" +  Type "(*a: bytes, **b: bytes) -> None" is not assignable to type "(*vals: bytes, **kwargs: str) -> None"     Parameter 2: type "str" is incompatible with type "bytes" -      "str" is incompatible with "bytes" (reportAssignmentType) -callables_protocol.py:70:7 - error: Expression of type "(**b: str) -> None" is incompatible with declared type "Proto2" -  Type "(**b: str) -> None" is incompatible with type "(*vals: bytes, **kwargs: str) -> None" +      "str" is not assignable to "bytes" (reportAssignmentType) +callables_protocol.py:70:7 - error: Type "(**b: str) -> None" is not assignable to declared type "Proto2" +  Type "(**b: str) -> None" is not assignable to type "(*vals: bytes, **kwargs: str) -> None"     Parameter "*vals" has no corresponding parameter (reportAssignmentType) -callables_protocol.py:97:16 - error: Expression of type "(x: int) -> None" is incompatible with declared type "Proto4" -  "function" is incompatible with protocol "Proto4" -    "other_attribute" is not present -    "__call__" is not present (reportAssignmentType) -callables_protocol.py:121:18 - error: Expression of type "(*vals: bytes, max_len: int | None = None) -> list[bytes]" is incompatible with declared type "NotProto6" -  "function" is incompatible with "NotProto6" (reportAssignmentType) -callables_protocol.py:169:7 - error: Expression of type "(x: int) -> Any" is incompatible with declared type "Proto8" +callables_protocol.py:97:16 - error: Type "(x: int) -> None" is not assignable to declared type "Proto4" +  "FunctionType" is incompatible with protocol "Proto4" +    "other_attribute" is not present (reportAssignmentType) +callables_protocol.py:121:18 - error: Type "(*vals: bytes, max_len: int | None = None) -> list[bytes]" is not assignable to declared type "NotProto6" +  "FunctionType" is not assignable to "NotProto6" (reportAssignmentType) +callables_protocol.py:169:7 - error: Type "(x: int) -> Any" is not assignable to declared type "Proto8"   One or more overloads of "__call__" is not assignable -    Type "(x: int) -> Any" is incompatible with type "(x: str) -> str" +    Type "(x: int) -> Any" is not assignable to type "(x: str) -> str"       Parameter 1: type "str" is incompatible with type "int" -        "str" is incompatible with "int" (reportAssignmentType) +        "str" is not assignable to "int" (reportAssignmentType) callables_protocol.py:186:33 - error: Cannot assign to attribute "other_attribute" for class "Proto9[P@decorator1, R@decorator1]" -  "Literal['str']" is incompatible with "int" (reportAttributeAccessIssue) +  "Literal['str']" is not assignable to "int" (reportAttributeAccessIssue) callables_protocol.py:187:15 - error: Cannot assign to attribute "xxx" for class "Proto9[P@decorator1, R@decorator1]"   Attribute "xxx" is unknown (reportAttributeAccessIssue) callables_protocol.py:197:16 - error: Cannot access attribute "other_attribute2" for class "Proto9[(x: int), str]"   Attribute "other_attribute2" is unknown (reportAttributeAccessIssue) -callables_protocol.py:238:8 - error: Expression of type "(x: int, y: str, /) -> Any" is incompatible with declared type "Proto11" -  Type "(x: int, y: str, /) -> Any" is incompatible with type "(x: int, /, y: str) -> Any" -    Keyword parameter "y" is missing in source +callables_protocol.py:238:8 - error: Type "(x: int, y: str, /) -> Any" is not assignable to declared type "Proto11" +  Type "(x: int, y: str, /) -> Any" is not assignable to type "(x: int, /, y: str) -> Any" +    Missing keyword parameter "y"       Position-only parameter mismatch; parameter "y" is not position-only       Position-only parameter mismatch; expected 2 but received 1 (reportAssignmentType) -callables_protocol.py:260:8 - error: Expression of type "(*args: Any, kwarg0: Any) -> None" is incompatible with declared type "Proto12" -  Type "(*args: Any, kwarg0: Any) -> None" is incompatible with type "(*args: Any, kwarg0: Any, kwarg1: Any) -> None" -    Keyword parameter "kwarg1" is missing in source (reportAssignmentType) -callables_protocol.py:284:27 - error: Expression of type "(path: str) -> str" is incompatible with declared type "Proto13_Default" -  Type "(path: str) -> str" is incompatible with type "(path: str = ...) -> str" +callables_protocol.py:260:8 - error: Type "(*args: Any, kwarg0: Any) -> None" is not assignable to declared type "Proto12" +  Type "(*args: Any, kwarg0: Any) -> None" is not assignable to type "(*args: Any, kwarg0: Any, kwarg1: Any) -> None" +    Missing keyword parameter "kwarg1" (reportAssignmentType) +callables_protocol.py:284:27 - error: Type "(path: str) -> str" is not assignable to declared type "Proto13_Default" +  Type "(path: str) -> str" is not assignable to type "(path: str = ...) -> str"     Parameter "path" is missing default argument (reportAssignmentType) -callables_protocol.py:311:27 - error: Expression of type "(*, path: str) -> str" is incompatible with declared type "Proto14_Default" -  Type "(*, path: str) -> str" is incompatible with type "(*, path: str = ...) -> str" +callables_protocol.py:311:27 - error: Type "(*, path: str) -> str" is not assignable to declared type "Proto14_Default" +  Type "(*, path: str) -> str" is not assignable to type "(*, path: str = ...) -> str"     Parameter "path" is missing default argument (reportAssignmentType) """ conformance_automated = "Pass" diff --git a/conformance/results/pyright/callables_subtyping.toml b/conformance/results/pyright/callables_subtyping.toml index 3a852269a..55956770c 100644 --- a/conformance/results/pyright/callables_subtyping.toml +++ b/conformance/results/pyright/callables_subtyping.toml @@ -2,197 +2,201 @@ conformant = "Pass" errors_diff = """ """ output = """ -callables_subtyping.py:26:36 - error: Expression of type "(int) -> int" is incompatible with declared type "(float) -> float" -  Type "(int) -> int" is incompatible with type "(float) -> float" +callables_subtyping.py:26:36 - error: Type "(int) -> int" is not assignable to declared type "(float) -> float" +  Type "(int) -> int" is not assignable to type "(float) -> float"     Parameter 1: type "float" is incompatible with type "int" -      "float" is incompatible with "int" (reportAssignmentType) -callables_subtyping.py:29:32 - error: Expression of type "(float) -> float" is incompatible with declared type "(int) -> int" -  Type "(float) -> float" is incompatible with type "(int) -> int" +      "float" is not assignable to "int" (reportAssignmentType) +callables_subtyping.py:29:32 - error: Type "(float) -> float" is not assignable to declared type "(int) -> int" +  Type "(float) -> float" is not assignable to type "(int) -> int"     Function return type "float" is incompatible with type "int" -      "float" is incompatible with "int" (reportAssignmentType) -callables_subtyping.py:51:21 - error: Expression of type "PosOnly2" is incompatible with declared type "Standard2" +      "float" is not assignable to "int" (reportAssignmentType) +callables_subtyping.py:51:21 - error: Type "PosOnly2" is not assignable to declared type "Standard2"   "PosOnly2" is incompatible with protocol "Standard2"     "__call__" is an incompatible type -      Type "(b: int, a: int, /) -> None" is incompatible with type "(a: int, b: int) -> None" -        Keyword parameter "a" is missing in source -        Keyword parameter "b" is missing in source +      Type "(b: int, a: int, /) -> None" is not assignable to type "(a: int, b: int) -> None" +        Missing keyword parameter "a" +        Missing keyword parameter "b"           Position-only parameter mismatch; parameter "a" is not position-only           Position-only parameter mismatch; parameter "b" is not position-only           Position-only parameter mismatch; expected 2 but received 0 (reportAssignmentType) -callables_subtyping.py:52:21 - error: Expression of type "KwOnly2" is incompatible with declared type "Standard2" +callables_subtyping.py:52:21 - error: Type "KwOnly2" is not assignable to declared type "Standard2"   "KwOnly2" is incompatible with protocol "Standard2"     "__call__" is an incompatible type -      Type "(*, b: int, a: int) -> None" is incompatible with type "(a: int, b: int) -> None" -        Function accepts too many positional parameters; expected 0 but received 2 -          Keyword parameter "b" is missing in destination -          Keyword parameter "a" is missing in destination (reportAssignmentType) -callables_subtyping.py:55:20 - error: Expression of type "KwOnly2" is incompatible with declared type "PosOnly2" +      Type "(*, b: int, a: int) -> None" is not assignable to type "(a: int, b: int) -> None" +        Function accepts too few positional parameters; expected 2 but received 0 +          Parameter "b" is missing default argument +          Parameter "a" is missing default argument (reportAssignmentType) +callables_subtyping.py:55:20 - error: Type "KwOnly2" is not assignable to declared type "PosOnly2"   "KwOnly2" is incompatible with protocol "PosOnly2"     "__call__" is an incompatible type -      Type "(*, b: int, a: int) -> None" is incompatible with type "(b: int, a: int, /) -> None" -        Function accepts too many positional parameters; expected 0 but received 2 -          Keyword parameter "b" is missing in destination -          Keyword parameter "a" is missing in destination (reportAssignmentType) -callables_subtyping.py:58:19 - error: Expression of type "PosOnly2" is incompatible with declared type "KwOnly2" +      Type "(*, b: int, a: int) -> None" is not assignable to type "(b: int, a: int, /) -> None" +        Function accepts too few positional parameters; expected 2 but received 0 +          Extra parameter "b" +          Extra parameter "a" (reportAssignmentType) +callables_subtyping.py:58:19 - error: Type "PosOnly2" is not assignable to declared type "KwOnly2"   "PosOnly2" is incompatible with protocol "KwOnly2"     "__call__" is an incompatible type -      Type "(b: int, a: int, /) -> None" is incompatible with type "(*, b: int, a: int) -> None" +      Type "(b: int, a: int, /) -> None" is not assignable to type "(*, b: int, a: int) -> None"         Position-only parameter mismatch; expected 2 but received 0 -        Keyword parameter "b" is missing in source -        Keyword parameter "a" is missing in source (reportAssignmentType) -callables_subtyping.py:82:20 - error: Expression of type "NoArgs3" is incompatible with declared type "IntArgs3" +        Function accepts too many positional parameters; expected 0 but received 2 +        Missing keyword parameter "b" +        Missing keyword parameter "a" (reportAssignmentType) +callables_subtyping.py:82:20 - error: Type "NoArgs3" is not assignable to declared type "IntArgs3"   "NoArgs3" is incompatible with protocol "IntArgs3"     "__call__" is an incompatible type -      Type "() -> None" is incompatible with type "(*args: int) -> None" +      Type "() -> None" is not assignable to type "(*args: int) -> None"         Parameter "*args" has no corresponding parameter (reportAssignmentType) -callables_subtyping.py:85:22 - error: Expression of type "NoArgs3" is incompatible with declared type "FloatArgs3" +callables_subtyping.py:85:22 - error: Type "NoArgs3" is not assignable to declared type "FloatArgs3"   "NoArgs3" is incompatible with protocol "FloatArgs3"     "__call__" is an incompatible type -      Type "() -> None" is incompatible with type "(*args: float) -> None" +      Type "() -> None" is not assignable to type "(*args: float) -> None"         Parameter "*args" has no corresponding parameter (reportAssignmentType) -callables_subtyping.py:86:22 - error: Expression of type "IntArgs3" is incompatible with declared type "FloatArgs3" +callables_subtyping.py:86:22 - error: Type "IntArgs3" is not assignable to declared type "FloatArgs3"   "IntArgs3" is incompatible with protocol "FloatArgs3"     "__call__" is an incompatible type -      Type "(*args: int) -> None" is incompatible with type "(*args: float) -> None" +      Type "(*args: int) -> None" is not assignable to type "(*args: float) -> None"         Parameter 1: type "*tuple[float, ...]" is incompatible with type "*tuple[int, ...]" -          "*tuple[float, ...]" is incompatible with "*tuple[int, ...]" (reportAssignmentType) -callables_subtyping.py:116:20 - error: Expression of type "IntArgs4" is incompatible with declared type "PosOnly4" +          "*tuple[float, ...]" is not assignable to "*tuple[int, ...]" (reportAssignmentType) +callables_subtyping.py:116:20 - error: Type "IntArgs4" is not assignable to declared type "PosOnly4"   "IntArgs4" is incompatible with protocol "PosOnly4"     "__call__" is an incompatible type -      Type "(*args: int) -> None" is incompatible with type "(a: int, b: str, /) -> None" +      Type "(*args: int) -> None" is not assignable to type "(a: int, b: str, /) -> None"         Parameter 2: type "str" is incompatible with type "int" -          "str" is incompatible with "int" (reportAssignmentType) -callables_subtyping.py:119:23 - error: Expression of type "StrArgs4" is incompatible with declared type "IntStrArgs4" +          "str" is not assignable to "int" (reportAssignmentType) +callables_subtyping.py:119:23 - error: Type "StrArgs4" is not assignable to declared type "IntStrArgs4"   "StrArgs4" is incompatible with protocol "IntStrArgs4"     "__call__" is an incompatible type -      Type "(a: int, /, *args: str) -> None" is incompatible with type "(*args: int | str) -> None" +      Type "(a: int, /, *args: str) -> None" is not assignable to type "(*args: int | str) -> None" +        Parameter 1: type "int | str" is incompatible with type "int" +          Type "int | str" is not assignable to type "int"         Parameter 2: type "int | str" is incompatible with type "str" -          Type "int | str" is incompatible with type "str" +          Type "int | str" is not assignable to type "str"         Parameter 1: type "*tuple[int | str, ...]" is incompatible with type "*tuple[str, ...]" -          "*tuple[int | str, ...]" is incompatible with "*tuple[str, ...]" (reportAssignmentType) -callables_subtyping.py:120:23 - error: Expression of type "IntArgs4" is incompatible with declared type "IntStrArgs4" + ... (reportAssignmentType) +callables_subtyping.py:120:23 - error: Type "IntArgs4" is not assignable to declared type "IntStrArgs4"   "IntArgs4" is incompatible with protocol "IntStrArgs4"     "__call__" is an incompatible type -      Type "(*args: int) -> None" is incompatible with type "(*args: int | str) -> None" +      Type "(*args: int) -> None" is not assignable to type "(*args: int | str) -> None"         Parameter 1: type "*tuple[int | str, ...]" is incompatible with type "*tuple[int, ...]" -          "*tuple[int | str, ...]" is incompatible with "*tuple[int, ...]" (reportAssignmentType) -callables_subtyping.py:122:20 - error: Expression of type "IntArgs4" is incompatible with declared type "StrArgs4" +          "*tuple[int | str, ...]" is not assignable to "*tuple[int, ...]" (reportAssignmentType) +callables_subtyping.py:122:20 - error: Type "IntArgs4" is not assignable to declared type "StrArgs4"   "IntArgs4" is incompatible with protocol "StrArgs4"     "__call__" is an incompatible type -      Type "(*args: int) -> None" is incompatible with type "(a: int, /, *args: str) -> None" +      Type "(*args: int) -> None" is not assignable to type "(a: int, /, *args: str) -> None"         Parameter 2: type "str" is incompatible with type "int" -          "str" is incompatible with "int" +          "str" is not assignable to "int"         Parameter 3: type "*tuple[str, ...]" is incompatible with type "*tuple[int, ...]" -          "*tuple[str, ...]" is incompatible with "*tuple[int, ...]" (reportAssignmentType) -callables_subtyping.py:124:20 - error: Expression of type "StrArgs4" is incompatible with declared type "IntArgs4" +          "*tuple[str, ...]" is not assignable to "*tuple[int, ...]" (reportAssignmentType) +callables_subtyping.py:124:20 - error: Type "StrArgs4" is not assignable to declared type "IntArgs4"   "StrArgs4" is incompatible with protocol "IntArgs4"     "__call__" is an incompatible type -      Type "(a: int, /, *args: str) -> None" is incompatible with type "(*args: int) -> None" +      Type "(a: int, /, *args: str) -> None" is not assignable to type "(*args: int) -> None"         Parameter 2: type "int" is incompatible with type "str" -          "int" is incompatible with "str" +          "int" is not assignable to "str"         Parameter 1: type "*tuple[int, ...]" is incompatible with type "*tuple[str, ...]" -          "*tuple[int, ...]" is incompatible with "*tuple[str, ...]" (reportAssignmentType) -callables_subtyping.py:125:22 - error: Expression of type "IntStrArgs4" is incompatible with declared type "Standard4" +          "*tuple[int, ...]" is not assignable to "*tuple[str, ...]" (reportAssignmentType) +callables_subtyping.py:125:22 - error: Type "IntStrArgs4" is not assignable to declared type "Standard4"   "IntStrArgs4" is incompatible with protocol "Standard4"     "__call__" is an incompatible type -      Type "(*args: int | str) -> None" is incompatible with type "(a: int, b: str) -> None" -        Keyword parameter "a" is missing in source -        Keyword parameter "b" is missing in source (reportAssignmentType) -callables_subtyping.py:126:22 - error: Expression of type "StrArgs4" is incompatible with declared type "Standard4" +      Type "(*args: int | str) -> None" is not assignable to type "(a: int, b: str) -> None" +        Missing keyword parameter "a" +        Missing keyword parameter "b" (reportAssignmentType) +callables_subtyping.py:126:22 - error: Type "StrArgs4" is not assignable to declared type "Standard4"   "StrArgs4" is incompatible with protocol "Standard4"     "__call__" is an incompatible type -      Type "(a: int, /, *args: str) -> None" is incompatible with type "(a: int, b: str) -> None" -        Keyword parameter "a" is missing in source -        Keyword parameter "b" is missing in source +      Type "(a: int, /, *args: str) -> None" is not assignable to type "(a: int, b: str) -> None" +        Missing keyword parameter "a" +        Missing keyword parameter "b"           Position-only parameter mismatch; parameter "a" is not position-only           Position-only parameter mismatch; expected 1 but received 0 (reportAssignmentType) -callables_subtyping.py:151:22 - error: Expression of type "NoKwargs5" is incompatible with declared type "IntKwargs5" +callables_subtyping.py:151:22 - error: Type "NoKwargs5" is not assignable to declared type "IntKwargs5"   "NoKwargs5" is incompatible with protocol "IntKwargs5"     "__call__" is an incompatible type -      Type "() -> None" is incompatible with type "(**kwargs: int) -> None" +      Type "() -> None" is not assignable to type "(**kwargs: int) -> None"         Parameter "**kwargs" has no corresponding parameter (reportAssignmentType) -callables_subtyping.py:154:24 - error: Expression of type "NoKwargs5" is incompatible with declared type "FloatKwargs5" +callables_subtyping.py:154:24 - error: Type "NoKwargs5" is not assignable to declared type "FloatKwargs5"   "NoKwargs5" is incompatible with protocol "FloatKwargs5"     "__call__" is an incompatible type -      Type "() -> None" is incompatible with type "(**kwargs: float) -> None" +      Type "() -> None" is not assignable to type "(**kwargs: float) -> None"         Parameter "**kwargs" has no corresponding parameter (reportAssignmentType) -callables_subtyping.py:155:24 - error: Expression of type "IntKwargs5" is incompatible with declared type "FloatKwargs5" +callables_subtyping.py:155:24 - error: Type "IntKwargs5" is not assignable to declared type "FloatKwargs5"   "IntKwargs5" is incompatible with protocol "FloatKwargs5"     "__call__" is an incompatible type -      Type "(**kwargs: int) -> None" is incompatible with type "(**kwargs: float) -> None" +      Type "(**kwargs: int) -> None" is not assignable to type "(**kwargs: float) -> None"         Parameter 1: type "float" is incompatible with type "int" -          "float" is incompatible with "int" (reportAssignmentType) -callables_subtyping.py:187:19 - error: Expression of type "IntKwargs6" is incompatible with declared type "KwOnly6" +          "float" is not assignable to "int" (reportAssignmentType) +callables_subtyping.py:187:19 - error: Type "IntKwargs6" is not assignable to declared type "KwOnly6"   "IntKwargs6" is incompatible with protocol "KwOnly6"     "__call__" is an incompatible type -      Type "(**kwargs: int) -> None" is incompatible with type "(*, a: int, b: str) -> None" +      Type "(**kwargs: int) -> None" is not assignable to type "(*, a: int, b: str) -> None"         Parameter 3: type "str" is incompatible with type "int" -          "str" is incompatible with "int" (reportAssignmentType) -callables_subtyping.py:190:25 - error: Expression of type "StrKwargs6" is incompatible with declared type "IntStrKwargs6" +          "str" is not assignable to "int" (reportAssignmentType) +callables_subtyping.py:190:25 - error: Type "StrKwargs6" is not assignable to declared type "IntStrKwargs6"   "StrKwargs6" is incompatible with protocol "IntStrKwargs6"     "__call__" is an incompatible type -      Type "(*, a: int, **kwargs: str) -> None" is incompatible with type "(**kwargs: int | str) -> None" +      Type "(*, a: int, **kwargs: str) -> None" is not assignable to type "(**kwargs: int | str) -> None"         Parameter 1: type "int | str" is incompatible with type "int" -          Type "int | str" is incompatible with type "int" +          Type "int | str" is not assignable to type "int"         Parameter 1: type "int | str" is incompatible with type "str" -          Type "int | str" is incompatible with type "str" (reportAssignmentType) -callables_subtyping.py:191:25 - error: Expression of type "IntKwargs6" is incompatible with declared type "IntStrKwargs6" +          Type "int | str" is not assignable to type "str" (reportAssignmentType) +callables_subtyping.py:191:25 - error: Type "IntKwargs6" is not assignable to declared type "IntStrKwargs6"   "IntKwargs6" is incompatible with protocol "IntStrKwargs6"     "__call__" is an incompatible type -      Type "(**kwargs: int) -> None" is incompatible with type "(**kwargs: int | str) -> None" +      Type "(**kwargs: int) -> None" is not assignable to type "(**kwargs: int | str) -> None"         Parameter 1: type "int | str" is incompatible with type "int" -          Type "int | str" is incompatible with type "int" (reportAssignmentType) -callables_subtyping.py:193:22 - error: Expression of type "IntKwargs6" is incompatible with declared type "StrKwargs6" +          Type "int | str" is not assignable to type "int" (reportAssignmentType) +callables_subtyping.py:193:22 - error: Type "IntKwargs6" is not assignable to declared type "StrKwargs6"   "IntKwargs6" is incompatible with protocol "StrKwargs6"     "__call__" is an incompatible type -      Type "(**kwargs: int) -> None" is incompatible with type "(*, a: int, **kwargs: str) -> None" +      Type "(**kwargs: int) -> None" is not assignable to type "(*, a: int, **kwargs: str) -> None"         Parameter 3: type "str" is incompatible with type "int" -          "str" is incompatible with "int" (reportAssignmentType) -callables_subtyping.py:195:22 - error: Expression of type "StrKwargs6" is incompatible with declared type "IntKwargs6" +          "str" is not assignable to "int" (reportAssignmentType) +callables_subtyping.py:195:22 - error: Type "StrKwargs6" is not assignable to declared type "IntKwargs6"   "StrKwargs6" is incompatible with protocol "IntKwargs6"     "__call__" is an incompatible type -      Type "(*, a: int, **kwargs: str) -> None" is incompatible with type "(**kwargs: int) -> None" +      Type "(*, a: int, **kwargs: str) -> None" is not assignable to type "(**kwargs: int) -> None"         Parameter 1: type "int" is incompatible with type "str" -          "int" is incompatible with "str" (reportAssignmentType) -callables_subtyping.py:196:22 - error: Expression of type "IntStrKwargs6" is incompatible with declared type "Standard6" +          "int" is not assignable to "str" (reportAssignmentType) +callables_subtyping.py:196:22 - error: Type "IntStrKwargs6" is not assignable to declared type "Standard6"   "IntStrKwargs6" is incompatible with protocol "Standard6"     "__call__" is an incompatible type -      Type "(**kwargs: int | str) -> None" is incompatible with type "(a: int, b: str) -> None" -        Function accepts too many positional parameters; expected 0 but received 2 (reportAssignmentType) -callables_subtyping.py:197:22 - error: Expression of type "StrKwargs6" is incompatible with declared type "Standard6" +      Type "(**kwargs: int | str) -> None" is not assignable to type "(a: int, b: str) -> None" +        Function accepts too few positional parameters; expected 2 but received 0 (reportAssignmentType) +callables_subtyping.py:197:22 - error: Type "StrKwargs6" is not assignable to declared type "Standard6"   "StrKwargs6" is incompatible with protocol "Standard6"     "__call__" is an incompatible type -      Type "(*, a: int, **kwargs: str) -> None" is incompatible with type "(a: int, b: str) -> None" -        Function accepts too many positional parameters; expected 0 but received 2 -          Keyword parameter "a" is missing in destination (reportAssignmentType) -callables_subtyping.py:236:23 - error: Expression of type "NoDefaultArg8" is incompatible with declared type "DefaultArg8" +      Type "(*, a: int, **kwargs: str) -> None" is not assignable to type "(a: int, b: str) -> None" +        Function accepts too few positional parameters; expected 2 but received 0 +          Parameter "a" is missing default argument (reportAssignmentType) +callables_subtyping.py:236:23 - error: Type "NoDefaultArg8" is not assignable to declared type "DefaultArg8"   "NoDefaultArg8" is incompatible with protocol "DefaultArg8"     "__call__" is an incompatible type -      Type "(x: int) -> None" is incompatible with type "(x: int = 0) -> None" +      Type "(x: int) -> None" is not assignable to type "(x: int = 0) -> None"         Parameter "x" is missing default argument (reportAssignmentType) -callables_subtyping.py:237:23 - error: Expression of type "NoX8" is incompatible with declared type "DefaultArg8" +callables_subtyping.py:237:23 - error: Type "NoX8" is not assignable to declared type "DefaultArg8"   "NoX8" is incompatible with protocol "DefaultArg8"     "__call__" is an incompatible type -      Type "() -> None" is incompatible with type "(x: int = 0) -> None" -        Function accepts too many positional parameters; expected 0 but received 1 (reportAssignmentType) -callables_subtyping.py:240:25 - error: Expression of type "NoX8" is incompatible with declared type "NoDefaultArg8" +      Type "() -> None" is not assignable to type "(x: int = 0) -> None" +        Function accepts too few positional parameters; expected 1 but received 0 (reportAssignmentType) +callables_subtyping.py:240:25 - error: Type "NoX8" is not assignable to declared type "NoDefaultArg8"   "NoX8" is incompatible with protocol "NoDefaultArg8"     "__call__" is an incompatible type -      Type "() -> None" is incompatible with type "(x: int) -> None" -        Function accepts too many positional parameters; expected 0 but received 1 (reportAssignmentType) -callables_subtyping.py:243:16 - error: Expression of type "NoDefaultArg8" is incompatible with declared type "NoX8" +      Type "() -> None" is not assignable to type "(x: int) -> None" +        Function accepts too few positional parameters; expected 1 but received 0 (reportAssignmentType) +callables_subtyping.py:243:16 - error: Type "NoDefaultArg8" is not assignable to declared type "NoX8"   "NoDefaultArg8" is incompatible with protocol "NoX8"     "__call__" is an incompatible type -      Type "(x: int) -> None" is incompatible with type "() -> None" (reportAssignmentType) -callables_subtyping.py:273:21 - error: Expression of type "Overloaded9" is incompatible with declared type "FloatArg9" +      Type "(x: int) -> None" is not assignable to type "() -> None" +        Extra parameter "x" (reportAssignmentType) +callables_subtyping.py:273:21 - error: Type "Overloaded9" is not assignable to declared type "FloatArg9"   "Overloaded9" is incompatible with protocol "FloatArg9"     "__call__" is an incompatible type       No overloaded function matches type "(x: float) -> float" (reportAssignmentType) -callables_subtyping.py:297:24 - error: Expression of type "StrArg10" is incompatible with declared type "Overloaded10" +callables_subtyping.py:297:24 - error: Type "StrArg10" is not assignable to declared type "Overloaded10"   "StrArg10" is incompatible with protocol "Overloaded10"     "__call__" is an incompatible type       One or more overloads of "__call__" is not assignable -        Type "(x: str) -> complex" is incompatible with type "(x: int, y: str) -> float" -          Function accepts too many positional parameters; expected 1 but received 2 (reportAssignmentType) +        Type "(x: str) -> complex" is not assignable to type "(x: int, y: str) -> float" +          Function accepts too few positional parameters; expected 2 but received 1 (reportAssignmentType) """ conformance_automated = "Pass" diff --git a/conformance/results/pyright/classes_classvar.toml b/conformance/results/pyright/classes_classvar.toml index b922102b3..19026e6f9 100644 --- a/conformance/results/pyright/classes_classvar.toml +++ b/conformance/results/pyright/classes_classvar.toml @@ -1,24 +1,25 @@ conformant = "Pass" output = """ -classes_classvar.py:37:25 - error: Expected only one type argument after "ClassVar" -classes_classvar.py:38:14 - error: Expected type expression but received "Literal[3]" (reportGeneralTypeIssues) -classes_classvar.py:39:14 - error: "var" is not defined (reportUndefinedVariable) -classes_classvar.py:44:20 - error: "ClassVar" type cannot include type variables (reportGeneralTypeIssues) -classes_classvar.py:45:20 - error: "ClassVar" type cannot include type variables (reportGeneralTypeIssues) -classes_classvar.py:46:20 - error: "ClassVar" type cannot include type variables (reportGeneralTypeIssues) -classes_classvar.py:51:33 - error: Expression of type "dict[Any, Any]" is incompatible with declared type "list[str]" (reportAssignmentType) -classes_classvar.py:53:17 - error: "ClassVar" is not allowed in this context -classes_classvar.py:54:17 - error: "ClassVar" is not allowed in this context -classes_classvar.py:62:26 - error: "ClassVar" is not allowed in this context -classes_classvar.py:63:12 - error: "ClassVar" is not allowed in this context -classes_classvar.py:64:18 - error: "ClassVar" is not allowed in this context -classes_classvar.py:66:26 - error: "ClassVar" is not allowed in this context -classes_classvar.py:70:8 - error: "ClassVar" is not allowed in this context -classes_classvar.py:71:20 - error: "ClassVar" is not allowed in this context -classes_classvar.py:101:14 - error: Cannot assign to attribute "stats" for class "Starship" -  Attribute "stats" cannot be assigned through a class instance because it is a ClassVar -    Attribute "__set__" is unknown (reportAttributeAccessIssue) -classes_classvar.py:130:13 - error: Expression of type "ProtoAImpl" is incompatible with declared type "ProtoA" +classes_classvar.py:40:25 - error: Expected only one type argument after "ClassVar" (reportInvalidTypeForm) +classes_classvar.py:41:14 - error: Expected class but received "Literal[3]" (reportGeneralTypeIssues) +classes_classvar.py:42:14 - error: "var" is not defined (reportUndefinedVariable) +classes_classvar.py:47:20 - error: "ClassVar" type cannot include type variables (reportGeneralTypeIssues) +classes_classvar.py:48:20 - error: "ClassVar" type cannot include type variables (reportGeneralTypeIssues) +classes_classvar.py:49:20 - error: "ClassVar" type cannot include type variables (reportGeneralTypeIssues) +classes_classvar.py:54:33 - error: Type "dict[Any, Any]" is not assignable to declared type "list[str]" (reportAssignmentType) +classes_classvar.py:56:17 - error: "ClassVar" is not allowed in this context (reportInvalidTypeForm) +classes_classvar.py:57:17 - error: "ClassVar" is not allowed in this context (reportInvalidTypeForm) +classes_classvar.py:71:26 - error: "ClassVar" is not allowed in this context (reportInvalidTypeForm) +classes_classvar.py:72:12 - error: "ClassVar" is not allowed in this context (reportInvalidTypeForm) +classes_classvar.py:73:18 - error: "ClassVar" is not allowed in this context (reportInvalidTypeForm) +classes_classvar.py:75:26 - error: "ClassVar" is not allowed in this context (reportInvalidTypeForm) +classes_classvar.py:79:8 - error: "ClassVar" is not allowed in this context (reportInvalidTypeForm) +classes_classvar.py:80:20 - error: "ClassVar" is not allowed in this context (reportInvalidTypeForm) +classes_classvar.py:89:8 - error: "ClassVar" is not allowed in this context (reportInvalidTypeForm) +classes_classvar.py:94:8 - error: "ClassVar" is not allowed in this context (reportInvalidTypeForm) +classes_classvar.py:127:14 - error: Cannot assign to attribute "stats" for class "Starship" +  Attribute "stats" cannot be assigned through a class instance because it is a ClassVar (reportAttributeAccessIssue) +classes_classvar.py:156:13 - error: Type "ProtoAImpl" is not assignable to declared type "ProtoA"   "ProtoAImpl" is incompatible with protocol "ProtoA"     "x" is defined as a ClassVar in protocol     "y" is defined as a ClassVar in protocol (reportAssignmentType) diff --git a/conformance/results/pyright/classes_override.toml b/conformance/results/pyright/classes_override.toml index d27bd43de..42cda7e34 100644 --- a/conformance/results/pyright/classes_override.toml +++ b/conformance/results/pyright/classes_override.toml @@ -1,4 +1,8 @@ -conformant = "Pass" +conformant = "Partial" +notes = """ +Does not honor `@override` compatibility checks for `__init__` and `__new__`: +the incompatible constructor overrides in `ChildC2` are not flagged. +""" output = """ classes_override.py:53:9 - error: Method "method3" is marked as override, but no base method of same name is present (reportGeneralTypeIssues) classes_override.py:65:9 - error: Method "method4" is marked as override, but no base method of same name is present (reportGeneralTypeIssues) @@ -6,6 +10,8 @@ classes_override.py:79:9 - error: Method "static_method1" is marked as override, classes_override.py:84:9 - error: Method "class_method1" is marked as override, but no base method of same name is present (reportGeneralTypeIssues) classes_override.py:89:9 - error: Method "property1" is marked as override, but no base method of same name is present (reportGeneralTypeIssues) """ -conformance_automated = "Pass" +conformance_automated = "Fail" errors_diff = """ +Lines 134, 135: Expected error (tag 'init') +Lines 137, 138: Expected error (tag 'new') """ diff --git a/conformance/results/pyright/constructors_call_init.toml b/conformance/results/pyright/constructors_call_init.toml index 1b9371f6c..4d6672588 100644 --- a/conformance/results/pyright/constructors_call_init.toml +++ b/conformance/results/pyright/constructors_call_init.toml @@ -4,15 +4,15 @@ errors_diff = """ """ output = """ constructors_call_init.py:21:13 - error: Argument of type "float" cannot be assigned to parameter "x" of type "int" in function "__init__" -  "float" is incompatible with "int" (reportArgumentType) +  "float" is not assignable to "int" (reportArgumentType) constructors_call_init.py:42:8 - error: Argument of type "Class2[Unknown]" cannot be assigned to parameter "x" of type "Class3 | None" in function "__init__" -  Type "Class2[Unknown]" is incompatible with type "Class3 | None" -    "Class2[Unknown]" is incompatible with "Class3" -    "Class2[Unknown]" is incompatible with "None" (reportArgumentType) +  Type "Class2[Unknown]" is not assignable to type "Class3 | None" +    "Class2[Unknown]" is not assignable to "Class3" +    "Class2[Unknown]" is not assignable to "None" (reportArgumentType) constructors_call_init.py:56:1 - error:   Could not bind method "__init__" because "Class4[str]" is not assignable to parameter "self" -    "Class4[str]" is incompatible with "Class4[int]" +    "Class4[str]" is not assignable to "Class4[int]"       Type parameter "T@Class4" is invariant, but "str" is not the same as "int" (reportGeneralTypeIssues) constructors_call_init.py:107:24 - warning: Type annotation for "self" parameter of "__init__" method cannot contain class-scoped type variables (reportInvalidTypeVarUse) -constructors_call_init.py:130:1 - error: Expected no arguments to "Class11" constructor (reportCallIssue) +constructors_call_init.py:130:9 - error: Expected 0 positional arguments (reportCallIssue) """ diff --git a/conformance/results/pyright/constructors_call_metaclass.toml b/conformance/results/pyright/constructors_call_metaclass.toml index 0736d700b..96498014e 100644 --- a/conformance/results/pyright/constructors_call_metaclass.toml +++ b/conformance/results/pyright/constructors_call_metaclass.toml @@ -2,7 +2,7 @@ conformant = "Pass" errors_diff = """ """ output = """ -constructors_call_metaclass.py:51:1 - error: Argument missing for parameter "x" (reportCallIssue) -constructors_call_metaclass.py:65:1 - error: Argument missing for parameter "x" (reportCallIssue) +constructors_call_metaclass.py:54:1 - error: Argument missing for parameter "x" (reportCallIssue) +constructors_call_metaclass.py:68:1 - error: Argument missing for parameter "x" (reportCallIssue) """ conformance_automated = "Pass" diff --git a/conformance/results/pyright/constructors_call_new.toml b/conformance/results/pyright/constructors_call_new.toml index 8ca005715..e2387d4fc 100644 --- a/conformance/results/pyright/constructors_call_new.toml +++ b/conformance/results/pyright/constructors_call_new.toml @@ -3,10 +3,11 @@ errors_diff = """ """ output = """ constructors_call_new.py:21:13 - error: Argument of type "float" cannot be assigned to parameter "x" of type "int" in function "__new__" -  "float" is incompatible with "int" (reportArgumentType) -constructors_call_new.py:145:1 - error: +  "float" is not assignable to "int" (reportArgumentType) +constructors_call_new.py:148:1 - error:   Could not bind method "__new__" because "type[Class11[str]]" is not assignable to parameter "cls" -    "type[Class11[str]]" is incompatible with "type[Class11[int]]" -    Type "type[Class11[str]]" is incompatible with type "type[Class11[int]]" +    "type[Class11[str]]" is not assignable to "type[Class11[int]]" +    Type "type[Class11[str]]" is not assignable to type "type[Class11[int]]"       Type parameter "T@Class11" is invariant, but "str" is not the same as "int" (reportGeneralTypeIssues) """ +conformance_automated = "Pass" diff --git a/conformance/results/pyright/constructors_call_type.toml b/conformance/results/pyright/constructors_call_type.toml index 536ad6fdc..da804d72e 100644 --- a/conformance/results/pyright/constructors_call_type.toml +++ b/conformance/results/pyright/constructors_call_type.toml @@ -5,11 +5,11 @@ output = """ constructors_call_type.py:30:5 - error: Arguments missing for parameters "x", "y" (reportCallIssue) constructors_call_type.py:40:5 - error: Arguments missing for parameters "x", "y" (reportCallIssue) constructors_call_type.py:50:5 - error: Arguments missing for parameters "x", "y" (reportCallIssue) -constructors_call_type.py:59:5 - error: Expected no arguments to "Class4" constructor (reportCallIssue) -constructors_call_type.py:64:5 - error: Expected no arguments to "object" constructor (reportCallIssue) +constructors_call_type.py:59:9 - error: Expected 0 positional arguments (reportCallIssue) +constructors_call_type.py:64:9 - error: Expected 0 positional arguments (reportCallIssue) constructors_call_type.py:72:5 - error: Arguments missing for parameters "x", "y" (reportCallIssue) constructors_call_type.py:81:5 - error: Argument missing for parameter "y" (reportCallIssue) constructors_call_type.py:82:12 - error: Argument of type "Literal[2]" cannot be assigned to parameter "y" of type "str" in function "__new__" -  "Literal[2]" is incompatible with "str" (reportArgumentType) +  "Literal[2]" is not assignable to "str" (reportArgumentType) """ conformance_automated = "Pass" diff --git a/conformance/results/pyright/constructors_callable.toml b/conformance/results/pyright/constructors_callable.toml index 6c0039665..901fe77b0 100644 --- a/conformance/results/pyright/constructors_callable.toml +++ b/conformance/results/pyright/constructors_callable.toml @@ -1,4 +1,3 @@ -conformant = "Pass" conformance_automated = "Pass" errors_diff = """ """ @@ -9,25 +8,29 @@ constructors_callable.py:39:1 - error: Argument missing for parameter "x" (repor constructors_callable.py:39:4 - error: No parameter named "y" (reportCallIssue) constructors_callable.py:49:13 - information: Type of "r2" is "() -> Class2" constructors_callable.py:51:4 - error: Expected 0 positional arguments (reportCallIssue) -constructors_callable.py:63:13 - information: Type of "r3" is "(x: int) -> Class3" -constructors_callable.py:65:1 - error: Argument missing for parameter "x" (reportCallIssue) +constructors_callable.py:64:13 - information: Type of "r3" is "(x: int) -> Class3" constructors_callable.py:66:1 - error: Argument missing for parameter "x" (reportCallIssue) -constructors_callable.py:66:4 - error: No parameter named "y" (reportCallIssue) -constructors_callable.py:67:7 - error: Expected 1 positional argument (reportCallIssue) -constructors_callable.py:77:13 - information: Type of "r4" is "(x: int) -> int" -constructors_callable.py:79:1 - error: Argument missing for parameter "x" (reportCallIssue) -constructors_callable.py:80:1 - error: Argument missing for parameter "x" (reportCallIssue) -constructors_callable.py:80:4 - error: No parameter named "y" (reportCallIssue) -constructors_callable.py:97:13 - information: Type of "r5" is "(...) -> NoReturn" -constructors_callable.py:125:13 - information: Type of "r6" is "() -> Class6Proxy" -constructors_callable.py:127:4 - error: Expected 0 positional arguments (reportCallIssue) -constructors_callable.py:142:13 - information: Type of "r6_any" is "() -> Any" -constructors_callable.py:144:8 - error: Expected 0 positional arguments (reportCallIssue) -constructors_callable.py:162:5 - information: Type of "r7" is "Overload[(x: int) -> Class7[int], (x: str) -> Class7[str]]" -constructors_callable.py:182:13 - information: Type of "r8" is "(x: list[T@Class8], y: list[T@Class8]) -> Class8[T@Class8]" -constructors_callable.py:184:10 - error: Argument of type "list[str]" cannot be assigned to parameter "y" of type "list[T@Class8]" -  "Literal['']" is incompatible with "int" (reportArgumentType) -constructors_callable.py:193:13 - information: Type of "r9" is "(x: list[T@__init__], y: list[T@__init__]) -> Class9" -constructors_callable.py:195:10 - error: Argument of type "list[str]" cannot be assigned to parameter "y" of type "list[T@__init__]" -  "Literal['']" is incompatible with "int" (reportArgumentType) +constructors_callable.py:67:1 - error: Argument missing for parameter "x" (reportCallIssue) +constructors_callable.py:67:4 - error: No parameter named "y" (reportCallIssue) +constructors_callable.py:68:7 - error: Expected 1 positional argument (reportCallIssue) +constructors_callable.py:79:13 - information: Type of "r4" is "(x: int) -> int" +constructors_callable.py:81:1 - error: Argument missing for parameter "x" (reportCallIssue) +constructors_callable.py:82:1 - error: Argument missing for parameter "x" (reportCallIssue) +constructors_callable.py:82:4 - error: No parameter named "y" (reportCallIssue) +constructors_callable.py:99:13 - information: Type of "r5" is "(...) -> NoReturn" +constructors_callable.py:127:13 - information: Type of "r6" is "() -> Class6Proxy" +constructors_callable.py:129:4 - error: Expected 0 positional arguments (reportCallIssue) +constructors_callable.py:144:13 - information: Type of "r6_any" is "() -> Any" +constructors_callable.py:146:8 - error: Expected 0 positional arguments (reportCallIssue) +constructors_callable.py:164:5 - information: Type of "r7" is "Overload[(x: int) -> Class7[int], (x: str) -> Class7[str]]" +constructors_callable.py:184:13 - information: Type of "r8" is "(x: list[T@Class8], y: list[T@Class8]) -> Class8[T@Class8]" +constructors_callable.py:185:10 - error: Argument of type "Literal['not a list']" cannot be assigned to parameter "y" of type "list[T@Class8]" +  "Literal['not a list']" is not assignable to "list[str]" (reportArgumentType) +constructors_callable.py:187:10 - error: Argument of type "list[str]" cannot be assigned to parameter "y" of type "list[T@Class8]" +  "Literal['']" is not assignable to "int" (reportArgumentType) +constructors_callable.py:196:13 - information: Type of "r9" is "(x: list[T@__init__], y: list[T@__init__]) -> Class9" +constructors_callable.py:197:10 - error: Argument of type "Literal['not a list']" cannot be assigned to parameter "y" of type "list[T@__init__]" +  "Literal['not a list']" is not assignable to "list[str]" (reportArgumentType) +constructors_callable.py:199:10 - error: Argument of type "list[str]" cannot be assigned to parameter "y" of type "list[T@__init__]" +  "Literal['']" is not assignable to "int" (reportArgumentType) """ diff --git a/conformance/results/pyright/constructors_consistency.toml b/conformance/results/pyright/constructors_consistency.toml index 8a3840678..b335fa1ce 100644 --- a/conformance/results/pyright/constructors_consistency.toml +++ b/conformance/results/pyright/constructors_consistency.toml @@ -3,6 +3,7 @@ errors_diff = """ """ output = """ constructors_consistency.py:25:9 - error: Mismatch between signature of __new__ and __init__ in class "Class1" -  Signature of __init__ is "(x: str)" -  Signature of __new__ is "()" (reportInconsistentConstructor) +  Signature of __init__ is "(x: str) -> None" +  Signature of __new__ is "() -> Class1" (reportInconsistentConstructor) """ +conformance_automated = "Pass" diff --git a/conformance/results/pyright/dataclasses_final.toml b/conformance/results/pyright/dataclasses_final.toml index a0ab43daa..9b85ad5ab 100644 --- a/conformance/results/pyright/dataclasses_final.toml +++ b/conformance/results/pyright/dataclasses_final.toml @@ -4,18 +4,13 @@ errors_diff = """ """ output = """ dataclasses_final.py:27:3 - error: Cannot assign to attribute "final_classvar" for class "type[D]" -  "final_classvar" is declared as Final and cannot be reassigned -    Attribute "__set__" is unknown (reportAttributeAccessIssue) +  "final_classvar" is declared as Final and cannot be reassigned (reportAttributeAccessIssue) dataclasses_final.py:35:3 - error: Cannot assign to attribute "final_no_default" for class "D" -  "final_no_default" is declared as Final and cannot be reassigned -    Attribute "__set__" is unknown (reportAttributeAccessIssue) +  "final_no_default" is declared as Final and cannot be reassigned (reportAttributeAccessIssue) dataclasses_final.py:36:3 - error: Cannot assign to attribute "final_with_default" for class "D" -  "final_with_default" is declared as Final and cannot be reassigned -    Attribute "__set__" is unknown (reportAttributeAccessIssue) +  "final_with_default" is declared as Final and cannot be reassigned (reportAttributeAccessIssue) dataclasses_final.py:37:3 - error: Cannot assign to attribute "final_no_default" for class "type[D]" -  "final_no_default" is declared as Final and cannot be reassigned -    Attribute "__set__" is unknown (reportAttributeAccessIssue) +  "final_no_default" is declared as Final and cannot be reassigned (reportAttributeAccessIssue) dataclasses_final.py:38:3 - error: Cannot assign to attribute "final_with_default" for class "type[D]" -  "final_with_default" is declared as Final and cannot be reassigned -    Attribute "__set__" is unknown (reportAttributeAccessIssue) +  "final_with_default" is declared as Final and cannot be reassigned (reportAttributeAccessIssue) """ diff --git a/conformance/results/pyright/dataclasses_frozen.toml b/conformance/results/pyright/dataclasses_frozen.toml index 4175c762d..87a046e23 100644 --- a/conformance/results/pyright/dataclasses_frozen.toml +++ b/conformance/results/pyright/dataclasses_frozen.toml @@ -1,11 +1,9 @@ conformant = "Pass" output = """ dataclasses_frozen.py:16:5 - error: Cannot assign to attribute "a" for class "DC1" -  "DC1" is frozen -    Attribute "__set__" is unknown (reportAttributeAccessIssue) +  Attribute "a" is read-only (reportAttributeAccessIssue) dataclasses_frozen.py:17:5 - error: Cannot assign to attribute "b" for class "DC1" -  "DC1" is frozen -    Attribute "__set__" is unknown (reportAttributeAccessIssue) +  Attribute "b" is read-only (reportAttributeAccessIssue) dataclasses_frozen.py:22:1 - error: A non-frozen class cannot inherit from a class that is frozen (reportGeneralTypeIssues) dataclasses_frozen.py:32:12 - error: A frozen class cannot inherit from a class that is not frozen (reportGeneralTypeIssues) """ diff --git a/conformance/results/pyright/dataclasses_hash.toml b/conformance/results/pyright/dataclasses_hash.toml index 748f32bdb..7e05cf570 100644 --- a/conformance/results/pyright/dataclasses_hash.toml +++ b/conformance/results/pyright/dataclasses_hash.toml @@ -1,13 +1,15 @@ conformant = "Pass" output = """ -dataclasses_hash.py:15:16 - error: Expression of type "DC1" is incompatible with declared type "Hashable" +dataclasses_hash.py:17:1 - error: Object of type "None" cannot be called (reportOptionalCall) +dataclasses_hash.py:18:16 - error: Type "DC1" is not assignable to declared type "Hashable"   "DC1" is incompatible with protocol "Hashable"     "__hash__" is an incompatible type -      Type "None" is incompatible with type "() -> int" (reportAssignmentType) -dataclasses_hash.py:32:16 - error: Expression of type "DC3" is incompatible with declared type "Hashable" +      Type "None" is not assignable to type "() -> int" (reportAssignmentType) +dataclasses_hash.py:39:1 - error: Object of type "None" cannot be called (reportOptionalCall) +dataclasses_hash.py:40:16 - error: Type "DC3" is not assignable to declared type "Hashable"   "DC3" is incompatible with protocol "Hashable"     "__hash__" is an incompatible type -      Type "None" is incompatible with type "() -> int" (reportAssignmentType) +      Type "None" is not assignable to type "() -> int" (reportAssignmentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/dataclasses_inheritance.toml b/conformance/results/pyright/dataclasses_inheritance.toml index a77817ee2..8576bb702 100644 --- a/conformance/results/pyright/dataclasses_inheritance.toml +++ b/conformance/results/pyright/dataclasses_inheritance.toml @@ -1,7 +1,7 @@ conformant = "Pass" output = """ -dataclasses_inheritance.py:60:5 - error: Class variable "x" overrides instance variable of same name in class "DC6" (reportIncompatibleVariableOverride) -dataclasses_inheritance.py:64:5 - error: Instance variable "y" overrides class variable of same name in class "DC6" (reportIncompatibleVariableOverride) +dataclasses_inheritance.py:62:5 - error: Class variable "x" overrides instance variable of same name in class "DC6" (reportIncompatibleVariableOverride) +dataclasses_inheritance.py:66:5 - error: Instance variable "y" overrides class variable of same name in class "DC6" (reportIncompatibleVariableOverride) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/dataclasses_match_args.toml b/conformance/results/pyright/dataclasses_match_args.toml new file mode 100644 index 000000000..570ca46c9 --- /dev/null +++ b/conformance/results/pyright/dataclasses_match_args.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_match_args.py:42:5 - error: Cannot access attribute "__match_args__" for class "type[DC4]" +  Attribute "__match_args__" is unknown (reportAttributeAccessIssue) +""" diff --git a/conformance/results/pyright/dataclasses_postinit.toml b/conformance/results/pyright/dataclasses_postinit.toml index 029868bc5..9ba5550ab 100644 --- a/conformance/results/pyright/dataclasses_postinit.toml +++ b/conformance/results/pyright/dataclasses_postinit.toml @@ -1,7 +1,7 @@ conformant = "Pass" output = """ dataclasses_postinit.py:19:40 - error: Dataclass __post_init__ method parameter type mismatch for field "y" -  "str" is incompatible with "int" (reportGeneralTypeIssues) +  "str" is not assignable to "int" (reportGeneralTypeIssues) dataclasses_postinit.py:28:11 - error: Cannot access attribute "x" for class "DC1"   "x" is an init-only field (reportAttributeAccessIssue) dataclasses_postinit.py:29:11 - error: Cannot access attribute "y" for class "DC1" diff --git a/conformance/results/pyright/dataclasses_transform_class.toml b/conformance/results/pyright/dataclasses_transform_class.toml index 76157c6d6..25b8ccc83 100644 --- a/conformance/results/pyright/dataclasses_transform_class.toml +++ b/conformance/results/pyright/dataclasses_transform_class.toml @@ -1,15 +1,13 @@ conformant = "Pass" output = """ -dataclasses_transform_class.py:48:7 - error: A non-frozen class cannot inherit from a class that is frozen (reportGeneralTypeIssues) -dataclasses_transform_class.py:60:6 - error: Cannot assign to attribute "id" for class "Customer1" -  "Customer1" is frozen -    Attribute "__set__" is unknown (reportAttributeAccessIssue) -dataclasses_transform_class.py:63:18 - error: Expected 0 positional arguments (reportCallIssue) -dataclasses_transform_class.py:69:6 - error: Operator "<" not supported for types "Customer1" and "Customer1" (reportOperatorIssue) -dataclasses_transform_class.py:79:18 - error: Expected 0 positional arguments (reportCallIssue) -dataclasses_transform_class.py:119:6 - error: Cannot assign to attribute "id" for class "Customer3" -  "Customer3" is frozen -    Attribute "__set__" is unknown (reportAttributeAccessIssue) +dataclasses_transform_class.py:51:7 - error: A non-frozen class cannot inherit from a class that is frozen (reportGeneralTypeIssues) +dataclasses_transform_class.py:63:6 - error: Cannot assign to attribute "id" for class "Customer1" +  Attribute "id" is read-only (reportAttributeAccessIssue) +dataclasses_transform_class.py:66:18 - error: Expected 0 positional arguments (reportCallIssue) +dataclasses_transform_class.py:72:6 - error: Operator "<" not supported for types "Customer1" and "Customer1" (reportOperatorIssue) +dataclasses_transform_class.py:82:18 - error: Expected 0 positional arguments (reportCallIssue) +dataclasses_transform_class.py:122:6 - error: Cannot assign to attribute "id" for class "Customer3" +  Attribute "id" is read-only (reportAttributeAccessIssue) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/dataclasses_transform_converter.toml b/conformance/results/pyright/dataclasses_transform_converter.toml new file mode 100644 index 000000000..6ec751736 --- /dev/null +++ b/conformance/results/pyright/dataclasses_transform_converter.toml @@ -0,0 +1,44 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_transform_converter.py:48:31 - error: Argument of type "() -> int" is not a valid converter for field "field1" of type "int" +  Type "() -> int" is not assignable to type "(__converterInput) -> int" +    Function accepts too few positional parameters; expected 1 but received 0 (reportGeneralTypeIssues) +dataclasses_transform_converter.py:48:41 - error: Argument of type "() -> int" cannot be assigned to parameter "converter" of type "(S@model_field) -> T@model_field" in function "model_field" +  Type "() -> int" is not assignable to type "(S@model_field) -> int" +    Function accepts too few positional parameters; expected 1 but received 0 (reportArgumentType) +dataclasses_transform_converter.py:49:31 - error: Argument of type "(*, x: int) -> int" is not a valid converter for field "field2" of type "int" +  Type "(*, x: int) -> int" is not assignable to type "(__converterInput) -> int" +    Function accepts too few positional parameters; expected 1 but received 0 +      Extra parameter "x" (reportGeneralTypeIssues) +dataclasses_transform_converter.py:49:41 - error: Argument of type "(*, x: int) -> int" cannot be assigned to parameter "converter" of type "(S@model_field) -> T@model_field" in function "model_field" +  Type "(*, x: int) -> int" is not assignable to type "(S@model_field) -> int" +    Function accepts too few positional parameters; expected 1 but received 0 +      Extra parameter "x" (reportArgumentType) +dataclasses_transform_converter.py:107:5 - error: Argument of type "Literal[1]" cannot be assigned to parameter "field0" of type "str" in function "__init__" +  "Literal[1]" is not assignable to "str" (reportArgumentType) +dataclasses_transform_converter.py:108:23 - error: Argument of type "Literal[1]" cannot be assigned to parameter "field3" of type "str | bytes" in function "__init__" +  Type "Literal[1]" is not assignable to type "str | bytes" +    "Literal[1]" is not assignable to "str" +    "Literal[1]" is not assignable to "bytes" (reportArgumentType) +dataclasses_transform_converter.py:109:29 - error: Argument of type "complex" cannot be assigned to parameter "field4" of type "str | list[str]" in function "__init__" +  Type "complex" is not assignable to type "str | list[str]" +    "complex" is not assignable to "str" +    "complex" is not assignable to "list[str]" (reportArgumentType) +dataclasses_transform_converter.py:118:14 - error: Cannot assign to attribute "field0" for class "DC2" +  "Literal[1]" is not assignable to "str" (reportAttributeAccessIssue) +dataclasses_transform_converter.py:119:14 - error: Cannot assign to attribute "field3" for class "DC2" +  Type "Literal[1]" is not assignable to type "str | bytes" +    "Literal[1]" is not assignable to "str" +    "Literal[1]" is not assignable to "bytes" (reportAttributeAccessIssue) +dataclasses_transform_converter.py:130:67 - error: Argument of type "Literal[1]" cannot be assigned to parameter "default" of type "S@model_field | None" in function "model_field" +  Type "Literal[1]" is not assignable to type "str | None" +    "Literal[1]" is not assignable to "str" +    "Literal[1]" is not assignable to "None" (reportArgumentType) +dataclasses_transform_converter.py:133:75 - error: Argument of type "type[int]" cannot be assigned to parameter "default_factory" of type "(() -> S@model_field) | None" in function "model_field" +  Type "type[int]" is not assignable to type "(() -> str) | None" +    No overloaded function matches type "() -> str" +    Type is not assignable to "None" (reportArgumentType) +""" diff --git a/conformance/results/pyright/dataclasses_transform_func.toml b/conformance/results/pyright/dataclasses_transform_func.toml index 55a0df3e3..86e12bfcf 100644 --- a/conformance/results/pyright/dataclasses_transform_func.toml +++ b/conformance/results/pyright/dataclasses_transform_func.toml @@ -1,14 +1,13 @@ conformant = "Pass" output = """ -dataclasses_transform_func.py:57:13 - error: Cannot assign to attribute "name" for class "Customer1" -  "Literal[3]" is incompatible with "str" (reportAttributeAccessIssue) -dataclasses_transform_func.py:61:6 - error: Operator "<" not supported for types "Customer1" and "Customer1" (reportOperatorIssue) -dataclasses_transform_func.py:65:36 - error: No parameter named "salary" (reportCallIssue) -dataclasses_transform_func.py:71:18 - error: Expected 0 positional arguments (reportCallIssue) -dataclasses_transform_func.py:89:1 - error: A non-frozen class cannot inherit from a class that is frozen (reportGeneralTypeIssues) -dataclasses_transform_func.py:97:6 - error: Cannot assign to attribute "id" for class "Customer3" -  "Customer3" is frozen -    Attribute "__set__" is unknown (reportAttributeAccessIssue) +dataclasses_transform_func.py:56:13 - error: Cannot assign to attribute "name" for class "Customer1" +  "Literal[3]" is not assignable to "str" (reportAttributeAccessIssue) +dataclasses_transform_func.py:60:6 - error: Operator "<" not supported for types "Customer1" and "Customer1" (reportOperatorIssue) +dataclasses_transform_func.py:64:36 - error: No parameter named "salary" (reportCallIssue) +dataclasses_transform_func.py:70:18 - error: Expected 0 positional arguments (reportCallIssue) +dataclasses_transform_func.py:88:1 - error: A non-frozen class cannot inherit from a class that is frozen (reportGeneralTypeIssues) +dataclasses_transform_func.py:96:6 - error: Cannot assign to attribute "id" for class "Customer3" +  Attribute "id" is read-only (reportAttributeAccessIssue) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/dataclasses_transform_meta.toml b/conformance/results/pyright/dataclasses_transform_meta.toml index 6e77a130f..392f95a70 100644 --- a/conformance/results/pyright/dataclasses_transform_meta.toml +++ b/conformance/results/pyright/dataclasses_transform_meta.toml @@ -1,15 +1,13 @@ conformant = "Pass" output = """ -dataclasses_transform_meta.py:48:36 - error: A non-frozen class cannot inherit from a class that is frozen (reportGeneralTypeIssues) -dataclasses_transform_meta.py:60:6 - error: Cannot assign to attribute "id" for class "Customer1" -  "Customer1" is frozen -    Attribute "__set__" is unknown (reportAttributeAccessIssue) -dataclasses_transform_meta.py:63:18 - error: Expected 0 positional arguments (reportCallIssue) -dataclasses_transform_meta.py:70:6 - error: Operator "<" not supported for types "Customer1" and "Customer1" (reportOperatorIssue) -dataclasses_transform_meta.py:80:18 - error: Expected 0 positional arguments (reportCallIssue) -dataclasses_transform_meta.py:100:6 - error: Cannot assign to attribute "id" for class "Customer3" -  "Customer3" is frozen -    Attribute "__set__" is unknown (reportAttributeAccessIssue) +dataclasses_transform_meta.py:51:36 - error: A non-frozen class cannot inherit from a class that is frozen (reportGeneralTypeIssues) +dataclasses_transform_meta.py:63:6 - error: Cannot assign to attribute "id" for class "Customer1" +  Attribute "id" is read-only (reportAttributeAccessIssue) +dataclasses_transform_meta.py:66:18 - error: Expected 0 positional arguments (reportCallIssue) +dataclasses_transform_meta.py:73:6 - error: Operator "<" not supported for types "Customer1" and "Customer1" (reportOperatorIssue) +dataclasses_transform_meta.py:83:18 - error: Expected 0 positional arguments (reportCallIssue) +dataclasses_transform_meta.py:103:6 - error: Cannot assign to attribute "id" for class "Customer3" +  Attribute "id" is read-only (reportAttributeAccessIssue) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/dataclasses_usage.toml b/conformance/results/pyright/dataclasses_usage.toml index e9c7365f3..62d5a0cb7 100644 --- a/conformance/results/pyright/dataclasses_usage.toml +++ b/conformance/results/pyright/dataclasses_usage.toml @@ -1,19 +1,20 @@ conformant = "Pass" output = """ -dataclasses_usage.py:50:6 - error: Argument missing for parameter "unit_price" (reportCallIssue) -dataclasses_usage.py:51:28 - error: Argument of type "Literal['price']" cannot be assigned to parameter "unit_price" of type "float" in function "__init__" -  "Literal['price']" is incompatible with "float" (reportArgumentType) -dataclasses_usage.py:52:36 - error: Expected 3 positional arguments (reportCallIssue) -dataclasses_usage.py:61:5 - error: Fields without default values cannot appear after fields with default values (reportGeneralTypeIssues) -dataclasses_usage.py:67:5 - error: Fields without default values cannot appear after fields with default values (reportGeneralTypeIssues) -dataclasses_usage.py:73:5 - error: Fields without default values cannot appear after fields with default values (reportGeneralTypeIssues) -dataclasses_usage.py:83:13 - error: Expected 1 positional argument (reportCallIssue) -dataclasses_usage.py:88:36 - error: Argument of type "type[str]" cannot be assigned to parameter "default_factory" of type "() -> _T@field" in function "field" -  No overloaded function matches type "() -> int" (reportArgumentType) -dataclasses_usage.py:126:8 - error: Expected 1 positional argument (reportCallIssue) -dataclasses_usage.py:129:1 - error: Argument missing for parameter "y" (reportCallIssue) -dataclasses_usage.py:178:1 - error: Expected no arguments to "DC13" constructor (reportCallIssue) -dataclasses_usage.py:227:9 - error: Dataclass field without type annotation will cause runtime exception (reportGeneralTypeIssues) +dataclasses_usage.py:51:6 - error: Argument missing for parameter "unit_price" (reportCallIssue) +dataclasses_usage.py:52:28 - error: Argument of type "Literal['price']" cannot be assigned to parameter "unit_price" of type "float" in function "__init__" +  "Literal['price']" is not assignable to "float" (reportArgumentType) +dataclasses_usage.py:53:36 - error: Expected 3 positional arguments (reportCallIssue) +dataclasses_usage.py:62:5 - error: Fields without default values cannot appear after fields with default values (reportGeneralTypeIssues) +dataclasses_usage.py:68:5 - error: Fields without default values cannot appear after fields with default values (reportGeneralTypeIssues) +dataclasses_usage.py:74:5 - error: Fields without default values cannot appear after fields with default values (reportGeneralTypeIssues) +dataclasses_usage.py:84:13 - error: Expected 1 positional argument (reportCallIssue) +dataclasses_usage.py:89:14 - error: Type "str" is not assignable to declared type "int" +  "str" is not assignable to "int" (reportAssignmentType) +dataclasses_usage.py:128:8 - error: Expected 1 positional argument (reportCallIssue) +dataclasses_usage.py:131:1 - error: Argument missing for parameter "y" (reportCallIssue) +dataclasses_usage.py:180:6 - error: Expected 0 positional arguments (reportCallIssue) +dataclasses_usage.py:229:9 - error: Dataclass field without type annotation will cause runtime exception (reportGeneralTypeIssues) +dataclasses_usage.py:246:12 - error: Expected 2 positional arguments (reportCallIssue) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/directives_assert_type.toml b/conformance/results/pyright/directives_assert_type.toml index 993dfb73d..cb868983d 100644 --- a/conformance/results/pyright/directives_assert_type.toml +++ b/conformance/results/pyright/directives_assert_type.toml @@ -1,11 +1,13 @@ conformant = "Pass" output = """ directives_assert_type.py:27:17 - error: "assert_type" mismatch: expected "int" but received "int | str" (reportAssertTypeFailure) -directives_assert_type.py:28:17 - error: "assert_type" mismatch: expected "int" but received "Any" (reportAssertTypeFailure) -directives_assert_type.py:29:17 - error: "assert_type" mismatch: expected "int" but received "Literal[4]" (reportAssertTypeFailure) -directives_assert_type.py:31:5 - error: "assert_type" expects two positional arguments -directives_assert_type.py:32:17 - error: "assert_type" mismatch: expected "int" but received "Literal['']" (reportAssertTypeFailure) -directives_assert_type.py:33:5 - error: "assert_type" expects two positional arguments +directives_assert_type.py:28:17 - error: "assert_type" mismatch: expected "Any" but received "int | str" (reportAssertTypeFailure) +directives_assert_type.py:29:17 - error: "assert_type" mismatch: expected "int" but received "Any" (reportAssertTypeFailure) +directives_assert_type.py:30:17 - error: "assert_type" mismatch: expected "int" but received "Literal[4]" (reportAssertTypeFailure) +directives_assert_type.py:32:5 - error: "assert_type" expects two positional arguments (reportCallIssue) +directives_assert_type.py:33:17 - error: "assert_type" mismatch: expected "int" but received "Literal['']" (reportAssertTypeFailure) +directives_assert_type.py:34:5 - error: "assert_type" expects two positional arguments (reportCallIssue) +directives_assert_type.py:41:17 - error: "assert_type" mismatch: expected "str | Literal['spam']" but received "str" (reportAssertTypeFailure) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/directives_cast.toml b/conformance/results/pyright/directives_cast.toml index 9e439f77a..d7dc7e221 100644 --- a/conformance/results/pyright/directives_cast.toml +++ b/conformance/results/pyright/directives_cast.toml @@ -2,7 +2,7 @@ conformant = "Pass" output = """ directives_cast.py:15:8 - error: No overloads for "cast" match the provided arguments   Argument types: () (reportCallIssue) -directives_cast.py:16:13 - error: Expected type expression but received "Literal[1]" (reportGeneralTypeIssues) +directives_cast.py:16:13 - error: Expected class but received "Literal[1]" (reportGeneralTypeIssues) directives_cast.py:17:8 - error: No overloads for "cast" match the provided arguments   Argument types: (type[int], Literal[''], Literal['']) (reportCallIssue) """ diff --git a/conformance/results/pyright/directives_deprecated.toml b/conformance/results/pyright/directives_deprecated.toml new file mode 100644 index 000000000..21cb8172a --- /dev/null +++ b/conformance/results/pyright/directives_deprecated.toml @@ -0,0 +1,32 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +directives_deprecated.py:18:44 - error: The class "Ham" is deprecated +  Use Spam instead (reportDeprecated) +directives_deprecated.py:24:9 - error: The function "norwegian_blue" is deprecated +  It is pining for the fjords (reportDeprecated) +directives_deprecated.py:25:13 - error: The function "norwegian_blue" is deprecated +  It is pining for the fjords (reportDeprecated) +directives_deprecated.py:30:9 - error: The function "foo" is deprecated +  Only str will be allowed (reportDeprecated) +directives_deprecated.py:34:7 - error: The class "Ham" is deprecated +  Use Spam instead (reportDeprecated) +directives_deprecated.py:41:5 - error: The method "__add__" in class "Spam" is deprecated +  There is enough spam in the world (reportDeprecated) +directives_deprecated.py:42:1 - error: The method "__add__" in class "Spam" is deprecated +  There is enough spam in the world (reportDeprecated) +directives_deprecated.py:44:6 - error: The getter for property "greasy" is deprecated +  All spam will be equally greasy (reportDeprecated) +directives_deprecated.py:47:6 - error: The setter for property "shape" is deprecated +  Shapes are becoming immutable (reportDeprecated) +directives_deprecated.py:48:6 - error: The setter for property "shape" is deprecated +  Shapes are becoming immutable (reportDeprecated) +directives_deprecated.py:58:1 - error: The function "invocable" is deprecated +  Deprecated (reportDeprecated) +directives_deprecated.py:69:1 - error: The function "lorem" is deprecated +  Deprecated (reportDeprecated) +directives_deprecated.py:98:7 - error: The method "foo" in class "SupportsFoo1" is deprecated +  Deprecated (reportDeprecated) +""" diff --git a/conformance/results/pyright/directives_disjoint_base.toml b/conformance/results/pyright/directives_disjoint_base.toml new file mode 100644 index 000000000..3aa39bab8 --- /dev/null +++ b/conformance/results/pyright/directives_disjoint_base.toml @@ -0,0 +1,15 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +directives_disjoint_base.py:69:7 - error: Base classes have incompatible disjoint bases: "Left", "Right" (reportGeneralTypeIssues) +directives_disjoint_base.py:73:7 - error: Base classes have incompatible disjoint bases: "LeftChild", "Right" (reportGeneralTypeIssues) +directives_disjoint_base.py:77:7 - error: Base classes have incompatible disjoint bases: "Left", "Right" (reportGeneralTypeIssues) +directives_disjoint_base.py:81:7 - error: Base classes have incompatible disjoint bases: "Left", "Record" (reportGeneralTypeIssues) +directives_disjoint_base.py:105:7 - error: Base classes have incompatible disjoint bases: "SlotBase1", "SlotBase2" (reportGeneralTypeIssues) +directives_disjoint_base.py:113:2 - error: @disjoint_base cannot be applied to a function (reportGeneralTypeIssues) +directives_disjoint_base.py:118:2 - error: @disjoint_base cannot be applied to a TypedDict class (reportGeneralTypeIssues) +directives_disjoint_base.py:123:2 - error: @disjoint_base cannot be applied to a Protocol class (reportGeneralTypeIssues) +directives_disjoint_base.py:135:22 - error: Argument of type "" cannot be assigned to parameter "arg" of type "Never" in function "assert_never" +  Type "" is not assignable to type "Never" (reportArgumentType) +""" diff --git a/conformance/results/pyright/directives_no_type_check.toml b/conformance/results/pyright/directives_no_type_check.toml index 9f73f7153..858c581eb 100644 --- a/conformance/results/pyright/directives_no_type_check.toml +++ b/conformance/results/pyright/directives_no_type_check.toml @@ -3,8 +3,8 @@ notes = """ Does not honor `@no_type_check` class decorator (allowed). """ output = """ -directives_no_type_check.py:15:14 - error: Expression of type "Literal['']" is incompatible with declared type "int" -  "Literal['']" is incompatible with "int" (reportAssignmentType) +directives_no_type_check.py:15:14 - error: Type "Literal['']" is not assignable to declared type "int" +  "Literal['']" is not assignable to "int" (reportAssignmentType) directives_no_type_check.py:32:1 - error: Arguments missing for parameters "a", "b" (reportCallIssue) """ conformance_automated = "Pass" diff --git a/conformance/results/pyright/directives_reveal_type.toml b/conformance/results/pyright/directives_reveal_type.toml index 679849716..8f427c3b3 100644 --- a/conformance/results/pyright/directives_reveal_type.toml +++ b/conformance/results/pyright/directives_reveal_type.toml @@ -4,8 +4,8 @@ directives_reveal_type.py:14:17 - information: Type of "a" is "int | str" directives_reveal_type.py:15:17 - information: Type of "b" is "list[int]" directives_reveal_type.py:16:17 - information: Type of "c" is "Any" directives_reveal_type.py:17:17 - information: Type of "d" is "ForwardReference" -directives_reveal_type.py:19:5 - error: Expected a single positional argument for "reveal_type" call -directives_reveal_type.py:20:5 - error: Expected a single positional argument for "reveal_type" call +directives_reveal_type.py:19:5 - error: Expected a single positional argument for "reveal_type" call (reportCallIssue) +directives_reveal_type.py:20:5 - error: Expected a single positional argument for "reveal_type" call (reportCallIssue) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/directives_type_ignore_file2.toml b/conformance/results/pyright/directives_type_ignore_file2.toml index 21a0a593b..667eeb77b 100644 --- a/conformance/results/pyright/directives_type_ignore_file2.toml +++ b/conformance/results/pyright/directives_type_ignore_file2.toml @@ -1,7 +1,7 @@ conformant = "Pass" output = """ -directives_type_ignore_file2.py:14:10 - error: Expression of type "Literal['']" is incompatible with declared type "int" -  "Literal['']" is incompatible with "int" (reportAssignmentType) +directives_type_ignore_file2.py:14:10 - error: Type "Literal['']" is not assignable to declared type "int" +  "Literal['']" is not assignable to "int" (reportAssignmentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/directives_version_platform.toml b/conformance/results/pyright/directives_version_platform.toml index 5e485e856..e37efb6b3 100644 --- a/conformance/results/pyright/directives_version_platform.toml +++ b/conformance/results/pyright/directives_version_platform.toml @@ -1,5 +1,10 @@ conformant = "Pass" output = """ +directives_version_platform.py:33:19 - error: "val3" is not defined (reportUndefinedVariable) +directives_version_platform.py:50:19 - error: "val6" is not defined (reportUndefinedVariable) +directives_version_platform.py:59:19 - error: "val9" is not defined (reportUndefinedVariable) +directives_version_platform.py:66:19 - error: "val10" is not defined (reportUndefinedVariable) +directives_version_platform.py:75:19 - error: "val13" is not defined (reportUndefinedVariable) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/enums_behaviors.toml b/conformance/results/pyright/enums_behaviors.toml new file mode 100644 index 000000000..3d5c93daa --- /dev/null +++ b/conformance/results/pyright/enums_behaviors.toml @@ -0,0 +1,9 @@ +conformant = "Pass" +errors_diff = """ +""" +output = """ +enums_behaviors.py:28:13 - error: "assert_type" mismatch: expected "Literal[Color.RED]" but received "Color" (reportAssertTypeFailure) +enums_behaviors.py:32:13 - error: "assert_type" mismatch: expected "Literal[Color.BLUE]" but received "Color" (reportAssertTypeFailure) +enums_behaviors.py:44:21 - error: Enum class "Shape" is final and cannot be subclassed (reportGeneralTypeIssues) +""" +conformance_automated = "Pass" diff --git a/conformance/results/pyright/enums_definition.toml b/conformance/results/pyright/enums_definition.toml new file mode 100644 index 000000000..6741494f1 --- /dev/null +++ b/conformance/results/pyright/enums_definition.toml @@ -0,0 +1,8 @@ +conformant = "Pass" +errors_diff = """ +""" +output = """ +enums_definition.py:92:9 - error: Cannot access attribute "BLUE" for class "type[Color12]" +  Attribute "BLUE" is unknown (reportAttributeAccessIssue) +""" +conformance_automated = "Pass" diff --git a/conformance/results/pyright/enums_expansion.toml b/conformance/results/pyright/enums_expansion.toml new file mode 100644 index 000000000..1e0a7d1d9 --- /dev/null +++ b/conformance/results/pyright/enums_expansion.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +enums_expansion.py:56:21 - error: "assert_type" mismatch: expected "Literal[CustomFlags.FLAG3]" but received "CustomFlags" (reportAssertTypeFailure) +""" diff --git a/conformance/results/pyright/enums_member_names.toml b/conformance/results/pyright/enums_member_names.toml new file mode 100644 index 000000000..be211bd5b --- /dev/null +++ b/conformance/results/pyright/enums_member_names.toml @@ -0,0 +1,6 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/pyright/enums_member_values.toml b/conformance/results/pyright/enums_member_values.toml new file mode 100644 index 000000000..2efe3d766 --- /dev/null +++ b/conformance/results/pyright/enums_member_values.toml @@ -0,0 +1,14 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +enums_member_values.py:50:12 - error: Argument missing for parameter "radius" (reportCallIssue) +enums_member_values.py:51:15 - error: Arguments missing for parameters "mass", "radius" (reportCallIssue) +enums_member_values.py:54:13 - error: "assert_type" mismatch: expected "Literal[1]" but received "Any" (reportAssertTypeFailure) +enums_member_values.py:68:13 - error: "assert_type" mismatch: expected "Literal[1]" but received "int" (reportAssertTypeFailure) +enums_member_values.py:78:13 - error: Type "Literal['green']" is not assignable to declared type "int" +  "Literal['green']" is not assignable to "int" (reportAssignmentType) +enums_member_values.py:85:24 - error: Cannot assign to attribute "_value_" for class "Planet2*" +  "int" is not assignable to "str" (reportAttributeAccessIssue) +""" diff --git a/conformance/results/pyright/enums_members.toml b/conformance/results/pyright/enums_members.toml new file mode 100644 index 000000000..563fb2297 --- /dev/null +++ b/conformance/results/pyright/enums_members.toml @@ -0,0 +1,24 @@ +conformant = "Pass" +notes = """ +Does not support `_ignore_` mechanism (optional). +""" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +enums_members.py:54:5 - error: Type annotations are not allowed for enum members (reportGeneralTypeIssues) +enums_members.py:86:20 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm) +enums_members.py:86:25 - error: Variable not allowed in type expression (reportInvalidTypeForm) +enums_members.py:87:20 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm) +enums_members.py:87:25 - error: Variable not allowed in type expression (reportInvalidTypeForm) +enums_members.py:88:18 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm) +enums_members.py:89:16 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm) +enums_members.py:120:13 - error: "assert_type" mismatch: expected "Unknown" but received "int" (reportAssertTypeFailure) +enums_members.py:120:32 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm) +enums_members.py:132:21 - information: Type of "Example2.__B" is "Literal[2]" +enums_members.py:133:21 - error: "assert_type" mismatch: expected "Unknown" but received "Literal[2]" (reportAssertTypeFailure) +enums_members.py:133:43 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm) +enums_members.py:133:52 - error: Variable not allowed in type expression (reportInvalidTypeForm) +enums_members.py:150:13 - error: "assert_type" mismatch: expected "int" but received "Literal[Pet5.DOG]" (reportAssertTypeFailure) +enums_members.py:151:13 - error: "assert_type" mismatch: expected "int" but received "Literal[Pet5.FISH]" (reportAssertTypeFailure) +""" diff --git a/conformance/results/pyright/exceptions_context_managers.toml b/conformance/results/pyright/exceptions_context_managers.toml index cd630cbf5..513dbe853 100644 --- a/conformance/results/pyright/exceptions_context_managers.toml +++ b/conformance/results/pyright/exceptions_context_managers.toml @@ -3,3 +3,4 @@ errors_diff = """ """ output = """ """ +conformance_automated = "Pass" diff --git a/conformance/results/pyright/generics_base_class.toml b/conformance/results/pyright/generics_base_class.toml index 806c4b0f9..e39db1ee5 100644 --- a/conformance/results/pyright/generics_base_class.toml +++ b/conformance/results/pyright/generics_base_class.toml @@ -1,15 +1,17 @@ conformant = "Pass" output = """ generics_base_class.py:26:26 - error: Argument of type "SymbolTable" cannot be assigned to parameter "x" of type "dict[str, list[object]]" in function "takes_dict_incorrect" -  "SymbolTable" is incompatible with "dict[str, list[object]]" +  "SymbolTable" is not assignable to "dict[str, list[object]]"     Type parameter "_VT@dict" is invariant, but "list[Node]" is not the same as "list[object]"     Consider switching from "dict" to "Mapping" which is covariant in the value type (reportArgumentType) generics_base_class.py:29:14 - error: "Generic" is not valid in this context (reportGeneralTypeIssues) -generics_base_class.py:30:8 - error: "Generic" requires at least one type argument +generics_base_class.py:30:8 - error: "Generic" requires at least one type argument (reportInvalidTypeForm) generics_base_class.py:30:8 - error: "Generic" is not valid in this context (reportGeneralTypeIssues) generics_base_class.py:49:38 - error: Too many type arguments provided for "LinkedList"; expected 1 but received 2 (reportInvalidTypeArguments) generics_base_class.py:61:30 - error: Too many type arguments provided for "MyDict"; expected 1 but received 2 (reportInvalidTypeArguments) -generics_base_class.py:68:28 - error: Type arguments for "Generic" must be unique +generics_base_class.py:68:28 - error: Type arguments for "Generic" must be unique (reportInvalidTypeForm) +generics_base_class.py:98:7 - error: Base classes of BadChild are mutually incompatible +  Base class "Grandparent[T2@BadChild, T1@BadChild]" derives from "Grandparent[T2@BadChild, T1@BadChild]" which is incompatible with type "Grandparent[T1@BadChild, T2@BadChild]" (reportGeneralTypeIssues) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/generics_basic.toml b/conformance/results/pyright/generics_basic.toml index b18ae527c..2fa41eea6 100644 --- a/conformance/results/pyright/generics_basic.toml +++ b/conformance/results/pyright/generics_basic.toml @@ -1,19 +1,41 @@ conformant = "Pass" output = """ generics_basic.py:40:15 - error: Argument of type "bytes" cannot be assigned to parameter "y" of type "AnyStr@concat" in function "concat" -  "bytes" is incompatible with "str" (reportArgumentType) +  "bytes" is not assignable to "str" (reportArgumentType) generics_basic.py:41:15 - error: Argument of type "str" cannot be assigned to parameter "y" of type "AnyStr@concat" in function "concat" -  "str" is incompatible with "bytes" (reportArgumentType) +  "str" is not assignable to "bytes" (reportArgumentType) generics_basic.py:49:44 - error: TypeVar must have at least two constrained types (reportGeneralTypeIssues) -generics_basic.py:55:53 - error: TypeVar constraint type cannot be generic +generics_basic.py:55:53 - error: TypeVar constraint type cannot be generic (reportGeneralTypeIssues) generics_basic.py:69:15 - error: Argument of type "bytes" cannot be assigned to parameter "y" of type "AnyStr@concat" in function "concat" -  "bytes" is incompatible with "str" (reportArgumentType) -generics_basic.py:121:24 - error: Type arguments for "Generic" must be unique +  "bytes" is not assignable to "str" (reportArgumentType) +generics_basic.py:121:24 - error: Type arguments for "Generic" must be unique (reportInvalidTypeForm) generics_basic.py:157:5 - error: Argument of type "Literal[0]" cannot be assigned to parameter "key" of type "str" in function "__getitem__" -  "Literal[0]" is incompatible with "str" (reportArgumentType) +  "Literal[0]" is not assignable to "str" (reportArgumentType) generics_basic.py:158:5 - error: Argument of type "Literal[0]" cannot be assigned to parameter "key" of type "str" in function "__getitem__" -  "Literal[0]" is incompatible with "str" (reportArgumentType) -generics_basic.py:191:37 - error: Metaclass cannot be generic (reportGeneralTypeIssues) +  "Literal[0]" is not assignable to "str" (reportArgumentType) +generics_basic.py:162:20 - error: Type argument for "Generic" must be a type variable (reportInvalidTypeForm) +generics_basic.py:163:21 - error: Type argument for "Protocol" must be a type parameter (reportInvalidTypeForm) +generics_basic.py:171:7 - error: Generic[] or Protocol[] must include all type variables +  Missing type variables: "T_co" (reportGeneralTypeIssues) +generics_basic.py:172:7 - error: Generic[] or Protocol[] must include all type variables +  Missing type variables: "T_co" (reportGeneralTypeIssues) +generics_basic.py:208:37 - error: Metaclass cannot be generic (reportGeneralTypeIssues) +generics_basic.py:223:22 - error: Argument of type "Literal['not a list']" cannot be assigned to parameter "y" of type "list[T@takes_two_lists]" in function "takes_two_lists" +  "Literal['not a list']" is not assignable to "list[int]" (reportArgumentType) +generics_basic.py:225:23 - error: Argument of type "list[str]" cannot be assigned to parameter "y" of type "list[T@takes_two_lists]" in function "takes_two_lists" +  "Literal['']" is not assignable to "int" (reportArgumentType) +generics_basic.py:232:24 - error: Argument of type "list[str]" cannot be assigned to parameter "y" of type "list[T@takes_two_lists]" in function "takes_two_lists" +  "list[str]" is not assignable to "list[int]" +    Type parameter "_T@list" is invariant, but "str" is not the same as "int" +    Consider switching from "list" to "Sequence" which is covariant (reportArgumentType) +generics_basic.py:240:26 - error: Argument of type "Literal['not a list']" cannot be assigned to parameter "y" of type "list[T_int@takes_two_int_lists]" in function "takes_two_int_lists" +  "Literal['not a list']" is not assignable to "list[int]" (reportArgumentType) +generics_basic.py:241:27 - error: Argument of type "list[str]" cannot be assigned to parameter "y" of type "list[T_int@takes_two_int_lists]" in function "takes_two_int_lists" +  "Literal['']" is not assignable to "int" (reportArgumentType) +generics_basic.py:251:28 - error: Argument of type "list[bool]" cannot be assigned to parameter "y" of type "list[T_int@takes_two_int_lists]" in function "takes_two_int_lists" +  "list[bool]" is not assignable to "list[int]" +    Type parameter "_T@list" is invariant, but "bool" is not the same as "int" +    Consider switching from "list" to "Sequence" which is covariant (reportArgumentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/generics_defaults.toml b/conformance/results/pyright/generics_defaults.toml index 21ced6ee0..d306076f2 100644 --- a/conformance/results/pyright/generics_defaults.toml +++ b/conformance/results/pyright/generics_defaults.toml @@ -1,11 +1,11 @@ conformant = "Pass" output = """ generics_defaults.py:24:7 - error: "T" cannot appear after "DefaultStrT" in type parameter list because it has no default type (reportGeneralTypeIssues) -generics_defaults.py:50:16 - error: Too few type arguments provided for "AllTheDefaults"; expected 2 but received 1 (reportInvalidTypeArguments) -generics_defaults.py:104:39 - error: TypeVar default type must be a subtype of the bound type (reportGeneralTypeIssues) -generics_defaults.py:111:40 - error: TypeVar default type must be one of the constrained types (reportGeneralTypeIssues) -generics_defaults.py:138:7 - error: TypeVar "T5" has a default value and cannot follow TypeVarTuple "Ts" (reportGeneralTypeIssues) -generics_defaults.py:167:18 - error: Access to generic instance variable through class is ambiguous (reportGeneralTypeIssues) +generics_defaults.py:66:23 - error: Too few type arguments provided for "AllTheDefaults"; expected 2 but received 1 (reportInvalidTypeArguments) +generics_defaults.py:152:51 - error: TypeVar default type must be a subtype of the bound type (reportGeneralTypeIssues) +generics_defaults.py:159:52 - error: TypeVar default type must be one of the constrained types (reportGeneralTypeIssues) +generics_defaults.py:177:13 - error: "assert_type" mismatch: expected "Any" but received "int" (reportAssertTypeFailure) +generics_defaults.py:188:7 - error: TypeVar "T5" has a default value and cannot follow TypeVarTuple "Ts" (reportGeneralTypeIssues) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/generics_defaults_referential.toml b/conformance/results/pyright/generics_defaults_referential.toml index ff318bc3e..d8e21ca89 100644 --- a/conformance/results/pyright/generics_defaults_referential.toml +++ b/conformance/results/pyright/generics_defaults_referential.toml @@ -1,16 +1,16 @@ conformant = "Pass" output = """ -generics_defaults_referential.py:36:13 - error: Argument of type "Literal['']" cannot be assigned to parameter "b" of type "int" in function "__init__" -  "Literal['']" is incompatible with "int" (reportArgumentType) -generics_defaults_referential.py:37:10 - error: Argument of type "Literal['']" cannot be assigned to parameter "a" of type "int" in function "__init__" -  "Literal['']" is incompatible with "int" (reportArgumentType) +generics_defaults_referential.py:36:17 - error: Argument of type "str" cannot be assigned to parameter "b" of type "int" in function "__init__" +  "str" is not assignable to "int" (reportArgumentType) +generics_defaults_referential.py:37:14 - error: Argument of type "str" cannot be assigned to parameter "a" of type "int" in function "__init__" +  "str" is not assignable to "int" (reportArgumentType) generics_defaults_referential.py:53:7 - error: Type parameter "Start2T" has a default type that refers to one or more type variables that are out of scope   Type variable "StopT" is not in scope (reportGeneralTypeIssues) generics_defaults_referential.py:60:11 - error: Type parameter "S2" has a default type that refers to one or more type variables that are out of scope   Type variable "S1" is not in scope (reportGeneralTypeIssues) -generics_defaults_referential.py:68:29 - error: TypeVar default type must be a subtype of the bound type (reportGeneralTypeIssues) -generics_defaults_referential.py:74:41 - error: TypeVar default type must be one of the constrained types (reportGeneralTypeIssues) -generics_defaults_referential.py:78:48 - error: TypeVar default type must be one of the constrained types (reportGeneralTypeIssues) +generics_defaults_referential.py:68:40 - error: TypeVar default type must be a subtype of the bound type (reportGeneralTypeIssues) +generics_defaults_referential.py:74:52 - error: TypeVar default type must be one of the constrained types (reportGeneralTypeIssues) +generics_defaults_referential.py:78:63 - error: TypeVar default type must be one of the constrained types (reportGeneralTypeIssues) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/generics_defaults_specialization.toml b/conformance/results/pyright/generics_defaults_specialization.toml index 1c8691026..298694496 100644 --- a/conformance/results/pyright/generics_defaults_specialization.toml +++ b/conformance/results/pyright/generics_defaults_specialization.toml @@ -1,7 +1,11 @@ conformant = "Pass" output = """ -generics_defaults_specialization.py:30:15 - error: Too many type arguments provided for "MyAlias[DefaultStrT@MyAlias]"; expected 1 but received 2 -generics_defaults_specialization.py:55:5 - error: Expected no type arguments for class "Foo" (reportInvalidTypeArguments) +generics_defaults_specialization.py:30:15 - error: Too many type arguments provided for "MyAlias[DefaultStrT@MyAlias]"; expected 1 but received 2 (reportInvalidTypeForm) +generics_defaults_specialization.py:48:22 - error: Type "type[Bar[DefaultStrT@Bar]]" is not assignable to declared type "type[Bar[int]]" +  "type[Bar[str]]" is not assignable to "type[Bar[int]]" +  Type "type[Bar[DefaultStrT@Bar]]" is not assignable to type "type[Bar[int]]" +    Type parameter "DefaultStrT@Bar" is invariant, but "str" is not the same as "int" (reportAssignmentType) +generics_defaults_specialization.py:58:5 - error: Expected no type arguments for class "Foo" (reportInvalidTypeArguments) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/generics_mixed_variance_inference.toml b/conformance/results/pyright/generics_mixed_variance_inference.toml new file mode 100644 index 000000000..36e0b0436 --- /dev/null +++ b/conformance/results/pyright/generics_mixed_variance_inference.toml @@ -0,0 +1,24 @@ +conformant = "Unsupported" +conformance_automated = "Fail" +errors_diff = """ +Line 17: Unexpected errors ['generics_mixed_variance_inference.py:17:27 - error: Type "Mixed[int, bool, ()]" is not assignable to declared type "Mixed[int, int, ()]"'] +Line 20: Unexpected errors ['generics_mixed_variance_inference.py:20:25 - error: Type "Mixed[int, (object)]" is not assignable to declared type "Mixed[int, (int)]"'] +""" +output = """ +generics_mixed_variance_inference.py:13:22 - error: Type "Mixed[bool, ()]" is not assignable to declared type "Mixed[int, ()]" +  "Mixed[bool, ()]" is not assignable to "Mixed[int, ()]" +    Type parameter "T@Mixed" is contravariant, but "bool" is not a supertype of "int" +      "int" is not assignable to "bool" (reportAssignmentType) +generics_mixed_variance_inference.py:16:27 - error: Type "Mixed[int, object, ()]" is not assignable to declared type "Mixed[int, int, ()]" +  "Mixed[int, object, ()]" is not assignable to "Mixed[int, int, ()]" +    Type parameter "Ts@Mixed" is invariant, but "*tuple[object]" is not the same as "*tuple[int]" (reportAssignmentType) +generics_mixed_variance_inference.py:17:27 - error: Type "Mixed[int, bool, ()]" is not assignable to declared type "Mixed[int, int, ()]" +  "Mixed[int, bool, ()]" is not assignable to "Mixed[int, int, ()]" +    Type parameter "Ts@Mixed" is invariant, but "*tuple[bool]" is not the same as "*tuple[int]" (reportAssignmentType) +generics_mixed_variance_inference.py:20:25 - error: Type "Mixed[int, (object)]" is not assignable to declared type "Mixed[int, (int)]" +  "Mixed[int, (object)]" is not assignable to "Mixed[int, (int)]" +    Type parameter "P@Mixed" is invariant, but "(object)" is not the same as "(int)" (reportAssignmentType) +generics_mixed_variance_inference.py:21:25 - error: Type "Mixed[int, (bool)]" is not assignable to declared type "Mixed[int, (int)]" +  "Mixed[int, (bool)]" is not assignable to "Mixed[int, (int)]" +    Type parameter "P@Mixed" is invariant, but "(bool)" is not the same as "(int)" (reportAssignmentType) +""" diff --git a/conformance/results/pyright/generics_paramspec_basic.toml b/conformance/results/pyright/generics_paramspec_basic.toml index 4a0c2b7a5..4a4eed99a 100644 --- a/conformance/results/pyright/generics_paramspec_basic.toml +++ b/conformance/results/pyright/generics_paramspec_basic.toml @@ -1,15 +1,15 @@ conformant = "Pass" output = """ -generics_paramspec_basic.py:10:1 - error: ParamSpec must be assigned to a variable named "NotIt" -generics_paramspec_basic.py:15:18 - error: ParamSpec is not allowed in this context -generics_paramspec_basic.py:23:14 - error: ParamSpec is not allowed in this context -generics_paramspec_basic.py:23:20 - error: ParamSpec is not allowed in this context -generics_paramspec_basic.py:27:14 - error: "Concatenate" is not allowed in this context +generics_paramspec_basic.py:10:1 - error: ParamSpec must be assigned to a variable named "NotIt" (reportGeneralTypeIssues) +generics_paramspec_basic.py:15:18 - error: ParamSpec is not allowed in this context (reportInvalidTypeForm) +generics_paramspec_basic.py:23:14 - error: ParamSpec is not allowed in this context (reportInvalidTypeForm) +generics_paramspec_basic.py:23:20 - error: ParamSpec is not allowed in this context (reportInvalidTypeForm) +generics_paramspec_basic.py:27:14 - error: "Concatenate" is not allowed in this context (reportInvalidTypeForm) generics_paramspec_basic.py:31:19 - error: Type "P@func3" cannot be assigned to type variable "_T@list"   ParamSpec is not allowed in this context (reportInvalidTypeArguments) -generics_paramspec_basic.py:35:35 - error: ParamSpec is not allowed in this context -generics_paramspec_basic.py:39:18 - error: ParamSpec is not allowed in this context -generics_paramspec_basic.py:39:31 - error: ParamSpec is not allowed in this context +generics_paramspec_basic.py:35:35 - error: ParamSpec is not allowed in this context (reportInvalidTypeForm) +generics_paramspec_basic.py:39:18 - error: ParamSpec is not allowed in this context (reportInvalidTypeForm) +generics_paramspec_basic.py:39:31 - error: ParamSpec is not allowed in this context (reportInvalidTypeForm) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/generics_paramspec_components.toml b/conformance/results/pyright/generics_paramspec_components.toml index c66227eee..91d07a572 100644 --- a/conformance/results/pyright/generics_paramspec_components.toml +++ b/conformance/results/pyright/generics_paramspec_components.toml @@ -1,15 +1,14 @@ conformant = "Pass" output = """ -generics_paramspec_components.py:17:25 - error: "kwargs" attribute of ParamSpec is valid only when used with **kwargs parameter -generics_paramspec_components.py:17:45 - error: "args" attribute of ParamSpec is valid only when used with *args parameter -generics_paramspec_components.py:20:23 - error: "args" attribute of ParamSpec is valid only when used with *args parameter +generics_paramspec_components.py:17:25 - error: "kwargs" attribute of ParamSpec is valid only when used with **kwargs parameter (reportInvalidTypeForm) +generics_paramspec_components.py:17:45 - error: "args" attribute of ParamSpec is valid only when used with *args parameter (reportInvalidTypeForm) +generics_paramspec_components.py:20:23 - error: "args" attribute of ParamSpec is valid only when used with *args parameter (reportInvalidTypeForm) generics_paramspec_components.py:23:28 - error: "args" and "kwargs" attributes of ParamSpec must both appear within a function signature (reportGeneralTypeIssues) -generics_paramspec_components.py:23:46 - error: "args" attribute of ParamSpec is valid only when used with *args parameter +generics_paramspec_components.py:23:46 - error: "args" attribute of ParamSpec is valid only when used with *args parameter (reportInvalidTypeForm) generics_paramspec_components.py:26:28 - error: "args" and "kwargs" attributes of ParamSpec must both appear within a function signature (reportGeneralTypeIssues) generics_paramspec_components.py:30:25 - error: ParamSpec "P" has no meaning in this context (reportGeneralTypeIssues) -generics_paramspec_components.py:30:43 - error: ParamSpec "P" has no meaning in this context (reportGeneralTypeIssues) -generics_paramspec_components.py:35:18 - error: "args" attribute of ParamSpec is valid only when used with *args parameter -generics_paramspec_components.py:36:20 - error: "kwargs" attribute of ParamSpec is valid only when used with **kwargs parameter +generics_paramspec_components.py:35:18 - error: "args" attribute of ParamSpec is valid only when used with *args parameter (reportInvalidTypeForm) +generics_paramspec_components.py:36:20 - error: "kwargs" attribute of ParamSpec is valid only when used with **kwargs parameter (reportInvalidTypeForm) generics_paramspec_components.py:38:26 - error: "args" and "kwargs" attributes of ParamSpec must both appear within a function signature (reportGeneralTypeIssues) generics_paramspec_components.py:41:31 - error: "args" and "kwargs" attributes of ParamSpec must both appear within a function signature (reportGeneralTypeIssues) generics_paramspec_components.py:49:9 - error: Arguments for ParamSpec "P@decorator" are missing (reportCallIssue) @@ -17,11 +16,11 @@ generics_paramspec_components.py:51:11 - error: Expected 0 positional arguments generics_paramspec_components.py:60:28 - error: Keyword parameter "s" cannot appear in signature after ParamSpec args parameter (reportGeneralTypeIssues) generics_paramspec_components.py:70:12 - error: Expected 1 positional argument (reportCallIssue) generics_paramspec_components.py:72:12 - error: Expected 1 positional argument (reportCallIssue) -generics_paramspec_components.py:83:19 - error: Expected 2 positional arguments (reportCallIssue) +generics_paramspec_components.py:83:19 - error: Expected 1 positional argument (reportCallIssue) generics_paramspec_components.py:98:20 - error: Argument of type "Literal['A']" cannot be assigned to parameter "a" of type "int" -  "Literal['A']" is incompatible with "int" (reportArgumentType) +  "Literal['A']" is not assignable to "int" (reportArgumentType) generics_paramspec_components.py:98:25 - error: Argument of type "Literal[1]" cannot be assigned to parameter "b" of type "str" -  "Literal[1]" is incompatible with "str" (reportArgumentType) +  "Literal[1]" is not assignable to "str" (reportArgumentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/generics_paramspec_semantics.toml b/conformance/results/pyright/generics_paramspec_semantics.toml index 3a3e0bcd0..8c4c4ab54 100644 --- a/conformance/results/pyright/generics_paramspec_semantics.toml +++ b/conformance/results/pyright/generics_paramspec_semantics.toml @@ -1,35 +1,35 @@ conformant = "Pass" notes = """ -Constraint solver doesn't find common type for two signatures captured by a single ParamSpec (allowed). +Constraint solver doesn't find common type for two signatures captured by a single `ParamSpec` (allowed). """ output = """ generics_paramspec_semantics.py:26:6 - error: Expected 2 more positional arguments (reportCallIssue) generics_paramspec_semantics.py:27:9 - error: Argument of type "Literal['A']" cannot be assigned to parameter "b" of type "bool" -  "Literal['A']" is incompatible with "bool" (reportArgumentType) +  "Literal['A']" is not assignable to "bool" (reportArgumentType) generics_paramspec_semantics.py:46:17 - error: Argument of type "(y: int, x: str) -> int" cannot be assigned to parameter "y" of type "(**P@func1) -> int" in function "func1" -  Type "(y: int, x: str) -> int" is incompatible with type "(x: int, y: str) -> int" +  Type "(y: int, x: str) -> int" is not assignable to type "(x: int, y: str) -> int"     Parameter name mismatch: "x" versus "y"     Parameter name mismatch: "y" versus "x" (reportArgumentType) generics_paramspec_semantics.py:61:23 - error: Argument of type "(*, y: int) -> int" cannot be assigned to parameter "y" of type "(**P@func1) -> int" in function "func1" -  Type "(*, y: int) -> int" is incompatible with type "(*, x: int) -> int" -    Keyword parameter "y" is missing in destination -    Keyword parameter "x" is missing in source (reportArgumentType) -generics_paramspec_semantics.py:97:4 - error: Argument of type "Literal[1]" cannot be assigned to parameter of type "str" -  "Literal[1]" is incompatible with "str" (reportArgumentType) -generics_paramspec_semantics.py:107:4 - error: Argument of type "Literal[1]" cannot be assigned to parameter "args" of type "bool" -  "Literal[1]" is incompatible with "bool" (reportArgumentType) -generics_paramspec_semantics.py:119:4 - error: Argument of type "Literal[1]" cannot be assigned to parameter of type "str" -  "Literal[1]" is incompatible with "str" (reportArgumentType) -generics_paramspec_semantics.py:126:2 - error: Argument of type "(x: str) -> int" cannot be assigned to parameter "x" of type "(int, **P@expects_int_first) -> int" in function "expects_int_first" -  Type "(x: str) -> int" is incompatible with type "(int, **P@expects_int_first) -> int" +  Type "(*, y: int) -> int" is not assignable to type "(*, x: int) -> int" +    Extra parameter "y" +    Missing keyword parameter "x" (reportArgumentType) +generics_paramspec_semantics.py:98:4 - error: Argument of type "Literal[1]" cannot be assigned to parameter of type "str" +  "Literal[1]" is not assignable to "str" (reportArgumentType) +generics_paramspec_semantics.py:108:4 - error: Argument of type "Literal[1]" cannot be assigned to parameter "args" of type "bool" +  "Literal[1]" is not assignable to "bool" (reportArgumentType) +generics_paramspec_semantics.py:120:4 - error: Argument of type "Literal[1]" cannot be assigned to parameter of type "str" +  "Literal[1]" is not assignable to "str" (reportArgumentType) +generics_paramspec_semantics.py:127:2 - error: Argument of type "(x: str) -> int" cannot be assigned to parameter "x" of type "(int, **P@expects_int_first) -> int" in function "expects_int_first" +  Type "(x: str) -> int" is not assignable to type "(int, **P@expects_int_first) -> int"     Parameter 1: type "int" is incompatible with type "str" -      "int" is incompatible with "str" (reportArgumentType) -generics_paramspec_semantics.py:131:2 - error: Argument of type "(*, x: int) -> int" cannot be assigned to parameter "x" of type "(int, **P@expects_int_first) -> int" in function "expects_int_first" -  Type "(*, x: int) -> int" is incompatible with type "(int, **P@expects_int_first) -> int" -    Function accepts too many positional parameters; expected 0 but received 1 (reportArgumentType) -generics_paramspec_semantics.py:136:2 - error: Argument of type "(**kwargs: int) -> int" cannot be assigned to parameter "x" of type "(int, **P@expects_int_first) -> int" in function "expects_int_first" -  Type "(**kwargs: int) -> int" is incompatible with type "(int, **P@expects_int_first) -> int" -    Function accepts too many positional parameters; expected 0 but received 1 (reportArgumentType) +      "int" is not assignable to "str" (reportArgumentType) +generics_paramspec_semantics.py:132:2 - error: Argument of type "(*, x: int) -> int" cannot be assigned to parameter "x" of type "(int, **P@expects_int_first) -> int" in function "expects_int_first" +  Type "(*, x: int) -> int" is not assignable to type "(int, **P@expects_int_first) -> int" +    Function accepts too few positional parameters; expected 1 but received 0 (reportArgumentType) +generics_paramspec_semantics.py:137:2 - error: Argument of type "(**kwargs: int) -> int" cannot be assigned to parameter "x" of type "(int, **P@expects_int_first) -> int" in function "expects_int_first" +  Type "(**kwargs: int) -> int" is not assignable to type "(int, **P@expects_int_first) -> int" +    Function accepts too few positional parameters; expected 1 but received 0 (reportArgumentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/generics_paramspec_specialization.toml b/conformance/results/pyright/generics_paramspec_specialization.toml index 10d7c80a1..af1ab6764 100644 --- a/conformance/results/pyright/generics_paramspec_specialization.toml +++ b/conformance/results/pyright/generics_paramspec_specialization.toml @@ -1,15 +1,15 @@ conformant = "Pass" output = """ -generics_paramspec_specialization.py:45:27 - error: Type "int" cannot be assigned to type variable "P1@ClassA" +generics_paramspec_specialization.py:44:27 - error: Type "int" cannot be assigned to type variable "P1@ClassA"   Type "int" is incompatible with ParamSpec "P1@ClassA" (reportInvalidTypeArguments) -generics_paramspec_specialization.py:55:9 - error: Argument of type "Literal['']" cannot be assigned to parameter of type "int" -  "Literal['']" is incompatible with "int" (reportArgumentType) -generics_paramspec_specialization.py:56:16 - error: Argument of type "Literal['']" cannot be assigned to parameter of type "bool" -  "Literal['']" is incompatible with "bool" (reportArgumentType) -generics_paramspec_specialization.py:61:9 - error: Argument of type "Literal['']" cannot be assigned to parameter of type "int" -  "Literal['']" is incompatible with "int" (reportArgumentType) -generics_paramspec_specialization.py:62:16 - error: Argument of type "Literal['']" cannot be assigned to parameter of type "bool" -  "Literal['']" is incompatible with "bool" (reportArgumentType) +generics_paramspec_specialization.py:54:9 - error: Argument of type "Literal['']" cannot be assigned to parameter of type "int" +  "Literal['']" is not assignable to "int" (reportArgumentType) +generics_paramspec_specialization.py:55:16 - error: Argument of type "Literal['']" cannot be assigned to parameter of type "bool" +  "Literal['']" is not assignable to "bool" (reportArgumentType) +generics_paramspec_specialization.py:60:9 - error: Argument of type "Literal['']" cannot be assigned to parameter of type "int" +  "Literal['']" is not assignable to "int" (reportArgumentType) +generics_paramspec_specialization.py:61:16 - error: Argument of type "Literal['']" cannot be assigned to parameter of type "bool" +  "Literal['']" is not assignable to "bool" (reportArgumentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/generics_paramspec_variance.toml b/conformance/results/pyright/generics_paramspec_variance.toml new file mode 100644 index 000000000..f39f7d2aa --- /dev/null +++ b/conformance/results/pyright/generics_paramspec_variance.toml @@ -0,0 +1,101 @@ +conformant = "Unsupported" +conformance_automated = "Fail" +errors_diff = """ +Line 90: Expected 1 errors +Line 117: Expected 1 errors +Line 126: Expected 1 errors +Line 22: Unexpected errors ['generics_paramspec_variance.py:22:39 - error: Type "ContravariantParamSpec[(object)]" is not assignable to declared type "ContravariantParamSpec[(int)]"'] +Line 31: Unexpected errors ['generics_paramspec_variance.py:31:39 - error: Type "CovariantParamSpec[(int)]" is not assignable to declared type "CovariantParamSpec[(object)]"'] +Line 84: Unexpected errors ['generics_paramspec_variance.py:84:13 - error: Cannot assign to attribute "t" for class "Box[OutitP[(a: int)]]"'] +Line 86: Unexpected errors ['generics_paramspec_variance.py:86:13 - error: Cannot assign to attribute "t" for class "Box[OutitP[(a: int)]]"'] +Line 97: Unexpected errors ['generics_paramspec_variance.py:97:24 - error: "contravariant" is unknown parameter to ParamSpec (reportGeneralTypeIssues)'] +Line 98: Unexpected errors ['generics_paramspec_variance.py:98:26 - error: "covariant" is unknown parameter to ParamSpec (reportGeneralTypeIssues)'] +Line 99: Unexpected errors ['generics_paramspec_variance.py:99:30 - error: "infer_variance" is unknown parameter to ParamSpec (reportGeneralTypeIssues)'] +Line 122: Unexpected errors ['generics_paramspec_variance.py:122:46 - error: Type "ContravariantParamSpecOld[(object)]" is not assignable to declared type "ContravariantParamSpecOld[(int)]"'] +Line 133: Unexpected errors ['generics_paramspec_variance.py:133:46 - error: Type "CovariantParamSpecOld[(int)]" is not assignable to declared type "CovariantParamSpecOld[(object)]"'] +Line 143: Unexpected errors ['generics_paramspec_variance.py:143:60 - error: Type "InferredContravariantParamSpecOld[(object)]" is not assignable to declared type "InferredContravariantParamSpecOld[(int)]"'] +Line 152: Unexpected errors ['generics_paramspec_variance.py:152:60 - error: Type "InferredCovariantParamSpecOld[(int)]" is not assignable to declared type "InferredCovariantParamSpecOld[(object)]"'] +""" +output = """ +generics_paramspec_variance.py:14:42 - error: Type "InvariantParamSpec[(int)]" is not assignable to declared type "InvariantParamSpec[(object)]" +  "InvariantParamSpec[(int)]" is not assignable to "InvariantParamSpec[(object)]" +    Type parameter "InOutP@InvariantParamSpec" is invariant, but "(int)" is not the same as "(object)" (reportAssignmentType) +generics_paramspec_variance.py:15:39 - error: Type "InvariantParamSpec[(object)]" is not assignable to declared type "InvariantParamSpec[(int)]" +  "InvariantParamSpec[(object)]" is not assignable to "InvariantParamSpec[(int)]" +    Type parameter "InOutP@InvariantParamSpec" is invariant, but "(object)" is not the same as "(int)" (reportAssignmentType) +generics_paramspec_variance.py:21:42 - error: Type "ContravariantParamSpec[(int)]" is not assignable to declared type "ContravariantParamSpec[(object)]" +  "ContravariantParamSpec[(int)]" is not assignable to "ContravariantParamSpec[(object)]" +    Type parameter "InP@ContravariantParamSpec" is invariant, but "(int)" is not the same as "(object)" (reportAssignmentType) +generics_paramspec_variance.py:22:39 - error: Type "ContravariantParamSpec[(object)]" is not assignable to declared type "ContravariantParamSpec[(int)]" +  "ContravariantParamSpec[(object)]" is not assignable to "ContravariantParamSpec[(int)]" +    Type parameter "InP@ContravariantParamSpec" is invariant, but "(object)" is not the same as "(int)" (reportAssignmentType) +generics_paramspec_variance.py:30:36 - error: Type "CovariantParamSpec[(object)]" is not assignable to declared type "CovariantParamSpec[(int)]" +  "CovariantParamSpec[(object)]" is not assignable to "CovariantParamSpec[(int)]" +    Type parameter "OutP@CovariantParamSpec" is invariant, but "(object)" is not the same as "(int)" (reportAssignmentType) +generics_paramspec_variance.py:31:39 - error: Type "CovariantParamSpec[(int)]" is not assignable to declared type "CovariantParamSpec[(object)]" +  "CovariantParamSpec[(int)]" is not assignable to "CovariantParamSpec[(object)]" +    Type parameter "OutP@CovariantParamSpec" is invariant, but "(int)" is not the same as "(object)" (reportAssignmentType) +generics_paramspec_variance.py:61:12 - error: Cannot assign to attribute "t" for class "Box[InitP[(a: int)]]" +  "InitP[(*, a: int)]" is not assignable to "InitP[(a: int)]" +    Type parameter "P@InitP" is invariant, but "(*, a: int)" is not the same as "(a: int)" (reportAttributeAccessIssue) +generics_paramspec_variance.py:63:12 - error: Cannot assign to attribute "t" for class "Box[InitP[(a: int)]]" +  "InitP[(a: int, /)]" is not assignable to "InitP[(a: int)]" +    Type parameter "P@InitP" is invariant, but "(a: int, /)" is not the same as "(a: int)" (reportAttributeAccessIssue) +generics_paramspec_variance.py:65:12 - error: Cannot assign to attribute "t" for class "Box[InitP[(a: int)]]" +  "InitP[(b: int)]" is not assignable to "InitP[(a: int)]" +    Type parameter "P@InitP" is invariant, but "(b: int)" is not the same as "(a: int)" (reportAttributeAccessIssue) +generics_paramspec_variance.py:69:12 - error: Cannot assign to attribute "t" for class "Box[InitP[(a: int)]]" +  "InitP[(a: int, b: str)]" is not assignable to "InitP[(a: int)]" +    Type parameter "P@InitP" is invariant, but "(a: int, b: str)" is not the same as "(a: int)" (reportAttributeAccessIssue) +generics_paramspec_variance.py:84:13 - error: Cannot assign to attribute "t" for class "Box[OutitP[(a: int)]]" +  "OutitP[(*, a: int)]" is not assignable to "OutitP[(a: int)]" +    Type parameter "P@OutitP" is invariant, but "(*, a: int)" is not the same as "(a: int)" (reportAttributeAccessIssue) +generics_paramspec_variance.py:86:13 - error: Cannot assign to attribute "t" for class "Box[OutitP[(a: int)]]" +  "OutitP[(a: int, /)]" is not assignable to "OutitP[(a: int)]" +    Type parameter "P@OutitP" is invariant, but "(a: int, /)" is not the same as "(a: int)" (reportAttributeAccessIssue) +generics_paramspec_variance.py:88:13 - error: Cannot assign to attribute "t" for class "Box[OutitP[(a: int)]]" +  "OutitP[(b: int)]" is not assignable to "OutitP[(a: int)]" +    Type parameter "P@OutitP" is invariant, but "(b: int)" is not the same as "(a: int)" (reportAttributeAccessIssue) +generics_paramspec_variance.py:92:13 - error: Cannot assign to attribute "t" for class "Box[OutitP[(a: int)]]" +  "OutitP[(a: int, b: str)]" is not assignable to "OutitP[(a: int)]" +    Type parameter "P@OutitP" is invariant, but "(a: int, b: str)" is not the same as "(a: int)" (reportAttributeAccessIssue) +generics_paramspec_variance.py:97:24 - error: "contravariant" is unknown parameter to ParamSpec (reportGeneralTypeIssues) +generics_paramspec_variance.py:98:26 - error: "covariant" is unknown parameter to ParamSpec (reportGeneralTypeIssues) +generics_paramspec_variance.py:99:30 - error: "infer_variance" is unknown parameter to ParamSpec (reportGeneralTypeIssues) +generics_paramspec_variance.py:100:28 - error: "covariant" is unknown parameter to ParamSpec (reportGeneralTypeIssues) +generics_paramspec_variance.py:100:44 - error: "contravariant" is unknown parameter to ParamSpec (reportGeneralTypeIssues) +generics_paramspec_variance.py:101:28 - error: "covariant" is unknown parameter to ParamSpec (reportGeneralTypeIssues) +generics_paramspec_variance.py:101:44 - error: "infer_variance" is unknown parameter to ParamSpec (reportGeneralTypeIssues) +generics_paramspec_variance.py:102:28 - error: "contravariant" is unknown parameter to ParamSpec (reportGeneralTypeIssues) +generics_paramspec_variance.py:102:48 - error: "infer_variance" is unknown parameter to ParamSpec (reportGeneralTypeIssues) +generics_paramspec_variance.py:110:14 - error: Type "InvariantParamSpecOld[(bool)]" is not assignable to declared type "InvariantParamSpecOld[(int)]" +  "InvariantParamSpecOld[(bool)]" is not assignable to "InvariantParamSpecOld[(int)]" +    Type parameter "P@InvariantParamSpecOld" is invariant, but "(bool)" is not the same as "(int)" (reportAssignmentType) +generics_paramspec_variance.py:111:14 - error: Type "InvariantParamSpecOld[(object)]" is not assignable to declared type "InvariantParamSpecOld[(int)]" +  "InvariantParamSpecOld[(object)]" is not assignable to "InvariantParamSpecOld[(int)]" +    Type parameter "P@InvariantParamSpecOld" is invariant, but "(object)" is not the same as "(int)" (reportAssignmentType) +generics_paramspec_variance.py:121:49 - error: Type "ContravariantParamSpecOld[(int)]" is not assignable to declared type "ContravariantParamSpecOld[(object)]" +  "ContravariantParamSpecOld[(int)]" is not assignable to "ContravariantParamSpecOld[(object)]" +    Type parameter "InP@ContravariantParamSpecOld" is invariant, but "(int)" is not the same as "(object)" (reportAssignmentType) +generics_paramspec_variance.py:122:46 - error: Type "ContravariantParamSpecOld[(object)]" is not assignable to declared type "ContravariantParamSpecOld[(int)]" +  "ContravariantParamSpecOld[(object)]" is not assignable to "ContravariantParamSpecOld[(int)]" +    Type parameter "InP@ContravariantParamSpecOld" is invariant, but "(object)" is not the same as "(int)" (reportAssignmentType) +generics_paramspec_variance.py:132:43 - error: Type "CovariantParamSpecOld[(object)]" is not assignable to declared type "CovariantParamSpecOld[(int)]" +  "CovariantParamSpecOld[(object)]" is not assignable to "CovariantParamSpecOld[(int)]" +    Type parameter "OutP@CovariantParamSpecOld" is invariant, but "(object)" is not the same as "(int)" (reportAssignmentType) +generics_paramspec_variance.py:133:46 - error: Type "CovariantParamSpecOld[(int)]" is not assignable to declared type "CovariantParamSpecOld[(object)]" +  "CovariantParamSpecOld[(int)]" is not assignable to "CovariantParamSpecOld[(object)]" +    Type parameter "OutP@CovariantParamSpecOld" is invariant, but "(int)" is not the same as "(object)" (reportAssignmentType) +generics_paramspec_variance.py:142:63 - error: Type "InferredContravariantParamSpecOld[(int)]" is not assignable to declared type "InferredContravariantParamSpecOld[(object)]" +  "InferredContravariantParamSpecOld[(int)]" is not assignable to "InferredContravariantParamSpecOld[(object)]" +    Type parameter "InferP@InferredContravariantParamSpecOld" is invariant, but "(int)" is not the same as "(object)" (reportAssignmentType) +generics_paramspec_variance.py:143:60 - error: Type "InferredContravariantParamSpecOld[(object)]" is not assignable to declared type "InferredContravariantParamSpecOld[(int)]" +  "InferredContravariantParamSpecOld[(object)]" is not assignable to "InferredContravariantParamSpecOld[(int)]" +    Type parameter "InferP@InferredContravariantParamSpecOld" is invariant, but "(object)" is not the same as "(int)" (reportAssignmentType) +generics_paramspec_variance.py:151:57 - error: Type "InferredCovariantParamSpecOld[(object)]" is not assignable to declared type "InferredCovariantParamSpecOld[(int)]" +  "InferredCovariantParamSpecOld[(object)]" is not assignable to "InferredCovariantParamSpecOld[(int)]" +    Type parameter "InferP@InferredCovariantParamSpecOld" is invariant, but "(object)" is not the same as "(int)" (reportAssignmentType) +generics_paramspec_variance.py:152:60 - error: Type "InferredCovariantParamSpecOld[(int)]" is not assignable to declared type "InferredCovariantParamSpecOld[(object)]" +  "InferredCovariantParamSpecOld[(int)]" is not assignable to "InferredCovariantParamSpecOld[(object)]" +    Type parameter "InferP@InferredCovariantParamSpecOld" is invariant, but "(int)" is not the same as "(object)" (reportAssignmentType) +""" diff --git a/conformance/results/pyright/generics_scoping.toml b/conformance/results/pyright/generics_scoping.toml index 229fa95ab..9e73f07dd 100644 --- a/conformance/results/pyright/generics_scoping.toml +++ b/conformance/results/pyright/generics_scoping.toml @@ -1,16 +1,20 @@ conformant = "Pass" output = """ -generics_scoping.py:29:10 - error: Argument of type "Literal['a']" cannot be assigned to parameter "x" of type "int" in function "meth_2" -  "Literal['a']" is incompatible with "int" (reportArgumentType) -generics_scoping.py:50:13 - error: Type variable "S" has no meaning in this context (reportGeneralTypeIssues) -generics_scoping.py:54:19 - error: Type variable "S" has no meaning in this context (reportGeneralTypeIssues) -generics_scoping.py:65:29 - error: TypeVar "T" is already in use by an outer scope (reportGeneralTypeIssues) -generics_scoping.py:75:24 - error: TypeVar "T" is already in use by an outer scope (reportGeneralTypeIssues) -generics_scoping.py:78:17 - error: Type variable "T" has no meaning in this context (reportGeneralTypeIssues) -generics_scoping.py:84:5 - error: Generic type alias within class cannot use bound type variables T -generics_scoping.py:88:14 - error: Type variable "T" has no meaning in this context (reportGeneralTypeIssues) -generics_scoping.py:89:19 - error: Type variable "T" has no meaning in this context (reportGeneralTypeIssues) -generics_scoping.py:90:6 - error: Type variable "T" has no meaning in this context (reportGeneralTypeIssues) +generics_scoping.py:16:13 - error: "assert_type" mismatch: expected "Literal[1]" but received "int" (reportAssertTypeFailure) +generics_scoping.py:20:13 - error: "assert_type" mismatch: expected "Literal['a']" but received "str" (reportAssertTypeFailure) +generics_scoping.py:34:10 - error: Argument of type "Literal['a']" cannot be assigned to parameter "x" of type "int" in function "meth_2" +  "Literal['a']" is not assignable to "int" (reportArgumentType) +generics_scoping.py:50:13 - error: "assert_type" mismatch: expected "Literal['abc']" but received "str" (reportAssertTypeFailure) +generics_scoping.py:54:13 - error: "assert_type" mismatch: expected "Literal[b"abc"]" but received "bytes" (reportAssertTypeFailure) +generics_scoping.py:61:13 - error: Type variable "S" has no meaning in this context (reportGeneralTypeIssues) +generics_scoping.py:65:19 - error: Type variable "S" has no meaning in this context (reportGeneralTypeIssues) +generics_scoping.py:76:29 - error: TypeVar "T" is already in use by an outer scope (reportGeneralTypeIssues) +generics_scoping.py:86:24 - error: TypeVar "T" is already in use by an outer scope (reportGeneralTypeIssues) +generics_scoping.py:89:17 - error: Type variable "T" has no meaning in this context (reportGeneralTypeIssues) +generics_scoping.py:98:5 - error: Generic type alias within class cannot use bound type variables T (reportInvalidTypeForm) +generics_scoping.py:105:14 - error: Type variable "T" has no meaning in this context (reportGeneralTypeIssues) +generics_scoping.py:106:19 - error: Type variable "T" has no meaning in this context (reportGeneralTypeIssues) +generics_scoping.py:107:6 - error: Type variable "T" has no meaning in this context (reportGeneralTypeIssues) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/generics_self_attributes.toml b/conformance/results/pyright/generics_self_attributes.toml index 6b439eb2e..b5c9fe45c 100644 --- a/conformance/results/pyright/generics_self_attributes.toml +++ b/conformance/results/pyright/generics_self_attributes.toml @@ -1,16 +1,14 @@ conformant = "Pass" output = """ generics_self_attributes.py:26:38 - error: Argument of type "LinkedList[int]" cannot be assigned to parameter "next" of type "OrdinalLinkedList | None" in function "__init__" -  Type "LinkedList[int]" is incompatible with type "OrdinalLinkedList | None" -    "LinkedList[int]" is incompatible with "OrdinalLinkedList" -    "LinkedList[int]" is incompatible with "None" (reportArgumentType) +  Type "LinkedList[int]" is not assignable to type "OrdinalLinkedList | None" +    "LinkedList[int]" is not assignable to "OrdinalLinkedList" +    "LinkedList[int]" is not assignable to "None" (reportArgumentType) generics_self_attributes.py:32:8 - error: Cannot assign to attribute "next" for class "OrdinalLinkedList"   Expression of type "LinkedList[int]" cannot be assigned to attribute "next" of class "OrdinalLinkedList" -    Attribute "__set__" is unknown -    Attribute "__set__" is unknown -    Type "LinkedList[int]" is incompatible with type "OrdinalLinkedList | None" -      "LinkedList[int]" is incompatible with "OrdinalLinkedList" -      "LinkedList[int]" is incompatible with "None" (reportAttributeAccessIssue) +    Type "LinkedList[int]" is not assignable to type "OrdinalLinkedList | None" +      "LinkedList[int]" is not assignable to "OrdinalLinkedList" +      "LinkedList[int]" is not assignable to "None" (reportAttributeAccessIssue) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/generics_self_basic.toml b/conformance/results/pyright/generics_self_basic.toml index 3fa07521f..6b1dc6c56 100644 --- a/conformance/results/pyright/generics_self_basic.toml +++ b/conformance/results/pyright/generics_self_basic.toml @@ -1,10 +1,10 @@ conformant = "Pass" output = """ -generics_self_basic.py:20:16 - error: Expression of type "Shape" is incompatible with return type "Self@Shape" -  Type "Shape" is incompatible with type "Self@Shape" (reportReturnType) -generics_self_basic.py:33:16 - error: Expression of type "Shape" is incompatible with return type "Self@Shape" -  Type "Shape" is incompatible with type "Self@Shape" (reportReturnType) -generics_self_basic.py:64:31 - error: Expected no type arguments for class "Self" (reportInvalidTypeArguments) +generics_self_basic.py:20:16 - error: Type "Shape" is not assignable to return type "Self@Shape" +  Type "Shape" is not assignable to type "Self@Shape" (reportReturnType) +generics_self_basic.py:33:16 - error: Type "Shape" is not assignable to return type "Self@Shape" +  Type "Shape" is not assignable to type "Self@Shape" (reportReturnType) +generics_self_basic.py:68:31 - error: Expected no type arguments for class "Self" (reportInvalidTypeArguments) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/generics_self_protocols.toml b/conformance/results/pyright/generics_self_protocols.toml index 9f77ef795..aa6455302 100644 --- a/conformance/results/pyright/generics_self_protocols.toml +++ b/conformance/results/pyright/generics_self_protocols.toml @@ -3,15 +3,15 @@ output = """ generics_self_protocols.py:61:19 - error: Argument of type "BadReturnType" cannot be assigned to parameter "shape" of type "ShapeProtocol" in function "accepts_shape"   "BadReturnType" is incompatible with protocol "ShapeProtocol"     "set_scale" is an incompatible type -      Type "(scale: float) -> int" is incompatible with type "(scale: float) -> BadReturnType" +      Type "(scale: float) -> int" is not assignable to type "(scale: float) -> BadReturnType"         Function return type "int" is incompatible with type "BadReturnType" -          "int" is incompatible with "BadReturnType" (reportArgumentType) +          "int" is not assignable to "BadReturnType" (reportArgumentType) generics_self_protocols.py:64:19 - error: Argument of type "ReturnDifferentClass" cannot be assigned to parameter "shape" of type "ShapeProtocol" in function "accepts_shape"   "ReturnDifferentClass" is incompatible with protocol "ShapeProtocol"     "set_scale" is an incompatible type -      Type "(scale: float) -> ReturnConcreteShape" is incompatible with type "(scale: float) -> ReturnDifferentClass" +      Type "(scale: float) -> ReturnConcreteShape" is not assignable to type "(scale: float) -> ReturnDifferentClass"         Function return type "ReturnConcreteShape" is incompatible with type "ReturnDifferentClass" -          "ReturnConcreteShape" is incompatible with "ReturnDifferentClass" (reportArgumentType) +          "ReturnConcreteShape" is not assignable to "ReturnDifferentClass" (reportArgumentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/generics_self_usage.toml b/conformance/results/pyright/generics_self_usage.toml index 5e7184bac..b3b609619 100644 --- a/conformance/results/pyright/generics_self_usage.toml +++ b/conformance/results/pyright/generics_self_usage.toml @@ -6,16 +6,16 @@ generics_self_usage.py:76:6 - error: "Self" is not valid in this context (report generics_self_usage.py:82:44 - warning: TypeVar "TFoo2" appears only once in generic function signature   Use "Foo2" instead (reportInvalidTypeVarUse) generics_self_usage.py:82:54 - error: "Self" cannot be used in a function with a `self` or `cls` parameter that has a type annotation other than "Self" (reportGeneralTypeIssues) -generics_self_usage.py:86:16 - error: Expression of type "Foo3" is incompatible with return type "Self@Foo3" -  Type "Foo3" is incompatible with type "Self@Foo3" (reportReturnType) -generics_self_usage.py:101:15 - error: "Self" is not valid in this context (reportGeneralTypeIssues) -generics_self_usage.py:103:12 - error: "Self" is not valid in this context (reportGeneralTypeIssues) -generics_self_usage.py:106:30 - error: "Self" is not valid in this context (reportGeneralTypeIssues) -generics_self_usage.py:111:19 - error: "Self" is not valid in this context (reportGeneralTypeIssues) -generics_self_usage.py:116:31 - error: "Self" is not valid in this context (reportGeneralTypeIssues) -generics_self_usage.py:116:40 - error: "Self" is not valid in this context (reportGeneralTypeIssues) -generics_self_usage.py:121:37 - error: "Self" cannot be used within a metaclass (a subclass of "type") (reportGeneralTypeIssues) -generics_self_usage.py:125:42 - error: "Self" cannot be used within a metaclass (a subclass of "type") (reportGeneralTypeIssues) +generics_self_usage.py:87:16 - error: Type "Foo3" is not assignable to return type "Self@Foo3" +  Type "Foo3" is not assignable to type "Self@Foo3" (reportReturnType) +generics_self_usage.py:103:15 - error: "Self" is not valid in this context (reportGeneralTypeIssues) +generics_self_usage.py:105:12 - error: "Self" is not valid in this context (reportGeneralTypeIssues) +generics_self_usage.py:108:30 - error: "Self" is not valid in this context (reportGeneralTypeIssues) +generics_self_usage.py:113:19 - error: "Self" is not valid in this context (reportGeneralTypeIssues) +generics_self_usage.py:118:31 - error: "Self" is not valid in this context (reportGeneralTypeIssues) +generics_self_usage.py:118:40 - error: "Self" is not valid in this context (reportGeneralTypeIssues) +generics_self_usage.py:123:37 - error: "Self" cannot be used within a metaclass (a subclass of "type") (reportGeneralTypeIssues) +generics_self_usage.py:127:42 - error: "Self" cannot be used within a metaclass (a subclass of "type") (reportGeneralTypeIssues) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/generics_syntax_declarations.toml b/conformance/results/pyright/generics_syntax_declarations.toml index d11d6b19c..bc076dc93 100644 --- a/conformance/results/pyright/generics_syntax_declarations.toml +++ b/conformance/results/pyright/generics_syntax_declarations.toml @@ -1,16 +1,18 @@ conformant = "Pass" output = """ -generics_syntax_declarations.py:19:17 - error: "Generic" base class cannot be used with type parameter syntax (reportGeneralTypeIssues) -generics_syntax_declarations.py:27:20 - error: Type arguments are not allowed with Protocol class when using type parameter syntax (reportGeneralTypeIssues) -generics_syntax_declarations.py:34:11 - error: Cannot access attribute "is_integer" for class "str*" +generics_syntax_declarations.py:17:17 - error: "Generic" base class cannot be used with type parameter syntax (reportGeneralTypeIssues) +generics_syntax_declarations.py:25:20 - error: Type arguments are not allowed with Protocol class when using type parameter syntax (reportGeneralTypeIssues) +generics_syntax_declarations.py:32:11 - error: Cannot access attribute "is_integer" for class "str*"   Attribute "is_integer" is unknown (reportAttributeAccessIssue) -generics_syntax_declarations.py:46:21 - error: TypeVar constraint type cannot be generic -generics_syntax_declarations.py:50:17 - error: Expected type expression but received "list[Unknown]" (reportGeneralTypeIssues) -generics_syntax_declarations.py:62:17 - error: TypeVar must have at least two constrained types (reportGeneralTypeIssues) -generics_syntax_declarations.py:66:17 - error: TypeVar must have at least two constrained types (reportGeneralTypeIssues) -generics_syntax_declarations.py:73:17 - error: Expected type expression but received "tuple[type[bytes], type[str]]" (reportGeneralTypeIssues) -generics_syntax_declarations.py:77:18 - error: Expected type expression but received "Literal[3]" (reportGeneralTypeIssues) -generics_syntax_declarations.py:81:23 - error: "S" is not defined (reportUndefinedVariable) +generics_syntax_declarations.py:44:21 - error: TypeVar constraint type cannot be generic (reportGeneralTypeIssues) +generics_syntax_declarations.py:48:17 - error: List expression not allowed in type expression +  Use list[T] to indicate a list type or T1 | T2 to indicate a union type (reportInvalidTypeForm) +generics_syntax_declarations.py:48:17 - error: Expected class but received "list[Unknown]" (reportGeneralTypeIssues) +generics_syntax_declarations.py:60:17 - error: TypeVar must have at least two constrained types (reportGeneralTypeIssues) +generics_syntax_declarations.py:64:17 - error: TypeVar must have at least two constrained types (reportGeneralTypeIssues) +generics_syntax_declarations.py:71:17 - error: Variable not allowed in type expression (reportInvalidTypeForm) +generics_syntax_declarations.py:75:18 - error: Expected class but received "Literal[3]" (reportGeneralTypeIssues) +generics_syntax_declarations.py:79:23 - error: "S" is not defined (reportUndefinedVariable) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/generics_syntax_infer_variance.toml b/conformance/results/pyright/generics_syntax_infer_variance.toml index 355c321a4..a871ffee0 100644 --- a/conformance/results/pyright/generics_syntax_infer_variance.toml +++ b/conformance/results/pyright/generics_syntax_infer_variance.toml @@ -1,65 +1,61 @@ conformant = "Pass" output = """ -generics_syntax_infer_variance.py:15:51 - error: TypeVar cannot be both covariant and contravariant -generics_syntax_infer_variance.py:17:55 - error: TypeVar cannot be both covariant and contravariant -generics_syntax_infer_variance.py:29:35 - error: Expression of type "ShouldBeCovariant1[float]" is incompatible with declared type "ShouldBeCovariant1[int]" -  "ShouldBeCovariant1[float]" is incompatible with "ShouldBeCovariant1[int]" +generics_syntax_infer_variance.py:15:51 - error: TypeVar cannot be both covariant and contravariant (reportGeneralTypeIssues) +generics_syntax_infer_variance.py:17:55 - error: TypeVar cannot be both covariant and contravariant (reportGeneralTypeIssues) +generics_syntax_infer_variance.py:29:35 - error: Type "ShouldBeCovariant1[float]" is not assignable to declared type "ShouldBeCovariant1[int]" +  "ShouldBeCovariant1[float]" is not assignable to "ShouldBeCovariant1[int]"     Type parameter "T@ShouldBeCovariant1" is covariant, but "float" is not a subtype of "int" -      "float" is incompatible with "int" (reportAssignmentType) -generics_syntax_infer_variance.py:37:35 - error: Expression of type "ShouldBeCovariant2[float]" is incompatible with declared type "ShouldBeCovariant2[int]" -  "ShouldBeCovariant2[float]" is incompatible with "ShouldBeCovariant2[int]" +      "float" is not assignable to "int" (reportAssignmentType) +generics_syntax_infer_variance.py:47:35 - error: Type "ShouldBeCovariant2[float]" is not assignable to declared type "ShouldBeCovariant2[int]" +  "ShouldBeCovariant2[float]" is not assignable to "ShouldBeCovariant2[int]"     Type parameter "T@ShouldBeCovariant2" is covariant, but "float" is not a subtype of "int" -      "float" is incompatible with "int" (reportAssignmentType) -generics_syntax_infer_variance.py:46:35 - error: Expression of type "ShouldBeCovariant3[float]" is incompatible with declared type "ShouldBeCovariant3[int]" -  "ShouldBeCovariant3[float]" is incompatible with "ShouldBeCovariant3[int]" +      "float" is not assignable to "int" (reportAssignmentType) +generics_syntax_infer_variance.py:56:35 - error: Type "ShouldBeCovariant3[float]" is not assignable to declared type "ShouldBeCovariant3[int]" +  "ShouldBeCovariant3[float]" is not assignable to "ShouldBeCovariant3[int]"     Type parameter "T@ShouldBeCovariant3" is covariant, but "float" is not a subtype of "int" -      "float" is incompatible with "int" (reportAssignmentType) -generics_syntax_infer_variance.py:55:34 - error: Expression of type "ShouldBeCovariant4[float]" is incompatible with declared type "ShouldBeCovariant4[int]" -  "ShouldBeCovariant4[float]" is incompatible with "ShouldBeCovariant4[int]" -    Type parameter "T@ShouldBeCovariant4" is covariant, but "float" is not a subtype of "int" -      "float" is incompatible with "int" (reportAssignmentType) -generics_syntax_infer_variance.py:68:34 - error: Expression of type "ShouldBeCovariant5[float]" is incompatible with declared type "ShouldBeCovariant5[int]" -  "ShouldBeCovariant5[float]" is incompatible with "ShouldBeCovariant5[int]" +      "float" is not assignable to "int" (reportAssignmentType) +generics_syntax_infer_variance.py:85:34 - error: Type "ShouldBeCovariant5[float]" is not assignable to declared type "ShouldBeCovariant5[int]" +  "ShouldBeCovariant5[float]" is not assignable to "ShouldBeCovariant5[int]"     Type parameter "T@ShouldBeCovariant5" is covariant, but "float" is not a subtype of "int" -      "float" is incompatible with "int" (reportAssignmentType) -generics_syntax_infer_variance.py:79:34 - error: Expression of type "ShouldBeCovariant6[float]" is incompatible with declared type "ShouldBeCovariant6[int]" -  "ShouldBeCovariant6[float]" is incompatible with "ShouldBeCovariant6[int]" +      "float" is not assignable to "int" (reportAssignmentType) +generics_syntax_infer_variance.py:96:34 - error: Type "ShouldBeCovariant6[float]" is not assignable to declared type "ShouldBeCovariant6[int]" +  "ShouldBeCovariant6[float]" is not assignable to "ShouldBeCovariant6[int]"     Type parameter "T@ShouldBeCovariant6" is covariant, but "float" is not a subtype of "int" -      "float" is incompatible with "int" (reportAssignmentType) -generics_syntax_infer_variance.py:95:38 - error: Expression of type "ShouldBeInvariant1[int]" is incompatible with declared type "ShouldBeInvariant1[float]" -  "ShouldBeInvariant1[int]" is incompatible with "ShouldBeInvariant1[float]" +      "float" is not assignable to "int" (reportAssignmentType) +generics_syntax_infer_variance.py:112:38 - error: Type "ShouldBeInvariant1[int]" is not assignable to declared type "ShouldBeInvariant1[float]" +  "ShouldBeInvariant1[int]" is not assignable to "ShouldBeInvariant1[float]"     Type parameter "T@ShouldBeInvariant1" is invariant, but "int" is not the same as "float" (reportAssignmentType) -generics_syntax_infer_variance.py:96:36 - error: Expression of type "ShouldBeInvariant1[float]" is incompatible with declared type "ShouldBeInvariant1[int]" -  "ShouldBeInvariant1[float]" is incompatible with "ShouldBeInvariant1[int]" +generics_syntax_infer_variance.py:113:36 - error: Type "ShouldBeInvariant1[float]" is not assignable to declared type "ShouldBeInvariant1[int]" +  "ShouldBeInvariant1[float]" is not assignable to "ShouldBeInvariant1[int]"     Type parameter "T@ShouldBeInvariant1" is invariant, but "float" is not the same as "int" (reportAssignmentType) -generics_syntax_infer_variance.py:110:38 - error: Expression of type "ShouldBeInvariant2[int]" is incompatible with declared type "ShouldBeInvariant2[float]" -  "ShouldBeInvariant2[int]" is incompatible with "ShouldBeInvariant2[float]" +generics_syntax_infer_variance.py:127:38 - error: Type "ShouldBeInvariant2[int]" is not assignable to declared type "ShouldBeInvariant2[float]" +  "ShouldBeInvariant2[int]" is not assignable to "ShouldBeInvariant2[float]"     Type parameter "T@ShouldBeInvariant2" is invariant, but "int" is not the same as "float" (reportAssignmentType) -generics_syntax_infer_variance.py:111:36 - error: Expression of type "ShouldBeInvariant2[float]" is incompatible with declared type "ShouldBeInvariant2[int]" -  "ShouldBeInvariant2[float]" is incompatible with "ShouldBeInvariant2[int]" +generics_syntax_infer_variance.py:128:36 - error: Type "ShouldBeInvariant2[float]" is not assignable to declared type "ShouldBeInvariant2[int]" +  "ShouldBeInvariant2[float]" is not assignable to "ShouldBeInvariant2[int]"     Type parameter "T@ShouldBeInvariant2" is invariant, but "float" is not the same as "int" (reportAssignmentType) -generics_syntax_infer_variance.py:118:43 - error: Expression of type "ShouldBeInvariant3[int, str]" is incompatible with declared type "ShouldBeInvariant3[float, str]" -  "ShouldBeInvariant3[int, str]" is incompatible with "ShouldBeInvariant3[float, str]" +generics_syntax_infer_variance.py:135:43 - error: Type "ShouldBeInvariant3[int, str]" is not assignable to declared type "ShouldBeInvariant3[float, str]" +  "ShouldBeInvariant3[int, str]" is not assignable to "ShouldBeInvariant3[float, str]"     Type parameter "K@ShouldBeInvariant3" is invariant, but "int" is not the same as "float" (reportAssignmentType) -generics_syntax_infer_variance.py:119:41 - error: Expression of type "ShouldBeInvariant3[float, str]" is incompatible with declared type "ShouldBeInvariant3[int, str]" -  "ShouldBeInvariant3[float, str]" is incompatible with "ShouldBeInvariant3[int, str]" +generics_syntax_infer_variance.py:136:41 - error: Type "ShouldBeInvariant3[float, str]" is not assignable to declared type "ShouldBeInvariant3[int, str]" +  "ShouldBeInvariant3[float, str]" is not assignable to "ShouldBeInvariant3[int, str]"     Type parameter "K@ShouldBeInvariant3" is invariant, but "float" is not the same as "int" (reportAssignmentType) -generics_syntax_infer_variance.py:120:43 - error: Expression of type "ShouldBeInvariant3[str, int]" is incompatible with declared type "ShouldBeInvariant3[str, float]" -  "ShouldBeInvariant3[str, int]" is incompatible with "ShouldBeInvariant3[str, float]" +generics_syntax_infer_variance.py:137:43 - error: Type "ShouldBeInvariant3[str, int]" is not assignable to declared type "ShouldBeInvariant3[str, float]" +  "ShouldBeInvariant3[str, int]" is not assignable to "ShouldBeInvariant3[str, float]"     Type parameter "V@ShouldBeInvariant3" is invariant, but "int" is not the same as "float" (reportAssignmentType) -generics_syntax_infer_variance.py:121:41 - error: Expression of type "ShouldBeInvariant3[str, float]" is incompatible with declared type "ShouldBeInvariant3[str, int]" -  "ShouldBeInvariant3[str, float]" is incompatible with "ShouldBeInvariant3[str, int]" +generics_syntax_infer_variance.py:138:41 - error: Type "ShouldBeInvariant3[str, float]" is not assignable to declared type "ShouldBeInvariant3[str, int]" +  "ShouldBeInvariant3[str, float]" is not assignable to "ShouldBeInvariant3[str, int]"     Type parameter "V@ShouldBeInvariant3" is invariant, but "float" is not the same as "int" (reportAssignmentType) -generics_syntax_infer_variance.py:129:38 - error: Expression of type "ShouldBeInvariant4[int]" is incompatible with declared type "ShouldBeInvariant4[float]" -  "ShouldBeInvariant4[int]" is incompatible with "ShouldBeInvariant4[float]" +generics_syntax_infer_variance.py:146:38 - error: Type "ShouldBeInvariant4[int]" is not assignable to declared type "ShouldBeInvariant4[float]" +  "ShouldBeInvariant4[int]" is not assignable to "ShouldBeInvariant4[float]"     Type parameter "T@ShouldBeInvariant4" is invariant, but "int" is not the same as "float" (reportAssignmentType) -generics_syntax_infer_variance.py:137:38 - error: Expression of type "ShouldBeInvariant5[int]" is incompatible with declared type "ShouldBeInvariant5[float]" -  "ShouldBeInvariant5[int]" is incompatible with "ShouldBeInvariant5[float]" +generics_syntax_infer_variance.py:154:38 - error: Type "ShouldBeInvariant5[int]" is not assignable to declared type "ShouldBeInvariant5[float]" +  "ShouldBeInvariant5[int]" is not assignable to "ShouldBeInvariant5[float]"     Type parameter "T@ShouldBeInvariant5" is invariant, but "int" is not the same as "float" (reportAssignmentType) -generics_syntax_infer_variance.py:148:45 - error: Expression of type "ShouldBeContravariant1[int]" is incompatible with declared type "ShouldBeContravariant1[float]" -  "ShouldBeContravariant1[int]" is incompatible with "ShouldBeContravariant1[float]" +generics_syntax_infer_variance.py:165:45 - error: Type "ShouldBeContravariant1[int]" is not assignable to declared type "ShouldBeContravariant1[float]" +  "ShouldBeContravariant1[int]" is not assignable to "ShouldBeContravariant1[float]"     Type parameter "T@ShouldBeContravariant1" is contravariant, but "int" is not a supertype of "float" -      "float" is incompatible with "int" (reportAssignmentType) +      "float" is not assignable to "int" (reportAssignmentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/generics_syntax_scoping.toml b/conformance/results/pyright/generics_syntax_scoping.toml index 1124df499..5cc46a887 100644 --- a/conformance/results/pyright/generics_syntax_scoping.toml +++ b/conformance/results/pyright/generics_syntax_scoping.toml @@ -1,13 +1,13 @@ conformant = "Pass" output = """ -generics_syntax_scoping.py:14:20 - error: TypeVar constraint type cannot be generic -generics_syntax_scoping.py:18:17 - error: TypeVar constraint type cannot be generic -generics_syntax_scoping.py:35:7 - error: "T" is not defined (reportUndefinedVariable) -generics_syntax_scoping.py:44:17 - error: "T" is not defined (reportUndefinedVariable) -generics_syntax_scoping.py:92:17 - error: TypeVar "T" is already in use by an outer scope (reportGeneralTypeIssues) -generics_syntax_scoping.py:95:17 - error: TypeVar "T" is already in use by an outer scope (reportGeneralTypeIssues) -generics_syntax_scoping.py:98:17 - error: TypeVar "T" is already in use by an outer scope (reportGeneralTypeIssues) -generics_syntax_scoping.py:98:29 - warning: TypeVar "T" appears only once in generic function signature +generics_syntax_scoping.py:14:20 - error: TypeVar constraint type cannot be generic (reportGeneralTypeIssues) +generics_syntax_scoping.py:18:17 - error: TypeVar constraint type cannot be generic (reportGeneralTypeIssues) +generics_syntax_scoping.py:26:7 - error: "T" is not defined (reportUndefinedVariable) +generics_syntax_scoping.py:35:17 - error: "T" is not defined (reportUndefinedVariable) +generics_syntax_scoping.py:83:17 - error: TypeVar "T" is already in use by an outer scope (reportGeneralTypeIssues) +generics_syntax_scoping.py:86:17 - error: TypeVar "T" is already in use by an outer scope (reportGeneralTypeIssues) +generics_syntax_scoping.py:89:17 - error: TypeVar "T" is already in use by an outer scope (reportGeneralTypeIssues) +generics_syntax_scoping.py:89:29 - warning: TypeVar "T" appears only once in generic function signature   Use "object" instead (reportInvalidTypeVarUse) """ conformance_automated = "Pass" diff --git a/conformance/results/pyright/generics_type_erasure.toml b/conformance/results/pyright/generics_type_erasure.toml index 35398f2c1..cbbc0d1c6 100644 --- a/conformance/results/pyright/generics_type_erasure.toml +++ b/conformance/results/pyright/generics_type_erasure.toml @@ -1,18 +1,18 @@ conformant = "Pass" output = """ -generics_type_erasure.py:36:16 - error: Argument of type "Literal['']" cannot be assigned to parameter "label" of type "int | None" in function "__init__" -  Type "Literal['']" is incompatible with type "int | None" -    "Literal['']" is incompatible with "int" -    "Literal['']" is incompatible with "None" (reportArgumentType) -generics_type_erasure.py:38:16 - error: Argument of type "Literal[0]" cannot be assigned to parameter "label" of type "str | None" in function "__init__" -  Type "Literal[0]" is incompatible with type "str | None" -    "Literal[0]" is incompatible with "str" -    "Literal[0]" is incompatible with "None" (reportArgumentType) -generics_type_erasure.py:40:11 - error: Access to generic instance variable through class is ambiguous (reportGeneralTypeIssues) -generics_type_erasure.py:41:11 - error: Access to generic instance variable through class is ambiguous (reportGeneralTypeIssues) -generics_type_erasure.py:42:6 - error: Access to generic instance variable through class is ambiguous (reportGeneralTypeIssues) -generics_type_erasure.py:43:6 - error: Access to generic instance variable through class is ambiguous (reportGeneralTypeIssues) -generics_type_erasure.py:44:10 - error: Access to generic instance variable through class is ambiguous (reportGeneralTypeIssues) +generics_type_erasure.py:38:16 - error: Argument of type "Literal['']" cannot be assigned to parameter "label" of type "int | None" in function "__init__" +  Type "Literal['']" is not assignable to type "int | None" +    "Literal['']" is not assignable to "int" +    "Literal['']" is not assignable to "None" (reportArgumentType) +generics_type_erasure.py:40:16 - error: Argument of type "Literal[0]" cannot be assigned to parameter "label" of type "str | None" in function "__init__" +  Type "Literal[0]" is not assignable to type "str | None" +    "Literal[0]" is not assignable to "str" +    "Literal[0]" is not assignable to "None" (reportArgumentType) +generics_type_erasure.py:42:11 - error: Access to generic instance variable through class is ambiguous (reportGeneralTypeIssues) +generics_type_erasure.py:43:11 - error: Access to generic instance variable through class is ambiguous (reportGeneralTypeIssues) +generics_type_erasure.py:44:6 - error: Access to generic instance variable through class is ambiguous (reportGeneralTypeIssues) +generics_type_erasure.py:45:6 - error: Access to generic instance variable through class is ambiguous (reportGeneralTypeIssues) +generics_type_erasure.py:46:10 - error: Access to generic instance variable through class is ambiguous (reportGeneralTypeIssues) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/generics_typevartuple_args.toml b/conformance/results/pyright/generics_typevartuple_args.toml index 6e0ee4b27..10459bf1c 100644 --- a/conformance/results/pyright/generics_typevartuple_args.toml +++ b/conformance/results/pyright/generics_typevartuple_args.toml @@ -1,22 +1,19 @@ -conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" output = """ -generics_typevartuple_args.py:33:16 - error: Argument of type "Literal['']" cannot be assigned to parameter of type "Env" in function "exec_le" -  "Literal['']" is incompatible with "Env" (reportArgumentType) -generics_typevartuple_args.py:34:16 - error: Argument of type "Literal['']" cannot be assigned to parameter of type "Env" in function "exec_le" -  "Literal['']" is incompatible with "Env" (reportArgumentType) +generics_typevartuple_args.py:33:20 - error: Argument of type "Literal['']" cannot be assigned to parameter of type "Env" in function "exec_le" +  "Literal['']" is not assignable to "Env" (reportArgumentType) +generics_typevartuple_args.py:34:20 - error: Argument of type "Literal['']" cannot be assigned to parameter of type "Env" in function "exec_le" +  "Literal['']" is not assignable to "Env" (reportArgumentType) generics_typevartuple_args.py:48:10 - error: Argument of type "Literal['2']" cannot be assigned to parameter of type "int" in function "func1" -  "Literal['2']" is incompatible with "int" (reportArgumentType) +  "Literal['2']" is not assignable to "int" (reportArgumentType) generics_typevartuple_args.py:57:10 - error: Argument of type "Literal[1]" cannot be assigned to parameter of type "str" in function "func2" -  "Literal[1]" is incompatible with "str" (reportArgumentType) +  "Literal[1]" is not assignable to "str" (reportArgumentType) generics_typevartuple_args.py:58:1 - error: Argument missing for parameter "args[2]" (reportCallIssue) generics_typevartuple_args.py:59:1 - error: Argument missing for parameter "args[2]" (reportCallIssue) generics_typevartuple_args.py:67:1 - error: Argument missing for parameter "args[1]" (reportCallIssue) generics_typevartuple_args.py:75:13 - error: Argument of type "tuple[Literal[1], Literal[2]]" cannot be assigned to parameter "args" of type "tuple[*Ts@func4]" in function "func4" -  "tuple[Literal[1], Literal[2]]" is incompatible with "tuple[int]" +  "tuple[Literal[1], Literal[2]]" is not assignable to "tuple[int]"     Tuple size mismatch; expected 1 but received 2 (reportArgumentType) -generics_typevartuple_args.py:76:14 - error: Argument of type "tuple[Literal['1']]" cannot be assigned to parameter "args" of type "tuple[*Ts@func4]" in function "func4" -  "Literal['1']" is incompatible with "int" (reportArgumentType) -""" -conformance_automated = "Pass" -errors_diff = """ """ diff --git a/conformance/results/pyright/generics_typevartuple_basic.toml b/conformance/results/pyright/generics_typevartuple_basic.toml index af03b67e2..70edf3f24 100644 --- a/conformance/results/pyright/generics_typevartuple_basic.toml +++ b/conformance/results/pyright/generics_typevartuple_basic.toml @@ -1,35 +1,32 @@ -conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" output = """ -generics_typevartuple_basic.py:42:34 - error: Argument of type "Height" cannot be assigned to parameter "shape" of type "tuple[*Shape@Array]" in function "__init__" -  "Height" is incompatible with "tuple[*Shape@Array]" (reportArgumentType) -generics_typevartuple_basic.py:43:35 - error: Expression of type "Array[Batch, Width]" is incompatible with declared type "Array[Batch, Height, Width]" -  "Array[Batch, Width]" is incompatible with "Array[Batch, Height, Width]" +generics_typevartuple_basic.py:43:34 - error: Argument of type "Height" cannot be assigned to parameter "shape" of type "tuple[*Shape@Array]" in function "__init__" +  "Height" is not assignable to "tuple[*Shape@Array]" (reportArgumentType) +generics_typevartuple_basic.py:44:35 - error: Type "Array[Batch, Width]" is not assignable to declared type "Array[Batch, Height, Width]" +  "Array[Batch, Width]" is not assignable to "Array[Batch, Height, Width]"     Type parameter "Shape@Array" is invariant, but "*tuple[Batch, Width]" is not the same as "*tuple[Batch, Height, Width]" (reportAssignmentType) -generics_typevartuple_basic.py:44:41 - error: Expression of type "Array[Time, Batch, Width, Height]" is incompatible with declared type "Array[Time, Batch, Height, Width]" -  "Array[Time, Batch, Width, Height]" is incompatible with "Array[Time, Batch, Height, Width]" +generics_typevartuple_basic.py:45:41 - error: Type "Array[Time, Batch, Width, Height]" is not assignable to declared type "Array[Time, Batch, Height, Width]" +  "Array[Time, Batch, Width, Height]" is not assignable to "Array[Time, Batch, Height, Width]"     Type parameter "Shape@Array" is invariant, but "*tuple[Time, Batch, Width, Height]" is not the same as "*tuple[Time, Batch, Height, Width]" (reportAssignmentType) -generics_typevartuple_basic.py:52:22 - error: Expected unpacked TypeVarTuple; use Unpack[Shape] or *Shape -generics_typevartuple_basic.py:53:37 - error: Expected unpacked TypeVarTuple; use Unpack[Shape] or *Shape -generics_typevartuple_basic.py:56:34 - error: Expected unpacked TypeVarTuple; use Unpack[Shape] or *Shape -generics_typevartuple_basic.py:59:24 - error: Expected unpacked TypeVarTuple; use Unpack[Shape] or *Shape -generics_typevartuple_basic.py:65:27 - error: "covariant" is unknown parameter to TypeVarTuple -generics_typevartuple_basic.py:66:27 - error: TypeVarTuple cannot have value constraints -generics_typevartuple_basic.py:66:32 - error: TypeVarTuple cannot have value constraints -generics_typevartuple_basic.py:67:27 - error: "bound" is unknown parameter to TypeVarTuple -generics_typevartuple_basic.py:89:14 - error: Argument of type "tuple[Literal['0']]" cannot be assigned to parameter "arg2" of type "tuple[*Ts@func2]" in function "func2" -  "Literal['0']" is incompatible with "int" (reportArgumentType) -generics_typevartuple_basic.py:90:15 - error: Argument of type "tuple[Literal[0]]" cannot be assigned to parameter "arg2" of type "tuple[*Ts@func2]" in function "func2" -  "tuple[Literal[0]]" is incompatible with "tuple[int, int]" +generics_typevartuple_basic.py:53:22 - error: Expected unpacked TypeVarTuple; use Unpack[Shape] or *Shape (reportInvalidTypeForm) +generics_typevartuple_basic.py:54:37 - error: Expected unpacked TypeVarTuple; use Unpack[Shape] or *Shape (reportInvalidTypeForm) +generics_typevartuple_basic.py:57:34 - error: Expected unpacked TypeVarTuple; use Unpack[Shape] or *Shape (reportInvalidTypeForm) +generics_typevartuple_basic.py:60:24 - error: Expected unpacked TypeVarTuple; use Unpack[Shape] or *Shape (reportInvalidTypeForm) +generics_typevartuple_basic.py:66:27 - error: TypeVarTuple cannot have value constraints (reportGeneralTypeIssues) +generics_typevartuple_basic.py:66:32 - error: TypeVarTuple cannot have value constraints (reportGeneralTypeIssues) +generics_typevartuple_basic.py:67:27 - error: "bound" is unknown parameter to TypeVarTuple (reportGeneralTypeIssues) +generics_typevartuple_basic.py:91:15 - error: Argument of type "tuple[Literal[0]]" cannot be assigned to parameter "arg2" of type "tuple[*Ts@func2]" in function "func2" +  "tuple[Literal[0]]" is not assignable to "tuple[int, int]"     Tuple size mismatch; expected 2 but received 1 (reportArgumentType) -generics_typevartuple_basic.py:99:17 - error: Argument of type "Array[Width]" cannot be assigned to parameter "y" of type "Array[*Shape@multiply]" in function "multiply" -  "Array[Width]" is incompatible with "Array[Height]" +generics_typevartuple_basic.py:100:17 - error: Argument of type "Array[Width]" cannot be assigned to parameter "y" of type "Array[*Shape@multiply]" in function "multiply" +  "Array[Width]" is not assignable to "Array[Height]"     Type parameter "Shape@Array" is invariant, but "*tuple[Width]" is not the same as "*tuple[Height]" (reportArgumentType) -generics_typevartuple_basic.py:100:17 - error: Argument of type "Array[Height, Width]" cannot be assigned to parameter "y" of type "Array[*Shape@multiply]" in function "multiply" -  "Array[Height, Width]" is incompatible with "Array[Height]" +generics_typevartuple_basic.py:101:17 - error: Argument of type "Array[Height, Width]" cannot be assigned to parameter "y" of type "Array[*Shape@multiply]" in function "multiply" +  "Array[Height, Width]" is not assignable to "Array[Height]"     Type parameter "Shape@Array" is invariant, but "*tuple[Height, Width]" is not the same as "*tuple[Height]" (reportArgumentType) -generics_typevartuple_basic.py:106:14 - error: Generic class can have at most one TypeVarTuple type parameter but received multiple ("Ts1", "Ts2") (reportGeneralTypeIssues) -generics_typevartuple_basic.py:106:29 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple -""" -conformance_automated = "Pass" -errors_diff = """ +generics_typevartuple_basic.py:107:14 - error: Generic class can have at most one TypeVarTuple type parameter but received multiple ("Ts", "Ts1") (reportGeneralTypeIssues) +generics_typevartuple_basic.py:107:28 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple (reportInvalidTypeForm) +generics_typevartuple_basic.py:111:7 - error: Generic class can have at most one TypeVarTuple type parameter but received multiple ("Ts1", "Ts2") (reportGeneralTypeIssues) """ diff --git a/conformance/results/pyright/generics_typevartuple_callable.toml b/conformance/results/pyright/generics_typevartuple_callable.toml index 7c22ef0e8..fb569c88c 100644 --- a/conformance/results/pyright/generics_typevartuple_callable.toml +++ b/conformance/results/pyright/generics_typevartuple_callable.toml @@ -1,8 +1,8 @@ conformant = "Pass" output = """ generics_typevartuple_callable.py:26:28 - error: Argument of type "tuple[Literal[''], Literal[0]]" cannot be assigned to parameter "args" of type "tuple[*Ts@__init__]" in function "__init__" -  "Literal['']" is incompatible with "int" -  "Literal[0]" is incompatible with "str" (reportArgumentType) +  "Literal['']" is not assignable to "int" +  "Literal[0]" is not assignable to "str" (reportArgumentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/generics_typevartuple_specialization.toml b/conformance/results/pyright/generics_typevartuple_specialization.toml index bf87f1f32..24066fc5d 100644 --- a/conformance/results/pyright/generics_typevartuple_specialization.toml +++ b/conformance/results/pyright/generics_typevartuple_specialization.toml @@ -2,14 +2,14 @@ conformant = "Pass" output = """ generics_typevartuple_specialization.py:109:18 - error: Type variable "Ts" has no meaning in this context (reportGeneralTypeIssues) generics_typevartuple_specialization.py:109:18 - error: Could not specialize type "IntTupleGeneric[T@IntTupleGeneric]" -  Unpacked arguments cannot be used in this context +  Unpacked arguments cannot be used in this context (reportInvalidTypeForm) generics_typevartuple_specialization.py:110:18 - error: Could not specialize type "IntTupleGeneric[T@IntTupleGeneric]" -  Unpacked arguments cannot be used in this context -generics_typevartuple_specialization.py:121:27 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple -generics_typevartuple_specialization.py:122:27 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple -generics_typevartuple_specialization.py:127:9 - error: Too few type arguments provided for "TA7[*Ts@TA7, T1@TA7, T2@TA7]"; expected 3 but received 2 +  Unpacked arguments cannot be used in this context (reportInvalidTypeForm) +generics_typevartuple_specialization.py:121:27 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple (reportInvalidTypeForm) +generics_typevartuple_specialization.py:122:27 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple (reportInvalidTypeForm) +generics_typevartuple_specialization.py:127:9 - error: Too few type arguments provided for "TA7[*Ts@TA7, T1@TA7, T2@TA7]"; expected 3 but received 2 (reportInvalidTypeForm) generics_typevartuple_specialization.py:163:14 - error: Could not specialize type "TA11[T@TA11, *Ts1@TA11]" -  Unpacked arguments cannot be used in this context +  Unpacked arguments cannot be used in this context (reportInvalidTypeForm) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/generics_typevartuple_unpack.toml b/conformance/results/pyright/generics_typevartuple_unpack.toml index 22576b797..a6484a5a2 100644 --- a/conformance/results/pyright/generics_typevartuple_unpack.toml +++ b/conformance/results/pyright/generics_typevartuple_unpack.toml @@ -1,7 +1,7 @@ conformant = "Pass" output = """ generics_typevartuple_unpack.py:30:28 - error: Argument of type "Array[Batch]" cannot be assigned to parameter "x" of type "Array[Batch, *tuple[Any, ...], Channels]" in function "process_batch_channels" -  "Array[Batch]" is incompatible with "Array[Batch, *tuple[Any, ...], Channels]" +  "Array[Batch]" is not assignable to "Array[Batch, *tuple[Any, ...], Channels]"     Type parameter "Ts@Array" is invariant, but "*tuple[Batch]" is not the same as "*tuple[Batch, *tuple[Any, ...], Channels]" (reportArgumentType) """ conformance_automated = "Pass" diff --git a/conformance/results/pyright/generics_typevartuple_variance.toml b/conformance/results/pyright/generics_typevartuple_variance.toml new file mode 100644 index 000000000..3bfb0f7c7 --- /dev/null +++ b/conformance/results/pyright/generics_typevartuple_variance.toml @@ -0,0 +1,119 @@ +conformant = "Unsupported" +conformance_automated = "Fail" +errors_diff = """ +Line 21: Expected 1 errors +Line 34: Expected 1 errors +Line 79: Expected 1 errors +Line 90: Expected 1 errors +Line 29: Unexpected errors ['generics_typevartuple_variance.py:29:42 - error: Type "ContravariantTypeVarTuple[object]" is not assignable to declared type "ContravariantTypeVarTuple[int]"'] +Line 30: Unexpected errors ['generics_typevartuple_variance.py:30:64 - error: Type "ContravariantTypeVarTuple[*tuple[object, ...]]" is not assignable to declared type "ContravariantTypeVarTuple[*tuple[int, ...]]"'] +Line 33: Unexpected errors ['generics_typevartuple_variance.py:33:58 - error: Type "ContravariantTypeVarTuple[*tuple[int, ...]]" is not assignable to declared type "ContravariantTypeVarTuple[int]"'] +Line 43: Unexpected errors ['generics_typevartuple_variance.py:43:42 - error: Type "CovariantTypeVarTuple[int]" is not assignable to declared type "CovariantTypeVarTuple[object]"'] +Line 44: Unexpected errors ['generics_typevartuple_variance.py:44:50 - error: Type "CovariantTypeVarTuple[bool, bool]" is not assignable to declared type "CovariantTypeVarTuple[int, int]"'] +Line 49: Unexpected errors ['generics_typevartuple_variance.py:49:67 - error: Type "CovariantTypeVarTuple[*tuple[int, ...]]" is not assignable to declared type "CovariantTypeVarTuple[*tuple[object, ...]]"'] +Line 55: Unexpected errors ['generics_typevartuple_variance.py:55:35 - error: "infer_variance" is unknown parameter to TypeVarTuple (reportGeneralTypeIssues)'] +Line 73: Unexpected errors ['generics_typevartuple_variance.py:73:29 - error: "contravariant" is unknown parameter to TypeVarTuple (reportGeneralTypeIssues)'] +Line 84: Unexpected errors ['generics_typevartuple_variance.py:84:49 - error: Type "ContravariantTypeVarTupleOld[object]" is not assignable to declared type "ContravariantTypeVarTupleOld[int]"'] +Line 87: Unexpected errors ['generics_typevartuple_variance.py:87:31 - error: "covariant" is unknown parameter to TypeVarTuple (reportGeneralTypeIssues)'] +Line 98: Unexpected errors ['generics_typevartuple_variance.py:98:49 - error: Type "CovariantTypeVarTupleOld[int]" is not assignable to declared type "CovariantTypeVarTupleOld[object]"'] +Line 108: Unexpected errors ['generics_typevartuple_variance.py:108:63 - error: Type "InferredContravariantTypeVarTupleOld[object]" is not assignable to declared type "InferredContravariantTypeVarTupleOld[int]"'] +Line 117: Unexpected errors ['generics_typevartuple_variance.py:117:63 - error: Type "InferredCovariantTypeVarTupleOld[int]" is not assignable to declared type "InferredCovariantTypeVarTupleOld[object]"'] +""" +output = """ +generics_typevartuple_variance.py:14:45 - error: Type "InvariantTypeVarTuple[int]" is not assignable to declared type "InvariantTypeVarTuple[object]" +  "InvariantTypeVarTuple[int]" is not assignable to "InvariantTypeVarTuple[object]" +    Type parameter "InOutTs@InvariantTypeVarTuple" is invariant, but "*tuple[int]" is not the same as "*tuple[object]" (reportAssignmentType) +generics_typevartuple_variance.py:15:42 - error: Type "InvariantTypeVarTuple[object]" is not assignable to declared type "InvariantTypeVarTuple[int]" +  "InvariantTypeVarTuple[object]" is not assignable to "InvariantTypeVarTuple[int]" +    Type parameter "InOutTs@InvariantTypeVarTuple" is invariant, but "*tuple[object]" is not the same as "*tuple[int]" (reportAssignmentType) +generics_typevartuple_variance.py:17:64 - error: Type "InvariantTypeVarTuple[*tuple[object, ...]]" is not assignable to declared type "InvariantTypeVarTuple[*tuple[int, ...]]" +  "InvariantTypeVarTuple[*tuple[object, ...]]" is not assignable to "InvariantTypeVarTuple[*tuple[int, ...]]" +    Type parameter "InOutTs@InvariantTypeVarTuple" is invariant, but "*tuple[object, ...]" is not the same as "*tuple[int, ...]" (reportAssignmentType) +generics_typevartuple_variance.py:18:70 - error: Type "InvariantTypeVarTuple[*tuple[int, ...]]" is not assignable to declared type "InvariantTypeVarTuple[*tuple[object, ...]]" +  "InvariantTypeVarTuple[*tuple[int, ...]]" is not assignable to "InvariantTypeVarTuple[*tuple[object, ...]]" +    Type parameter "InOutTs@InvariantTypeVarTuple" is invariant, but "*tuple[int, ...]" is not the same as "*tuple[object, ...]" (reportAssignmentType) +generics_typevartuple_variance.py:20:58 - error: Type "InvariantTypeVarTuple[*tuple[int, ...]]" is not assignable to declared type "InvariantTypeVarTuple[int]" +  "InvariantTypeVarTuple[*tuple[int, ...]]" is not assignable to "InvariantTypeVarTuple[int]" +    Type parameter "InOutTs@InvariantTypeVarTuple" is invariant, but "*tuple[int, ...]" is not the same as "*tuple[int]" (reportAssignmentType) +generics_typevartuple_variance.py:28:53 - error: Type "ContravariantTypeVarTuple[object, int]" is not assignable to declared type "ContravariantTypeVarTuple[object, object]" +  "ContravariantTypeVarTuple[object, int]" is not assignable to "ContravariantTypeVarTuple[object, object]" +    Type parameter "InTs@ContravariantTypeVarTuple" is invariant, but "*tuple[object, int]" is not the same as "*tuple[object, object]" (reportAssignmentType) +generics_typevartuple_variance.py:29:42 - error: Type "ContravariantTypeVarTuple[object]" is not assignable to declared type "ContravariantTypeVarTuple[int]" +  "ContravariantTypeVarTuple[object]" is not assignable to "ContravariantTypeVarTuple[int]" +    Type parameter "InTs@ContravariantTypeVarTuple" is invariant, but "*tuple[object]" is not the same as "*tuple[int]" (reportAssignmentType) +generics_typevartuple_variance.py:30:64 - error: Type "ContravariantTypeVarTuple[*tuple[object, ...]]" is not assignable to declared type "ContravariantTypeVarTuple[*tuple[int, ...]]" +  "ContravariantTypeVarTuple[*tuple[object, ...]]" is not assignable to "ContravariantTypeVarTuple[*tuple[int, ...]]" +    Type parameter "InTs@ContravariantTypeVarTuple" is invariant, but "*tuple[object, ...]" is not the same as "*tuple[int, ...]" (reportAssignmentType) +generics_typevartuple_variance.py:31:70 - error: Type "ContravariantTypeVarTuple[*tuple[int, ...]]" is not assignable to declared type "ContravariantTypeVarTuple[*tuple[object, ...]]" +  "ContravariantTypeVarTuple[*tuple[int, ...]]" is not assignable to "ContravariantTypeVarTuple[*tuple[object, ...]]" +    Type parameter "InTs@ContravariantTypeVarTuple" is invariant, but "*tuple[int, ...]" is not the same as "*tuple[object, ...]" (reportAssignmentType) +generics_typevartuple_variance.py:33:58 - error: Type "ContravariantTypeVarTuple[*tuple[int, ...]]" is not assignable to declared type "ContravariantTypeVarTuple[int]" +  "ContravariantTypeVarTuple[*tuple[int, ...]]" is not assignable to "ContravariantTypeVarTuple[int]" +    Type parameter "InTs@ContravariantTypeVarTuple" is invariant, but "*tuple[int, ...]" is not the same as "*tuple[int]" (reportAssignmentType) +generics_typevartuple_variance.py:42:39 - error: Type "CovariantTypeVarTuple[object]" is not assignable to declared type "CovariantTypeVarTuple[int]" +  "CovariantTypeVarTuple[object]" is not assignable to "CovariantTypeVarTuple[int]" +    Type parameter "OutTs@CovariantTypeVarTuple" is invariant, but "*tuple[object]" is not the same as "*tuple[int]" (reportAssignmentType) +generics_typevartuple_variance.py:43:42 - error: Type "CovariantTypeVarTuple[int]" is not assignable to declared type "CovariantTypeVarTuple[object]" +  "CovariantTypeVarTuple[int]" is not assignable to "CovariantTypeVarTuple[object]" +    Type parameter "OutTs@CovariantTypeVarTuple" is invariant, but "*tuple[int]" is not the same as "*tuple[object]" (reportAssignmentType) +generics_typevartuple_variance.py:44:50 - error: Type "CovariantTypeVarTuple[bool, bool]" is not assignable to declared type "CovariantTypeVarTuple[int, int]" +  "CovariantTypeVarTuple[bool, bool]" is not assignable to "CovariantTypeVarTuple[int, int]" +    Type parameter "OutTs@CovariantTypeVarTuple" is invariant, but "*tuple[bool, bool]" is not the same as "*tuple[int, int]" (reportAssignmentType) +generics_typevartuple_variance.py:45:50 - error: Type "CovariantTypeVarTuple[bool, object]" is not assignable to declared type "CovariantTypeVarTuple[int, int]" +  "CovariantTypeVarTuple[bool, object]" is not assignable to "CovariantTypeVarTuple[int, int]" +    Type parameter "OutTs@CovariantTypeVarTuple" is invariant, but "*tuple[bool, object]" is not the same as "*tuple[int, int]" (reportAssignmentType) +generics_typevartuple_variance.py:46:50 - error: Type "CovariantTypeVarTuple[object, bool]" is not assignable to declared type "CovariantTypeVarTuple[int, int]" +  "CovariantTypeVarTuple[object, bool]" is not assignable to "CovariantTypeVarTuple[int, int]" +    Type parameter "OutTs@CovariantTypeVarTuple" is invariant, but "*tuple[object, bool]" is not the same as "*tuple[int, int]" (reportAssignmentType) +generics_typevartuple_variance.py:47:50 - error: Type "CovariantTypeVarTuple[object, object]" is not assignable to declared type "CovariantTypeVarTuple[int, int]" +  "CovariantTypeVarTuple[object, object]" is not assignable to "CovariantTypeVarTuple[int, int]" +    Type parameter "OutTs@CovariantTypeVarTuple" is invariant, but "*tuple[object, object]" is not the same as "*tuple[int, int]" (reportAssignmentType) +generics_typevartuple_variance.py:48:61 - error: Type "CovariantTypeVarTuple[*tuple[object, ...]]" is not assignable to declared type "CovariantTypeVarTuple[*tuple[int, ...]]" +  "CovariantTypeVarTuple[*tuple[object, ...]]" is not assignable to "CovariantTypeVarTuple[*tuple[int, ...]]" +    Type parameter "OutTs@CovariantTypeVarTuple" is invariant, but "*tuple[object, ...]" is not the same as "*tuple[int, ...]" (reportAssignmentType) +generics_typevartuple_variance.py:49:67 - error: Type "CovariantTypeVarTuple[*tuple[int, ...]]" is not assignable to declared type "CovariantTypeVarTuple[*tuple[object, ...]]" +  "CovariantTypeVarTuple[*tuple[int, ...]]" is not assignable to "CovariantTypeVarTuple[*tuple[object, ...]]" +    Type parameter "OutTs@CovariantTypeVarTuple" is invariant, but "*tuple[int, ...]" is not the same as "*tuple[object, ...]" (reportAssignmentType) +generics_typevartuple_variance.py:51:55 - error: Type "CovariantTypeVarTuple[*tuple[int, ...]]" is not assignable to declared type "CovariantTypeVarTuple[int]" +  "CovariantTypeVarTuple[*tuple[int, ...]]" is not assignable to "CovariantTypeVarTuple[int]" +    Type parameter "OutTs@CovariantTypeVarTuple" is invariant, but "*tuple[int, ...]" is not the same as "*tuple[int]" (reportAssignmentType) +generics_typevartuple_variance.py:55:35 - error: "infer_variance" is unknown parameter to TypeVarTuple (reportGeneralTypeIssues) +generics_typevartuple_variance.py:56:33 - error: "covariant" is unknown parameter to TypeVarTuple (reportGeneralTypeIssues) +generics_typevartuple_variance.py:56:49 - error: "contravariant" is unknown parameter to TypeVarTuple (reportGeneralTypeIssues) +generics_typevartuple_variance.py:57:33 - error: "covariant" is unknown parameter to TypeVarTuple (reportGeneralTypeIssues) +generics_typevartuple_variance.py:57:49 - error: "infer_variance" is unknown parameter to TypeVarTuple (reportGeneralTypeIssues) +generics_typevartuple_variance.py:58:33 - error: "contravariant" is unknown parameter to TypeVarTuple (reportGeneralTypeIssues) +generics_typevartuple_variance.py:58:53 - error: "infer_variance" is unknown parameter to TypeVarTuple (reportGeneralTypeIssues) +generics_typevartuple_variance.py:68:45 - error: Type "InvariantTypeVarTupleOld[int]" is not assignable to declared type "InvariantTypeVarTupleOld[object]" +  "InvariantTypeVarTupleOld[int]" is not assignable to "InvariantTypeVarTupleOld[object]" +    Type parameter "Ts@InvariantTypeVarTupleOld" is invariant, but "*tuple[int]" is not the same as "*tuple[object]" (reportAssignmentType) +generics_typevartuple_variance.py:69:42 - error: Type "InvariantTypeVarTupleOld[object]" is not assignable to declared type "InvariantTypeVarTupleOld[int]" +  "InvariantTypeVarTupleOld[object]" is not assignable to "InvariantTypeVarTupleOld[int]" +    Type parameter "Ts@InvariantTypeVarTupleOld" is invariant, but "*tuple[object]" is not the same as "*tuple[int]" (reportAssignmentType) +generics_typevartuple_variance.py:73:29 - error: "contravariant" is unknown parameter to TypeVarTuple (reportGeneralTypeIssues) +generics_typevartuple_variance.py:83:52 - error: Type "ContravariantTypeVarTupleOld[int]" is not assignable to declared type "ContravariantTypeVarTupleOld[object]" +  "ContravariantTypeVarTupleOld[int]" is not assignable to "ContravariantTypeVarTupleOld[object]" +    Type parameter "InTs@ContravariantTypeVarTupleOld" is invariant, but "*tuple[int]" is not the same as "*tuple[object]" (reportAssignmentType) +generics_typevartuple_variance.py:84:49 - error: Type "ContravariantTypeVarTupleOld[object]" is not assignable to declared type "ContravariantTypeVarTupleOld[int]" +  "ContravariantTypeVarTupleOld[object]" is not assignable to "ContravariantTypeVarTupleOld[int]" +    Type parameter "InTs@ContravariantTypeVarTupleOld" is invariant, but "*tuple[object]" is not the same as "*tuple[int]" (reportAssignmentType) +generics_typevartuple_variance.py:87:31 - error: "covariant" is unknown parameter to TypeVarTuple (reportGeneralTypeIssues) +generics_typevartuple_variance.py:97:46 - error: Type "CovariantTypeVarTupleOld[object]" is not assignable to declared type "CovariantTypeVarTupleOld[int]" +  "CovariantTypeVarTupleOld[object]" is not assignable to "CovariantTypeVarTupleOld[int]" +    Type parameter "OutTs@CovariantTypeVarTupleOld" is invariant, but "*tuple[object]" is not the same as "*tuple[int]" (reportAssignmentType) +generics_typevartuple_variance.py:98:49 - error: Type "CovariantTypeVarTupleOld[int]" is not assignable to declared type "CovariantTypeVarTupleOld[object]" +  "CovariantTypeVarTupleOld[int]" is not assignable to "CovariantTypeVarTupleOld[object]" +    Type parameter "OutTs@CovariantTypeVarTupleOld" is invariant, but "*tuple[int]" is not the same as "*tuple[object]" (reportAssignmentType) +generics_typevartuple_variance.py:107:66 - error: Type "InferredContravariantTypeVarTupleOld[int]" is not assignable to declared type "InferredContravariantTypeVarTupleOld[object]" +  "InferredContravariantTypeVarTupleOld[int]" is not assignable to "InferredContravariantTypeVarTupleOld[object]" +    Type parameter "InferTs@InferredContravariantTypeVarTupleOld" is invariant, but "*tuple[int]" is not the same as "*tuple[object]" (reportAssignmentType) +generics_typevartuple_variance.py:108:63 - error: Type "InferredContravariantTypeVarTupleOld[object]" is not assignable to declared type "InferredContravariantTypeVarTupleOld[int]" +  "InferredContravariantTypeVarTupleOld[object]" is not assignable to "InferredContravariantTypeVarTupleOld[int]" +    Type parameter "InferTs@InferredContravariantTypeVarTupleOld" is invariant, but "*tuple[object]" is not the same as "*tuple[int]" (reportAssignmentType) +generics_typevartuple_variance.py:116:60 - error: Type "InferredCovariantTypeVarTupleOld[object]" is not assignable to declared type "InferredCovariantTypeVarTupleOld[int]" +  "InferredCovariantTypeVarTupleOld[object]" is not assignable to "InferredCovariantTypeVarTupleOld[int]" +    Type parameter "InferTs@InferredCovariantTypeVarTupleOld" is invariant, but "*tuple[object]" is not the same as "*tuple[int]" (reportAssignmentType) +generics_typevartuple_variance.py:117:63 - error: Type "InferredCovariantTypeVarTupleOld[int]" is not assignable to declared type "InferredCovariantTypeVarTupleOld[object]" +  "InferredCovariantTypeVarTupleOld[int]" is not assignable to "InferredCovariantTypeVarTupleOld[object]" +    Type parameter "InferTs@InferredCovariantTypeVarTupleOld" is invariant, but "*tuple[int]" is not the same as "*tuple[object]" (reportAssignmentType) +""" diff --git a/conformance/results/pyright/generics_upper_bound.toml b/conformance/results/pyright/generics_upper_bound.toml index bd21bd9ca..1fd34bceb 100644 --- a/conformance/results/pyright/generics_upper_bound.toml +++ b/conformance/results/pyright/generics_upper_bound.toml @@ -1,15 +1,16 @@ conformant = "Pass" output = """ -generics_upper_bound.py:24:38 - error: TypeVar bound type cannot be generic -generics_upper_bound.py:51:8 - error: Argument of type "Literal[3]" cannot be assigned to parameter "x" of type "ST@longer" in function "longer" -  Type "Literal[3]" is incompatible with type "Sized" +generics_upper_bound.py:24:38 - error: TypeVar bound type cannot be generic (reportGeneralTypeIssues) +generics_upper_bound.py:44:17 - error: "assert_type" mismatch: expected "Collection[int]" but received "list[int] | set[int]" (reportAssertTypeFailure) +generics_upper_bound.py:52:8 - error: Argument of type "Literal[3]" cannot be assigned to parameter "x" of type "ST@longer" in function "longer" +  Type "Literal[3]" is not assignable to type "Sized"     "Literal[3]" is incompatible with protocol "Sized"       "__len__" is not present (reportArgumentType) -generics_upper_bound.py:51:11 - error: Argument of type "Literal[3]" cannot be assigned to parameter "y" of type "ST@longer" in function "longer" -  Type "Literal[3]" is incompatible with type "Sized" +generics_upper_bound.py:52:11 - error: Argument of type "Literal[3]" cannot be assigned to parameter "y" of type "ST@longer" in function "longer" +  Type "Literal[3]" is not assignable to type "Sized"     "Literal[3]" is incompatible with protocol "Sized"       "__len__" is not present (reportArgumentType) -generics_upper_bound.py:56:44 - error: TypeVar cannot be both bound and constrained +generics_upper_bound.py:57:44 - error: TypeVar cannot be both bound and constrained (reportGeneralTypeIssues) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/generics_variance.toml b/conformance/results/pyright/generics_variance.toml index fcfeac246..113a44121 100644 --- a/conformance/results/pyright/generics_variance.toml +++ b/conformance/results/pyright/generics_variance.toml @@ -1,6 +1,6 @@ conformant = "Pass" output = """ -generics_variance.py:14:50 - error: TypeVar cannot be both covariant and contravariant +generics_variance.py:14:50 - error: TypeVar cannot be both covariant and contravariant (reportGeneralTypeIssues) generics_variance.py:77:18 - error: Type "T_co@Class1" cannot be assigned to type variable "T@Inv"   Variance of type argument "T_co@Class1" is incompatible with base class "Inv" (reportInvalidTypeArguments) generics_variance.py:81:18 - error: Type "T_contra@Class2" cannot be assigned to type variable "T@Inv" @@ -22,9 +22,9 @@ generics_variance.py:163:33 - error: Type "Co[Contra[T_contra@CoToContraToContra generics_variance.py:167:37 - error: Type "Contra[Contra[T_co@ContraToContraToContra]]" cannot be assigned to type variable "T_contra@Contra"   Variance of type argument "Contra[Contra[T_co@ContraToContraToContra]]" is incompatible with base class "Contra" (reportInvalidTypeArguments) generics_variance.py:191:43 - error: Could not specialize type "Contra_TA[T_contra@Contra_TA]" -  Variance of type argument "Co_TA[Contra_TA[T_contra@CoToContraToContra_WithTA]]" is incompatible with "T_contra@Contra_TA" +  Variance of type argument "Co_TA[Contra_TA[T_contra@CoToContraToContra_WithTA]]" is incompatible with "T_contra@Contra_TA" (reportInvalidTypeForm) generics_variance.py:196:15 - error: Could not specialize type "Contra_TA[T_contra@Contra_TA]" -  Variance of type argument "Contra_TA[Contra_TA[T_co@ContraToContraToContra_WithTA]]" is incompatible with "T_contra@Contra_TA" +  Variance of type argument "Contra_TA[Contra_TA[T_co@ContraToContraToContra_WithTA]]" is incompatible with "T_contra@Contra_TA" (reportInvalidTypeForm) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/generics_variance_inference.toml b/conformance/results/pyright/generics_variance_inference.toml index e2b3de347..1bbd86ed4 100644 --- a/conformance/results/pyright/generics_variance_inference.toml +++ b/conformance/results/pyright/generics_variance_inference.toml @@ -1,84 +1,88 @@ conformant = "Pass" output = """ -generics_variance_inference.py:24:33 - error: Expression of type "ClassA[float, int, int]" is incompatible with declared type "ClassA[int, int, int]" -  "ClassA[float, int, int]" is incompatible with "ClassA[int, int, int]" +generics_variance_inference.py:24:33 - error: Type "ClassA[float, int, int]" is not assignable to declared type "ClassA[int, int, int]" +  "ClassA[float, int, int]" is not assignable to "ClassA[int, int, int]"     Type parameter "T1@ClassA" is invariant, but "float" is not the same as "int" (reportAssignmentType) -generics_variance_inference.py:25:37 - error: Expression of type "ClassA[float, int, int]" is incompatible with declared type "ClassA[float, float, int]" -  "ClassA[float, int, int]" is incompatible with "ClassA[float, float, int]" +generics_variance_inference.py:25:37 - error: Type "ClassA[float, int, int]" is not assignable to declared type "ClassA[float, float, int]" +  "ClassA[float, int, int]" is not assignable to "ClassA[float, float, int]"     Type parameter "T2@ClassA" is contravariant, but "int" is not a supertype of "float" -      "float" is incompatible with "int" (reportAssignmentType) -generics_variance_inference.py:28:33 - error: Expression of type "ClassA[int, float, float]" is incompatible with declared type "ClassA[int, int, int]" -  "ClassA[int, float, float]" is incompatible with "ClassA[int, int, int]" +      "float" is not assignable to "int" (reportAssignmentType) +generics_variance_inference.py:28:33 - error: Type "ClassA[int, float, float]" is not assignable to declared type "ClassA[int, int, int]" +  "ClassA[int, float, float]" is not assignable to "ClassA[int, int, int]"     Type parameter "T3@ClassA" is covariant, but "float" is not a subtype of "int" -      "float" is incompatible with "int" (reportAssignmentType) -generics_variance_inference.py:41:35 - error: Expression of type "ShouldBeCovariant1[float]" is incompatible with declared type "ShouldBeCovariant1[int]" -  "ShouldBeCovariant1[float]" is incompatible with "ShouldBeCovariant1[int]" +      "float" is not assignable to "int" (reportAssignmentType) +generics_variance_inference.py:41:35 - error: Type "ShouldBeCovariant1[float]" is not assignable to declared type "ShouldBeCovariant1[int]" +  "ShouldBeCovariant1[float]" is not assignable to "ShouldBeCovariant1[int]"     Type parameter "T@ShouldBeCovariant1" is covariant, but "float" is not a subtype of "int" -      "float" is incompatible with "int" (reportAssignmentType) -generics_variance_inference.py:49:35 - error: Expression of type "ShouldBeCovariant2[float]" is incompatible with declared type "ShouldBeCovariant2[int]" -  "ShouldBeCovariant2[float]" is incompatible with "ShouldBeCovariant2[int]" +      "float" is not assignable to "int" (reportAssignmentType) +generics_variance_inference.py:49:35 - error: Type "ShouldBeCovariant2[float]" is not assignable to declared type "ShouldBeCovariant2[int]" +  "ShouldBeCovariant2[float]" is not assignable to "ShouldBeCovariant2[int]"     Type parameter "T@ShouldBeCovariant2" is covariant, but "float" is not a subtype of "int" -      "float" is incompatible with "int" (reportAssignmentType) -generics_variance_inference.py:58:35 - error: Expression of type "ShouldBeCovariant3[float]" is incompatible with declared type "ShouldBeCovariant3[int]" -  "ShouldBeCovariant3[float]" is incompatible with "ShouldBeCovariant3[int]" +      "float" is not assignable to "int" (reportAssignmentType) +generics_variance_inference.py:58:35 - error: Type "ShouldBeCovariant3[float]" is not assignable to declared type "ShouldBeCovariant3[int]" +  "ShouldBeCovariant3[float]" is not assignable to "ShouldBeCovariant3[int]"     Type parameter "T@ShouldBeCovariant3" is covariant, but "float" is not a subtype of "int" -      "float" is incompatible with "int" (reportAssignmentType) -generics_variance_inference.py:67:34 - error: Expression of type "ShouldBeCovariant4[float]" is incompatible with declared type "ShouldBeCovariant4[int]" -  "ShouldBeCovariant4[float]" is incompatible with "ShouldBeCovariant4[int]" +      "float" is not assignable to "int" (reportAssignmentType) +generics_variance_inference.py:67:34 - error: Type "ShouldBeCovariant4[float]" is not assignable to declared type "ShouldBeCovariant4[int]" +  "ShouldBeCovariant4[float]" is not assignable to "ShouldBeCovariant4[int]"     Type parameter "T@ShouldBeCovariant4" is covariant, but "float" is not a subtype of "int" -      "float" is incompatible with "int" (reportAssignmentType) -generics_variance_inference.py:80:34 - error: Expression of type "ShouldBeCovariant5[float]" is incompatible with declared type "ShouldBeCovariant5[int]" -  "ShouldBeCovariant5[float]" is incompatible with "ShouldBeCovariant5[int]" +      "float" is not assignable to "int" (reportAssignmentType) +generics_variance_inference.py:80:34 - error: Type "ShouldBeCovariant5[float]" is not assignable to declared type "ShouldBeCovariant5[int]" +  "ShouldBeCovariant5[float]" is not assignable to "ShouldBeCovariant5[int]"     Type parameter "T@ShouldBeCovariant5" is covariant, but "float" is not a subtype of "int" -      "float" is incompatible with "int" (reportAssignmentType) -generics_variance_inference.py:96:38 - error: Expression of type "ShouldBeInvariant1[int]" is incompatible with declared type "ShouldBeInvariant1[float]" -  "ShouldBeInvariant1[int]" is incompatible with "ShouldBeInvariant1[float]" +      "float" is not assignable to "int" (reportAssignmentType) +generics_variance_inference.py:96:38 - error: Type "ShouldBeInvariant1[int]" is not assignable to declared type "ShouldBeInvariant1[float]" +  "ShouldBeInvariant1[int]" is not assignable to "ShouldBeInvariant1[float]"     Type parameter "T@ShouldBeInvariant1" is invariant, but "int" is not the same as "float" (reportAssignmentType) -generics_variance_inference.py:97:36 - error: Expression of type "ShouldBeInvariant1[float]" is incompatible with declared type "ShouldBeInvariant1[int]" -  "ShouldBeInvariant1[float]" is incompatible with "ShouldBeInvariant1[int]" +generics_variance_inference.py:97:36 - error: Type "ShouldBeInvariant1[float]" is not assignable to declared type "ShouldBeInvariant1[int]" +  "ShouldBeInvariant1[float]" is not assignable to "ShouldBeInvariant1[int]"     Type parameter "T@ShouldBeInvariant1" is invariant, but "float" is not the same as "int" (reportAssignmentType) -generics_variance_inference.py:111:38 - error: Expression of type "ShouldBeInvariant2[int]" is incompatible with declared type "ShouldBeInvariant2[float]" -  "ShouldBeInvariant2[int]" is incompatible with "ShouldBeInvariant2[float]" +generics_variance_inference.py:111:38 - error: Type "ShouldBeInvariant2[int]" is not assignable to declared type "ShouldBeInvariant2[float]" +  "ShouldBeInvariant2[int]" is not assignable to "ShouldBeInvariant2[float]"     Type parameter "T@ShouldBeInvariant2" is invariant, but "int" is not the same as "float" (reportAssignmentType) -generics_variance_inference.py:112:36 - error: Expression of type "ShouldBeInvariant2[float]" is incompatible with declared type "ShouldBeInvariant2[int]" -  "ShouldBeInvariant2[float]" is incompatible with "ShouldBeInvariant2[int]" +generics_variance_inference.py:112:36 - error: Type "ShouldBeInvariant2[float]" is not assignable to declared type "ShouldBeInvariant2[int]" +  "ShouldBeInvariant2[float]" is not assignable to "ShouldBeInvariant2[int]"     Type parameter "T@ShouldBeInvariant2" is invariant, but "float" is not the same as "int" (reportAssignmentType) -generics_variance_inference.py:119:43 - error: Expression of type "ShouldBeInvariant3[int, str]" is incompatible with declared type "ShouldBeInvariant3[float, str]" -  "ShouldBeInvariant3[int, str]" is incompatible with "ShouldBeInvariant3[float, str]" +generics_variance_inference.py:119:43 - error: Type "ShouldBeInvariant3[int, str]" is not assignable to declared type "ShouldBeInvariant3[float, str]" +  "ShouldBeInvariant3[int, str]" is not assignable to "ShouldBeInvariant3[float, str]"     Type parameter "K@ShouldBeInvariant3" is invariant, but "int" is not the same as "float" (reportAssignmentType) -generics_variance_inference.py:120:41 - error: Expression of type "ShouldBeInvariant3[float, str]" is incompatible with declared type "ShouldBeInvariant3[int, str]" -  "ShouldBeInvariant3[float, str]" is incompatible with "ShouldBeInvariant3[int, str]" +generics_variance_inference.py:120:41 - error: Type "ShouldBeInvariant3[float, str]" is not assignable to declared type "ShouldBeInvariant3[int, str]" +  "ShouldBeInvariant3[float, str]" is not assignable to "ShouldBeInvariant3[int, str]"     Type parameter "K@ShouldBeInvariant3" is invariant, but "float" is not the same as "int" (reportAssignmentType) -generics_variance_inference.py:121:43 - error: Expression of type "ShouldBeInvariant3[str, int]" is incompatible with declared type "ShouldBeInvariant3[str, float]" -  "ShouldBeInvariant3[str, int]" is incompatible with "ShouldBeInvariant3[str, float]" +generics_variance_inference.py:121:43 - error: Type "ShouldBeInvariant3[str, int]" is not assignable to declared type "ShouldBeInvariant3[str, float]" +  "ShouldBeInvariant3[str, int]" is not assignable to "ShouldBeInvariant3[str, float]"     Type parameter "V@ShouldBeInvariant3" is invariant, but "int" is not the same as "float" (reportAssignmentType) -generics_variance_inference.py:122:41 - error: Expression of type "ShouldBeInvariant3[str, float]" is incompatible with declared type "ShouldBeInvariant3[str, int]" -  "ShouldBeInvariant3[str, float]" is incompatible with "ShouldBeInvariant3[str, int]" +generics_variance_inference.py:122:41 - error: Type "ShouldBeInvariant3[str, float]" is not assignable to declared type "ShouldBeInvariant3[str, int]" +  "ShouldBeInvariant3[str, float]" is not assignable to "ShouldBeInvariant3[str, int]"     Type parameter "V@ShouldBeInvariant3" is invariant, but "float" is not the same as "int" (reportAssignmentType) -generics_variance_inference.py:130:38 - error: Expression of type "ShouldBeInvariant4[int]" is incompatible with declared type "ShouldBeInvariant4[float]" -  "ShouldBeInvariant4[int]" is incompatible with "ShouldBeInvariant4[float]" +generics_variance_inference.py:130:38 - error: Type "ShouldBeInvariant4[int]" is not assignable to declared type "ShouldBeInvariant4[float]" +  "ShouldBeInvariant4[int]" is not assignable to "ShouldBeInvariant4[float]"     Type parameter "T@ShouldBeInvariant4" is invariant, but "int" is not the same as "float" (reportAssignmentType) -generics_variance_inference.py:138:38 - error: Expression of type "ShouldBeInvariant5[int]" is incompatible with declared type "ShouldBeInvariant5[float]" -  "ShouldBeInvariant5[int]" is incompatible with "ShouldBeInvariant5[float]" +generics_variance_inference.py:138:38 - error: Type "ShouldBeInvariant5[int]" is not assignable to declared type "ShouldBeInvariant5[float]" +  "ShouldBeInvariant5[int]" is not assignable to "ShouldBeInvariant5[float]"     Type parameter "T@ShouldBeInvariant5" is invariant, but "int" is not the same as "float" (reportAssignmentType) -generics_variance_inference.py:149:45 - error: Expression of type "ShouldBeContravariant1[int]" is incompatible with declared type "ShouldBeContravariant1[float]" -  "ShouldBeContravariant1[int]" is incompatible with "ShouldBeContravariant1[float]" +generics_variance_inference.py:149:45 - error: Type "ShouldBeContravariant1[int]" is not assignable to declared type "ShouldBeContravariant1[float]" +  "ShouldBeContravariant1[int]" is not assignable to "ShouldBeContravariant1[float]"     Type parameter "T@ShouldBeContravariant1" is contravariant, but "int" is not a supertype of "float" -      "float" is incompatible with "int" (reportAssignmentType) -generics_variance_inference.py:169:31 - error: Expression of type "ShouldBeInvariant6[float]" is incompatible with declared type "ShouldBeInvariant6[int]" -  "ShouldBeInvariant6[float]" is incompatible with "ShouldBeInvariant6[int]" +      "float" is not assignable to "int" (reportAssignmentType) +generics_variance_inference.py:169:31 - error: Type "ShouldBeInvariant6[float]" is not assignable to declared type "ShouldBeInvariant6[int]" +  "ShouldBeInvariant6[float]" is not assignable to "ShouldBeInvariant6[int]"     Type parameter "T@ShouldBeInvariant6" is invariant, but "float" is not the same as "int" (reportAssignmentType) -generics_variance_inference.py:170:33 - error: Expression of type "ShouldBeInvariant6[int]" is incompatible with declared type "ShouldBeInvariant6[float]" -  "ShouldBeInvariant6[int]" is incompatible with "ShouldBeInvariant6[float]" +generics_variance_inference.py:170:33 - error: Type "ShouldBeInvariant6[int]" is not assignable to declared type "ShouldBeInvariant6[float]" +  "ShouldBeInvariant6[int]" is not assignable to "ShouldBeInvariant6[float]"     Type parameter "T@ShouldBeInvariant6" is invariant, but "int" is not the same as "float" (reportAssignmentType) -generics_variance_inference.py:181:31 - error: Expression of type "ShouldBeCovariant6[float]" is incompatible with declared type "ShouldBeCovariant6[int]" -  "ShouldBeCovariant6[float]" is incompatible with "ShouldBeCovariant6[int]" +generics_variance_inference.py:181:31 - error: Type "ShouldBeCovariant6[float]" is not assignable to declared type "ShouldBeCovariant6[int]" +  "ShouldBeCovariant6[float]" is not assignable to "ShouldBeCovariant6[int]"     Type parameter "T@ShouldBeCovariant6" is covariant, but "float" is not a subtype of "int" -      "float" is incompatible with "int" (reportAssignmentType) -generics_variance_inference.py:194:37 - error: Expression of type "ShouldBeContravariant2[int]" is incompatible with declared type "ShouldBeContravariant2[float]" -  "ShouldBeContravariant2[int]" is incompatible with "ShouldBeContravariant2[float]" +      "float" is not assignable to "int" (reportAssignmentType) +generics_variance_inference.py:194:37 - error: Type "ShouldBeContravariant2[int]" is not assignable to declared type "ShouldBeContravariant2[float]" +  "ShouldBeContravariant2[int]" is not assignable to "ShouldBeContravariant2[float]"     Type parameter "T@ShouldBeContravariant2" is contravariant, but "int" is not a supertype of "float" -      "float" is incompatible with "int" (reportAssignmentType) +      "float" is not assignable to "int" (reportAssignmentType) +generics_variance_inference.py:205:31 - error: Type "ShouldBeCovariant7[object]" is not assignable to declared type "ShouldBeCovariant7[int]" +  "ShouldBeCovariant7[object]" is not assignable to "ShouldBeCovariant7[int]" +    Type parameter "T@ShouldBeCovariant7" is covariant, but "object" is not a subtype of "int" +      "object" is not assignable to "int" (reportAssignmentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/historical_positional.toml b/conformance/results/pyright/historical_positional.toml index 0fae0f638..ccb120e5d 100644 --- a/conformance/results/pyright/historical_positional.toml +++ b/conformance/results/pyright/historical_positional.toml @@ -2,8 +2,8 @@ conformant = "Pass" output = """ historical_positional.py:18:8 - error: Expected 1 more positional argument (reportCallIssue) historical_positional.py:26:16 - error: Position-only parameter not allowed after parameter that is not position-only (reportGeneralTypeIssues) -historical_positional.py:38:26 - error: Position-only parameter not allowed after parameter that is not position-only (reportGeneralTypeIssues) -historical_positional.py:43:10 - error: Expected 1 more positional argument (reportCallIssue) +historical_positional.py:54:26 - error: Position-only parameter not allowed after parameter that is not position-only (reportGeneralTypeIssues) +historical_positional.py:59:10 - error: Expected 1 more positional argument (reportCallIssue) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/literals_interactions.toml b/conformance/results/pyright/literals_interactions.toml index cd51f439b..1ecbc1f04 100644 --- a/conformance/results/pyright/literals_interactions.toml +++ b/conformance/results/pyright/literals_interactions.toml @@ -1,9 +1,9 @@ conformant = "Pass" output = """ -literals_interactions.py:15:5 - error: Index 5 is out of range for type tuple[int, str, list[bool]] (reportGeneralTypeIssues) -literals_interactions.py:16:5 - error: Index -5 is out of range for type tuple[int, str, list[bool]] (reportGeneralTypeIssues) -literals_interactions.py:17:5 - error: Index 4 is out of range for type tuple[int, str, list[bool]] (reportGeneralTypeIssues) -literals_interactions.py:18:5 - error: Index -4 is out of range for type tuple[int, str, list[bool]] (reportGeneralTypeIssues) +literals_interactions.py:14:5 - error: Index 5 is out of range for type tuple[int, str, list[bool]] (reportGeneralTypeIssues) +literals_interactions.py:15:5 - error: Index -5 is out of range for type tuple[int, str, list[bool]] (reportGeneralTypeIssues) +literals_interactions.py:16:5 - error: Index 4 is out of range for type tuple[int, str, list[bool]] (reportGeneralTypeIssues) +literals_interactions.py:17:5 - error: Index -4 is out of range for type tuple[int, str, list[bool]] (reportGeneralTypeIssues) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/literals_literalstring.toml b/conformance/results/pyright/literals_literalstring.toml index f82f0123d..c917941ac 100644 --- a/conformance/results/pyright/literals_literalstring.toml +++ b/conformance/results/pyright/literals_literalstring.toml @@ -1,23 +1,23 @@ conformant = "Pass" output = """ -literals_literalstring.py:36:29 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value -literals_literalstring.py:37:22 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value -literals_literalstring.py:43:23 - error: Expression of type "Literal['two']" is incompatible with declared type "Literal['']" -  "Literal['two']" is incompatible with type "Literal['']" (reportAssignmentType) -literals_literalstring.py:66:25 - error: Expression of type "str" is incompatible with declared type "LiteralString" -  "str" is incompatible with "LiteralString" (reportAssignmentType) -literals_literalstring.py:74:25 - error: Expression of type "Literal[3]" is incompatible with declared type "LiteralString" -  "Literal[3]" is incompatible with "LiteralString" (reportAssignmentType) -literals_literalstring.py:75:25 - error: Expression of type "Literal[b"test"]" is incompatible with declared type "LiteralString" -  "Literal[b"test"]" is incompatible with "LiteralString" (reportAssignmentType) -literals_literalstring.py:120:22 - error: Argument of type "str" cannot be assigned to parameter "s" of type "TLiteral@literal_identity" in function "literal_identity" -  Type "str" is incompatible with type "LiteralString" -    "str" is incompatible with "LiteralString" (reportArgumentType) -literals_literalstring.py:134:51 - error: Argument of type "str" cannot be assigned to parameter "value" of type "T@Container" in function "__init__" -  Type "str" is incompatible with type "LiteralString" -    "str" is incompatible with "LiteralString" (reportArgumentType) -literals_literalstring.py:171:21 - error: Expression of type "list[LiteralString]" is incompatible with declared type "list[str]" -  "list[LiteralString]" is incompatible with "list[str]" +literals_literalstring.py:36:29 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm) +literals_literalstring.py:37:22 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm) +literals_literalstring.py:43:23 - error: Type "Literal['two']" is not assignable to declared type "Literal['']" +  "Literal['two']" is not assignable to type "Literal['']" (reportAssignmentType) +literals_literalstring.py:65:25 - error: Type "str" is not assignable to declared type "LiteralString" +  "str" is not assignable to "LiteralString" (reportAssignmentType) +literals_literalstring.py:73:25 - error: Type "Literal[3]" is not assignable to declared type "LiteralString" +  "Literal[3]" is not assignable to "LiteralString" (reportAssignmentType) +literals_literalstring.py:74:25 - error: Type "Literal[b"test"]" is not assignable to declared type "LiteralString" +  "Literal[b"test"]" is not assignable to "LiteralString" (reportAssignmentType) +literals_literalstring.py:119:22 - error: Argument of type "str" cannot be assigned to parameter "s" of type "TLiteral@literal_identity" in function "literal_identity" +  Type "str" is not assignable to type "LiteralString" +    "str" is not assignable to "LiteralString" (reportArgumentType) +literals_literalstring.py:133:51 - error: Argument of type "str" cannot be assigned to parameter "value" of type "T@Container" in function "__init__" +  Type "str" is not assignable to type "LiteralString" +    "str" is not assignable to "LiteralString" (reportArgumentType) +literals_literalstring.py:171:21 - error: Type "list[LiteralString]" is not assignable to declared type "list[str]" +  "list[LiteralString]" is not assignable to "list[str]"     Type parameter "_T@list" is invariant, but "LiteralString" is not the same as "str"     Consider switching from "list" to "Sequence" which is covariant (reportAssignmentType) """ diff --git a/conformance/results/pyright/literals_parameterizations.toml b/conformance/results/pyright/literals_parameterizations.toml index 4b5ab694f..bad4ec5e3 100644 --- a/conformance/results/pyright/literals_parameterizations.toml +++ b/conformance/results/pyright/literals_parameterizations.toml @@ -1,23 +1,31 @@ conformant = "Pass" output = """ -literals_parameterizations.py:41:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value -literals_parameterizations.py:42:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value -literals_parameterizations.py:43:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value -literals_parameterizations.py:44:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value -literals_parameterizations.py:45:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value -literals_parameterizations.py:46:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value -literals_parameterizations.py:47:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value -literals_parameterizations.py:48:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value -literals_parameterizations.py:49:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value -literals_parameterizations.py:50:16 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value -literals_parameterizations.py:51:16 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value -literals_parameterizations.py:52:16 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value -literals_parameterizations.py:53:16 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value -literals_parameterizations.py:56:28 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value -literals_parameterizations.py:60:4 - error: "Literal" cannot be used in this context without a type argument -literals_parameterizations.py:61:12 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value -literals_parameterizations.py:65:32 - error: Expression of type "Literal[Color.RED]" is incompatible with declared type "Literal['Color.RED']" -  "Literal[Color.RED]" is incompatible with type "Literal['Color.RED']" (reportAssignmentType) +literals_parameterizations.py:41:15 - error: Binary operator not allowed in type expression (reportInvalidTypeForm) +literals_parameterizations.py:41:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm) +literals_parameterizations.py:42:15 - error: Call expression not allowed in type expression (reportInvalidTypeForm) +literals_parameterizations.py:42:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm) +literals_parameterizations.py:43:15 - error: Binary operator not allowed in type expression (reportInvalidTypeForm) +literals_parameterizations.py:43:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm) +literals_parameterizations.py:44:15 - error: Unary operator not allowed in type expression (reportInvalidTypeForm) +literals_parameterizations.py:44:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm) +literals_parameterizations.py:45:15 - error: Unary operator not allowed in type expression (reportInvalidTypeForm) +literals_parameterizations.py:45:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm) +literals_parameterizations.py:46:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm) +literals_parameterizations.py:47:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm) +literals_parameterizations.py:48:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm) +literals_parameterizations.py:49:15 - error: Variable not allowed in type expression (reportInvalidTypeForm) +literals_parameterizations.py:49:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm) +literals_parameterizations.py:50:16 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm) +literals_parameterizations.py:51:16 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm) +literals_parameterizations.py:52:16 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm) +literals_parameterizations.py:53:16 - error: "..." is not allowed in this context (reportInvalidTypeForm) +literals_parameterizations.py:53:16 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm) +literals_parameterizations.py:56:28 - error: Binary operator not allowed in type expression (reportInvalidTypeForm) +literals_parameterizations.py:56:28 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm) +literals_parameterizations.py:60:4 - error: "Literal" cannot be used in this context without a type argument (reportInvalidTypeForm) +literals_parameterizations.py:61:12 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value (reportInvalidTypeForm) +literals_parameterizations.py:65:32 - error: Type "Literal[Color.RED]" is not assignable to declared type "Literal['Color.RED']" +  "Literal[Color.RED]" is not assignable to "Literal['Color.RED']" (reportAssignmentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/literals_semantics.toml b/conformance/results/pyright/literals_semantics.toml index 2606d3f0e..7d8b8af5f 100644 --- a/conformance/results/pyright/literals_semantics.toml +++ b/conformance/results/pyright/literals_semantics.toml @@ -1,12 +1,17 @@ conformant = "Pass" output = """ -literals_semantics.py:10:18 - error: Expression of type "Literal[4]" is incompatible with declared type "Literal[3]" -  "Literal[4]" is incompatible with type "Literal[3]" (reportAssignmentType) -literals_semantics.py:24:26 - error: Expression of type "Literal[0]" is incompatible with declared type "Literal[False]" -  "Literal[0]" is incompatible with type "Literal[False]" (reportAssignmentType) -literals_semantics.py:25:22 - error: Expression of type "Literal[False]" is incompatible with declared type "Literal[0]" -  "Literal[False]" is incompatible with type "Literal[0]" (reportAssignmentType) -literals_semantics.py:33:10 - error: Expression of type "Literal[6, 7, 8]" is incompatible with declared type "Literal[3, 4, 5]" (reportAssignmentType) +literals_semantics.py:10:18 - error: Type "Literal[4]" is not assignable to declared type "Literal[3]" +  "Literal[4]" is not assignable to type "Literal[3]" (reportAssignmentType) +literals_semantics.py:24:26 - error: Type "Literal[0]" is not assignable to declared type "Literal[False]" +  "Literal[0]" is not assignable to "Literal[False]" (reportAssignmentType) +literals_semantics.py:25:22 - error: Type "Literal[False]" is not assignable to declared type "Literal[0]" +  "Literal[False]" is not assignable to "Literal[0]" (reportAssignmentType) +literals_semantics.py:33:10 - error: Type "Literal[6, 7, 8]" is not assignable to declared type "Literal[3, 4, 5]" +  Type "Literal[6, 7, 8]" is not assignable to type "Literal[3, 4, 5]" +    Type "Literal[6]" is not assignable to type "Literal[3, 4, 5]" +      "Literal[6]" is not assignable to type "Literal[3]" +      "Literal[6]" is not assignable to type "Literal[4]" +      "Literal[6]" is not assignable to type "Literal[5]" (reportAssignmentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/namedtuples_define_class.toml b/conformance/results/pyright/namedtuples_define_class.toml index 2da523d93..59049fa48 100644 --- a/conformance/results/pyright/namedtuples_define_class.toml +++ b/conformance/results/pyright/namedtuples_define_class.toml @@ -1,20 +1,23 @@ conformant = "Pass" output = """ -namedtuples_define_class.py:32:7 - error: Index 3 is out of range for type Point (reportGeneralTypeIssues) -namedtuples_define_class.py:33:7 - error: Index -4 is out of range for type Point (reportGeneralTypeIssues) -namedtuples_define_class.py:44:6 - error: Argument missing for parameter "y" (reportCallIssue) +namedtuples_define_class.py:33:7 - error: Index 3 is out of range for type Point (reportGeneralTypeIssues) +namedtuples_define_class.py:34:7 - error: Index -4 is out of range for type Point (reportGeneralTypeIssues) namedtuples_define_class.py:45:6 - error: Argument missing for parameter "y" (reportCallIssue) -namedtuples_define_class.py:46:15 - error: Argument of type "Literal['']" cannot be assigned to parameter "y" of type "int" in function "__new__" -  "Literal['']" is incompatible with "int" (reportArgumentType) -namedtuples_define_class.py:47:24 - error: Argument of type "Literal[3]" cannot be assigned to parameter "units" of type "str" in function "__new__" -  "Literal[3]" is incompatible with "str" (reportArgumentType) -namedtuples_define_class.py:48:22 - error: Expected 3 positional arguments (reportCallIssue) -namedtuples_define_class.py:49:23 - error: No parameter named "other" (reportCallIssue) -namedtuples_define_class.py:59:5 - error: Fields without default values cannot appear after fields with default values (reportGeneralTypeIssues) -namedtuples_define_class.py:79:5 - error: Cannot override "x" because parent class "Point" is a named tuple (reportIncompatibleVariableOverride) -namedtuples_define_class.py:98:19 - error: Argument of type "float" cannot be assigned to parameter "value" of type "str" in function "__new__" -  "float" is incompatible with "str" (reportArgumentType) -namedtuples_define_class.py:105:7 - error: Multiple inheritance with NamedTuple is not supported (reportGeneralTypeIssues) +namedtuples_define_class.py:46:6 - error: Argument missing for parameter "y" (reportCallIssue) +namedtuples_define_class.py:47:15 - error: Argument of type "Literal['']" cannot be assigned to parameter "y" of type "int" in function "__new__" +  "Literal['']" is not assignable to "int" (reportArgumentType) +namedtuples_define_class.py:48:24 - error: Argument of type "Literal[3]" cannot be assigned to parameter "units" of type "str" in function "__new__" +  "Literal[3]" is not assignable to "str" (reportArgumentType) +namedtuples_define_class.py:49:22 - error: Expected 3 positional arguments (reportCallIssue) +namedtuples_define_class.py:50:23 - error: No parameter named "other" (reportCallIssue) +namedtuples_define_class.py:70:20 - error: Expected 2 positional arguments (reportCallIssue) +namedtuples_define_class.py:77:5 - error: Named tuple field names cannot start with an underscore (reportGeneralTypeIssues) +namedtuples_define_class.py:87:5 - error: Fields without default values cannot appear after fields with default values (reportGeneralTypeIssues) +namedtuples_define_class.py:107:5 - error: Cannot override "x" because parent class "Point" is a named tuple (reportIncompatibleVariableOverride) +namedtuples_define_class.py:121:24 - error: Expected 2 positional arguments (reportCallIssue) +namedtuples_define_class.py:140:19 - error: Argument of type "float" cannot be assigned to parameter "value" of type "str" in function "__new__" +  "float" is not assignable to "str" (reportArgumentType) +namedtuples_define_class.py:147:7 - error: Multiple inheritance with NamedTuple is not supported (reportGeneralTypeIssues) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/namedtuples_define_functional.toml b/conformance/results/pyright/namedtuples_define_functional.toml index c76f18e84..2c9738f7b 100644 --- a/conformance/results/pyright/namedtuples_define_functional.toml +++ b/conformance/results/pyright/namedtuples_define_functional.toml @@ -1,4 +1,3 @@ -conformant = "Pass" output = """ namedtuples_define_functional.py:16:8 - error: Argument missing for parameter "y" (reportCallIssue) namedtuples_define_functional.py:21:8 - error: Arguments missing for parameters "x", "y" (reportCallIssue) @@ -6,16 +5,17 @@ namedtuples_define_functional.py:26:21 - error: Expected 2 positional arguments namedtuples_define_functional.py:31:8 - error: Argument missing for parameter "y" (reportCallIssue) namedtuples_define_functional.py:31:18 - error: No parameter named "z" (reportCallIssue) namedtuples_define_functional.py:36:18 - error: Argument of type "Literal['1']" cannot be assigned to parameter "y" of type "int" in function "__new__" -  "Literal['1']" is incompatible with "int" (reportArgumentType) +  "Literal['1']" is not assignable to "int" (reportArgumentType) namedtuples_define_functional.py:37:21 - error: Expected 2 positional arguments (reportCallIssue) namedtuples_define_functional.py:42:18 - error: Argument of type "Literal['1']" cannot be assigned to parameter "y" of type "int" in function "__new__" -  "Literal['1']" is incompatible with "int" (reportArgumentType) +  "Literal['1']" is not assignable to "int" (reportArgumentType) namedtuples_define_functional.py:43:17 - error: Argument of type "float" cannot be assigned to parameter "x" of type "int" in function "__new__" -  "float" is incompatible with "int" (reportArgumentType) +  "float" is not assignable to "int" (reportArgumentType) namedtuples_define_functional.py:52:31 - error: Names within a named tuple must be unique (reportGeneralTypeIssues) namedtuples_define_functional.py:53:33 - error: Field names cannot be a keyword (reportGeneralTypeIssues) namedtuples_define_functional.py:54:33 - error: Field names cannot be a keyword (reportGeneralTypeIssues) -namedtuples_define_functional.py:66:1 - error: Argument missing for parameter "a" (reportCallIssue) +namedtuples_define_functional.py:55:33 - error: Named tuple field names cannot start with an underscore (reportGeneralTypeIssues) +namedtuples_define_functional.py:69:1 - error: Argument missing for parameter "a" (reportCallIssue) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/namedtuples_type_compat.toml b/conformance/results/pyright/namedtuples_type_compat.toml index aa8f69e63..c31192fc8 100644 --- a/conformance/results/pyright/namedtuples_type_compat.toml +++ b/conformance/results/pyright/namedtuples_type_compat.toml @@ -1,12 +1,12 @@ conformant = "Pass" output = """ -namedtuples_type_compat.py:22:23 - error: Expression of type "Point" is incompatible with declared type "tuple[int, int]" -  "Point" is incompatible with "tuple[int, int]" +namedtuples_type_compat.py:22:23 - error: Type "Point" is not assignable to declared type "tuple[int, int]" +  "Point" is not assignable to "tuple[int, int]"     Tuple size mismatch; expected 2 but received 3 (reportAssignmentType) -namedtuples_type_compat.py:23:28 - error: Expression of type "Point" is incompatible with declared type "tuple[int, str, str]" -  "Point" is incompatible with "tuple[int, str, str]" +namedtuples_type_compat.py:23:28 - error: Type "Point" is not assignable to declared type "tuple[int, str, str]" +  "Point" is not assignable to "tuple[int, str, str]"     Tuple entry 2 is incorrect type -      "int" is incompatible with "str" (reportAssignmentType) +      "int" is not assignable to "str" (reportAssignmentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/namedtuples_usage.toml b/conformance/results/pyright/namedtuples_usage.toml index 693e8c389..76f53162e 100644 --- a/conformance/results/pyright/namedtuples_usage.toml +++ b/conformance/results/pyright/namedtuples_usage.toml @@ -3,12 +3,10 @@ output = """ namedtuples_usage.py:34:7 - error: Index 3 is out of range for type Point (reportGeneralTypeIssues) namedtuples_usage.py:35:7 - error: Index -4 is out of range for type Point (reportGeneralTypeIssues) namedtuples_usage.py:40:3 - error: Cannot assign to attribute "x" for class "Point" -  Attribute "x" is read-only -    Attribute "__set__" is unknown (reportAttributeAccessIssue) +  Attribute "x" is read-only (reportAttributeAccessIssue) namedtuples_usage.py:41:1 - error: "__setitem__" method not defined on type "Point" (reportIndexIssue) namedtuples_usage.py:42:7 - error: Cannot delete attribute "x" for class "Point" -  Attribute "x" is read-only -    Attribute "__delete__" is unknown (reportAttributeAccessIssue) +  Attribute "x" is read-only (reportAttributeAccessIssue) namedtuples_usage.py:43:5 - error: "__delitem__" method not defined on type "Point" (reportIndexIssue) namedtuples_usage.py:52:1 - error: Expression with type "Point" cannot be assigned to target tuple   Type "Point" is incompatible with target tuple diff --git a/conformance/results/pyright/narrowing_typeguard.toml b/conformance/results/pyright/narrowing_typeguard.toml index ecab95858..a363ec8f3 100644 --- a/conformance/results/pyright/narrowing_typeguard.toml +++ b/conformance/results/pyright/narrowing_typeguard.toml @@ -3,15 +3,15 @@ output = """ narrowing_typeguard.py:102:9 - error: User-defined type guard functions and methods must have at least one input parameter (reportGeneralTypeIssues) narrowing_typeguard.py:107:9 - error: User-defined type guard functions and methods must have at least one input parameter (reportGeneralTypeIssues) narrowing_typeguard.py:128:20 - error: Argument of type "(val: object) -> TypeGuard[int]" cannot be assigned to parameter "f" of type "(object) -> str" in function "takes_callable_str" -  Type "(val: object) -> TypeGuard[int]" is incompatible with type "(object) -> str" +  Type "(val: object) -> TypeGuard[int]" is not assignable to type "(object) -> str"     Function return type "TypeGuard[int]" is incompatible with type "str" -      "TypeGuard[int]" is incompatible with "str" -      "bool" is incompatible with "str" (reportArgumentType) +      "TypeGuard[int]" is not assignable to "str" +      "bool" is not assignable to "str" (reportArgumentType) narrowing_typeguard.py:148:26 - error: Argument of type "(val: object) -> TypeGuard[int]" cannot be assigned to parameter "f" of type "CallableStrProto" in function "takes_callable_str_proto" -  Type "(val: object) -> TypeGuard[int]" is incompatible with type "(val: object) -> str" +  Type "(val: object) -> TypeGuard[int]" is not assignable to type "(val: object) -> str"     Function return type "TypeGuard[int]" is incompatible with type "str" -      "TypeGuard[int]" is incompatible with "str" -      "bool" is incompatible with "str" (reportArgumentType) +      "TypeGuard[int]" is not assignable to "str" +      "bool" is not assignable to "str" (reportArgumentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/narrowing_typeis.toml b/conformance/results/pyright/narrowing_typeis.toml index 731a636e8..327ec9f19 100644 --- a/conformance/results/pyright/narrowing_typeis.toml +++ b/conformance/results/pyright/narrowing_typeis.toml @@ -3,34 +3,34 @@ conformance_automated = "Pass" errors_diff = """ """ output = """ -narrowing_typeis.py:105:9 - error: User-defined type guard functions and methods must have at least one input parameter (reportGeneralTypeIssues) narrowing_typeis.py:110:9 - error: User-defined type guard functions and methods must have at least one input parameter (reportGeneralTypeIssues) -narrowing_typeis.py:132:20 - error: Argument of type "(val: object) -> TypeIs[int]" cannot be assigned to parameter "f" of type "(object) -> str" in function "takes_callable_str" -  Type "(val: object) -> TypeIs[int]" is incompatible with type "(object) -> str" +narrowing_typeis.py:115:9 - error: User-defined type guard functions and methods must have at least one input parameter (reportGeneralTypeIssues) +narrowing_typeis.py:137:20 - error: Argument of type "(val: object) -> TypeIs[int]" cannot be assigned to parameter "f" of type "(object) -> str" in function "takes_callable_str" +  Type "(val: object) -> TypeIs[int]" is not assignable to type "(object) -> str"     Function return type "TypeIs[int]" is incompatible with type "str" -      "TypeIs[int]" is incompatible with "str" -      "bool" is incompatible with "str" (reportArgumentType) -narrowing_typeis.py:152:26 - error: Argument of type "(val: object) -> TypeIs[int]" cannot be assigned to parameter "f" of type "CallableStrProto" in function "takes_callable_str_proto" -  Type "(val: object) -> TypeIs[int]" is incompatible with type "(val: object) -> str" +      "TypeIs[int]" is not assignable to "str" +      "bool" is not assignable to "str" (reportArgumentType) +narrowing_typeis.py:157:26 - error: Argument of type "(val: object) -> TypeIs[int]" cannot be assigned to parameter "f" of type "CallableStrProto" in function "takes_callable_str_proto" +  Type "(val: object) -> TypeIs[int]" is not assignable to type "(val: object) -> str"     Function return type "TypeIs[int]" is incompatible with type "str" -      "TypeIs[int]" is incompatible with "str" -      "bool" is incompatible with "str" (reportArgumentType) -narrowing_typeis.py:169:17 - error: Argument of type "(val: object) -> TypeIs[int]" cannot be assigned to parameter "f" of type "(object) -> TypeGuard[int]" in function "takes_typeguard" -  Type "(val: object) -> TypeIs[int]" is incompatible with type "(object) -> TypeGuard[int]" +      "TypeIs[int]" is not assignable to "str" +      "bool" is not assignable to "str" (reportArgumentType) +narrowing_typeis.py:174:17 - error: Argument of type "(val: object) -> TypeIs[int]" cannot be assigned to parameter "f" of type "(object) -> TypeGuard[int]" in function "takes_typeguard" +  Type "(val: object) -> TypeIs[int]" is not assignable to type "(object) -> TypeGuard[int]"     Function return type "TypeIs[int]" is incompatible with type "TypeGuard[int]" -      "TypeIs[int]" is incompatible with "TypeGuard[int]" -      "bool" is incompatible with "TypeGuard[int]" (reportArgumentType) -narrowing_typeis.py:170:14 - error: Argument of type "(val: object) -> TypeGuard[int]" cannot be assigned to parameter "f" of type "(object) -> TypeIs[int]" in function "takes_typeis" -  Type "(val: object) -> TypeGuard[int]" is incompatible with type "(object) -> TypeIs[int]" +      "TypeIs[int]" is not assignable to "TypeGuard[int]" +      "bool" is not assignable to "TypeGuard[int]" (reportArgumentType) +narrowing_typeis.py:175:14 - error: Argument of type "(val: object) -> TypeGuard[int]" cannot be assigned to parameter "f" of type "(object) -> TypeIs[int]" in function "takes_typeis" +  Type "(val: object) -> TypeGuard[int]" is not assignable to type "(object) -> TypeIs[int]"     Function return type "TypeGuard[int]" is incompatible with type "TypeIs[int]" -      "TypeGuard[int]" is incompatible with "TypeIs[int]" -      "bool" is incompatible with "TypeIs[int]" (reportArgumentType) -narrowing_typeis.py:191:18 - error: Argument of type "(val: object) -> TypeIs[bool]" cannot be assigned to parameter "f" of type "(object) -> TypeIs[int]" in function "takes_int_typeis" -  Type "(val: object) -> TypeIs[bool]" is incompatible with type "(object) -> TypeIs[int]" +      "TypeGuard[int]" is not assignable to "TypeIs[int]" +      "bool" is not assignable to "TypeIs[int]" (reportArgumentType) +narrowing_typeis.py:196:18 - error: Argument of type "(val: object) -> TypeIs[bool]" cannot be assigned to parameter "f" of type "(object) -> TypeIs[int]" in function "takes_int_typeis" +  Type "(val: object) -> TypeIs[bool]" is not assignable to type "(object) -> TypeIs[int]"     Function return type "TypeIs[bool]" is incompatible with type "TypeIs[int]" -      "TypeIs[bool]" is incompatible with "TypeIs[int]" +      "TypeIs[bool]" is not assignable to "TypeIs[int]"         Type parameter "T@TypeIs" is invariant, but "bool" is not the same as "int" -      "bool" is incompatible with "TypeIs[int]" (reportArgumentType) -narrowing_typeis.py:195:27 - error: Return type of TypeIs ("str") is not consistent with value parameter type ("int") (reportGeneralTypeIssues) -narrowing_typeis.py:199:45 - error: Return type of TypeIs ("list[int]") is not consistent with value parameter type ("list[object]") (reportGeneralTypeIssues) +      "bool" is not assignable to "TypeIs[int]" (reportArgumentType) +narrowing_typeis.py:200:27 - error: Return type of TypeIs ("str") is not consistent with value parameter type ("int") (reportGeneralTypeIssues) +narrowing_typeis.py:204:45 - error: Return type of TypeIs ("list[int]") is not consistent with value parameter type ("list[object]") (reportGeneralTypeIssues) """ diff --git a/conformance/results/pyright/overloads_basic.toml b/conformance/results/pyright/overloads_basic.toml index a4f03e2f5..78bfb673a 100644 --- a/conformance/results/pyright/overloads_basic.toml +++ b/conformance/results/pyright/overloads_basic.toml @@ -1,10 +1,8 @@ conformant = "Pass" output = """ -overloads_basic.py:37:1 - error: No overloads for "__getitem__" match the provided arguments (reportCallIssue) -overloads_basic.py:37:1 - error: Argument of type "Literal['']" cannot be assigned to parameter "__s" of type "slice" in function "__getitem__" -  "Literal['']" is incompatible with "slice" (reportArgumentType) -overloads_basic.py:63:5 - error: "func1" is marked as overload, but additional overloads are missing (reportInconsistentOverload) -overloads_basic.py:75:5 - error: "func2" is marked as overload, but no implementation is provided (reportNoOverloadImplementation) +overloads_basic.py:39:1 - error: No overloads for "__getitem__" match the provided arguments (reportCallIssue) +overloads_basic.py:39:1 - error: Argument of type "Literal['']" cannot be assigned to parameter "__s" of type "slice[Any, Any, Any]" in function "__getitem__" +  "Literal['']" is not assignable to "slice[Any, Any, Any]" (reportArgumentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/overloads_consistency.toml b/conformance/results/pyright/overloads_consistency.toml new file mode 100644 index 000000000..4568f8d82 --- /dev/null +++ b/conformance/results/pyright/overloads_consistency.toml @@ -0,0 +1,13 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +overloads_consistency.py:28:5 - error: Overloaded implementation is not consistent with signature of overload 2 +  Function return type "str" is incompatible with type "int" +    "str" is not assignable to "int" (reportInconsistentOverload) +overloads_consistency.py:44:5 - error: Overloaded implementation is not consistent with signature of overload 2 +  Type "(x: int) -> (int | str)" is not assignable to type "(x: str) -> str" +    Parameter 1: type "str" is incompatible with type "int" +      "str" is not assignable to "int" (reportInconsistentOverload) +""" diff --git a/conformance/results/pyright/overloads_definitions.toml b/conformance/results/pyright/overloads_definitions.toml new file mode 100644 index 000000000..e6118e2a3 --- /dev/null +++ b/conformance/results/pyright/overloads_definitions.toml @@ -0,0 +1,18 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +overloads_definitions.py:16:5 - error: "func1" is marked as overload, but additional overloads are missing (reportInconsistentOverload) +overloads_definitions.py:28:5 - error: "func2" is marked as overload, but no implementation is provided (reportNoOverloadImplementation) +overloads_definitions.py:59:9 - error: "not_abstract" is marked as overload, but no implementation is provided (reportNoOverloadImplementation) +overloads_definitions.py:73:9 - error: Overloads for "func5" use @staticmethod inconsistently (reportInconsistentOverload) +overloads_definitions.py:86:9 - error: Overloads for "func6" use @classmethod inconsistently (reportInconsistentOverload) +overloads_definitions.py:124:9 - error: @final decorator should be applied only to the implementation (reportInconsistentOverload) +overloads_definitions.py:139:9 - error: @final decorator should be applied only to the implementation (reportInconsistentOverload) +overloads_definitions.py:144:9 - error: @final decorator should be applied only to the implementation (reportInconsistentOverload) +overloads_definitions.py:186:9 - error: Method "final_method" cannot override final method defined in class "Base" (reportIncompatibleMethodOverride) +overloads_definitions.py:203:9 - error: Method "bad_override" is marked as override, but no base method of same name is present (reportGeneralTypeIssues) +overloads_definitions.py:228:9 - error: @override decorator should be applied only to the implementation (reportInconsistentOverload) +overloads_definitions.py:232:9 - error: @override decorator should be applied only to the implementation (reportInconsistentOverload) +""" diff --git a/conformance/results/pyright/overloads_definitions_stub.toml b/conformance/results/pyright/overloads_definitions_stub.toml new file mode 100644 index 000000000..a043c6cf1 --- /dev/null +++ b/conformance/results/pyright/overloads_definitions_stub.toml @@ -0,0 +1,14 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +overloads_definitions_stub.pyi:14:5 - error: "func1" is marked as overload, but additional overloads are missing (reportInconsistentOverload) +overloads_definitions_stub.pyi:33:9 - error: Overloads for "func5" use @staticmethod inconsistently (reportInconsistentOverload) +overloads_definitions_stub.pyi:41:9 - error: Overloads for "func6" use @classmethod inconsistently (reportInconsistentOverload) +overloads_definitions_stub.pyi:73:9 - error: Only the first overload should be marked @final (reportInconsistentOverload) +overloads_definitions_stub.pyi:86:9 - error: Only the first overload should be marked @final (reportInconsistentOverload) +overloads_definitions_stub.pyi:111:9 - error: Method "final_method" cannot override final method defined in class "Base" (reportIncompatibleMethodOverride) +overloads_definitions_stub.pyi:122:9 - error: Method "bad_override" is marked as override, but no base method of same name is present (reportGeneralTypeIssues) +overloads_definitions_stub.pyi:147:9 - error: Only the first overload should be marked @override (reportInconsistentOverload) +""" diff --git a/conformance/results/pyright/overloads_evaluation.toml b/conformance/results/pyright/overloads_evaluation.toml new file mode 100644 index 000000000..3c23761b0 --- /dev/null +++ b/conformance/results/pyright/overloads_evaluation.toml @@ -0,0 +1,18 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +overloads_evaluation.py:38:1 - error: No overloads for "example1_1" match the provided arguments +  Argument types: () (reportCallIssue) +overloads_evaluation.py:46:15 - error: Argument of type "Literal[1]" cannot be assigned to parameter "y" of type "str" in function "example1_1" +  "Literal[1]" is not assignable to "str" (reportArgumentType) +overloads_evaluation.py:51:12 - error: Argument of type "Literal[1]" cannot be assigned to parameter "x" of type "str" in function "example1_1" +  "Literal[1]" is not assignable to "str" (reportArgumentType) +overloads_evaluation.py:116:5 - error: No overloads for "example2" match the provided arguments (reportCallIssue) +overloads_evaluation.py:116:14 - error: Argument of type "int | str" cannot be assigned to parameter "x" of type "int" in function "example2" +  Type "int | str" is not assignable to type "int" +    "str" is not assignable to "int" (reportArgumentType) +overloads_evaluation.py:116:17 - error: Argument of type "int | str" cannot be assigned to parameter "y" of type "int" in function "example2" +  Type "int | str" is not assignable to type "int" +    "str" is not assignable to "int" (reportArgumentType) +""" diff --git a/conformance/results/pyright/protocols_class_objects.toml b/conformance/results/pyright/protocols_class_objects.toml index 8841024c2..ebfe905db 100644 --- a/conformance/results/pyright/protocols_class_objects.toml +++ b/conformance/results/pyright/protocols_class_objects.toml @@ -2,26 +2,26 @@ conformant = "Pass" output = """ protocols_class_objects.py:29:5 - error: Argument of type "type[Proto]" cannot be assigned to parameter "cls" of type "type[Proto]" in function "fun"   "Proto" is not a concrete class type and cannot be assigned to type "type[Proto]" (reportArgumentType) -protocols_class_objects.py:34:7 - error: Expression of type "type[Proto]" is incompatible with declared type "type[Proto]" +protocols_class_objects.py:34:7 - error: Type "type[Proto]" is not assignable to declared type "type[Proto]"   "Proto" is not a concrete class type and cannot be assigned to type "type[Proto]" (reportAssignmentType) -protocols_class_objects.py:58:16 - error: Expression of type "type[ConcreteA]" is incompatible with declared type "ProtoA1" -  "type[type]" is incompatible with "type[ConcreteA]" -  "type[type]" is incompatible with "type[ConcreteA]" +protocols_class_objects.py:58:16 - error: Type "type[ConcreteA]" is not assignable to declared type "ProtoA1" +  Type "type[ConcreteA]" is not assignable to type "ConcreteA" +  Type "type[ConcreteA]" is not assignable to type "ConcreteA"   "method1" is an incompatible type -    Type "(self: ConcreteA, x: int) -> int" is incompatible with type "(x: int) -> int" +    Type "(self: ConcreteA, x: int) -> int" is not assignable to type "(x: int) -> int"       Parameter name mismatch: "x" versus "self"       Parameter 1: type "int" is incompatible with type "ConcreteA" -        "int" is incompatible with "ConcreteA" (reportAssignmentType) -protocols_class_objects.py:74:16 - error: Expression of type "type[ConcreteB]" is incompatible with declared type "ProtoB1" +        "int" is not assignable to "ConcreteA" (reportAssignmentType) +protocols_class_objects.py:74:16 - error: Type "type[ConcreteB]" is not assignable to declared type "ProtoB1"   "prop1" is an incompatible type -    "property" is incompatible with "int" (reportAssignmentType) -protocols_class_objects.py:101:16 - error: Expression of type "type[ConcreteC1]" is incompatible with declared type "ProtoC1" +    "property" is not assignable to "int" (reportAssignmentType) +protocols_class_objects.py:104:16 - error: Type "type[ConcreteC1]" is not assignable to declared type "ProtoC1"   "attr1" is defined as a ClassVar in protocol (reportAssignmentType) -protocols_class_objects.py:103:16 - error: Expression of type "type[ConcreteC2]" is incompatible with declared type "ProtoC1" +protocols_class_objects.py:106:16 - error: Type "type[ConcreteC2]" is not assignable to declared type "ProtoC1"   "attr1" is defined as a ClassVar in protocol (reportAssignmentType) -protocols_class_objects.py:104:16 - error: Expression of type "type[ConcreteC2]" is incompatible with declared type "ProtoC2" +protocols_class_objects.py:107:16 - error: Type "type[ConcreteC2]" is not assignable to declared type "ProtoC2"   "attr1" must be defined as a ClassVar to be compatible with protocol (reportAssignmentType) -protocols_class_objects.py:105:16 - error: Expression of type "type[ConcreteC3]" is incompatible with declared type "ProtoC1" +protocols_class_objects.py:108:16 - error: Type "type[ConcreteC3]" is not assignable to declared type "ProtoC1"   "attr1" is defined as a ClassVar in protocol (reportAssignmentType) """ conformance_automated = "Pass" diff --git a/conformance/results/pyright/protocols_definition.toml b/conformance/results/pyright/protocols_definition.toml index 60efcd1ef..27fd7e88c 100644 --- a/conformance/results/pyright/protocols_definition.toml +++ b/conformance/results/pyright/protocols_definition.toml @@ -3,97 +3,105 @@ output = """ protocols_definition.py:30:12 - error: Argument of type "list[int]" cannot be assigned to parameter "things" of type "Iterable[SupportsClose]" in function "close_all"   "Literal[1]" is incompatible with protocol "SupportsClose"     "close" is not present (reportArgumentType) -protocols_definition.py:67:14 - error: Instance or class variables within a Protocol class must be explicitly declared within the class body -protocols_definition.py:114:22 - error: Expression of type "Concrete2_Bad1" is incompatible with declared type "Template2" +protocols_definition.py:67:14 - error: Instance or class variables within a Protocol class must be explicitly declared within the class body (reportGeneralTypeIssues) +protocols_definition.py:114:22 - error: Type "Concrete2_Bad1" is not assignable to declared type "Template2"   "Concrete2_Bad1" is incompatible with protocol "Template2"     "val1" is not present (reportAssignmentType) -protocols_definition.py:115:22 - error: Expression of type "Concrete2_Bad2" is incompatible with declared type "Template2" +protocols_definition.py:115:22 - error: Type "Concrete2_Bad2" is not assignable to declared type "Template2"   "Concrete2_Bad2" is incompatible with protocol "Template2"     "val1" is invariant because it is mutable     "val1" is an incompatible type     "val1" is defined as a ClassVar in protocol -      "Sequence[float]" is incompatible with "Sequence[int]" (reportAssignmentType) -protocols_definition.py:116:22 - error: Expression of type "Concrete2_Bad3" is incompatible with declared type "Template2" +      "Sequence[float]" is not assignable to "Sequence[int]" (reportAssignmentType) +protocols_definition.py:116:22 - error: Type "Concrete2_Bad3" is not assignable to declared type "Template2"   "Concrete2_Bad3" is incompatible with protocol "Template2"     "val1" is invariant because it is mutable     "val1" is an incompatible type     "val1" is defined as a ClassVar in protocol -      "list[int]" is incompatible with "Sequence[int]" (reportAssignmentType) -protocols_definition.py:117:22 - error: Expression of type "Concrete2_Bad4" is incompatible with declared type "Template2" +      "list[int]" is not assignable to "Sequence[int]" (reportAssignmentType) +protocols_definition.py:117:22 - error: Type "Concrete2_Bad4" is not assignable to declared type "Template2"   "Concrete2_Bad4" is incompatible with protocol "Template2"     "val1" is defined as a ClassVar in protocol (reportAssignmentType) -protocols_definition.py:156:22 - error: Expression of type "Concrete3_Bad1" is incompatible with declared type "Template3" +protocols_definition.py:156:22 - error: Type "Concrete3_Bad1" is not assignable to declared type "Template3"   "Concrete3_Bad1" is incompatible with protocol "Template3"     "val1" is not present (reportAssignmentType) -protocols_definition.py:157:22 - error: Expression of type "Concrete3_Bad2" is incompatible with declared type "Template3" +protocols_definition.py:157:22 - error: Type "Concrete3_Bad2" is not assignable to declared type "Template3"   "Concrete3_Bad2" is incompatible with protocol "Template3"     "val1" is not defined as a ClassVar in protocol (reportAssignmentType) -protocols_definition.py:158:22 - error: Expression of type "Concrete3_Bad3" is incompatible with declared type "Template3" +protocols_definition.py:158:22 - error: Type "Concrete3_Bad3" is not assignable to declared type "Template3"   "Concrete3_Bad3" is incompatible with protocol "Template3"     "val1" is invariant because it is mutable     "val1" is an incompatible type -      "property" is incompatible with "Sequence[int]" (reportAssignmentType) -protocols_definition.py:159:22 - error: Expression of type "Concrete3_Bad4" is incompatible with declared type "Template3" +      "property" is not assignable to "Sequence[int]" (reportAssignmentType) +protocols_definition.py:159:22 - error: Type "Concrete3_Bad4" is not assignable to declared type "Template3"   "Concrete3_Bad4" is incompatible with protocol "Template3"     "val1" is invariant because it is mutable     "val1" is an incompatible type -      "Sequence[float]" is incompatible with "Sequence[int]" (reportAssignmentType) -protocols_definition.py:160:22 - error: Expression of type "Concrete3_Bad5" is incompatible with declared type "Template3" +      "Sequence[float]" is not assignable to "Sequence[int]" (reportAssignmentType) +protocols_definition.py:160:22 - error: Type "Concrete3_Bad5" is not assignable to declared type "Template3"   "Concrete3_Bad5" is incompatible with protocol "Template3"     "val1" is invariant because it is mutable     "val1" is an incompatible type -      "list[int]" is incompatible with "Sequence[int]" (reportAssignmentType) -protocols_definition.py:218:22 - error: Expression of type "Concrete4_Bad1" is incompatible with declared type "Template4" +      "list[int]" is not assignable to "Sequence[int]" (reportAssignmentType) +protocols_definition.py:218:22 - error: Type "Concrete4_Bad1" is not assignable to declared type "Template4"   "Concrete4_Bad1" is incompatible with protocol "Template4"     "val1" is an incompatible type -      "function" is incompatible with "Sequence[float]" (reportAssignmentType) -protocols_definition.py:219:22 - error: Expression of type "Concrete4_Bad2" is incompatible with declared type "Template4" +      "MethodType" is not assignable to "Sequence[float]" (reportAssignmentType) +protocols_definition.py:219:22 - error: Type "Concrete4_Bad2" is not assignable to declared type "Template4"   "Concrete4_Bad2" is incompatible with protocol "Template4"     "val1" is not present (reportAssignmentType) protocols_definition.py:276:17 - warning: Static methods should not take a "self" or "cls" parameter (reportSelfClsParameterName) -protocols_definition.py:285:22 - error: Expression of type "Concrete5_Bad1" is incompatible with declared type "Template5" +protocols_definition.py:285:22 - error: Type "Concrete5_Bad1" is not assignable to declared type "Template5"   "Concrete5_Bad1" is incompatible with protocol "Template5"     "method1" is an incompatible type -      Type "(a: Unknown, c: Unknown) -> int" is incompatible with type "(a: int, b: int) -> float" +      Type "(a: Unknown, c: Unknown) -> int" is not assignable to type "(a: int, b: int) -> float"         Parameter name mismatch: "b" versus "c" (reportAssignmentType) -protocols_definition.py:286:22 - error: Expression of type "Concrete5_Bad2" is incompatible with declared type "Template5" +protocols_definition.py:286:22 - error: Type "Concrete5_Bad2" is not assignable to declared type "Template5"   "Concrete5_Bad2" is incompatible with protocol "Template5"     "method1" is an incompatible type -      Type "(a: int, c: int) -> int" is incompatible with type "(a: int, b: int) -> float" +      Type "(a: int, c: int) -> int" is not assignable to type "(a: int, b: int) -> float"         Parameter name mismatch: "b" versus "c" (reportAssignmentType) -protocols_definition.py:287:22 - error: Expression of type "Concrete5_Bad3" is incompatible with declared type "Template5" +protocols_definition.py:287:22 - error: Type "Concrete5_Bad3" is not assignable to declared type "Template5"   "Concrete5_Bad3" is incompatible with protocol "Template5"     "method1" is an incompatible type -      Type "(*, a: int, b: int) -> float" is incompatible with type "(a: int, b: int) -> float" -        Function accepts too many positional parameters; expected 0 but received 2 -          Keyword parameter "a" is missing in destination -          Keyword parameter "b" is missing in destination (reportAssignmentType) -protocols_definition.py:288:22 - error: Expression of type "Concrete5_Bad4" is incompatible with declared type "Template5" +      Type "(*, a: int, b: int) -> float" is not assignable to type "(a: int, b: int) -> float" +        Function accepts too few positional parameters; expected 2 but received 0 +          Parameter "a" is missing default argument +          Parameter "b" is missing default argument (reportAssignmentType) +protocols_definition.py:288:22 - error: Type "Concrete5_Bad4" is not assignable to declared type "Template5"   "Concrete5_Bad4" is incompatible with protocol "Template5"     "method1" is an incompatible type -      Type "(a: int, b: int, /) -> float" is incompatible with type "(a: int, b: int) -> float" -        Keyword parameter "a" is missing in source -        Keyword parameter "b" is missing in source +      Type "(a: int, b: int, /) -> float" is not assignable to type "(a: int, b: int) -> float" +        Missing keyword parameter "a" +        Missing keyword parameter "b"           Position-only parameter mismatch; parameter "a" is not position-only           Position-only parameter mismatch; parameter "b" is not position-only           Position-only parameter mismatch; expected 2 but received 0 (reportAssignmentType) -protocols_definition.py:289:22 - error: Expression of type "Concrete5_Bad5" is incompatible with declared type "Template5" +protocols_definition.py:289:22 - error: Type "Concrete5_Bad5" is not assignable to declared type "Template5"   "Concrete5_Bad5" is incompatible with protocol "Template5"     "method1" is an incompatible type -      Type "(self: Unknown, a: int, b: int) -> float" is incompatible with type "(a: int, b: int) -> float" +      Type "(self: Unknown, a: int, b: int) -> float" is not assignable to type "(a: int, b: int) -> float"         Parameter name mismatch: "a" versus "self"         Parameter name mismatch: "b" versus "a" (reportAssignmentType) -protocols_definition.py:339:22 - error: Expression of type "Concrete6_Bad1" is incompatible with declared type "Template6" +protocols_definition.py:339:22 - error: Type "Concrete6_Bad1" is not assignable to declared type "Template6"   "Concrete6_Bad1" is incompatible with protocol "Template6"     "val1" is an incompatible type       Property setter method is missing -        "Template6" is incompatible with "Concrete6_Bad1" (reportAssignmentType) -protocols_definition.py:340:22 - error: Expression of type "Concrete6_Bad2" is incompatible with declared type "Template6" +        "Template6" is not assignable to "Concrete6_Bad1" (reportAssignmentType) +protocols_definition.py:340:22 - error: Type "Concrete6_Bad2" is not assignable to declared type "Template6"   "Concrete6_Bad2" is incompatible with protocol "Template6" -    "val1" is writable in protocol (reportAssignmentType) -protocols_definition.py:341:22 - error: Expression of type "Concrete6_Bad3" is incompatible with declared type "Template6" +    "val1" is writable in protocol +    "val1" is not read-only in protocol (reportAssignmentType) +protocols_definition.py:341:22 - error: Type "Concrete6_Bad3" is not assignable to declared type "Template6"   "Concrete6_Bad3" is incompatible with protocol "Template6" -    "val1" is writable in protocol (reportAssignmentType) +    "val1" is writable in protocol +    "val1" is not read-only in protocol (reportAssignmentType) +protocols_definition.py:369:22 - error: Type "Concrete7_Bad1" is not assignable to declared type "Template7" +  "Concrete7_Bad1" is incompatible with protocol "Template7" +    "val1" is defined as a ClassVar in protocol (reportAssignmentType) +protocols_definition.py:370:22 - error: Type "Concrete7_Bad2" is not assignable to declared type "Template7" +  "Concrete7_Bad2" is incompatible with protocol "Template7" +    "val1" is defined as a ClassVar in protocol (reportAssignmentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/protocols_explicit.toml b/conformance/results/pyright/protocols_explicit.toml index c6b503d29..aad78c2f3 100644 --- a/conformance/results/pyright/protocols_explicit.toml +++ b/conformance/results/pyright/protocols_explicit.toml @@ -2,21 +2,15 @@ conformant = "Pass" output = """ protocols_explicit.py:27:16 - error: Method "draw" cannot be called because it is abstract and unimplemented (reportAbstractUsage) protocols_explicit.py:56:32 - error: Cannot assign to attribute "rgb" for class "Point*" -  "str" is incompatible with "int" (reportAttributeAccessIssue) -protocols_explicit.py:59:5 - error: Cannot instantiate abstract class "Point" -  "RGB.other" is not implemented +  "str" is not assignable to "int" (reportAttributeAccessIssue) +protocols_explicit.py:60:5 - error: Cannot instantiate abstract class "Point"   "RGB.intensity" is not implemented -  and 1 more... (reportAbstractUsage) -protocols_explicit.py:86:6 - error: Cannot instantiate abstract class "Concrete1" -  "Proto1.cm1" is not implemented -  "Proto1.im1" is not implemented (reportAbstractUsage) -protocols_explicit.py:104:6 - error: Cannot instantiate abstract class "Concrete3" -  "Proto2.cm10" is not implemented -  "Proto3.cm11" is not implemented -  and 1 more... (reportAbstractUsage) -protocols_explicit.py:129:6 - error: Cannot instantiate abstract class "Concrete5" +  "RGB.transparency" is not implemented (reportAbstractUsage) +protocols_explicit.py:89:6 - error: Cannot instantiate abstract class "Concrete1" +  "Proto1.cm1" is not implemented (reportAbstractUsage) +protocols_explicit.py:134:6 - error: Cannot instantiate abstract class "Concrete5"   "Proto5.method1" is not implemented (reportAbstractUsage) -protocols_explicit.py:159:7 - error: Cannot instantiate abstract class "Concrete7A" +protocols_explicit.py:164:7 - error: Cannot instantiate abstract class "Concrete7A"   "Proto7.method1" is not implemented (reportAbstractUsage) """ conformance_automated = "Pass" diff --git a/conformance/results/pyright/protocols_generic.toml b/conformance/results/pyright/protocols_generic.toml index 02a95883a..5045dd70a 100644 --- a/conformance/results/pyright/protocols_generic.toml +++ b/conformance/results/pyright/protocols_generic.toml @@ -1,42 +1,51 @@ conformant = "Pass" output = """ -protocols_generic.py:40:24 - error: Expression of type "Concrete1" is incompatible with declared type "Proto1[int, str]" +protocols_generic.py:40:24 - error: Type "Concrete1" is not assignable to declared type "Proto1[int, str]"   "Concrete1" is incompatible with protocol "Proto1[int, str]"     "method1" is an incompatible type -      Type "(x: str) -> str" is incompatible with type "(x: S@Proto1) -> S@Proto1" +      Type "(x: str) -> str" is not assignable to type "(x: S@Proto1) -> S@Proto1"         Parameter 1: type "S@Proto1" is incompatible with type "str" -          "int" is incompatible with "str" +          "int" is not assignable to "str"         Function return type "str" is incompatible with type "S@Proto1" -          Type "str" is incompatible with type "int" +          Type "int | str" is not assignable to type "int"     "__iter__" is an incompatible type ... (reportAssignmentType) protocols_generic.py:44:30 - error: Only one Generic[...] or Protocol[...] base class allowed (reportGeneralTypeIssues) -protocols_generic.py:56:20 - error: Expression of type "Box[float]" is incompatible with declared type "Box[int]" -  "Box[float]" is incompatible with "Box[int]" +protocols_generic.py:56:20 - error: Type "Box[float]" is not assignable to declared type "Box[int]" +  "Box[float]" is not assignable to "Box[int]"     Type parameter "T_co@Box" is covariant, but "float" is not a subtype of "int" -      "float" is incompatible with "int" (reportAssignmentType) -protocols_generic.py:66:25 - error: Expression of type "Sender[int]" is incompatible with declared type "Sender[float]" -  "Sender[int]" is incompatible with "Sender[float]" +      "float" is not assignable to "int" (reportAssignmentType) +protocols_generic.py:66:25 - error: Type "Sender[int]" is not assignable to declared type "Sender[float]" +  "Sender[int]" is not assignable to "Sender[float]"     Type parameter "T_contra@Sender" is contravariant, but "int" is not a supertype of "float" -      "float" is incompatible with "int" (reportAssignmentType) -protocols_generic.py:74:28 - error: Expression of type "AttrProto[int]" is incompatible with declared type "AttrProto[float]" -  "AttrProto[int]" is incompatible with "AttrProto[float]" +      "float" is not assignable to "int" (reportAssignmentType) +protocols_generic.py:74:28 - error: Type "AttrProto[int]" is not assignable to declared type "AttrProto[float]" +  "AttrProto[int]" is not assignable to "AttrProto[float]"     Type parameter "T@AttrProto" is invariant, but "int" is not the same as "float" (reportAssignmentType) -protocols_generic.py:75:26 - error: Expression of type "AttrProto[float]" is incompatible with declared type "AttrProto[int]" -  "AttrProto[float]" is incompatible with "AttrProto[int]" +protocols_generic.py:75:26 - error: Type "AttrProto[float]" is not assignable to declared type "AttrProto[int]" +  "AttrProto[float]" is not assignable to "AttrProto[int]"     Type parameter "T@AttrProto" is invariant, but "float" is not the same as "int" (reportAssignmentType) -protocols_generic.py:146:25 - error: Expression of type "ConcreteHasProperty3" is incompatible with declared type "HasPropertyProto" -  "ConcreteHasProperty3" is incompatible with protocol "HasPropertyProto" -    "f" is an incompatible type -      Type "() -> int" is incompatible with type "() -> HasPropertyProto" -        Function return type "int" is incompatible with type "HasPropertyProto" -          "int" is incompatible with protocol "HasPropertyProto" (reportAssignmentType) -protocols_generic.py:147:25 - error: Expression of type "ConcreteHasProperty4" is incompatible with declared type "HasPropertyProto" -  "ConcreteHasProperty4" is incompatible with protocol "HasPropertyProto" +protocols_generic.py:133:26 - error: Type "InvalidParentProperty" is not assignable to declared type "HasParentProperty" +  "InvalidParentProperty" is incompatible with protocol "HasParentProperty" +    "parent" is an incompatible type +      Type "() -> HasParentProperty" is not assignable to type "() -> InvalidParentProperty" +        "HasParentProperty" is not assignable to "InvalidParentProperty" +        Function return type "HasParentProperty" is incompatible with type "InvalidParentProperty" +          "HasParentProperty" is not assignable to "InvalidParentProperty" (reportAssignmentType) +protocols_generic.py:153:18 - error: Type "InvalidHasMethod" is not assignable to declared type "HasMethod" +  "InvalidHasMethod" is incompatible with protocol "HasMethod"     "m" is an incompatible type -      Type "(item: str, callback: (int) -> str) -> str" is incompatible with type "(item: T@m, callback: (T@m) -> str) -> str" +      Type "(item: int, callback: (int) -> str) -> str" is not assignable to type "(item: T@m, callback: (T@m) -> str) -> str" +        Parameter 1: type "T@m" is incompatible with type "int" +          "object*" is not assignable to "int"         Parameter 2: type "(T@m) -> str" is incompatible with type "(int) -> str" -          Type "(str) -> str" is incompatible with type "(int) -> str" (reportAssignmentType) +          Type "(T@m) -> str" is not assignable to type "(int) -> str" (reportAssignmentType) +protocols_generic.py:185:23 - error: Type "InvalidGreaterThan" is not assignable to declared type "HasGreaterThan" +  "InvalidGreaterThan" is incompatible with protocol "HasGreaterThan" +    "__gt__" is an incompatible type +      Type "(other: int) -> bool" is not assignable to type "(other: InvalidGreaterThan) -> bool" +        Parameter 1: type "InvalidGreaterThan" is incompatible with type "int" +          "InvalidGreaterThan" is not assignable to "int" (reportAssignmentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/protocols_merging.toml b/conformance/results/pyright/protocols_merging.toml index cb43e377f..1baa74a77 100644 --- a/conformance/results/pyright/protocols_merging.toml +++ b/conformance/results/pyright/protocols_merging.toml @@ -1,18 +1,18 @@ conformant = "Pass" output = """ -protocols_merging.py:52:25 - error: Expression of type "SCConcrete2" is incompatible with declared type "SizedAndClosable1" +protocols_merging.py:52:25 - error: Type "SCConcrete2" is not assignable to declared type "SizedAndClosable1"   "SCConcrete2" is incompatible with protocol "SizedAndClosable1"     "__len__" is not present (reportAssignmentType) -protocols_merging.py:53:25 - error: Expression of type "SCConcrete2" is incompatible with declared type "SizedAndClosable2" +protocols_merging.py:53:25 - error: Type "SCConcrete2" is not assignable to declared type "SizedAndClosable2"   "SCConcrete2" is incompatible with protocol "SizedAndClosable2"     "__len__" is not present (reportAssignmentType) -protocols_merging.py:54:25 - error: Expression of type "SCConcrete2" is incompatible with declared type "SizedAndClosable3" -  "SCConcrete2" is incompatible with "SizedAndClosable3" (reportAssignmentType) -protocols_merging.py:67:16 - error: Protocol class "BadProto" cannot derive from non-protocol class "SizedAndClosable3" (reportGeneralTypeIssues) +protocols_merging.py:54:25 - error: Type "SCConcrete2" is not assignable to declared type "SizedAndClosable3" +  "SCConcrete2" is not assignable to "SizedAndClosable3" (reportAssignmentType) +protocols_merging.py:67:16 - error: Protocol class "BadProto" cannot derive from non-Protocol class "SizedAndClosable3" (reportGeneralTypeIssues) protocols_merging.py:82:5 - error: Cannot instantiate abstract class "SizedAndClosable4"   "SizedAndClosable4.close" is not implemented (reportAbstractUsage) -protocols_merging.py:83:24 - error: Expression of type "SCConcrete1" is incompatible with declared type "SizedAndClosable4" -  "SCConcrete1" is incompatible with "SizedAndClosable4" (reportAssignmentType) +protocols_merging.py:83:24 - error: Type "SCConcrete1" is not assignable to declared type "SizedAndClosable4" +  "SCConcrete1" is not assignable to "SizedAndClosable4" (reportAssignmentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/protocols_modules.toml b/conformance/results/pyright/protocols_modules.toml index 646b6ba13..570cd977d 100644 --- a/conformance/results/pyright/protocols_modules.toml +++ b/conformance/results/pyright/protocols_modules.toml @@ -1,15 +1,15 @@ conformant = "Pass" output = """ -protocols_modules.py:26:17 - error: Expression of type "Module("_protocols_modules1")" is incompatible with declared type "Options2" +protocols_modules.py:26:17 - error: Type "Module("_protocols_modules1")" is not assignable to declared type "Options2"   "timeout" is invariant because it is mutable   "timeout" is an incompatible type -    "int" is incompatible with "str" (reportAssignmentType) -protocols_modules.py:48:18 - error: Expression of type "Module("_protocols_modules2")" is incompatible with declared type "Reporter2" +    "int" is not assignable to "str" (reportAssignmentType) +protocols_modules.py:48:18 - error: Type "Module("_protocols_modules2")" is not assignable to declared type "Reporter2"   "on_error" is an incompatible type -    Type "(x: int) -> None" is incompatible with type "(x: int) -> int" +    Type "(x: int) -> None" is not assignable to type "(x: int) -> int"       Function return type "None" is incompatible with type "int" -        "None" is incompatible with "int" (reportAssignmentType) -protocols_modules.py:49:18 - error: Expression of type "Module("_protocols_modules2")" is incompatible with declared type "Reporter3" +        "None" is not assignable to "int" (reportAssignmentType) +protocols_modules.py:49:18 - error: Type "Module("_protocols_modules2")" is not assignable to declared type "Reporter3"   "not_implemented" is not present (reportAssignmentType) """ conformance_automated = "Pass" diff --git a/conformance/results/pyright/protocols_runtime_checkable.toml b/conformance/results/pyright/protocols_runtime_checkable.toml index b94dcfe1f..06d9aa35c 100644 --- a/conformance/results/pyright/protocols_runtime_checkable.toml +++ b/conformance/results/pyright/protocols_runtime_checkable.toml @@ -6,13 +6,13 @@ protocols_runtime_checkable.py:55:22 - error: Data protocols (which include non- protocols_runtime_checkable.py:61:22 - error: Data protocols (which include non-method attributes) are not allowed in issubclass calls (reportGeneralTypeIssues) protocols_runtime_checkable.py:88:19 - error: Class overlaps "Proto3" unsafely and could produce a match at runtime   Attributes of "Concrete3A" have the same names as the protocol (reportGeneralTypeIssues) -protocols_runtime_checkable.py:92:9 - error: Class overlaps "Proto3" unsafely and could produce a match at runtime +protocols_runtime_checkable.py:91:19 - error: Class overlaps "Proto3" unsafely and could produce a match at runtime   Attributes of "Concrete3B" have the same names as the protocol (reportGeneralTypeIssues) -protocols_runtime_checkable.py:92:9 - error: Class overlaps "NonDataProtocol" unsafely and could produce a match at runtime +protocols_runtime_checkable.py:91:19 - error: Class overlaps "NonDataProtocol" unsafely and could produce a match at runtime   Attributes of "Concrete3B" have the same names as the protocol (reportGeneralTypeIssues) -protocols_runtime_checkable.py:96:19 - error: Class overlaps "Proto3" unsafely and could produce a match at runtime +protocols_runtime_checkable.py:94:19 - error: Class overlaps "Proto3" unsafely and could produce a match at runtime   Attributes of "Concrete3A" have the same names as the protocol (reportGeneralTypeIssues) -protocols_runtime_checkable.py:96:19 - error: Class overlaps "NonDataProtocol" unsafely and could produce a match at runtime +protocols_runtime_checkable.py:94:19 - error: Class overlaps "NonDataProtocol" unsafely and could produce a match at runtime   Attributes of "Concrete3A" have the same names as the protocol (reportGeneralTypeIssues) """ conformance_automated = "Pass" diff --git a/conformance/results/pyright/protocols_subtyping.toml b/conformance/results/pyright/protocols_subtyping.toml index 572ac5d8e..84a70f745 100644 --- a/conformance/results/pyright/protocols_subtyping.toml +++ b/conformance/results/pyright/protocols_subtyping.toml @@ -1,27 +1,37 @@ conformant = "Pass" output = """ -protocols_subtyping.py:16:6 - error: Cannot instantiate protocol class "Proto1" (reportAbstractUsage) -protocols_subtyping.py:38:21 - error: Expression of type "Proto2" is incompatible with declared type "Concrete2" -  "Proto2" is incompatible with "Concrete2" (reportAssignmentType) -protocols_subtyping.py:55:18 - error: Expression of type "Proto2" is incompatible with declared type "Proto3" +protocols_subtyping.py:16:6 - error: Cannot instantiate Protocol class "Proto1" (reportAbstractUsage) +protocols_subtyping.py:38:21 - error: Type "Proto2" is not assignable to declared type "Concrete2" +  "Proto2" is not assignable to "Concrete2" (reportAssignmentType) +protocols_subtyping.py:55:18 - error: Type "Proto2" is not assignable to declared type "Proto3"   "Proto2" is incompatible with protocol "Proto3"     "method2" is not present (reportAssignmentType) -protocols_subtyping.py:79:30 - error: Expression of type "Proto5[int]" is incompatible with declared type "Proto4[int, float]" +protocols_subtyping.py:79:30 - error: Type "Proto5[int]" is not assignable to declared type "Proto4[int, float]"   "Proto5[int]" is incompatible with protocol "Proto4[int, float]" -    Type parameter "T@Proto4" is invariant, but "int" is not the same as "float" (reportAssignmentType) -protocols_subtyping.py:80:25 - error: Expression of type "Proto4[int, int]" is incompatible with declared type "Proto5[float]" +    "method1" is an incompatible type +      Type "(a: int, b: int) -> tuple[int, int]" is not assignable to type "(a: S@Proto4, b: T@Proto4) -> tuple[S@Proto4, T@Proto4]" +        Parameter 2: type "T@Proto4" is incompatible with type "int" +          "float" is not assignable to "int" (reportAssignmentType) +protocols_subtyping.py:80:25 - error: Type "Proto4[int, int]" is not assignable to declared type "Proto5[float]"   "Proto4[int, int]" is incompatible with protocol "Proto5[float]" -    Type parameter "T@Proto5" is invariant, but "int" is not the same as "float" (reportAssignmentType) -protocols_subtyping.py:102:30 - error: Expression of type "Proto6[float, float]" is incompatible with declared type "Proto7[int, float]" +    "method1" is an incompatible type +      Type "(a: int, b: int) -> tuple[int, int]" is not assignable to type "(a: T@Proto5, b: T@Proto5) -> tuple[T@Proto5, T@Proto5]" +        Parameter 1: type "T@Proto5" is incompatible with type "int" +          "float" is not assignable to "int" +        Parameter 2: type "T@Proto5" is incompatible with type "int" +          "float" is not assignable to "int" (reportAssignmentType) +protocols_subtyping.py:102:30 - error: Type "Proto6[float, float]" is not assignable to declared type "Proto7[int, float]"   "Proto6[float, float]" is incompatible with protocol "Proto7[int, float]"     "method1" is an incompatible type -      Type "(a: float) -> Sequence[float]" is incompatible with type "(a: T_contra@Proto7) -> Sequence[S_co@Proto7]" +      Type "(a: float) -> Sequence[float]" is not assignable to type "(a: T_contra@Proto7) -> Sequence[S_co@Proto7]"         Function return type "Sequence[float]" is incompatible with type "Sequence[S_co@Proto7]" -          "Sequence[float]" is incompatible with "Sequence[S_co@Proto7]" (reportAssignmentType) -protocols_subtyping.py:103:33 - error: Expression of type "Proto6[float, float]" is incompatible with declared type "Proto7[float, object]" +          "Sequence[float]" is not assignable to "Sequence[S_co@Proto7]" (reportAssignmentType) +protocols_subtyping.py:103:33 - error: Type "Proto6[float, float]" is not assignable to declared type "Proto7[float, object]"   "Proto6[float, float]" is incompatible with protocol "Proto7[float, object]" -    Type parameter "T_contra@Proto7" is contravariant, but "float" is not a supertype of "object" -      "object" is incompatible with "float" (reportAssignmentType) +    "method1" is an incompatible type +      Type "(a: float) -> Sequence[float]" is not assignable to type "(a: T_contra@Proto7) -> Sequence[S_co@Proto7]" +        Parameter 1: type "T_contra@Proto7" is incompatible with type "float" +          "object" is not assignable to "float" (reportAssignmentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/protocols_variance.toml b/conformance/results/pyright/protocols_variance.toml index 041ce276a..761d7d473 100644 --- a/conformance/results/pyright/protocols_variance.toml +++ b/conformance/results/pyright/protocols_variance.toml @@ -1,15 +1,20 @@ -conformant = "Pass" +conformant = "Partial" +notes = """ +Doesn't support variance keyword arguments to ParamSpec. +""" output = """ -protocols_variance.py:21:7 - warning: Type variable "T1" used in generic protocol "AnotherBox" should be covariant (reportInvalidTypeVarUse) -protocols_variance.py:40:7 - warning: Type variable "T3" used in generic protocol "Protocol2" should be contravariant (reportInvalidTypeVarUse) -protocols_variance.py:56:7 - warning: Type variable "T1" used in generic protocol "Protocol4" should be contravariant (reportInvalidTypeVarUse) -protocols_variance.py:61:7 - warning: Type variable "T1_co" used in generic protocol "Protocol5" should be contravariant (reportInvalidTypeVarUse) -protocols_variance.py:62:22 - error: Covariant type variable cannot be used in parameter type (reportGeneralTypeIssues) -protocols_variance.py:66:7 - warning: Type variable "T1" used in generic protocol "Protocol6" should be covariant (reportInvalidTypeVarUse) -protocols_variance.py:71:7 - warning: Type variable "T1_contra" used in generic protocol "Protocol7" should be covariant (reportInvalidTypeVarUse) -protocols_variance.py:72:21 - error: Contravariant type variable cannot be used in return type (reportGeneralTypeIssues) -protocols_variance.py:104:7 - warning: Type variable "T1" used in generic protocol "Protocol12" should be covariant (reportInvalidTypeVarUse) +protocols_variance.py:15:20 - error: "contravariant" is unknown parameter to ParamSpec (reportGeneralTypeIssues) +protocols_variance.py:22:7 - warning: Type variable "T1" used in generic Protocol "AnotherBox" should be covariant (reportInvalidTypeVarUse) +protocols_variance.py:41:7 - warning: Type variable "T3" used in generic Protocol "Protocol2" should be contravariant (reportInvalidTypeVarUse) +protocols_variance.py:57:7 - warning: Type variable "T1" used in generic Protocol "Protocol4" should be contravariant (reportInvalidTypeVarUse) +protocols_variance.py:62:7 - warning: Type variable "T1_co" used in generic Protocol "Protocol5" should be contravariant (reportInvalidTypeVarUse) +protocols_variance.py:63:22 - error: Covariant type variable cannot be used in parameter type (reportGeneralTypeIssues) +protocols_variance.py:67:7 - warning: Type variable "T1" used in generic Protocol "Protocol6" should be covariant (reportInvalidTypeVarUse) +protocols_variance.py:72:7 - warning: Type variable "T1_contra" used in generic Protocol "Protocol7" should be covariant (reportInvalidTypeVarUse) +protocols_variance.py:73:21 - error: Contravariant type variable cannot be used in return type (reportGeneralTypeIssues) +protocols_variance.py:105:7 - warning: Type variable "T1" used in generic Protocol "Protocol12" should be covariant (reportInvalidTypeVarUse) """ -conformance_automated = "Pass" +conformance_automated = "Fail" errors_diff = """ +Line 15: Unexpected errors ['protocols_variance.py:15:20 - error: "contravariant" is unknown parameter to ParamSpec (reportGeneralTypeIssues)'] """ diff --git a/conformance/results/pyright/qualifiers_annotated.toml b/conformance/results/pyright/qualifiers_annotated.toml index 1722f6650..0e49034de 100644 --- a/conformance/results/pyright/qualifiers_annotated.toml +++ b/conformance/results/pyright/qualifiers_annotated.toml @@ -1,29 +1,36 @@ conformant = "Pass" output = """ -qualifiers_annotated.py:43:17 - error: List expression not allowed for this type argument -qualifiers_annotated.py:44:17 - error: Expected type expression but received "tuple[tuple[type[int], type[str]]]" (reportGeneralTypeIssues) -qualifiers_annotated.py:45:17 - error: List expression not allowed for this type argument -qualifiers_annotated.py:45:18 - error: Expected type expression but received "Generator[type[int], None, None]" (reportGeneralTypeIssues) -qualifiers_annotated.py:46:17 - error: Expected type expression but received "dict[str, str]" (reportGeneralTypeIssues) -qualifiers_annotated.py:46:17 - error: Dictionary expression not allowed in type annotation -qualifiers_annotated.py:47:17 - error: Call expression not allowed in type expression (reportInvalidTypeForm) -qualifiers_annotated.py:48:17 - error: List expression not allowed in type annotation -  Use List[T] to indicate a list type or Union[T1, T2] to indicate a union type (reportInvalidTypeForm) -qualifiers_annotated.py:48:17 - error: Expected type expression but received "list[type[int]]" (reportGeneralTypeIssues) -qualifiers_annotated.py:49:17 - error: Ternary expression not allowed in type annotation (reportInvalidTypeForm) -qualifiers_annotated.py:50:17 - error: "var1" is not defined (reportUndefinedVariable) -qualifiers_annotated.py:51:17 - error: Expected type expression but received "Literal[True]" (reportGeneralTypeIssues) -qualifiers_annotated.py:52:18 - error: Expected type expression but received "Literal[1]" (reportGeneralTypeIssues) -qualifiers_annotated.py:53:18 - error: Binary operator not allowed in type annotation (reportInvalidTypeForm) -qualifiers_annotated.py:54:18 - error: Type annotations cannot use format string literals (f-strings) (reportGeneralTypeIssues) -qualifiers_annotated.py:64:8 - error: Expected one type argument and one or more annotations for "Annotated" -qualifiers_annotated.py:76:24 - error: Expression of type "type[Annotated]" is incompatible with declared type "type[Any]" (reportAssignmentType) -qualifiers_annotated.py:77:24 - error: Expression of type "SmallInt" is incompatible with declared type "type[Any]" (reportAssignmentType) -qualifiers_annotated.py:84:7 - error: Argument of type "type[Annotated]" cannot be assigned to parameter "x" of type "type[T@func4]" in function "func4" (reportArgumentType) -qualifiers_annotated.py:85:7 - error: Argument of type "SmallInt" cannot be assigned to parameter "x" of type "type[T@func4]" in function "func4" (reportArgumentType) -qualifiers_annotated.py:91:1 - error: "Annotated" cannot be instantiated (reportCallIssue) -qualifiers_annotated.py:92:1 - error: Object of type "type[Annotated]" is not callable (reportCallIssue) -qualifiers_annotated.py:93:1 - error: Object of type "type[Annotated]" is not callable (reportCallIssue) +qualifiers_annotated.py:38:17 - error: List expression not allowed for this type argument (reportInvalidTypeForm) +qualifiers_annotated.py:39:17 - error: Expected class but received "tuple[tuple[type[int], type[str]]]" (reportGeneralTypeIssues) +qualifiers_annotated.py:40:17 - error: List expression not allowed for this type argument (reportInvalidTypeForm) +qualifiers_annotated.py:40:18 - error: Expected class but received "Generator[type[int], None, None]" (reportGeneralTypeIssues) +qualifiers_annotated.py:41:17 - error: Expected class but received "dict[str, Unknown]" (reportGeneralTypeIssues) +qualifiers_annotated.py:41:17 - error: Dictionary expression not allowed in type expression (reportInvalidTypeForm) +qualifiers_annotated.py:41:24 - error: "b" is not defined (reportUndefinedVariable) +qualifiers_annotated.py:42:17 - error: Call expression not allowed in type expression (reportInvalidTypeForm) +qualifiers_annotated.py:43:17 - error: List expression not allowed in type expression +  Use list[T] to indicate a list type or T1 | T2 to indicate a union type (reportInvalidTypeForm) +qualifiers_annotated.py:43:17 - error: Expected class but received "list[type[int]]" (reportGeneralTypeIssues) +qualifiers_annotated.py:43:23 - error: Expected class but received "Literal[0]" (reportGeneralTypeIssues) +qualifiers_annotated.py:44:17 - error: Ternary expression not allowed in type expression (reportInvalidTypeForm) +qualifiers_annotated.py:45:17 - error: "var1" is not defined (reportUndefinedVariable) +qualifiers_annotated.py:46:17 - error: Expected class but received "Literal[True]" (reportGeneralTypeIssues) +qualifiers_annotated.py:47:18 - error: Expected class but received "Literal[1]" (reportGeneralTypeIssues) +qualifiers_annotated.py:48:18 - error: Binary operator not allowed in type expression (reportInvalidTypeForm) +qualifiers_annotated.py:49:18 - error: Type expressions cannot use format string literals (f-strings) (reportGeneralTypeIssues) +qualifiers_annotated.py:59:8 - error: Expected one type argument and one or more annotations for "Annotated" (reportInvalidTypeForm) +qualifiers_annotated.py:71:24 - error: Type "Annotated" is not assignable to declared type "type[Any]" +  "Annotated" is not assignable to "type[Any]" (reportAssignmentType) +qualifiers_annotated.py:72:24 - error: Type "SmallInt" is not assignable to declared type "type[Any]" +  "Annotated" is not assignable to "type[Any]" (reportAssignmentType) +qualifiers_annotated.py:79:7 - error: Argument of type "Annotated" cannot be assigned to parameter "x" of type "type[T@func4]" in function "func4" +  Type "Annotated" is not assignable to type "type[T@func4]" (reportArgumentType) +qualifiers_annotated.py:80:7 - error: Argument of type "SmallInt" cannot be assigned to parameter "x" of type "type[T@func4]" in function "func4" +  Type "Annotated" is not assignable to type "type[T@func4]" (reportArgumentType) +qualifiers_annotated.py:86:1 - error: "Annotated" cannot be instantiated (reportCallIssue) +qualifiers_annotated.py:87:1 - error: Object of type "Annotated" is not callable +  Attribute "__call__" is unknown (reportCallIssue) +qualifiers_annotated.py:88:1 - error: Object of type "Annotated" is not callable (reportCallIssue) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/qualifiers_final_annotation.toml b/conformance/results/pyright/qualifiers_final_annotation.toml index 73d3648cc..0fb73bda6 100644 --- a/conformance/results/pyright/qualifiers_final_annotation.toml +++ b/conformance/results/pyright/qualifiers_final_annotation.toml @@ -1,45 +1,48 @@ conformant = "Pass" output = """ qualifiers_final_annotation.py:16:1 - error: "BAD1" is declared Final, but value is not assigned (reportGeneralTypeIssues) -qualifiers_final_annotation.py:18:7 - error: Expected a single type argument after "Final" +qualifiers_final_annotation.py:18:7 - error: Expected a single type argument after "Final" (reportInvalidTypeForm) qualifiers_final_annotation.py:34:5 - error: "ID2" is declared Final, but value is not assigned (reportGeneralTypeIssues) qualifiers_final_annotation.py:38:5 - error: "ID3" is declared Final, but value is not assigned (reportGeneralTypeIssues) qualifiers_final_annotation.py:54:14 - error: Cannot assign to attribute "ID5" for class "ClassA*"   Attribute "ID5" cannot be assigned through a class instance because it is a ClassVar -    Attribute "__set__" is unknown (reportAttributeAccessIssue) -qualifiers_final_annotation.py:62:19 - error: "Final" is not allowed in this context -qualifiers_final_annotation.py:63:19 - error: "Final" is not allowed in this context +  "ID5" is declared as Final and cannot be reassigned (reportAttributeAccessIssue) +qualifiers_final_annotation.py:62:19 - error: "Final" is not allowed in this context (reportInvalidTypeForm) +qualifiers_final_annotation.py:63:19 - error: "Final" is not allowed in this context (reportInvalidTypeForm) qualifiers_final_annotation.py:63:32 - error: Cannot assign to attribute "id4" for class "ClassA*" -  "Literal[1]" is incompatible with "Final" (reportAttributeAccessIssue) +  "Literal[1]" is not assignable to "Final" (reportAttributeAccessIssue) qualifiers_final_annotation.py:65:14 - error: Cannot assign to attribute "ID7" for class "ClassA*"   Attribute "ID7" cannot be assigned through a class instance because it is a ClassVar -  "ID7" is declared as Final and cannot be reassigned -    Attribute "__set__" is unknown (reportAttributeAccessIssue) +  "ID7" is declared as Final and cannot be reassigned (reportAttributeAccessIssue) qualifiers_final_annotation.py:67:14 - error: Cannot assign to attribute "ID7" for class "ClassA*"   Attribute "ID7" cannot be assigned through a class instance because it is a ClassVar -  "ID7" is declared as Final and cannot be reassigned -    Attribute "__set__" is unknown (reportAttributeAccessIssue) +  "ID7" is declared as Final and cannot be reassigned (reportAttributeAccessIssue) qualifiers_final_annotation.py:71:1 - error: "RATE" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) qualifiers_final_annotation.py:81:8 - error: Cannot assign to attribute "DEFAULT_ID" for class "type[ClassB]" -  "DEFAULT_ID" is declared as Final and cannot be reassigned -    Attribute "__set__" is unknown (reportAttributeAccessIssue) +  "DEFAULT_ID" is declared as Final and cannot be reassigned (reportAttributeAccessIssue) qualifiers_final_annotation.py:94:5 - error: "BORDER_WIDTH" cannot be redeclared because parent class "ClassC" declares it as Final (reportGeneralTypeIssues) -qualifiers_final_annotation.py:107:22 - error: "Final" is not allowed in this context -qualifiers_final_annotation.py:108:19 - error: "ClassVar" is not allowed in this context -qualifiers_final_annotation.py:118:9 - error: "Final" is not allowed in this context -qualifiers_final_annotation.py:121:14 - error: "Final" is not allowed in this context -qualifiers_final_annotation.py:134:1 - error: Arguments missing for parameters "x", "y" (reportCallIssue) -qualifiers_final_annotation.py:134:3 - error: No parameter named "a" (reportCallIssue) -qualifiers_final_annotation.py:135:5 - error: Argument of type "Literal['']" cannot be assigned to parameter "x" of type "int" in function "__new__" -  "Literal['']" is incompatible with "int" (reportArgumentType) -qualifiers_final_annotation.py:135:11 - error: Argument of type "Literal['']" cannot be assigned to parameter "y" of type "int" in function "__new__" -  "Literal['']" is incompatible with "int" (reportArgumentType) -qualifiers_final_annotation.py:141:5 - error: "ID1" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) -qualifiers_final_annotation.py:145:5 - error: "x" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) -qualifiers_final_annotation.py:147:10 - error: "x" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) -qualifiers_final_annotation.py:149:9 - error: "x" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) -qualifiers_final_annotation.py:152:30 - error: "x" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) -qualifiers_final_annotation.py:155:9 - error: "x" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) +qualifiers_final_annotation.py:107:22 - error: "Final" is not allowed in this context (reportInvalidTypeForm) +qualifiers_final_annotation.py:108:19 - error: "ClassVar" is not allowed in this context (reportInvalidTypeForm) +qualifiers_final_annotation.py:118:9 - error: "Final" is not allowed in this context (reportInvalidTypeForm) +qualifiers_final_annotation.py:121:14 - error: "Final" is not allowed in this context (reportInvalidTypeForm) +qualifiers_final_annotation.py:131:5 - error: "b" is declared Final, but value is not assigned (reportGeneralTypeIssues) +qualifiers_final_annotation.py:131:8 - error: "Final" is not allowed in this context (reportInvalidTypeForm) +qualifiers_final_annotation.py:136:5 - error: "b" is declared Final, but value is not assigned (reportGeneralTypeIssues) +qualifiers_final_annotation.py:136:8 - error: "Final" is not allowed in this context (reportInvalidTypeForm) +qualifiers_final_annotation.py:148:1 - error: Arguments missing for parameters "x", "y" (reportCallIssue) +qualifiers_final_annotation.py:148:3 - error: No parameter named "a" (reportCallIssue) +qualifiers_final_annotation.py:149:5 - error: Argument of type "Literal['']" cannot be assigned to parameter "x" of type "int" in function "__new__" +  "Literal['']" is not assignable to "int" (reportArgumentType) +qualifiers_final_annotation.py:149:11 - error: Argument of type "Literal['']" cannot be assigned to parameter "y" of type "int" in function "__new__" +  "Literal['']" is not assignable to "int" (reportArgumentType) +qualifiers_final_annotation.py:155:5 - error: "ID1" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) +qualifiers_final_annotation.py:159:5 - error: "x" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) +qualifiers_final_annotation.py:161:10 - error: "x" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) +qualifiers_final_annotation.py:163:9 - error: "x" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) +qualifiers_final_annotation.py:166:30 - error: "x" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) +qualifiers_final_annotation.py:169:9 - error: "x" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) +qualifiers_final_annotation.py:180:1 - error: "TEN" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) +qualifiers_final_annotation.py:184:1 - error: "PI" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/qualifiers_final_decorator.toml b/conformance/results/pyright/qualifiers_final_decorator.toml index 54cbee74d..94448af44 100644 --- a/conformance/results/pyright/qualifiers_final_decorator.toml +++ b/conformance/results/pyright/qualifiers_final_decorator.toml @@ -1,12 +1,11 @@ conformant = "Pass" output = """ -qualifiers_final_decorator.py:8:6 - warning: Import "_qualifiers_final_decorator" could not be resolved from source (reportMissingModuleSource) -qualifiers_final_decorator.py:21:16 - error: Base class "Base1" is marked final and cannot be subclassed +qualifiers_final_decorator.py:21:16 - error: Base class "Base1" is marked final and cannot be subclassed (reportGeneralTypeIssues) qualifiers_final_decorator.py:56:9 - error: Method "method1" cannot override final method defined in class "Base2" (reportIncompatibleMethodOverride) qualifiers_final_decorator.py:60:9 - error: Method "method2" cannot override final method defined in class "Base2" (reportIncompatibleMethodOverride) qualifiers_final_decorator.py:64:9 - error: Method "method3" cannot override final method defined in class "Base2" (reportIncompatibleMethodOverride) qualifiers_final_decorator.py:75:9 - error: Method "method4" cannot override final method defined in class "Base2" (reportIncompatibleMethodOverride) -qualifiers_final_decorator.py:86:9 - error: Overload for "method" is marked @final but implementation is not (reportInconsistentOverload) +qualifiers_final_decorator.py:86:9 - error: @final decorator should be applied only to the implementation (reportInconsistentOverload) qualifiers_final_decorator.py:89:9 - error: Method "method" cannot override final method defined in class "Base3" (reportIncompatibleMethodOverride) qualifiers_final_decorator.py:102:9 - error: Method "method" cannot override final method defined in class "Base4" (reportIncompatibleMethodOverride) qualifiers_final_decorator.py:118:9 - error: Method "method" cannot override final method defined in class "Base5_2" (reportIncompatibleMethodOverride) diff --git a/conformance/results/pyright/specialtypes_never.toml b/conformance/results/pyright/specialtypes_never.toml index 51770402b..ad3d6a257 100644 --- a/conformance/results/pyright/specialtypes_never.toml +++ b/conformance/results/pyright/specialtypes_never.toml @@ -1,12 +1,12 @@ conformant = "Pass" output = """ specialtypes_never.py:19:22 - error: Function with declared return type "NoReturn" cannot return "None" (reportReturnType) -specialtypes_never.py:82:21 - error: Expression of type "list[Never]" is incompatible with declared type "list[int]" -  "list[Never]" is incompatible with "list[int]" +specialtypes_never.py:85:21 - error: Type "list[Never]" is not assignable to declared type "list[int]" +  "list[Never]" is not assignable to "list[int]"     Type parameter "_T@list" is invariant, but "Never" is not the same as "int"     Consider switching from "list" to "Sequence" which is covariant (reportAssignmentType) -specialtypes_never.py:101:12 - error: Expression of type "ClassC[Never]" is incompatible with return type "ClassC[U@func10]" -  "ClassC[Never]" is incompatible with "ClassC[U@func10]" +specialtypes_never.py:104:12 - error: Type "ClassC[Never]" is not assignable to return type "ClassC[U@func10]" +  "ClassC[Never]" is not assignable to "ClassC[U@func10]"     Type parameter "T@ClassC" is invariant, but "Never" is not the same as "U@func10" (reportReturnType) """ conformance_automated = "Pass" diff --git a/conformance/results/pyright/specialtypes_none.toml b/conformance/results/pyright/specialtypes_none.toml index fe9033f6f..5bfb2d37d 100644 --- a/conformance/results/pyright/specialtypes_none.toml +++ b/conformance/results/pyright/specialtypes_none.toml @@ -1,12 +1,12 @@ conformant = "Pass" output = """ specialtypes_none.py:21:7 - error: Argument of type "type[None]" cannot be assigned to parameter "val1" of type "None" in function "func1" -  "type[type]" is incompatible with "type[None]" (reportArgumentType) -specialtypes_none.py:27:19 - error: Expression of type "None" is incompatible with declared type "Iterable[Unknown]" +  Type is not assignable to "None" (reportArgumentType) +specialtypes_none.py:27:19 - error: Type "None" is not assignable to declared type "Iterable[Unknown]"   "None" is incompatible with protocol "Iterable[Unknown]"     "__iter__" is not present (reportAssignmentType) specialtypes_none.py:41:7 - error: Argument of type "None" cannot be assigned to parameter "val1" of type "type[None]" in function "func2" -  Type "None" is incompatible with type "type[None]" (reportArgumentType) +  Type "None" is not assignable to type "type[None]" (reportArgumentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/specialtypes_sentinels.toml b/conformance/results/pyright/specialtypes_sentinels.toml new file mode 100644 index 000000000..a2f0cea7b --- /dev/null +++ b/conformance/results/pyright/specialtypes_sentinels.toml @@ -0,0 +1,31 @@ +conformant = "Partial" +notes = """ +Requires the string passed to `Sentinel` to match the assigned variable name. +This causes valid sentinel types and narrowing operations to be rejected. +""" +conformance_automated = "Fail" +errors_diff = """ +Line 14: Expected 1 errors +Line 36: Expected 1 errors +Line 39: Expected 1 errors +Line 7: Unexpected errors ['specialtypes_sentinels.py:7:1 - error: Sentinel must be assigned to a variable with the same name (reportGeneralTypeIssues)'] +Line 11: Unexpected errors ['specialtypes_sentinels.py:11:5 - error: Sentinel must be assigned to a variable with the same name (reportGeneralTypeIssues)'] +Line 20: Unexpected errors ['specialtypes_sentinels.py:20:20 - error: Variable not allowed in type expression (reportInvalidTypeForm)'] +Line 22: Unexpected errors ['specialtypes_sentinels.py:22:21 - error: "assert_type" mismatch: expected "Unknown" but received "int | Unknown | SPECIAL" (reportAssertTypeFailure)', 'specialtypes_sentinels.py:22:24 - error: Variable not allowed in type expression (reportInvalidTypeForm)'] +Line 24: Unexpected errors ['specialtypes_sentinels.py:24:21 - error: "assert_type" mismatch: expected "int | SPECIAL" but received "int | Unknown | SPECIAL" (reportAssertTypeFailure)'] +Line 26: Unexpected errors ['specialtypes_sentinels.py:26:24 - error: Variable not allowed in type expression (reportInvalidTypeForm)'] +Line 28: Unexpected errors ['specialtypes_sentinels.py:28:21 - error: "assert_type" mismatch: expected "Unknown" but received "int | Unknown" (reportAssertTypeFailure)', 'specialtypes_sentinels.py:28:28 - error: Variable not allowed in type expression (reportInvalidTypeForm)'] +Line 30: Unexpected errors ['specialtypes_sentinels.py:30:21 - error: "assert_type" mismatch: expected "int" but received "int | Unknown" (reportAssertTypeFailure)'] +""" +output = """ +specialtypes_sentinels.py:7:1 - error: Sentinel must be assigned to a variable with the same name (reportGeneralTypeIssues) +specialtypes_sentinels.py:11:5 - error: Sentinel must be assigned to a variable with the same name (reportGeneralTypeIssues) +specialtypes_sentinels.py:20:20 - error: Variable not allowed in type expression (reportInvalidTypeForm) +specialtypes_sentinels.py:22:21 - error: "assert_type" mismatch: expected "Unknown" but received "int | Unknown | SPECIAL" (reportAssertTypeFailure) +specialtypes_sentinels.py:22:24 - error: Variable not allowed in type expression (reportInvalidTypeForm) +specialtypes_sentinels.py:24:21 - error: "assert_type" mismatch: expected "int | SPECIAL" but received "int | Unknown | SPECIAL" (reportAssertTypeFailure) +specialtypes_sentinels.py:26:24 - error: Variable not allowed in type expression (reportInvalidTypeForm) +specialtypes_sentinels.py:28:21 - error: "assert_type" mismatch: expected "Unknown" but received "int | Unknown" (reportAssertTypeFailure) +specialtypes_sentinels.py:28:28 - error: Variable not allowed in type expression (reportInvalidTypeForm) +specialtypes_sentinels.py:30:21 - error: "assert_type" mismatch: expected "int" but received "int | Unknown" (reportAssertTypeFailure) +""" diff --git a/conformance/results/pyright/specialtypes_type.toml b/conformance/results/pyright/specialtypes_type.toml index 5a64d5e4a..904c541a0 100644 --- a/conformance/results/pyright/specialtypes_type.toml +++ b/conformance/results/pyright/specialtypes_type.toml @@ -1,13 +1,13 @@ conformant = "Pass" output = """ specialtypes_type.py:56:7 - error: Argument of type "type[TeamUser]" cannot be assigned to parameter "user_class" of type "type[BasicUser] | type[ProUser]" in function "func4" -  Type "type[TeamUser]" is incompatible with type "type[BasicUser] | type[ProUser]" -    "type[TeamUser]" is incompatible with "type[BasicUser]" -    Type "type[TeamUser]" is incompatible with type "type[BasicUser]" -    "type[TeamUser]" is incompatible with "type[ProUser]" -    Type "type[TeamUser]" is incompatible with type "type[ProUser]" (reportArgumentType) +  Type "type[TeamUser]" is not assignable to type "type[BasicUser] | type[ProUser]" +    "type[TeamUser]" is not assignable to "type[BasicUser]" +    Type "type[TeamUser]" is not assignable to type "type[BasicUser]" +    "type[TeamUser]" is not assignable to "type[ProUser]" +    Type "type[TeamUser]" is not assignable to type "type[ProUser]" (reportArgumentType) specialtypes_type.py:70:7 - error: Argument of type "type[Callable]" cannot be assigned to parameter "x" of type "type[T@func5]" in function "func5" (reportArgumentType) -specialtypes_type.py:76:22 - error: Too many type arguments provided for "type"; expected 1 but received 2 +specialtypes_type.py:76:22 - error: Too many type arguments provided for "type"; expected 1 but received 2 (reportInvalidTypeForm) specialtypes_type.py:117:7 - error: Cannot access attribute "unknown" for class "type[object]"   Attribute "unknown" is unknown (reportAttributeAccessIssue) specialtypes_type.py:120:7 - error: Cannot access attribute "unknown" for class "type[object]" diff --git a/conformance/results/pyright/tuples_type_compat.toml b/conformance/results/pyright/tuples_type_compat.toml index 184606a6b..72058759b 100644 --- a/conformance/results/pyright/tuples_type_compat.toml +++ b/conformance/results/pyright/tuples_type_compat.toml @@ -1,47 +1,55 @@ conformant = "Pass" output = """ -tuples_type_compat.py:15:27 - error: Expression of type "tuple[float, complex]" is incompatible with declared type "tuple[int, int]" -  "tuple[float, complex]" is incompatible with "tuple[int, int]" +tuples_type_compat.py:15:27 - error: Type "tuple[float, complex]" is not assignable to declared type "tuple[int, int]" +  "tuple[float, complex]" is not assignable to "tuple[int, int]"     Tuple entry 1 is incorrect type -      "float" is incompatible with "int" (reportAssignmentType) -tuples_type_compat.py:29:10 - error: Expression of type "tuple[int, ...]" is incompatible with declared type "tuple[int, *tuple[int, ...]]" -  "tuple[int, ...]" is incompatible with "tuple[int, *tuple[int, ...]]" +      "float" is not assignable to "int" (reportAssignmentType) +tuples_type_compat.py:29:10 - error: Type "tuple[int, ...]" is not assignable to declared type "tuple[int, *tuple[int, ...]]" +  "tuple[int, ...]" is not assignable to "tuple[int, *tuple[int, ...]]"     Tuple size mismatch; expected 1 or more but received indeterminate (reportAssignmentType) -tuples_type_compat.py:32:10 - error: Expression of type "tuple[int, *tuple[int, ...]]" is incompatible with declared type "tuple[int]" -  "tuple[int, *tuple[int, ...]]" is incompatible with "tuple[int]" +tuples_type_compat.py:32:10 - error: Type "tuple[int, *tuple[int, ...]]" is not assignable to declared type "tuple[int]" +  "tuple[int, *tuple[int, ...]]" is not assignable to "tuple[int]"     Tuple size mismatch; expected 1 but received indeterminate (reportAssignmentType) -tuples_type_compat.py:33:10 - error: Expression of type "tuple[int, ...]" is incompatible with declared type "tuple[int]" -  "tuple[int, ...]" is incompatible with "tuple[int]" +tuples_type_compat.py:33:10 - error: Type "tuple[int, ...]" is not assignable to declared type "tuple[int]" +  "tuple[int, ...]" is not assignable to "tuple[int]"     Tuple size mismatch; expected 1 but received indeterminate (reportAssignmentType) -tuples_type_compat.py:43:22 - error: Expression of type "tuple[int, ...]" is incompatible with declared type "tuple[int]" -  "tuple[int, ...]" is incompatible with "tuple[int]" +tuples_type_compat.py:43:22 - error: Type "tuple[int, ...]" is not assignable to declared type "tuple[int]" +  "tuple[int, ...]" is not assignable to "tuple[int]"     Tuple size mismatch; expected 1 but received indeterminate (reportAssignmentType) -tuples_type_compat.py:62:26 - error: Expression of type "tuple[int, ...]" is incompatible with declared type "tuple[int, int]" -  "tuple[int, ...]" is incompatible with "tuple[int, int]" +tuples_type_compat.py:62:26 - error: Type "tuple[int, ...]" is not assignable to declared type "tuple[int, int]" +  "tuple[int, ...]" is not assignable to "tuple[int, int]"     Tuple size mismatch; expected 2 but received indeterminate (reportAssignmentType) -tuples_type_compat.py:144:6 - error: Expression of type "tuple[Literal[1], Literal[''], Literal['']]" is incompatible with declared type "tuple[int, str]" -  "tuple[Literal[1], Literal[''], Literal['']]" is incompatible with "tuple[int, str]" +tuples_type_compat.py:76:21 - error: "assert_type" mismatch: expected "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]" but received "tuple[int]" (reportAssertTypeFailure) +tuples_type_compat.py:81:21 - error: "assert_type" mismatch: expected "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]" but received "tuple[str, str] | tuple[int, int]" (reportAssertTypeFailure) +tuples_type_compat.py:86:21 - error: "assert_type" mismatch: expected "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]" but received "tuple[int, str, int]" (reportAssertTypeFailure) +tuples_type_compat.py:102:25 - error: "assert_type" mismatch: expected "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]" but received "tuple[int]" (reportAssertTypeFailure) +tuples_type_compat.py:107:25 - error: "assert_type" mismatch: expected "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]" but received "tuple[str, str] | tuple[int, int]" (reportAssertTypeFailure) +tuples_type_compat.py:112:25 - error: "assert_type" mismatch: expected "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]" but received "tuple[int, str, int]" (reportAssertTypeFailure) +tuples_type_compat.py:127:25 - error: "assert_type" mismatch: expected "tuple[int | str, int | str]" but received "tuple[int | str, str]" (reportAssertTypeFailure) +tuples_type_compat.py:130:25 - error: "assert_type" mismatch: expected "tuple[int | str, int | str]" but received "tuple[int | str, int]" (reportAssertTypeFailure) +tuples_type_compat.py:157:6 - error: Type "tuple[Literal[1], Literal[''], Literal['']]" is not assignable to declared type "tuple[int, str]" +  "tuple[Literal[1], Literal[''], Literal['']]" is not assignable to "tuple[int, str]"     Tuple size mismatch; expected 2 but received 3 (reportAssignmentType) -tuples_type_compat.py:149:10 - error: Expression of type "tuple[Literal[1], Literal[1], Literal['']]" is incompatible with declared type "tuple[int, *tuple[str, ...]]" -  "Literal[1]" is incompatible with "str" (reportAssignmentType) -tuples_type_compat.py:150:14 - error: Expression of type "tuple[Literal[1], Literal[''], Literal[1]]" is incompatible with declared type "tuple[int, *tuple[str, ...]]" -  "Literal[1]" is incompatible with "str" (reportAssignmentType) -tuples_type_compat.py:156:14 - error: Expression of type "tuple[Literal[1], Literal[''], Literal['']]" is incompatible with declared type "tuple[int, *tuple[str, ...], int]" -  "Literal['']" is incompatible with "int" (reportAssignmentType) -tuples_type_compat.py:157:18 - error: Expression of type "tuple[Literal[1], Literal[''], Literal[''], float]" is incompatible with declared type "tuple[int, *tuple[str, ...], int]" -  "float" is incompatible with "int" (reportAssignmentType) -tuples_type_compat.py:162:7 - error: Expression of type "tuple[Literal[1], Literal[''], Literal[1]]" is incompatible with declared type "tuple[*tuple[str, ...], int]" -  "Literal[1]" is incompatible with "str" (reportAssignmentType) -tuples_type_compat.py:163:15 - error: Expression of type "tuple[Literal[''], Literal[''], float]" is incompatible with declared type "tuple[*tuple[str, ...], int]" -  "float" is incompatible with "int" (reportAssignmentType) -tuples_type_compat.py:168:40 - error: Expression of type "tuple[str, str]" is incompatible with declared type "tuple[str, str, int]" -  "tuple[str, str]" is incompatible with "tuple[str, str, int]" +tuples_type_compat.py:162:10 - error: Type "tuple[Literal[1], Literal[1], Literal['']]" is not assignable to declared type "tuple[int, *tuple[str, ...]]" +  "Literal[1]" is not assignable to "str" (reportAssignmentType) +tuples_type_compat.py:163:14 - error: Type "tuple[Literal[1], Literal[''], Literal[1]]" is not assignable to declared type "tuple[int, *tuple[str, ...]]" +  "Literal[1]" is not assignable to "str" (reportAssignmentType) +tuples_type_compat.py:169:14 - error: Type "tuple[Literal[1], Literal[''], Literal['']]" is not assignable to declared type "tuple[int, *tuple[str, ...], int]" +  "Literal['']" is not assignable to "int" (reportAssignmentType) +tuples_type_compat.py:170:18 - error: Type "tuple[Literal[1], Literal[''], Literal[''], float]" is not assignable to declared type "tuple[int, *tuple[str, ...], int]" +  "float" is not assignable to "int" (reportAssignmentType) +tuples_type_compat.py:175:7 - error: Type "tuple[Literal[1], Literal[''], Literal[1]]" is not assignable to declared type "tuple[*tuple[str, ...], int]" +  "Literal[1]" is not assignable to "str" (reportAssignmentType) +tuples_type_compat.py:176:15 - error: Type "tuple[Literal[''], Literal[''], float]" is not assignable to declared type "tuple[*tuple[str, ...], int]" +  "float" is not assignable to "int" (reportAssignmentType) +tuples_type_compat.py:181:40 - error: Type "tuple[str, str]" is not assignable to declared type "tuple[str, str, int]" +  "tuple[str, str]" is not assignable to "tuple[str, str, int]"     Tuple size mismatch; expected 3 but received 2 (reportAssignmentType) -tuples_type_compat.py:171:50 - error: Expression of type "tuple[str, str]" is incompatible with declared type "tuple[str, str, str, *tuple[str, ...]]" -  "tuple[str, str]" is incompatible with "tuple[str, str, str, *tuple[str, ...]]" +tuples_type_compat.py:184:50 - error: Type "tuple[str, str]" is not assignable to declared type "tuple[str, str, str, *tuple[str, ...]]" +  "tuple[str, str]" is not assignable to "tuple[str, str, str, *tuple[str, ...]]"     Tuple size mismatch; expected 3 or more but received 2 (reportAssignmentType) -tuples_type_compat.py:175:50 - error: Expression of type "tuple[str, str]" is incompatible with declared type "tuple[*tuple[str, ...], str, str, str]" -  "tuple[str, str]" is incompatible with "tuple[*tuple[str, ...], str, str, str]" +tuples_type_compat.py:188:50 - error: Type "tuple[str, str]" is not assignable to declared type "tuple[*tuple[str, ...], str, str, str]" +  "tuple[str, str]" is not assignable to "tuple[*tuple[str, ...], str, str, str]"     Tuple size mismatch; expected 3 or more but received 2 (reportAssignmentType) """ conformance_automated = "Pass" diff --git a/conformance/results/pyright/tuples_type_form.toml b/conformance/results/pyright/tuples_type_form.toml index 827bb138d..ca0d3792f 100644 --- a/conformance/results/pyright/tuples_type_form.toml +++ b/conformance/results/pyright/tuples_type_form.toml @@ -1,24 +1,24 @@ conformant = "Pass" output = """ -tuples_type_form.py:12:6 - error: Expression of type "tuple[Literal[1], Literal[2]]" is incompatible with declared type "tuple[int]" -  "tuple[Literal[1], Literal[2]]" is incompatible with "tuple[int]" +tuples_type_form.py:12:6 - error: Type "tuple[Literal[1], Literal[2]]" is not assignable to declared type "tuple[int]" +  "tuple[Literal[1], Literal[2]]" is not assignable to "tuple[int]"     Tuple size mismatch; expected 1 but received 2 (reportAssignmentType) -tuples_type_form.py:14:6 - error: Expression of type "tuple[Literal[1]]" is incompatible with declared type "tuple[int, int]" -  "tuple[Literal[1]]" is incompatible with "tuple[int, int]" +tuples_type_form.py:14:6 - error: Type "tuple[Literal[1]]" is not assignable to declared type "tuple[int, int]" +  "tuple[Literal[1]]" is not assignable to "tuple[int, int]"     Tuple size mismatch; expected 2 but received 1 (reportAssignmentType) -tuples_type_form.py:15:10 - error: Expression of type "tuple[Literal[1], Literal['']]" is incompatible with declared type "tuple[int, int]" -  "Literal['']" is incompatible with "int" (reportAssignmentType) -tuples_type_form.py:25:7 - error: Expression of type "tuple[Literal[1]]" is incompatible with declared type "tuple[()]" -  "tuple[Literal[1]]" is incompatible with "tuple[()]" +tuples_type_form.py:15:10 - error: Type "tuple[Literal[1], Literal['']]" is not assignable to declared type "tuple[int, int]" +  "Literal['']" is not assignable to "int" (reportAssignmentType) +tuples_type_form.py:25:7 - error: Type "tuple[Literal[1]]" is not assignable to declared type "tuple[()]" +  "tuple[Literal[1]]" is not assignable to "tuple[()]"     Tuple size mismatch; expected 0 but received 1 (reportAssignmentType) -tuples_type_form.py:36:17 - error: Expression of type "tuple[Literal[1], Literal[2], Literal[3], Literal['']]" is incompatible with declared type "tuple[int, ...]" -  "Literal['']" is incompatible with "int" (reportAssignmentType) -tuples_type_form.py:40:22 - error: "..." is allowed only as the second of two arguments -tuples_type_form.py:41:12 - error: "..." is allowed only as the second of two arguments -tuples_type_form.py:42:12 - error: "..." is allowed only as the second of two arguments -tuples_type_form.py:43:17 - error: "..." is allowed only as the second of two arguments -tuples_type_form.py:44:25 - error: "..." cannot be used with an unpacked TypeVarTuple or tuple -tuples_type_form.py:45:30 - error: "..." cannot be used with an unpacked TypeVarTuple or tuple +tuples_type_form.py:36:17 - error: Type "tuple[Literal[1], Literal[2], Literal[3], Literal['']]" is not assignable to declared type "tuple[int, ...]" +  "Literal['']" is not assignable to "int" (reportAssignmentType) +tuples_type_form.py:40:22 - error: "..." is allowed only as the second of two arguments (reportInvalidTypeForm) +tuples_type_form.py:41:12 - error: "..." is allowed only as the second of two arguments (reportInvalidTypeForm) +tuples_type_form.py:42:12 - error: "..." is allowed only as the second of two arguments (reportInvalidTypeForm) +tuples_type_form.py:43:17 - error: "..." is allowed only as the second of two arguments (reportInvalidTypeForm) +tuples_type_form.py:44:25 - error: "..." cannot be used with an unpacked TypeVarTuple or tuple (reportInvalidTypeForm) +tuples_type_form.py:45:30 - error: "..." cannot be used with an unpacked TypeVarTuple or tuple (reportInvalidTypeForm) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/tuples_unpacked.toml b/conformance/results/pyright/tuples_unpacked.toml index 71786b74a..d0bf64302 100644 --- a/conformance/results/pyright/tuples_unpacked.toml +++ b/conformance/results/pyright/tuples_unpacked.toml @@ -1,10 +1,10 @@ conformant = "Pass" output = """ -tuples_unpacked.py:40:30 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple -tuples_unpacked.py:41:43 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple -tuples_unpacked.py:51:34 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple -tuples_unpacked.py:59:37 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple -tuples_unpacked.py:61:50 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple +tuples_unpacked.py:40:30 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple (reportInvalidTypeForm) +tuples_unpacked.py:41:43 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple (reportInvalidTypeForm) +tuples_unpacked.py:51:34 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple (reportInvalidTypeForm) +tuples_unpacked.py:59:37 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple (reportInvalidTypeForm) +tuples_unpacked.py:61:50 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple (reportInvalidTypeForm) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/typeddicts_alt_syntax.toml b/conformance/results/pyright/typeddicts_alt_syntax.toml index ed85c45e0..8137309ea 100644 --- a/conformance/results/pyright/typeddicts_alt_syntax.toml +++ b/conformance/results/pyright/typeddicts_alt_syntax.toml @@ -4,8 +4,8 @@ typeddicts_alt_syntax.py:23:17 - error: Expected dict or keyword parameter as se typeddicts_alt_syntax.py:27:45 - error: Expected string literal for dictionary entry name (reportGeneralTypeIssues) typeddicts_alt_syntax.py:31:1 - error: TypedDict must be assigned to a variable named "WrongName" (reportGeneralTypeIssues) typeddicts_alt_syntax.py:35:78 - error: Extra TypedDict arguments not supported (reportCallIssue) -typeddicts_alt_syntax.py:45:43 - error: Expression of type "dict[str, str]" is incompatible with declared type "Movie2" -  "Literal['']" is incompatible with "int" (reportAssignmentType) +typeddicts_alt_syntax.py:45:43 - error: Type "dict[str, str]" is not assignable to declared type "Movie2" +  "Literal['']" is not assignable to "int" (reportAssignmentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/typeddicts_class_syntax.toml b/conformance/results/pyright/typeddicts_class_syntax.toml index 4c4ddb5d8..a3e919ddc 100644 --- a/conformance/results/pyright/typeddicts_class_syntax.toml +++ b/conformance/results/pyright/typeddicts_class_syntax.toml @@ -1,10 +1,11 @@ -conformant = "Pass" output = """ -typeddicts_class_syntax.py:29:5 - error: TypedDict classes can contain only type annotations (reportGeneralTypeIssues) -typeddicts_class_syntax.py:33:5 - error: TypedDict classes can contain only type annotations (reportGeneralTypeIssues) -typeddicts_class_syntax.py:38:5 - error: TypedDict classes can contain only type annotations (reportGeneralTypeIssues) -typeddicts_class_syntax.py:44:32 - error: TypedDict does not support __init_subclass__ parameter "metaclass" -typeddicts_class_syntax.py:49:32 - error: TypedDict does not support __init_subclass__ parameter "other" +typeddicts_class_syntax.py:30:5 - error: TypedDict classes can contain only type annotations (reportGeneralTypeIssues) +typeddicts_class_syntax.py:34:5 - error: TypedDict classes can contain only type annotations (reportGeneralTypeIssues) +typeddicts_class_syntax.py:39:5 - error: TypedDict classes can contain only type annotations (reportGeneralTypeIssues) +typeddicts_class_syntax.py:49:32 - error: TypedDict does not support __init_subclass__ parameter "metaclass" (reportGeneralTypeIssues) +typeddicts_class_syntax.py:54:32 - error: TypedDict does not support __init_subclass__ parameter "other" (reportGeneralTypeIssues) +typeddicts_class_syntax.py:69:1 - error: No overloads for "__init__" match the provided arguments +  Argument types: (Literal[1], Literal[2], Literal[3]) (reportCallIssue) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/typeddicts_extra_items.toml b/conformance/results/pyright/typeddicts_extra_items.toml new file mode 100644 index 000000000..0eb4f16ba --- /dev/null +++ b/conformance/results/pyright/typeddicts_extra_items.toml @@ -0,0 +1,66 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_extra_items.py:15:45 - error: Type "dict[str, str | int]" is not assignable to declared type "Movie" +  "Literal[1982]" is not assignable to "bool" (reportAssignmentType) +typeddicts_extra_items.py:22:55 - error: Type "dict[str, str | int]" is not assignable to declared type "MovieFunctional" +  "Literal[1982]" is not assignable to "bool" (reportAssignmentType) +typeddicts_extra_items.py:39:54 - error: Type "dict[str, str | None]" is not assignable to declared type "InheritedMovie" +  "None" is not assignable to "int" (reportAssignmentType) +typeddicts_extra_items.py:49:35 - error: Expected "closed" parameter to have a value of True or False (reportGeneralTypeIssues) +typeddicts_extra_items.py:67:40 - error: Base class "ClosedBase" is not an open TypedDict; closed=False is not allowed (reportGeneralTypeIssues) +typeddicts_extra_items.py:73:44 - error: Base class "ExtraItemsBase" is not an open TypedDict; closed=False is not allowed (reportGeneralTypeIssues) +typeddicts_extra_items.py:91:7 - error: Base class "MovieA" is a TypedDict that limits the type of extra items to type "Never" +  Cannot add item "age" (reportIncompatibleVariableOverride) +typeddicts_extra_items.py:94:7 - error: Base class "MovieB" is a TypedDict that limits the type of extra items to type "Never" +  Cannot add item "age" (reportIncompatibleVariableOverride) +typeddicts_extra_items.py:109:7 - error: Base class "ExtraItemsBase" is a TypedDict that limits the type of extra items to type "int" +  Cannot add item "extra_items" with type "Never" (reportIncompatibleVariableOverride) +typeddicts_extra_items.py:114:50 - error: "Required" is not allowed in this context (reportInvalidTypeForm) +typeddicts_extra_items.py:117:57 - error: "NotRequired" is not allowed in this context (reportInvalidTypeForm) +typeddicts_extra_items.py:128:9 - error: Could not delete item in TypedDict +  "name" is a required key and cannot be deleted (reportGeneralTypeIssues) +typeddicts_extra_items.py:143:48 - error: No parameter named "year" (reportCallIssue) +typeddicts_extra_items.py:174:7 - error: Base class "Parent" is a TypedDict that limits the type of extra items to type "int | None" +  Cannot add item "extra_items" with type "int" (reportIncompatibleVariableOverride) +typeddicts_extra_items.py:184:7 - error: Base class "MovieBase2" is a TypedDict that limits the type of extra items to type "int | None" +  Cannot add item "year" because it must be NotRequired (reportIncompatibleVariableOverride) +typeddicts_extra_items.py:187:7 - error: Base class "MovieBase2" is a TypedDict that limits the type of extra items to type "int | None" +  Cannot add item "year" with type "int" (reportIncompatibleVariableOverride) +typeddicts_extra_items.py:196:7 - error: Base class "BookBase" is a TypedDict that limits the type of extra items to type "int | None" +  Cannot add item "publisher" with type "str" (reportIncompatibleVariableOverride) +typeddicts_extra_items.py:215:22 - error: Type "MovieDetails" is not assignable to declared type "MovieBase2" +  Type of "year" is incompatible with type of "extra_items" in "MovieBase2" +    Type "int" is not assignable to type "int | None" +      "int" is not assignable to "None" (reportAssignmentType) +typeddicts_extra_items.py:222:22 - error: Type "MovieWithYear2" is not assignable to declared type "MovieBase2" +  "year" is not required in "MovieBase2" (reportAssignmentType) +typeddicts_extra_items.py:242:19 - error: Type "MovieDetails5" is not assignable to declared type "MovieSI" +  Type of "actors" is incompatible with type of "extra_items" in "MovieSI" +    Type "list[str]" is not assignable to type "str | int" +      "list[str]" is not assignable to "str" +      "list[str]" is not assignable to "int" (reportAssignmentType) +typeddicts_extra_items.py:256:13 - error: Type "MovieExtraStr" is not assignable to declared type "MovieExtraInt" +  Type of "extra_items" is incompatible with type of "extra_items" in "MovieExtraStr" +    "str" is not assignable to "int" (reportAssignmentType) +typeddicts_extra_items.py:257:13 - error: Type "MovieExtraInt" is not assignable to declared type "MovieExtraStr" +  Type of "extra_items" is incompatible with type of "extra_items" in "MovieExtraInt" +    "int" is not assignable to "str" (reportAssignmentType) +typeddicts_extra_items.py:268:14 - error: Type "MovieNotClosed" is not assignable to declared type "MovieExtraInt" +  Type of "extra_items" is incompatible with type of "extra_items" in "MovieNotClosed" +    "object" is not assignable to "int" (reportAssignmentType) +typeddicts_extra_items.py:278:1 - error: No overloads for "__init__" match the provided arguments +  Argument types: (Literal['No Country for Old Men'], Literal[2007]) (reportCallIssue) +typeddicts_extra_items.py:285:52 - error: Argument of type "Literal['English']" cannot be assigned to parameter "language" of type "int" in function "__init__" +  "Literal['English']" is not assignable to "int" (reportArgumentType) +typeddicts_extra_items.py:293:1 - error: No overloads for "__init__" match the provided arguments +  Argument types: (Literal['No Country for Old Men'], Literal[2007]) (reportCallIssue) +typeddicts_extra_items.py:303:34 - error: Type "MovieExtraInt" is not assignable to declared type "Mapping[str, int]" +  "Mapping[str, str | int]" is not assignable to "Mapping[str, int]" +    Type parameter "_VT_co@Mapping" is covariant, but "str | int" is not a subtype of "int" +      Type "str | int" is not assignable to type "int" +        "str" is not assignable to "int" (reportAssignmentType) +typeddicts_extra_items.py:352:25 - error: Type "dict[str, int]" is not assignable to declared type "IntDict" +  "dict[str, int]" is not assignable to "IntDict" (reportAssignmentType) +""" diff --git a/conformance/results/pyright/typeddicts_inheritance.toml b/conformance/results/pyright/typeddicts_inheritance.toml index 294dce2c7..a827b06ca 100644 --- a/conformance/results/pyright/typeddicts_inheritance.toml +++ b/conformance/results/pyright/typeddicts_inheritance.toml @@ -1,7 +1,7 @@ conformant = "Pass" output = """ typeddicts_inheritance.py:44:7 - error: All base classes for TypedDict classes must also be TypedDict classes -  Class "NonTypedDict" is not a TypedDict +  Class "NonTypedDict" is not a TypedDict (reportGeneralTypeIssues) typeddicts_inheritance.py:55:4 - error: "x" overrides symbol of same name in class "X1"   Variable is mutable so its type is invariant     Override type "int" is not the same as base type "str" (reportIncompatibleVariableOverride) diff --git a/conformance/results/pyright/typeddicts_operations.toml b/conformance/results/pyright/typeddicts_operations.toml index f98bba88d..9eae54519 100644 --- a/conformance/results/pyright/typeddicts_operations.toml +++ b/conformance/results/pyright/typeddicts_operations.toml @@ -1,20 +1,20 @@ conformant = "Pass" output = """ typeddicts_operations.py:22:1 - error: Could not assign item in TypedDict -  "Literal[1982]" is incompatible with "str" (reportGeneralTypeIssues) +  "Literal[1982]" is not assignable to "str" (reportGeneralTypeIssues) typeddicts_operations.py:23:1 - error: Could not assign item in TypedDict -  "Literal['']" is incompatible with "int" (reportGeneralTypeIssues) +  "Literal['']" is not assignable to "int" (reportGeneralTypeIssues) typeddicts_operations.py:24:1 - error: Could not assign item in TypedDict   "other" is not a defined key in "Movie" (reportGeneralTypeIssues) typeddicts_operations.py:26:7 - error: Could not access item in TypedDict   "other" is not a defined key in "Movie" (reportGeneralTypeIssues) -typeddicts_operations.py:28:9 - error: Expression of type "dict[str, str]" is incompatible with declared type "Movie" +typeddicts_operations.py:28:9 - error: Type "dict[str, str]" is not assignable to declared type "Movie"   "year" is required in "Movie" (reportAssignmentType) -typeddicts_operations.py:29:42 - error: Expression of type "dict[str, str | float]" is incompatible with declared type "Movie" -  "float" is incompatible with "int" (reportAssignmentType) -typeddicts_operations.py:32:36 - error: Expression of type "dict[str, str | int]" is incompatible with declared type "Movie" +typeddicts_operations.py:29:42 - error: Type "dict[str, str | float]" is not assignable to declared type "Movie" +  "float" is not assignable to "int" (reportAssignmentType) +typeddicts_operations.py:32:36 - error: Type "dict[str, str | int]" is not assignable to declared type "Movie"   "other" is an undefined item in type "Movie" (reportAssignmentType) -typeddicts_operations.py:37:20 - error: Expression of type "dict[str, str | int]" is incompatible with declared type "Movie" (reportAssignmentType) +typeddicts_operations.py:37:20 - error: Type "dict[str, str | int]" is not assignable to declared type "Movie" (reportAssignmentType) typeddicts_operations.py:47:7 - error: Cannot access attribute "clear" for class "Movie"   Attribute "clear" is unknown (reportAttributeAccessIssue) typeddicts_operations.py:49:5 - error: Could not delete item in TypedDict diff --git a/conformance/results/pyright/typeddicts_readonly_consistency.toml b/conformance/results/pyright/typeddicts_readonly_consistency.toml index c295c4779..bb53197cc 100644 --- a/conformance/results/pyright/typeddicts_readonly_consistency.toml +++ b/conformance/results/pyright/typeddicts_readonly_consistency.toml @@ -1,20 +1,20 @@ conformant = "Pass" output = """ -typeddicts_readonly_consistency.py:37:14 - error: Expression of type "A1" is incompatible with declared type "B1" +typeddicts_readonly_consistency.py:37:14 - error: Type "A1" is not assignable to declared type "B1"   "y" is missing from "A1" (reportAssignmentType) -typeddicts_readonly_consistency.py:38:14 - error: Expression of type "C1" is incompatible with declared type "B1" +typeddicts_readonly_consistency.py:38:14 - error: Type "C1" is not assignable to declared type "B1"   "y" is not read-only in "B1" (reportAssignmentType) -typeddicts_readonly_consistency.py:40:14 - error: Expression of type "A1" is incompatible with declared type "C1" +typeddicts_readonly_consistency.py:40:14 - error: Type "A1" is not assignable to declared type "C1"   "y" is an incompatible type -    "object" is incompatible with "str" (reportAssignmentType) -typeddicts_readonly_consistency.py:81:14 - error: Expression of type "A2" is incompatible with declared type "B2" +    "object" is not assignable to "str" (reportAssignmentType) +typeddicts_readonly_consistency.py:81:14 - error: Type "A2" is not assignable to declared type "B2"   "x" is not read-only in "B2" (reportAssignmentType) -typeddicts_readonly_consistency.py:82:14 - error: Expression of type "C2" is incompatible with declared type "B2" +typeddicts_readonly_consistency.py:82:14 - error: Type "C2" is not assignable to declared type "B2"   "x" is not required in "B2" (reportAssignmentType) -typeddicts_readonly_consistency.py:84:14 - error: Expression of type "A2" is incompatible with declared type "C2" +typeddicts_readonly_consistency.py:84:14 - error: Type "A2" is not assignable to declared type "C2"   "x" is required in "C2"   "x" is not read-only in "C2" (reportAssignmentType) -typeddicts_readonly_consistency.py:85:14 - error: Expression of type "B2" is incompatible with declared type "C2" +typeddicts_readonly_consistency.py:85:14 - error: Type "B2" is not assignable to declared type "C2"   "x" is required in "C2" (reportAssignmentType) """ conformance_automated = "Pass" diff --git a/conformance/results/pyright/typeddicts_readonly_inheritance.toml b/conformance/results/pyright/typeddicts_readonly_inheritance.toml index a77014bc5..d9e432b89 100644 --- a/conformance/results/pyright/typeddicts_readonly_inheritance.toml +++ b/conformance/results/pyright/typeddicts_readonly_inheritance.toml @@ -3,16 +3,16 @@ output = """ typeddicts_readonly_inheritance.py:36:1 - error: Could not assign item in TypedDict   "name" is a read-only key in "Album2" (reportTypedDictNotRequiredAccess) typeddicts_readonly_inheritance.py:50:5 - error: "alt" overrides symbol of same name in class "AlbumCollection" -  "list[str]" is incompatible with "list[str | int]" +  "list[str]" is not assignable to "list[str | int]"     Type parameter "_T@list" is invariant, but "str" is not the same as "str | int"     Consider switching from "list" to "Sequence" which is covariant (reportIncompatibleVariableOverride) -typeddicts_readonly_inheritance.py:65:19 - error: Expression of type "dict[Any, Any]" is incompatible with declared type "RequiredName" +typeddicts_readonly_inheritance.py:65:19 - error: Type "dict[Any, Any]" is not assignable to declared type "RequiredName"   "name" is required in "RequiredName" (reportAssignmentType) typeddicts_readonly_inheritance.py:82:1 - error: Could not assign item in TypedDict -  "Literal[3]" is incompatible with "str" (reportGeneralTypeIssues) -typeddicts_readonly_inheritance.py:83:15 - error: Expression of type "dict[str, int]" is incompatible with declared type "User" -  "Literal[3]" is incompatible with "str" (reportAssignmentType) -typeddicts_readonly_inheritance.py:84:5 - error: Expression of type "dict[Any, Any]" is incompatible with declared type "User" +  "Literal[3]" is not assignable to "str" (reportGeneralTypeIssues) +typeddicts_readonly_inheritance.py:83:15 - error: Type "dict[str, int]" is not assignable to declared type "User" +  "Literal[3]" is not assignable to "str" (reportAssignmentType) +typeddicts_readonly_inheritance.py:84:5 - error: Type "dict[Any, Any]" is not assignable to declared type "User"   "ident" is required in "User" (reportAssignmentType) typeddicts_readonly_inheritance.py:94:5 - error: TypedDict item "a" cannot be redefined as ReadOnly (reportGeneralTypeIssues) typeddicts_readonly_inheritance.py:98:5 - error: TypedDict item "a" cannot be redefined as NotRequired (reportGeneralTypeIssues) diff --git a/conformance/results/pyright/typeddicts_readonly_kwargs.toml b/conformance/results/pyright/typeddicts_readonly_kwargs.toml index 6ef10226e..4a2e2d220 100644 --- a/conformance/results/pyright/typeddicts_readonly_kwargs.toml +++ b/conformance/results/pyright/typeddicts_readonly_kwargs.toml @@ -1,7 +1,7 @@ conformant = "Pass" output = """ typeddicts_readonly_kwargs.py:33:5 - error: Could not assign item in TypedDict -  "key1" is a read-only key in "*ReadOnlyArgs" (reportTypedDictNotRequiredAccess) +  "key1" is a read-only key in "ReadOnlyArgs" (reportTypedDictNotRequiredAccess) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/typeddicts_readonly_update.toml b/conformance/results/pyright/typeddicts_readonly_update.toml index 405e1acca..650894094 100644 --- a/conformance/results/pyright/typeddicts_readonly_update.toml +++ b/conformance/results/pyright/typeddicts_readonly_update.toml @@ -3,7 +3,7 @@ output = """ typeddicts_readonly_update.py:23:1 - error: No overloads for "update" match the provided arguments (reportCallIssue) typeddicts_readonly_update.py:23:11 - error: Argument of type "A" cannot be assigned to parameter "__m" of type "Partial[A]" in function "update"   "x" is an incompatible type -    Type "int" is incompatible with type "Never" (reportArgumentType) +    Type "int" is not assignable to type "Never" (reportArgumentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/typeddicts_required.toml b/conformance/results/pyright/typeddicts_required.toml index 874099f4d..25b433e41 100644 --- a/conformance/results/pyright/typeddicts_required.toml +++ b/conformance/results/pyright/typeddicts_required.toml @@ -1,9 +1,9 @@ conformant = "Pass" output = """ -typeddicts_required.py:12:8 - error: "Required" is not allowed in this context -typeddicts_required.py:16:8 - error: "NotRequired" is not allowed in this context -typeddicts_required.py:59:8 - error: "Required" is not allowed in this context -typeddicts_required.py:60:8 - error: "Required" is not allowed in this context +typeddicts_required.py:12:8 - error: "Required" is not allowed in this context (reportInvalidTypeForm) +typeddicts_required.py:16:8 - error: "NotRequired" is not allowed in this context (reportInvalidTypeForm) +typeddicts_required.py:60:8 - error: "Required" is not allowed in this context (reportInvalidTypeForm) +typeddicts_required.py:61:8 - error: "Required" is not allowed in this context (reportInvalidTypeForm) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/typeddicts_type_consistency.toml b/conformance/results/pyright/typeddicts_type_consistency.toml index dcda72179..328b8b937 100644 --- a/conformance/results/pyright/typeddicts_type_consistency.toml +++ b/conformance/results/pyright/typeddicts_type_consistency.toml @@ -1,27 +1,27 @@ conformant = "Pass" output = """ -typeddicts_type_consistency.py:21:10 - error: Expression of type "B1" is incompatible with declared type "A1" +typeddicts_type_consistency.py:21:10 - error: Type "B1" is not assignable to declared type "A1"   "x" is an incompatible type -    Type "int" is incompatible with type "int | None" -      "int" is incompatible with "None" (reportAssignmentType) -typeddicts_type_consistency.py:38:10 - error: Expression of type "B2" is incompatible with declared type "A2" +    Type "int" is not assignable to type "int | None" +      "int" is not assignable to "None" (reportAssignmentType) +typeddicts_type_consistency.py:38:10 - error: Type "B2" is not assignable to declared type "A2"   "x" is not required in "A2" (reportAssignmentType) -typeddicts_type_consistency.py:65:6 - error: Expression of type "A3" is incompatible with declared type "B3" +typeddicts_type_consistency.py:65:6 - error: Type "A3" is not assignable to declared type "B3"   "y" is missing from "A3" (reportAssignmentType) -typeddicts_type_consistency.py:69:21 - error: Expression of type "dict[str, int]" is incompatible with declared type "A3" +typeddicts_type_consistency.py:69:21 - error: Type "dict[str, int]" is not assignable to declared type "A3"   "y" is an undefined item in type "A3" (reportAssignmentType) -typeddicts_type_consistency.py:76:22 - error: Expression of type "B3" is incompatible with declared type "dict[str, int]" -  "B3" is incompatible with "dict[str, int]" (reportAssignmentType) -typeddicts_type_consistency.py:77:25 - error: Expression of type "B3" is incompatible with declared type "dict[str, object]" -  "B3" is incompatible with "dict[str, object]" (reportAssignmentType) -typeddicts_type_consistency.py:78:22 - error: Expression of type "B3" is incompatible with declared type "dict[Any, Any]" -  "B3" is incompatible with "dict[Any, Any]" (reportAssignmentType) -typeddicts_type_consistency.py:82:25 - error: Expression of type "B3" is incompatible with declared type "Mapping[str, int]" -  "B3" is incompatible with "Mapping[str, int]" +typeddicts_type_consistency.py:76:22 - error: Type "B3" is not assignable to declared type "dict[str, int]" +  "B3" is not assignable to "dict[str, int]" (reportAssignmentType) +typeddicts_type_consistency.py:77:25 - error: Type "B3" is not assignable to declared type "dict[str, object]" +  "B3" is not assignable to "dict[str, object]" (reportAssignmentType) +typeddicts_type_consistency.py:78:22 - error: Type "B3" is not assignable to declared type "dict[Any, Any]" +  "B3" is not assignable to "dict[Any, Any]" (reportAssignmentType) +typeddicts_type_consistency.py:82:25 - error: Type "B3" is not assignable to declared type "Mapping[str, int]" +  "B3" is not assignable to "Mapping[str, int]"     Type parameter "_VT_co@Mapping" is covariant, but "object" is not a subtype of "int" -      "object" is incompatible with "int" (reportAssignmentType) -typeddicts_type_consistency.py:126:56 - error: Expression of type "dict[str, dict[str, dict[str, int]]]" is incompatible with declared type "Outer1" -  "Literal[1]" is incompatible with "str" (reportAssignmentType) +      "object" is not assignable to "int" (reportAssignmentType) +typeddicts_type_consistency.py:126:56 - error: Type "dict[str, dict[str, dict[str, int]]]" is not assignable to declared type "Outer1" +  "Literal[1]" is not assignable to "str" (reportAssignmentType) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/typeddicts_usage.toml b/conformance/results/pyright/typeddicts_usage.toml index ee77079b0..ce846f1dd 100644 --- a/conformance/results/pyright/typeddicts_usage.toml +++ b/conformance/results/pyright/typeddicts_usage.toml @@ -3,12 +3,12 @@ output = """ typeddicts_usage.py:23:1 - error: Could not assign item in TypedDict   "director" is not a defined key in "Movie" (reportGeneralTypeIssues) typeddicts_usage.py:24:1 - error: Could not assign item in TypedDict -  "Literal['1982']" is incompatible with "int" (reportGeneralTypeIssues) -typeddicts_usage.py:28:18 - error: Expression of type "dict[str, str | int]" is incompatible with declared type "Movie" +  "Literal['1982']" is not assignable to "int" (reportGeneralTypeIssues) +typeddicts_usage.py:28:18 - error: Type "dict[str, str | int]" is not assignable to declared type "Movie"   "title" is an undefined item in type "Movie" (reportAssignmentType) typeddicts_usage.py:35:22 - error: Second argument to "isinstance" must be a class or tuple of classes   TypedDict class not allowed for instance or class checks (reportArgumentType) -typeddicts_usage.py:40:24 - error: "TypedDict" cannot be used in this context +typeddicts_usage.py:40:24 - error: "TypedDict" cannot be used in this context (reportInvalidTypeForm) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/typeforms_typeform.toml b/conformance/results/pyright/typeforms_typeform.toml new file mode 100644 index 000000000..71610b09b --- /dev/null +++ b/conformance/results/pyright/typeforms_typeform.toml @@ -0,0 +1,38 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeforms_typeform.py:23:30 - error: Type "UnionType" is not assignable to declared type "TypeForm[str | None]" +  "UnionType" is not assignable to "TypeForm[str | None]" (reportAssignmentType) +typeforms_typeform.py:24:30 - error: Type "type[list[str | None]]" is not assignable to declared type "TypeForm[str | None]" +  Type "list[str | None]" is not assignable to type "str | None" +    "list[str | None]" is not assignable to "str" +    "list[str | None]" is not assignable to "None" (reportAssignmentType) +typeforms_typeform.py:59:7 - error: Argument of type "Literal['not a type']" cannot be assigned to parameter "x" of type "TypeForm[Any]" in function "func1" +  "Literal['not a type']" is not assignable to "TypeForm[Any]" (reportArgumentType) +typeforms_typeform.py:67:18 - error: Type "tuple[()]" is not assignable to declared type "TypeForm[Any]" +  "tuple[()]" is not assignable to "TypeForm[Any]" (reportAssignmentType) +typeforms_typeform.py:68:18 - error: Type "tuple[Literal[1], Literal[2]]" is not assignable to declared type "TypeForm[Any]" +  "tuple[Literal[1], Literal[2]]" is not assignable to "TypeForm[Any]" (reportAssignmentType) +typeforms_typeform.py:69:18 - error: Type "Literal[1]" is not assignable to declared type "TypeForm[Any]" +  "Literal[1]" is not assignable to "TypeForm[Any]" (reportAssignmentType) +typeforms_typeform.py:70:18 - error: "Self" is not valid in this context (reportGeneralTypeIssues) +typeforms_typeform.py:71:18 - error: "ClassVar" is not allowed in this context (reportInvalidTypeForm) +typeforms_typeform.py:72:18 - error: "Final" is not allowed in this context (reportInvalidTypeForm) +typeforms_typeform.py:73:25 - error: Type variable "Ts" has no meaning in this context (reportGeneralTypeIssues) +typeforms_typeform.py:74:18 - error: Expected one type argument after "Optional" (reportInvalidTypeForm) +typeforms_typeform.py:75:18 - error: Type "Literal['int + str']" is not assignable to declared type "TypeForm[Any]" +  "Literal['int + str']" is not assignable to "TypeForm[Any]" (reportAssignmentType) +typeforms_typeform.py:86:16 - error: type() call should not be used in type expression +  Use type[T] instead (reportInvalidTypeForm) +typeforms_typeform.py:86:16 - error: Call expression not allowed in type expression (reportInvalidTypeForm) +typeforms_typeform.py:88:15 - error: type() call should not be used in type expression +  Use type[T] instead (reportInvalidTypeForm) +typeforms_typeform.py:88:15 - error: Call expression not allowed in type expression (reportInvalidTypeForm) +typeforms_typeform.py:98:21 - error: Type "TypeForm[int]" is not assignable to declared type "TypeForm[str]" +  "TypeForm[int]" is not assignable to "TypeForm[str]" +    Type parameter "T@TypeForm" is covariant, but "int" is not a subtype of "str" +      "int" is not assignable to "str" (reportAssignmentType) +typeforms_typeform.py:108:21 - error: Type "type[int]" is not assignable to declared type "TypeForm[str]" +  "int" is not assignable to "str" (reportAssignmentType) +""" diff --git a/conformance/results/pyright/version.toml b/conformance/results/pyright/version.toml index 6302edbf3..0bcd901b3 100644 --- a/conformance/results/pyright/version.toml +++ b/conformance/results/pyright/version.toml @@ -1,2 +1 @@ -version = "pyright 1.1.364" -test_duration = 1.4 +version = "pyright 1.1.414" diff --git a/conformance/results/pytype/aliases_explicit.toml b/conformance/results/pytype/aliases_explicit.toml deleted file mode 100644 index 48f40da98..000000000 --- a/conformance/results/pytype/aliases_explicit.toml +++ /dev/null @@ -1,41 +0,0 @@ -conformant = "Partial" -notes = """ -Incorrectly reports error for type alias defined with ParamSpec. -Does not report invalid specialization of generic type alias with bound TypeVar. -Incorrectly evaluates generic type alias with ParamSpec with missing type argument. -Does not report some illegal annotation forms as invalid type aliases. -Does not report invalid specialization of already-specialized generic type alias. -""" -output = """ -File "aliases_explicit.py", line 41, in : Invalid type annotation '[str, str]' [invalid-annotation] -File "aliases_explicit.py", line 41, in : Invalid type annotation 'Callable[Concatenate[int, P], R][[str, str], None]' [invalid-annotation] -File "aliases_explicit.py", line 57, in good_type_aliases: Callable[Concatenate, Any] [assert-type] -File "aliases_explicit.py", line 60, in good_type_aliases: Callable[[Any], None] [assert-type] -File "aliases_explicit.py", line 67, in : Invalid type annotation 'Optional[int][int]' [invalid-annotation] -File "aliases_explicit.py", line 68, in : Invalid type annotation 'List[Optional[int]][int]' [invalid-annotation] -File "aliases_explicit.py", line 69, in : Invalid type annotation 'List[T][int, int]' [invalid-annotation] -File "aliases_explicit.py", line 70, in : Invalid type annotation 'Callable[[int, T], T][int, int]' [invalid-annotation] -File "aliases_explicit.py", line 71, in : Invalid type annotation 'Callable[Concatenate[int, P], R][int, int]' [invalid-annotation] -File "aliases_explicit.py", line 80, in : Invalid type annotation '[int, str]' for BadTypeAlias2 [invalid-annotation] -File "aliases_explicit.py", line 81, in : Invalid type annotation '((int, str),)' for BadTypeAlias3 [invalid-annotation] -File "aliases_explicit.py", line 82, in : Invalid type annotation '' for BadTypeAlias4 [invalid-annotation] -File "aliases_explicit.py", line 83, in : Invalid type annotation "{'a': 'b'}" for BadTypeAlias5 [invalid-annotation] -File "aliases_explicit.py", line 87, in : Invalid type annotation '3' for BadTypeAlias9 [invalid-annotation] -File "aliases_explicit.py", line 88, in : Invalid type annotation 'True' for BadTypeAlias10 [invalid-annotation] -File "aliases_explicit.py", line 89, in : Invalid type annotation '1' for BadTypeAlias11 [invalid-annotation] -File "aliases_explicit.py", line 91, in : Invalid type annotation '' for BadTypeAlias13 [invalid-annotation] -File "aliases_explicit.py", line 102, in : Invalid type annotation 'Union[list, set][int]' [invalid-annotation] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 79: Expected 1 errors -Line 84: Expected 1 errors -Line 85: Expected 1 errors -Line 86: Expected 1 errors -Line 90: Expected 1 errors -Line 100: Expected 1 errors -Line 101: Expected 1 errors -Line 41: Unexpected errors ['File "aliases_explicit.py", line 41, in : Invalid type annotation \\'[str, str]\\' [invalid-annotation]', 'File "aliases_explicit.py", line 41, in : Invalid type annotation \\'Callable[Concatenate[int, P], R][[str, str], None]\\' [invalid-annotation]'] -Line 57: Unexpected errors ['File "aliases_explicit.py", line 57, in good_type_aliases: Callable[Concatenate, Any] [assert-type]'] -Line 60: Unexpected errors ['File "aliases_explicit.py", line 60, in good_type_aliases: Callable[[Any], None] [assert-type]'] -""" diff --git a/conformance/results/pytype/aliases_implicit.toml b/conformance/results/pytype/aliases_implicit.toml deleted file mode 100644 index 26f6b5aa2..000000000 --- a/conformance/results/pytype/aliases_implicit.toml +++ /dev/null @@ -1,50 +0,0 @@ -conformant = "Partial" -notes = """ -Incorrectly reports error for type alias defined with ParamSpec. -Does not report invalid specialization of generic type alias with bound TypeVar. -Incorrectly evaluates generic type alias with ParamSpec with missing type argument. -Allows some illegal annotation forms to be interpreted as valid type aliases. -Does not report invalid specialization of already-specialized generic type alias. -""" -output = """ -File "aliases_implicit.py", line 54, in : Invalid type annotation '[str, str]' [invalid-annotation] -File "aliases_implicit.py", line 54, in : Invalid type annotation 'Callable[Concatenate[int, P], R][[str, str], None]' [invalid-annotation] -File "aliases_implicit.py", line 68, in good_type_aliases: Callable[Concatenate, Any] [assert-type] -File "aliases_implicit.py", line 72, in good_type_aliases: Callable[[Any], None] [assert-type] -File "aliases_implicit.py", line 76, in : Invalid type annotation 'Optional[int][int]' [invalid-annotation] -File "aliases_implicit.py", line 77, in : Invalid type annotation 'List[Optional[int]][int]' [invalid-annotation] -File "aliases_implicit.py", line 78, in : Invalid type annotation 'List[T][int, int]' [invalid-annotation] -File "aliases_implicit.py", line 79, in : Invalid type annotation 'Callable[[int, T], T][int, int]' [invalid-annotation] -File "aliases_implicit.py", line 80, in : Invalid type annotation 'Callable[Concatenate[int, P], R][int, int]' [invalid-annotation] -File "aliases_implicit.py", line 105, in : Invalid type annotation '[int, str]' for p2 [invalid-annotation] -File "aliases_implicit.py", line 105, in : Invalid type annotation 'True' for p10 [invalid-annotation] -File "aliases_implicit.py", line 105, in : Invalid type annotation '' for p4 [invalid-annotation] -File "aliases_implicit.py", line 105, in : Invalid type annotation '3' for p9 [invalid-annotation] -File "aliases_implicit.py", line 105, in : Invalid type annotation '1' for p11 [invalid-annotation] -File "aliases_implicit.py", line 105, in : Invalid type annotation '((int, str),)' for p3 [invalid-annotation] -File "aliases_implicit.py", line 105, in : Invalid type annotation "{'a': 'b'}" for p5 [invalid-annotation] -File "aliases_implicit.py", line 135, in : Invalid type annotation 'Union[list, set][int]' [invalid-annotation] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 81: Expected 1 errors -Line 106: Expected 1 errors -Line 107: Expected 1 errors -Line 108: Expected 1 errors -Line 109: Expected 1 errors -Line 110: Expected 1 errors -Line 111: Expected 1 errors -Line 112: Expected 1 errors -Line 113: Expected 1 errors -Line 114: Expected 1 errors -Line 115: Expected 1 errors -Line 116: Expected 1 errors -Line 117: Expected 1 errors -Line 118: Expected 1 errors -Line 119: Expected 1 errors -Line 133: Expected 1 errors -Line 54: Unexpected errors ['File "aliases_implicit.py", line 54, in : Invalid type annotation \\'[str, str]\\' [invalid-annotation]', 'File "aliases_implicit.py", line 54, in : Invalid type annotation \\'Callable[Concatenate[int, P], R][[str, str], None]\\' [invalid-annotation]'] -Line 68: Unexpected errors ['File "aliases_implicit.py", line 68, in good_type_aliases: Callable[Concatenate, Any] [assert-type]'] -Line 72: Unexpected errors ['File "aliases_implicit.py", line 72, in good_type_aliases: Callable[[Any], None] [assert-type]'] -Line 105: Unexpected errors ['File "aliases_implicit.py", line 105, in : Invalid type annotation \\'[int, str]\\' for p2 [invalid-annotation]', 'File "aliases_implicit.py", line 105, in : Invalid type annotation \\'True\\' for p10 [invalid-annotation]', 'File "aliases_implicit.py", line 105, in : Invalid type annotation \\'\\' for p4 [invalid-annotation]', 'File "aliases_implicit.py", line 105, in : Invalid type annotation \\'3\\' for p9 [invalid-annotation]', 'File "aliases_implicit.py", line 105, in : Invalid type annotation \\'1\\' for p11 [invalid-annotation]', 'File "aliases_implicit.py", line 105, in : Invalid type annotation \\'((int, str),)\\' for p3 [invalid-annotation]', 'File "aliases_implicit.py", line 105, in : Invalid type annotation "{\\'a\\': \\'b\\'}" for p5 [invalid-annotation]'] -""" diff --git a/conformance/results/pytype/aliases_newtype.toml b/conformance/results/pytype/aliases_newtype.toml deleted file mode 100644 index fc07d9bcf..000000000 --- a/conformance/results/pytype/aliases_newtype.toml +++ /dev/null @@ -1,28 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject use of NewType in `isinstance` call. -Does not reject use of NewType in class definition statement. -Does not report inconsistency between name of NewType and assigned identifier name. -Does not reject use of NewType with generic class with TypeVar. -Does not reject use of NewType with protocol class. -Does not reject use of NewType with TypedDict class. -Does not reject use of NewType with Any. -""" -output = """ -File "aliases_newtype.py", line 11, in : Function UserId.__init__ was called with the wrong arguments [wrong-arg-types] -File "aliases_newtype.py", line 12, in : Type annotation for u1 does not match type of assignment [annotation-type-mismatch] -File "aliases_newtype.py", line 38, in : class GoodNewType1 is not indexable [not-indexable] -File "aliases_newtype.py", line 60, in : Function typing.NewType expects 2 arg(s), got 3 [wrong-arg-count] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 20: Expected 1 errors -Line 23: Expected 1 errors -Line 32: Expected 1 errors -Line 44: Expected 1 errors -Line 47: Expected 1 errors -Line 49: Expected 1 errors -Line 51: Expected 1 errors -Line 58: Expected 1 errors -Line 62: Expected 1 errors -""" diff --git a/conformance/results/pytype/aliases_recursive.toml b/conformance/results/pytype/aliases_recursive.toml deleted file mode 100644 index e65418915..000000000 --- a/conformance/results/pytype/aliases_recursive.toml +++ /dev/null @@ -1,39 +0,0 @@ -conformant = "Partial" -notes = """ -Does not detect type violation for some deeply-nested types. -Does not properly handle `|` for unions in some recursive type alias definitions. -Does not detect cyclical references in recursive type alias definition. -""" -output = """ -File "aliases_recursive.py", line 19, in : Type annotation for j4 does not match type of assignment [annotation-type-mismatch] -File "aliases_recursive.py", line 20, in : Type annotation for j5 does not match type of assignment [annotation-type-mismatch] -File "aliases_recursive.py", line 38, in : Type annotation for t6 does not match type of assignment [annotation-type-mismatch] -File "aliases_recursive.py", line 39, in : Type annotation for t6 does not match type of assignment [annotation-type-mismatch] -File "aliases_recursive.py", line 50, in : Type annotation for m7 does not match type of assignment [annotation-type-mismatch] -File "aliases_recursive.py", line 51, in : Type annotation for m8 does not match type of assignment [annotation-type-mismatch] -File "aliases_recursive.py", line 58, in : unsupported operand type(s) for |: ''GenericTypeAlias1[T1]': str' and 'T1: TypeVar' [unsupported-operands] -File "aliases_recursive.py", line 59, in : Invalid type annotation 'list[str]' [invalid-annotation] -File "aliases_recursive.py", line 62, in : Invalid type annotation 'list[str]' [invalid-annotation] -File "aliases_recursive.py", line 62, in : Invalid type annotation 'GenericTypeAlias1[str]' [invalid-annotation] -File "aliases_recursive.py", line 63, in : Invalid type annotation 'list[str]' [invalid-annotation] -File "aliases_recursive.py", line 63, in : Invalid type annotation 'GenericTypeAlias1[str]' [invalid-annotation] -File "aliases_recursive.py", line 65, in : unsupported operand type(s) for |: ''GenericTypeAlias2[T1, T2]': str' and 'T1: TypeVar' [unsupported-operands] -File "aliases_recursive.py", line 67, in : Invalid type annotation 'list[str, int]' [invalid-annotation] -File "aliases_recursive.py", line 67, in : Invalid type annotation 'GenericTypeAlias2[str, int]' [invalid-annotation] -File "aliases_recursive.py", line 68, in : Invalid type annotation 'list[str, float]' [invalid-annotation] -File "aliases_recursive.py", line 68, in : Invalid type annotation 'GenericTypeAlias2[str, float]' [invalid-annotation] -File "aliases_recursive.py", line 69, in : Invalid type annotation 'list[str, int]' [invalid-annotation] -File "aliases_recursive.py", line 69, in : Invalid type annotation 'GenericTypeAlias2[str, int]' [invalid-annotation] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 52: Expected 1 errors -Line 72: Expected 1 errors -Line 75: Expected 1 errors -Line 58: Unexpected errors ['File "aliases_recursive.py", line 58, in : unsupported operand type(s) for |: \\'\\'GenericTypeAlias1[T1]\\': str\\' and \\'T1: TypeVar\\' [unsupported-operands]'] -Line 59: Unexpected errors ['File "aliases_recursive.py", line 59, in : Invalid type annotation \\'list[str]\\' [invalid-annotation]'] -Line 62: Unexpected errors ['File "aliases_recursive.py", line 62, in : Invalid type annotation \\'list[str]\\' [invalid-annotation]', 'File "aliases_recursive.py", line 62, in : Invalid type annotation \\'GenericTypeAlias1[str]\\' [invalid-annotation]'] -Line 65: Unexpected errors ['File "aliases_recursive.py", line 65, in : unsupported operand type(s) for |: \\'\\'GenericTypeAlias2[T1, T2]\\': str\\' and \\'T1: TypeVar\\' [unsupported-operands]'] -Line 67: Unexpected errors ['File "aliases_recursive.py", line 67, in : Invalid type annotation \\'list[str, int]\\' [invalid-annotation]', 'File "aliases_recursive.py", line 67, in : Invalid type annotation \\'GenericTypeAlias2[str, int]\\' [invalid-annotation]'] -Line 68: Unexpected errors ['File "aliases_recursive.py", line 68, in : Invalid type annotation \\'list[str, float]\\' [invalid-annotation]', 'File "aliases_recursive.py", line 68, in : Invalid type annotation \\'GenericTypeAlias2[str, float]\\' [invalid-annotation]'] -""" diff --git a/conformance/results/pytype/aliases_type_statement.toml b/conformance/results/pytype/aliases_type_statement.toml deleted file mode 100644 index cd7ae2953..000000000 --- a/conformance/results/pytype/aliases_type_statement.toml +++ /dev/null @@ -1,37 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support `type` statement. -""" -output = """ -SyntaxError: Type statement is only supported in Python 3.12 and greater (, line 8) -""" -conformance_automated = "Fail" -errors_diff = """ -Line 17: Expected 1 errors -Line 19: Expected 1 errors -Line 23: Expected 1 errors -Line 26: Expected 1 errors -Line 31: Expected 1 errors -Line 37: Expected 1 errors -Line 38: Expected 1 errors -Line 39: Expected 1 errors -Line 40: Expected 1 errors -Line 41: Expected 1 errors -Line 42: Expected 1 errors -Line 43: Expected 1 errors -Line 44: Expected 1 errors -Line 45: Expected 1 errors -Line 46: Expected 1 errors -Line 47: Expected 1 errors -Line 48: Expected 1 errors -Line 49: Expected 1 errors -Line 52: Expected 1 errors -Line 58: Expected 1 errors -Line 64: Expected 1 errors -Line 69: Expected 1 errors -Line 79: Expected 1 errors -Line 81: Expected 1 errors -Line 84: Expected 1 errors -Line 86: Expected 1 errors -Line 90: Expected 1 errors -""" diff --git a/conformance/results/pytype/aliases_typealiastype.toml b/conformance/results/pytype/aliases_typealiastype.toml deleted file mode 100644 index f2c6d2414..000000000 --- a/conformance/results/pytype/aliases_typealiastype.toml +++ /dev/null @@ -1,40 +0,0 @@ -conformant = "Unsupported" -notes = """ -Support for TypeAliasType is not implemented. -""" -output = """ -File "aliases_typealiastype.py", line 5, in : typing.TypeVarTuple not supported yet [not-supported-yet] -File "aliases_typealiastype.py", line 5, in : Can't find module 'typing.TypeAliasType'. [import-error] -File "aliases_typealiastype.py", line 11, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] -File "aliases_typealiastype.py", line 19, in : Name 'GoodAlias4' is not defined [name-error] -File "aliases_typealiastype.py", line 22, in : Name 'GoodAlias5' is not defined [name-error] -File "aliases_typealiastype.py", line 22, in : Invalid type annotation '' [invalid-annotation] -File "aliases_typealiastype.py", line 46, in : Name 'BadAlias4' is not defined [name-error] -File "aliases_typealiastype.py", line 47, in : Name 'BadAlias5' is not defined [name-error] -File "aliases_typealiastype.py", line 48, in : Name 'BadAlias7' is not defined [name-error] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 32: Expected 1 errors -Line 40: Expected 1 errors -Line 43: Expected 1 errors -Line 44: Expected 1 errors -Line 45: Expected 1 errors -Line 52: Expected 1 errors -Line 53: Expected 1 errors -Line 54: Expected 1 errors -Line 55: Expected 1 errors -Line 56: Expected 1 errors -Line 57: Expected 1 errors -Line 58: Expected 1 errors -Line 59: Expected 1 errors -Line 60: Expected 1 errors -Line 61: Expected 1 errors -Line 62: Expected 1 errors -Line 63: Expected 1 errors -Line 64: Expected 1 errors -Line 5: Unexpected errors ['File "aliases_typealiastype.py", line 5, in : typing.TypeVarTuple not supported yet [not-supported-yet]', 'File "aliases_typealiastype.py", line 5, in : Can\\'t find module \\'typing.TypeAliasType\\'. [import-error]'] -Line 11: Unexpected errors ['File "aliases_typealiastype.py", line 11, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count]'] -Line 19: Unexpected errors ['File "aliases_typealiastype.py", line 19, in : Name \\'GoodAlias4\\' is not defined [name-error]'] -Line 22: Unexpected errors ['File "aliases_typealiastype.py", line 22, in : Name \\'GoodAlias5\\' is not defined [name-error]', 'File "aliases_typealiastype.py", line 22, in : Invalid type annotation \\'\\' [invalid-annotation]'] -""" diff --git a/conformance/results/pytype/aliases_variance.toml b/conformance/results/pytype/aliases_variance.toml deleted file mode 100644 index 2bb30ee50..000000000 --- a/conformance/results/pytype/aliases_variance.toml +++ /dev/null @@ -1,17 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not detect variance incompatibility. -""" -output = """ -File "aliases_variance.py", line 9, in : argument "covariant" to TypeVar not supported yet [not-supported-yet] -File "aliases_variance.py", line 10, in : argument "contravariant" to TypeVar not supported yet [not-supported-yet] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 24: Expected 1 errors -Line 28: Expected 1 errors -Line 32: Expected 1 errors -Line 44: Expected 1 errors -Line 9: Unexpected errors ['File "aliases_variance.py", line 9, in : argument "covariant" to TypeVar not supported yet [not-supported-yet]'] -Line 10: Unexpected errors ['File "aliases_variance.py", line 10, in : argument "contravariant" to TypeVar not supported yet [not-supported-yet]'] -""" diff --git a/conformance/results/pytype/annotations_coroutines.toml b/conformance/results/pytype/annotations_coroutines.toml deleted file mode 100644 index a97531845..000000000 --- a/conformance/results/pytype/annotations_coroutines.toml +++ /dev/null @@ -1,10 +0,0 @@ -conformant = "Partial" -notes = """ -Does not evaluate correct type for async function. -""" -output = """ - -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pytype/annotations_forward_refs.toml b/conformance/results/pytype/annotations_forward_refs.toml deleted file mode 100644 index c9373b7cc..000000000 --- a/conformance/results/pytype/annotations_forward_refs.toml +++ /dev/null @@ -1,53 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject some illegal type expression forms when quoted. -Incorrectly generates error for quoted type defined in class scope. -Evaluates incorrect type for class variable annotated with quoted type expression. -Does not treat triple-quoted forward reference annotation as implicitly parenthesized. -""" -output = """ -File "annotations_forward_refs.py", line 22, in : Name 'ClassA' is not defined [name-error] -File "annotations_forward_refs.py", line 23, in : Name 'ClassA' is not defined [name-error] -File "annotations_forward_refs.py", line 24, in : unsupported operand type(s) for |: ''ClassA': str' and 'int: Type[int]' [unsupported-operands] -File "annotations_forward_refs.py", line 25, in : Missing parameter 'y' in call to function int.__or__ [missing-parameter] -File "annotations_forward_refs.py", line 40, in : invalid syntax [python-compiler-error] -File "annotations_forward_refs.py", line 40, in : Invalid type annotation '{}' for p5 [invalid-annotation] -File "annotations_forward_refs.py", line 40, in : Invalid type annotation '[int, str]' for p2 [invalid-annotation] -File "annotations_forward_refs.py", line 40, in : Invalid type annotation 'True' for p10 [invalid-annotation] -File "annotations_forward_refs.py", line 40, in : Invalid type annotation '' for p15 [invalid-annotation] -File "annotations_forward_refs.py", line 40, in : Invalid type annotation '' for p4 [invalid-annotation] -File "annotations_forward_refs.py", line 40, in : Invalid type annotation '1' for p9 [invalid-annotation] -File "annotations_forward_refs.py", line 40, in : Invalid type annotation '1' for p11 [invalid-annotation] -File "annotations_forward_refs.py", line 40, in : Invalid type annotation '-1' for p12 [invalid-annotation] -File "annotations_forward_refs.py", line 40, in : Invalid type annotation '(int, str)' for p3 [invalid-annotation] -File "annotations_forward_refs.py", line 66, in ClassB: Name 'ClassB' is not defined [name-error] -File "annotations_forward_refs.py", line 80, in ClassD: Name 'ClassF' is not defined [name-error] -File "annotations_forward_refs.py", line 82, in ClassD: Invalid type annotation '' for str [invalid-annotation] -File "annotations_forward_refs.py", line 87, in ClassD: Invalid type annotation '' for x [invalid-annotation] -File "annotations_forward_refs.py", line 89, in ClassD: Invalid type annotation '' for y [invalid-annotation] -File "annotations_forward_refs.py", line 93, in : Any [assert-type] -File "annotations_forward_refs.py", line 100, in : unexpected indent [python-compiler-error] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 41: Expected 1 errors -Line 42: Expected 1 errors -Line 43: Expected 1 errors -Line 44: Expected 1 errors -Line 45: Expected 1 errors -Line 46: Expected 1 errors -Line 47: Expected 1 errors -Line 48: Expected 1 errors -Line 49: Expected 1 errors -Line 50: Expected 1 errors -Line 51: Expected 1 errors -Line 52: Expected 1 errors -Line 53: Expected 1 errors -Line 54: Expected 1 errors -Line 55: Expected 1 errors -Line 40: Unexpected errors ['File "annotations_forward_refs.py", line 40, in : invalid syntax [python-compiler-error]', 'File "annotations_forward_refs.py", line 40, in : Invalid type annotation \\'{}\\' for p5 [invalid-annotation]', 'File "annotations_forward_refs.py", line 40, in : Invalid type annotation \\'[int, str]\\' for p2 [invalid-annotation]', 'File "annotations_forward_refs.py", line 40, in : Invalid type annotation \\'True\\' for p10 [invalid-annotation]', 'File "annotations_forward_refs.py", line 40, in : Invalid type annotation \\'\\' for p15 [invalid-annotation]', 'File "annotations_forward_refs.py", line 40, in : Invalid type annotation \\'\\' for p4 [invalid-annotation]', 'File "annotations_forward_refs.py", line 40, in : Invalid type annotation \\'1\\' for p9 [invalid-annotation]', 'File "annotations_forward_refs.py", line 40, in : Invalid type annotation \\'1\\' for p11 [invalid-annotation]', 'File "annotations_forward_refs.py", line 40, in : Invalid type annotation \\'-1\\' for p12 [invalid-annotation]', 'File "annotations_forward_refs.py", line 40, in : Invalid type annotation \\'(int, str)\\' for p3 [invalid-annotation]'] -Line 82: Unexpected errors ['File "annotations_forward_refs.py", line 82, in ClassD: Invalid type annotation \\'\\' for str [invalid-annotation]'] -Line 87: Unexpected errors ['File "annotations_forward_refs.py", line 87, in ClassD: Invalid type annotation \\'\\' for x [invalid-annotation]'] -Line 93: Unexpected errors ['File "annotations_forward_refs.py", line 93, in : Any [assert-type]'] -Line 100: Unexpected errors ['File "annotations_forward_refs.py", line 100, in : unexpected indent [python-compiler-error]'] -""" diff --git a/conformance/results/pytype/annotations_generators.toml b/conformance/results/pytype/annotations_generators.toml deleted file mode 100644 index 4be5d0125..000000000 --- a/conformance/results/pytype/annotations_generators.toml +++ /dev/null @@ -1,28 +0,0 @@ -conformant = "Partial" -notes = """ -Does not report invalid return type for generator when function implicitly returns None. -Reports invalid error when return type of generator is annotated as a compatible protocol. -Does not report type violation in `yield from` statement. -""" -output = """ -File "annotations_generators.py", line 54, in generator2: bad return type [bad-return-type] -File "annotations_generators.py", line 57, in generator2: bad return type [bad-return-type] -File "annotations_generators.py", line 57, in generator2: bad return type [bad-return-type] -File "annotations_generators.py", line 66, in generator3: bad return type [bad-return-type] -File "annotations_generators.py", line 75, in generator5: bad return type [bad-return-type] -File "annotations_generators.py", line 86, in : Bad return type 'int' for generator function generator8 [bad-yield-annotation] -File "annotations_generators.py", line 91, in : Bad return type 'int' for async generator function generator9 [bad-yield-annotation] -File "annotations_generators.py", line 100, in : Bad return type 'IntIterator' for generator function generator15 [bad-yield-annotation] -File "annotations_generators.py", line 109, in : Bad return type 'AsyncIntIterator' for async generator function generator16 [bad-yield-annotation] -File "annotations_generators.py", line 118, in generator18: bad return type [bad-return-type] -File "annotations_generators.py", line 119, in generator18: bad return type [bad-return-type] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 51: Expected 1 errors -Line 87: Expected 1 errors -Line 92: Expected 1 errors -Line 135: Expected 1 errors -Line 100: Unexpected errors ['File "annotations_generators.py", line 100, in : Bad return type \\'IntIterator\\' for generator function generator15 [bad-yield-annotation]'] -Line 109: Unexpected errors ['File "annotations_generators.py", line 109, in : Bad return type \\'AsyncIntIterator\\' for async generator function generator16 [bad-yield-annotation]'] -""" diff --git a/conformance/results/pytype/annotations_methods.toml b/conformance/results/pytype/annotations_methods.toml deleted file mode 100644 index f86e18674..000000000 --- a/conformance/results/pytype/annotations_methods.toml +++ /dev/null @@ -1,10 +0,0 @@ -conformant = "Pass" -notes = """ -Type evaluation differs from other type checkers because of ambiguity in the spec related to method bindings. -""" -output = """ -File "annotations_methods.py", line 42, in : B [assert-type] -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pytype/annotations_typeexpr.toml b/conformance/results/pytype/annotations_typeexpr.toml deleted file mode 100644 index bfefd545b..000000000 --- a/conformance/results/pytype/annotations_typeexpr.toml +++ /dev/null @@ -1,39 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject call expressions in type annotation. -Does not reject call lambda expression in type annotation. -Does not reject list expression in type annotation. -Does not reject ternary expression in type annotation. -Does not reject f-string in type annotation. -Does not reject module in type annotation. -""" -output = """ -File "annotations_typeexpr.py", line 87, in : Invalid type annotation '{}' for p5 [invalid-annotation] -File "annotations_typeexpr.py", line 87, in : Invalid type annotation '[int, str]' for p2 [invalid-annotation] -File "annotations_typeexpr.py", line 87, in : Invalid type annotation 'True' for p10 [invalid-annotation] -File "annotations_typeexpr.py", line 87, in : Invalid type annotation '' for p15 [invalid-annotation] -File "annotations_typeexpr.py", line 87, in : Invalid type annotation '' for p4 [invalid-annotation] -File "annotations_typeexpr.py", line 87, in : Invalid type annotation '3' for p9 [invalid-annotation] -File "annotations_typeexpr.py", line 87, in : Invalid type annotation '1' for p11 [invalid-annotation] -File "annotations_typeexpr.py", line 87, in : Invalid type annotation '-1' for p12 [invalid-annotation] -File "annotations_typeexpr.py", line 87, in : Invalid type annotation '(int, str)' for p3 [invalid-annotation] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 88: Expected 1 errors -Line 89: Expected 1 errors -Line 90: Expected 1 errors -Line 91: Expected 1 errors -Line 92: Expected 1 errors -Line 93: Expected 1 errors -Line 94: Expected 1 errors -Line 95: Expected 1 errors -Line 96: Expected 1 errors -Line 97: Expected 1 errors -Line 98: Expected 1 errors -Line 99: Expected 1 errors -Line 100: Expected 1 errors -Line 101: Expected 1 errors -Line 102: Expected 1 errors -Line 87: Unexpected errors ['File "annotations_typeexpr.py", line 87, in : Invalid type annotation \\'{}\\' for p5 [invalid-annotation]', 'File "annotations_typeexpr.py", line 87, in : Invalid type annotation \\'[int, str]\\' for p2 [invalid-annotation]', 'File "annotations_typeexpr.py", line 87, in : Invalid type annotation \\'True\\' for p10 [invalid-annotation]', 'File "annotations_typeexpr.py", line 87, in : Invalid type annotation \\'\\' for p15 [invalid-annotation]', 'File "annotations_typeexpr.py", line 87, in : Invalid type annotation \\'\\' for p4 [invalid-annotation]', 'File "annotations_typeexpr.py", line 87, in : Invalid type annotation \\'3\\' for p9 [invalid-annotation]', 'File "annotations_typeexpr.py", line 87, in : Invalid type annotation \\'1\\' for p11 [invalid-annotation]', 'File "annotations_typeexpr.py", line 87, in : Invalid type annotation \\'-1\\' for p12 [invalid-annotation]', 'File "annotations_typeexpr.py", line 87, in : Invalid type annotation \\'(int, str)\\' for p3 [invalid-annotation]'] -""" diff --git a/conformance/results/pytype/callables_annotation.toml b/conformance/results/pytype/callables_annotation.toml deleted file mode 100644 index 2373cd1cc..000000000 --- a/conformance/results/pytype/callables_annotation.toml +++ /dev/null @@ -1,27 +0,0 @@ -conformant = "Partial" -notes = """ -Does not support Concatenate. -Does not treat "*args: Any, **kwargs: Any" as "...". -""" -output = """ -AttributeError: 'Concatenate' object has no attribute 'formal_type_parameters' -""" -conformance_automated = "Fail" -errors_diff = """ -Line 25: Expected 1 errors -Line 26: Expected 1 errors -Line 27: Expected 1 errors -Line 29: Expected 1 errors -Line 35: Expected 1 errors -Line 55: Expected 1 errors -Line 56: Expected 1 errors -Line 57: Expected 1 errors -Line 58: Expected 1 errors -Line 59: Expected 1 errors -Line 91: Expected 1 errors -Line 93: Expected 1 errors -Line 159: Expected 1 errors -Line 172: Expected 1 errors -Line 187: Expected 1 errors -Line 189: Expected 1 errors -""" diff --git a/conformance/results/pytype/callables_kwargs.toml b/conformance/results/pytype/callables_kwargs.toml deleted file mode 100644 index 3723069b8..000000000 --- a/conformance/results/pytype/callables_kwargs.toml +++ /dev/null @@ -1,36 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not understand Unpack in the context of **kwargs annotation. -""" -output = """ -File "callables_kwargs.py", line 10, in : typing.Unpack not supported yet [not-supported-yet] -File "callables_kwargs.py", line 24, in func1: Unpack[TD2] [assert-type] -File "callables_kwargs.py", line 32, in func1: Unpack[TD2] [assert-type] -File "callables_kwargs.py", line 35, in func1: Unpack[TD2] [assert-type] -File "callables_kwargs.py", line 41, in func2: Dict[str, Unpack[TD1]] [assert-type] -File "callables_kwargs.py", line 47, in func3: Function func1 was called with the wrong arguments [wrong-arg-types] -File "callables_kwargs.py", line 49, in func3: Missing parameter 'v2' in call to function TD2.__init__ [missing-parameter] -File "callables_kwargs.py", line 51, in func3: Function func1 was called with the wrong arguments [wrong-arg-types] -File "callables_kwargs.py", line 52, in func3: Function func1 expects 0 arg(s), got 3 [wrong-arg-count] -File "callables_kwargs.py", line 58, in func3: Function func1 was called with the wrong arguments [wrong-arg-types] -File "callables_kwargs.py", line 61, in func3: Function func1 was called with the wrong arguments [wrong-arg-types] -File "callables_kwargs.py", line 63, in func3: Function func1 was called with the wrong arguments [wrong-arg-types] -File "callables_kwargs.py", line 64, in func3: Function func2 was called with the wrong arguments [wrong-arg-types] -File "callables_kwargs.py", line 65, in func3: Function func2 was called with the wrong arguments [wrong-arg-types] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 46: Expected 1 errors -Line 101: Expected 1 errors -Line 102: Expected 1 errors -Line 103: Expected 1 errors -Line 111: Expected 1 errors -Line 122: Expected 1 errors -Line 10: Unexpected errors ['File "callables_kwargs.py", line 10, in : typing.Unpack not supported yet [not-supported-yet]'] -Line 24: Unexpected errors ['File "callables_kwargs.py", line 24, in func1: Unpack[TD2] [assert-type]'] -Line 32: Unexpected errors ['File "callables_kwargs.py", line 32, in func1: Unpack[TD2] [assert-type]'] -Line 35: Unexpected errors ['File "callables_kwargs.py", line 35, in func1: Unpack[TD2] [assert-type]'] -Line 41: Unexpected errors ['File "callables_kwargs.py", line 41, in func2: Dict[str, Unpack[TD1]] [assert-type]'] -Line 47: Unexpected errors ['File "callables_kwargs.py", line 47, in func3: Function func1 was called with the wrong arguments [wrong-arg-types]'] -Line 49: Unexpected errors ['File "callables_kwargs.py", line 49, in func3: Missing parameter \\'v2\\' in call to function TD2.__init__ [missing-parameter]'] -""" diff --git a/conformance/results/pytype/callables_protocol.toml b/conformance/results/pytype/callables_protocol.toml deleted file mode 100644 index c80c657f1..000000000 --- a/conformance/results/pytype/callables_protocol.toml +++ /dev/null @@ -1,38 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not properly handle type compatibility checks with callback protocols. -""" -output = """ -File "callables_protocol.py", line 9, in : argument "contravariant" to TypeVar not supported yet [not-supported-yet] -File "callables_protocol.py", line 10, in : argument "covariant" to TypeVar not supported yet [not-supported-yet] -File "callables_protocol.py", line 121, in : Type annotation for cb6 does not match type of assignment [annotation-type-mismatch] -File "callables_protocol.py", line 173, in : argument "covariant" to TypeVar not supported yet [not-supported-yet] -File "callables_protocol.py", line 188, in decorator1: bad return type [bad-return-type] -Called from (traceback): - line 191, in current file -File "callables_protocol.py", line 197, in : No attribute 'other_attribute2' on Proto9[Any, str] [attribute-error] -File "callables_protocol.py", line 199, in : Function Proto9.__call__ was called with the wrong arguments [wrong-arg-types] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 35: Expected 1 errors -Line 36: Expected 1 errors -Line 37: Expected 1 errors -Line 67: Expected 1 errors -Line 68: Expected 1 errors -Line 69: Expected 1 errors -Line 70: Expected 1 errors -Line 97: Expected 1 errors -Line 169: Expected 1 errors -Line 186: Expected 1 errors -Line 187: Expected 1 errors -Line 238: Expected 1 errors -Line 260: Expected 1 errors -Line 284: Expected 1 errors -Line 311: Expected 1 errors -Line 9: Unexpected errors ['File "callables_protocol.py", line 9, in : argument "contravariant" to TypeVar not supported yet [not-supported-yet]'] -Line 10: Unexpected errors ['File "callables_protocol.py", line 10, in : argument "covariant" to TypeVar not supported yet [not-supported-yet]'] -Line 173: Unexpected errors ['File "callables_protocol.py", line 173, in : argument "covariant" to TypeVar not supported yet [not-supported-yet]'] -Line 188: Unexpected errors ['File "callables_protocol.py", line 188, in decorator1: bad return type [bad-return-type]'] -Line 199: Unexpected errors ['File "callables_protocol.py", line 199, in : Function Proto9.__call__ was called with the wrong arguments [wrong-arg-types]'] -""" diff --git a/conformance/results/pytype/callables_subtyping.toml b/conformance/results/pytype/callables_subtyping.toml deleted file mode 100644 index 43e7ac96b..000000000 --- a/conformance/results/pytype/callables_subtyping.toml +++ /dev/null @@ -1,50 +0,0 @@ -conformant = "Partial" -notes = """ -Does not detect many subtyping rule violations for callables. -Does not correctly handle type alias parameterized by ParamSpec. -""" -errors_diff = """ -Line 51: Expected 1 errors -Line 52: Expected 1 errors -Line 55: Expected 1 errors -Line 58: Expected 1 errors -Line 82: Expected 1 errors -Line 85: Expected 1 errors -Line 86: Expected 1 errors -Line 116: Expected 1 errors -Line 119: Expected 1 errors -Line 120: Expected 1 errors -Line 122: Expected 1 errors -Line 124: Expected 1 errors -Line 125: Expected 1 errors -Line 126: Expected 1 errors -Line 151: Expected 1 errors -Line 154: Expected 1 errors -Line 155: Expected 1 errors -Line 187: Expected 1 errors -Line 190: Expected 1 errors -Line 191: Expected 1 errors -Line 193: Expected 1 errors -Line 195: Expected 1 errors -Line 196: Expected 1 errors -Line 197: Expected 1 errors -Line 236: Expected 1 errors -Line 237: Expected 1 errors -Line 240: Expected 1 errors -Line 243: Expected 1 errors -Line 273: Expected 1 errors -Line 297: Expected 1 errors -Line 211: Unexpected errors ['File "callables_subtyping.py", line 211, in : Invalid type annotation \\'Callable[[P], None][P]\\' [invalid-annotation]'] -Line 213: Unexpected errors ['File "callables_subtyping.py", line 213, in func7: Invalid type annotation \\'TypeAliasWithP[P]\\' [invalid-annotation]'] -Line 255: Unexpected errors ['File "callables_subtyping.py", line 255, in __call__: @typing.overload-decorated \\'Overloaded9.__call__\\' object is not callable [not-callable]'] -Line 284: Unexpected errors ['File "callables_subtyping.py", line 284, in __call__: @typing.overload-decorated \\'Overloaded10.__call__\\' object is not callable [not-callable]'] -""" -output = """ -File "callables_subtyping.py", line 26, in func1: Type annotation for f6 does not match type of assignment [annotation-type-mismatch] -File "callables_subtyping.py", line 29, in func1: Type annotation for f8 does not match type of assignment [annotation-type-mismatch] -File "callables_subtyping.py", line 211, in : Invalid type annotation 'Callable[[P], None][P]' [invalid-annotation] -File "callables_subtyping.py", line 213, in func7: Invalid type annotation 'TypeAliasWithP[P]' [invalid-annotation] -File "callables_subtyping.py", line 255, in __call__: @typing.overload-decorated 'Overloaded9.__call__' object is not callable [not-callable] -File "callables_subtyping.py", line 284, in __call__: @typing.overload-decorated 'Overloaded10.__call__' object is not callable [not-callable] -""" -conformance_automated = "Fail" diff --git a/conformance/results/pytype/classes_classvar.toml b/conformance/results/pytype/classes_classvar.toml deleted file mode 100644 index eae642386..000000000 --- a/conformance/results/pytype/classes_classvar.toml +++ /dev/null @@ -1,47 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject use of TypeVar in ClassVar. -Does not reject use of ParamSpec in ClassVar. -Does not reject use of ClassVar as a generic type argument. -Rejects initialization of ClassVar if no type argument is provided. -Does not reject use of ClassVar in parameter type annotation. -Does not reject use of ClassVar in local variable annotation. -Does not reject use of ClassVar in instance variable annotation. -Does not reject use of ClassVar in return type annotation. -Does not reject use of ClassVar in type alias definition. -Does not reject assignment of ClassVar through instance of class. -""" -output = """ -File "classes_classvar.py", line 7, in : typing.TypeVarTuple not supported yet [not-supported-yet] -File "classes_classvar.py", line 28, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] -File "classes_classvar.py", line 37, in ClassA: Invalid type annotation 'ClassVar[int, str]' [invalid-annotation] -File "classes_classvar.py", line 38, in ClassA: class ClassVar is not indexable [not-indexable] -File "classes_classvar.py", line 39, in ClassA: Name 'var' is not defined [name-error] -File "classes_classvar.py", line 51, in ClassA: Type annotation for bad8 does not match type of assignment [annotation-type-mismatch] -File "classes_classvar.py", line 59, in ClassA: Type annotation for good4 does not match type of assignment [annotation-type-mismatch] -File "classes_classvar.py", line 67, in method2: bad return type [bad-return-type] -File "classes_classvar.py", line 77, in : ClassVar [assert-type] -File "classes_classvar.py", line 120, in ProtoA: Type annotation for z does not match type of assignment [annotation-type-mismatch] -File "classes_classvar.py", line 130, in : Type annotation for a does not match type of assignment [annotation-type-mismatch] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 44: Expected 1 errors -Line 45: Expected 1 errors -Line 46: Expected 1 errors -Line 53: Expected 1 errors -Line 54: Expected 1 errors -Line 62: Expected 1 errors -Line 63: Expected 1 errors -Line 64: Expected 1 errors -Line 66: Expected 1 errors -Line 70: Expected 1 errors -Line 71: Expected 1 errors -Line 101: Expected 1 errors -Line 7: Unexpected errors ['File "classes_classvar.py", line 7, in : typing.TypeVarTuple not supported yet [not-supported-yet]'] -Line 28: Unexpected errors ['File "classes_classvar.py", line 28, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count]'] -Line 59: Unexpected errors ['File "classes_classvar.py", line 59, in ClassA: Type annotation for good4 does not match type of assignment [annotation-type-mismatch]'] -Line 67: Unexpected errors ['File "classes_classvar.py", line 67, in method2: bad return type [bad-return-type]'] -Line 77: Unexpected errors ['File "classes_classvar.py", line 77, in : ClassVar [assert-type]'] -Line 120: Unexpected errors ['File "classes_classvar.py", line 120, in ProtoA: Type annotation for z does not match type of assignment [annotation-type-mismatch]'] -""" diff --git a/conformance/results/pytype/classes_override.toml b/conformance/results/pytype/classes_override.toml deleted file mode 100644 index 8395e9206..000000000 --- a/conformance/results/pytype/classes_override.toml +++ /dev/null @@ -1,26 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not yet support the @override decorator. -""" -output = """ -File "classes_override.py", line 7, in : typing.override not supported yet [not-supported-yet] -File "classes_override.py", line 30, in method2: bad return type [bad-return-type] -File "classes_override.py", line 50, in method2: bad return type [bad-return-type] -File "classes_override.py", line 53, in ChildA: Attribute 'method3' not found on any parent class [override-error] -File "classes_override.py", line 57, in ChildA: Attribute 'method4' not found on any parent class [override-error] -File "classes_override.py", line 66, in method4: bad return type [bad-return-type] -File "classes_override.py", line 101, in ChildB: Attribute 'method1' not found on any parent class [override-error] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 79: Expected 1 errors -Line 84: Expected 1 errors -Line 89: Expected 1 errors -Lines 56, 65: Expected error (tag 'method4') -Line 7: Unexpected errors ['File "classes_override.py", line 7, in : typing.override not supported yet [not-supported-yet]'] -Line 30: Unexpected errors ['File "classes_override.py", line 30, in method2: bad return type [bad-return-type]'] -Line 50: Unexpected errors ['File "classes_override.py", line 50, in method2: bad return type [bad-return-type]'] -Line 57: Unexpected errors ['File "classes_override.py", line 57, in ChildA: Attribute \\'method4\\' not found on any parent class [override-error]'] -Line 66: Unexpected errors ['File "classes_override.py", line 66, in method4: bad return type [bad-return-type]'] -Line 101: Unexpected errors ['File "classes_override.py", line 101, in ChildB: Attribute \\'method1\\' not found on any parent class [override-error]'] -""" diff --git a/conformance/results/pytype/constructors_call_init.toml b/conformance/results/pytype/constructors_call_init.toml deleted file mode 100644 index 0b8000993..000000000 --- a/conformance/results/pytype/constructors_call_init.toml +++ /dev/null @@ -1,38 +0,0 @@ -conformant = "Partial" -notes = """ -Does not report errors during binding to self parameter of __init__ method. -Does not infer type of Self for self parameter of __init__ method. -Rejects valid type annotation for self parameter in __init__ method. -Does not support function-scoped TypeVars in self annotation in __init__ method. -Does not reject use of class-scoped type variables in annotation of self parameter in __init__ method. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 21: Expected 1 errors -Line 42: Expected 1 errors -Line 56: Expected 1 errors -Line 107: Expected 1 errors -Line 51: Unexpected errors ['File "constructors_call_init.py", line 51, in __init__: Invalid type annotation \\'Class4[int]\\' for self [invalid-annotation]'] -Line 72: Unexpected errors ['File "constructors_call_init.py", line 72, in : Class5 [assert-type]'] -Line 74: Unexpected errors ['File "constructors_call_init.py", line 74, in : Class5 [assert-type]'] -Line 88: Unexpected errors ['File "constructors_call_init.py", line 88, in Class6: Invalid type annotation \\'V2\\' [invalid-annotation]', 'File "constructors_call_init.py", line 88, in Class6: Invalid type annotation \\'V1\\' [invalid-annotation]', 'File "constructors_call_init.py", line 88, in __init__: Invalid type annotation \\'Class6[V1, V2]\\' for self [invalid-annotation]'] -Line 91: Unexpected errors ['File "constructors_call_init.py", line 91, in : Class6 [assert-type]'] -Line 96: Unexpected errors ['File "constructors_call_init.py", line 96, in Class7: Invalid type annotation \\'V2\\' [invalid-annotation]', 'File "constructors_call_init.py", line 96, in Class7: Invalid type annotation \\'V1\\' [invalid-annotation]', 'File "constructors_call_init.py", line 96, in __init__: Invalid type annotation \\'Class7[V2, V1]\\' for self [invalid-annotation]'] -Line 99: Unexpected errors ['File "constructors_call_init.py", line 99, in : Class7 [assert-type]'] -Line 108: Unexpected errors ['File "constructors_call_init.py", line 108, in __init__: Invalid type annotation \\'Class8[T2, T1]\\' for self [invalid-annotation]'] -""" -output = """ -File "constructors_call_init.py", line 51, in __init__: Invalid type annotation 'Class4[int]' for self [invalid-annotation] -File "constructors_call_init.py", line 72, in : Class5 [assert-type] -File "constructors_call_init.py", line 74, in : Class5 [assert-type] -File "constructors_call_init.py", line 88, in Class6: Invalid type annotation 'V2' [invalid-annotation] -File "constructors_call_init.py", line 88, in Class6: Invalid type annotation 'V1' [invalid-annotation] -File "constructors_call_init.py", line 88, in __init__: Invalid type annotation 'Class6[V1, V2]' for self [invalid-annotation] -File "constructors_call_init.py", line 91, in : Class6 [assert-type] -File "constructors_call_init.py", line 96, in Class7: Invalid type annotation 'V2' [invalid-annotation] -File "constructors_call_init.py", line 96, in Class7: Invalid type annotation 'V1' [invalid-annotation] -File "constructors_call_init.py", line 96, in __init__: Invalid type annotation 'Class7[V2, V1]' for self [invalid-annotation] -File "constructors_call_init.py", line 99, in : Class7 [assert-type] -File "constructors_call_init.py", line 108, in __init__: Invalid type annotation 'Class8[T2, T1]' for self [invalid-annotation] -File "constructors_call_init.py", line 130, in : Function Class11.__init__ expects 1 arg(s), got 2 [wrong-arg-count] -""" diff --git a/conformance/results/pytype/constructors_call_metaclass.toml b/conformance/results/pytype/constructors_call_metaclass.toml deleted file mode 100644 index 377ea2840..000000000 --- a/conformance/results/pytype/constructors_call_metaclass.toml +++ /dev/null @@ -1,17 +0,0 @@ -conformant = "Unupported" -notes = """ -Does not honor metaclass __call__ method when evaluating constructor call. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 23: Unexpected errors ['File "constructors_call_metaclass.py", line 23, in : Missing parameter \\'x\\' in call to function Class1.__new__ [missing-parameter]', 'File "constructors_call_metaclass.py", line 23, in : Any [assert-type]'] -Line 36: Unexpected errors ['File "constructors_call_metaclass.py", line 36, in : Missing parameter \\'x\\' in call to function Class2.__new__ [missing-parameter]', 'File "constructors_call_metaclass.py", line 36, in : Any [assert-type]'] -""" -output = """ -File "constructors_call_metaclass.py", line 23, in : Missing parameter 'x' in call to function Class1.__new__ [missing-parameter] -File "constructors_call_metaclass.py", line 23, in : Any [assert-type] -File "constructors_call_metaclass.py", line 36, in : Missing parameter 'x' in call to function Class2.__new__ [missing-parameter] -File "constructors_call_metaclass.py", line 36, in : Any [assert-type] -File "constructors_call_metaclass.py", line 51, in : Missing parameter 'x' in call to function Class3.__new__ [missing-parameter] -File "constructors_call_metaclass.py", line 65, in : Missing parameter 'x' in call to function Class4.__new__ [missing-parameter] -""" diff --git a/conformance/results/pytype/constructors_call_new.toml b/conformance/results/pytype/constructors_call_new.toml deleted file mode 100644 index 022364fe5..000000000 --- a/conformance/results/pytype/constructors_call_new.toml +++ /dev/null @@ -1,25 +0,0 @@ -conformant = "Partial" -notes = """ -Does not honor explicit specialization of generic class when used in constructor call. -Does not support __new__ return type that is not a subclass of the class being constructed. -Does not skip evaluation of __init__ based on __new__ return type. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 21: Expected 1 errors -Line 76: Unexpected errors ['File "constructors_call_new.py", line 76, in : Any [assert-type]'] -Line 89: Unexpected errors ['File "constructors_call_new.py", line 89, in : Missing parameter \\'x\\' in call to function Class6.__init__ [missing-parameter]'] -Line 113: Unexpected errors ['File "constructors_call_new.py", line 113, in __new__: bad return type [bad-return-type]'] -Line 125: Unexpected errors ['File "constructors_call_new.py", line 125, in __new__: bad return type [bad-return-type]'] -Line 140: Unexpected errors ['File "constructors_call_new.py", line 140, in __new__: bad return type [bad-return-type]'] -""" -output = """ -File "constructors_call_new.py", line 76, in : Any [assert-type] -File "constructors_call_new.py", line 89, in : Missing parameter 'x' in call to function Class6.__init__ [missing-parameter] -File "constructors_call_new.py", line 113, in __new__: bad return type [bad-return-type] -File "constructors_call_new.py", line 125, in __new__: bad return type [bad-return-type] -File "constructors_call_new.py", line 140, in __new__: bad return type [bad-return-type] -Called from (traceback): - line 143, in current file -File "constructors_call_new.py", line 145, in : Function Class11.__new__ was called with the wrong arguments [wrong-arg-types] -""" diff --git a/conformance/results/pytype/constructors_call_type.toml b/conformance/results/pytype/constructors_call_type.toml deleted file mode 100644 index 7c07a5f50..000000000 --- a/conformance/results/pytype/constructors_call_type.toml +++ /dev/null @@ -1,26 +0,0 @@ -conformant = "Partial" -notes = """ -Does not validate call to custom metaclass __call__ method through type[T]. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 30: Expected 1 errors -Line 64: Expected 1 errors -Line 72: Expected 1 errors -Line 81: Expected 1 errors -Line 82: Expected 1 errors -Line 25: Unexpected errors ['File "constructors_call_type.py", line 25, in __new__: Missing parameter \\'cls\\' in call to function object.__new__ [missing-parameter]', 'File "constructors_call_type.py", line 25, in __new__: Invalid keyword arguments (x, y) to function object.__new__ [wrong-keyword-args]'] -Line 62: Unexpected errors ['File "constructors_call_type.py", line 62, in : Invalid type annotation \\'T\\' [invalid-annotation]'] -""" -output = """ -File "constructors_call_type.py", line 25, in __new__: Missing parameter 'cls' in call to function object.__new__ [missing-parameter] -Called from (traceback): - line 30, in func1 -File "constructors_call_type.py", line 25, in __new__: Invalid keyword arguments (x, y) to function object.__new__ [wrong-keyword-args] -Called from (traceback): - line 29, in func1 -File "constructors_call_type.py", line 40, in func2: Missing parameter 'x' in call to function Class2.__new__ [missing-parameter] -File "constructors_call_type.py", line 50, in func3: Missing parameter 'x' in call to function Class3.__init__ [missing-parameter] -File "constructors_call_type.py", line 59, in func4: Function Class4.__init__ expects 1 arg(s), got 2 [wrong-arg-count] -File "constructors_call_type.py", line 62, in : Invalid type annotation 'T' [invalid-annotation] -""" diff --git a/conformance/results/pytype/constructors_callable.toml b/conformance/results/pytype/constructors_callable.toml deleted file mode 100644 index 93ae94e97..000000000 --- a/conformance/results/pytype/constructors_callable.toml +++ /dev/null @@ -1,82 +0,0 @@ -conformant = "Partial" -notes = """ -Does not generate a union type for __new__ and __init__ when converting class to callable. -Does not ignore __init__ based on __new__ return type when converting class to callable. -Does not support __new__ return type that is different from class being constructed. -Does not use annotated type of self in __init__ method to generate return type of callable. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 51: Expected 1 errors -Line 127: Expected 1 errors -Line 144: Expected 1 errors -Line 36: Unexpected errors ['File "constructors_callable.py", line 36, in : Callable[[Any], Class1] [reveal-type]'] -Line 49: Unexpected errors ['File "constructors_callable.py", line 49, in : Callable[[Any], Class2] [reveal-type]'] -Line 50: Unexpected errors ['File "constructors_callable.py", line 50, in : Function expects 1 arg(s), got 0 [wrong-arg-count]', 'File "constructors_callable.py", line 50, in : Any [assert-type]'] -Line 57: Unexpected errors ['File "constructors_callable.py", line 57, in __new__: bad return type [bad-return-type]'] -Line 63: Unexpected errors ['File "constructors_callable.py", line 63, in : Callable[[Any], Class3] [reveal-type]'] -Line 73: Unexpected errors ['File "constructors_callable.py", line 73, in __new__: bad return type [bad-return-type]'] -Line 77: Unexpected errors ['File "constructors_callable.py", line 77, in : Callable[[Any], Class4] [reveal-type]'] -Line 78: Unexpected errors ['File "constructors_callable.py", line 78, in : nothing [assert-type]'] -Line 97: Unexpected errors ['File "constructors_callable.py", line 97, in : Callable[[Any], Class5] [reveal-type]'] -Line 100: Unexpected errors ['File "constructors_callable.py", line 100, in : Function expects 1 arg(s), got 0 [wrong-arg-count]', 'File "constructors_callable.py", line 100, in : Any [assert-type]'] -Line 105: Unexpected errors ['File "constructors_callable.py", line 105, in : Invalid keyword argument x to function [wrong-keyword-args]', 'File "constructors_callable.py", line 105, in : Any [assert-type]'] -Line 117: Unexpected errors ['File "constructors_callable.py", line 117, in __new__: bad return type [bad-return-type]'] -Line 125: Unexpected errors ['File "constructors_callable.py", line 125, in : Callable[[Any], Class6] [reveal-type]'] -Line 126: Unexpected errors ['File "constructors_callable.py", line 126, in : Function expects 1 arg(s), got 0 [wrong-arg-count]', 'File "constructors_callable.py", line 126, in : Any [assert-type]'] -Line 142: Unexpected errors ['File "constructors_callable.py", line 142, in : Callable[[Any], Class6Any] [reveal-type]'] -Line 143: Unexpected errors ['File "constructors_callable.py", line 143, in : Function expects 1 arg(s), got 0 [wrong-arg-count]'] -Line 161: Unexpected errors ['File "constructors_callable.py", line 161, in : Callable[[Any], Class7] [reveal-type]'] -Line 164: Unexpected errors ['File "constructors_callable.py", line 164, in : Class7 [assert-type]'] -Line 165: Unexpected errors ['File "constructors_callable.py", line 165, in : Class7 [assert-type]'] -Line 182: Unexpected errors ['File "constructors_callable.py", line 182, in : Callable[[Any], Class8[nothing]] [reveal-type]'] -Line 183: Unexpected errors ['File "constructors_callable.py", line 183, in : Function expects 1 arg(s), got 2 [wrong-arg-count]', 'File "constructors_callable.py", line 183, in : Any [assert-type]'] -Line 193: Unexpected errors ['File "constructors_callable.py", line 193, in : Callable[[Any], Class9] [reveal-type]'] -Line 194: Unexpected errors ['File "constructors_callable.py", line 194, in : Function expects 1 arg(s), got 2 [wrong-arg-count]', 'File "constructors_callable.py", line 194, in : Any [assert-type]'] -""" -output = """ -File "constructors_callable.py", line 36, in : Callable[[Any], Class1] [reveal-type] -File "constructors_callable.py", line 38, in : Function expects 1 arg(s), got 0 [wrong-arg-count] -File "constructors_callable.py", line 39, in : Invalid keyword argument y to function [wrong-keyword-args] -File "constructors_callable.py", line 49, in : Callable[[Any], Class2] [reveal-type] -File "constructors_callable.py", line 50, in : Function expects 1 arg(s), got 0 [wrong-arg-count] -File "constructors_callable.py", line 50, in : Any [assert-type] -File "constructors_callable.py", line 57, in __new__: bad return type [bad-return-type] -Called from (traceback): - line 64, in current file -File "constructors_callable.py", line 63, in : Callable[[Any], Class3] [reveal-type] -File "constructors_callable.py", line 65, in : Function expects 1 arg(s), got 0 [wrong-arg-count] -File "constructors_callable.py", line 66, in : Invalid keyword argument y to function [wrong-keyword-args] -File "constructors_callable.py", line 67, in : Function expects 1 arg(s), got 2 [wrong-arg-count] -File "constructors_callable.py", line 73, in __new__: bad return type [bad-return-type] -Called from (traceback): - line 78, in current file -File "constructors_callable.py", line 77, in : Callable[[Any], Class4] [reveal-type] -File "constructors_callable.py", line 78, in : nothing [assert-type] -File "constructors_callable.py", line 79, in : Function expects 1 arg(s), got 0 [wrong-arg-count] -File "constructors_callable.py", line 80, in : Invalid keyword argument y to function [wrong-keyword-args] -File "constructors_callable.py", line 97, in : Callable[[Any], Class5] [reveal-type] -File "constructors_callable.py", line 100, in : Function expects 1 arg(s), got 0 [wrong-arg-count] -File "constructors_callable.py", line 100, in : Any [assert-type] -File "constructors_callable.py", line 105, in : Invalid keyword argument x to function [wrong-keyword-args] -File "constructors_callable.py", line 105, in : Any [assert-type] -File "constructors_callable.py", line 117, in __new__: bad return type [bad-return-type] -Called from (traceback): - line 127, in current file -File "constructors_callable.py", line 125, in : Callable[[Any], Class6] [reveal-type] -File "constructors_callable.py", line 126, in : Function expects 1 arg(s), got 0 [wrong-arg-count] -File "constructors_callable.py", line 126, in : Any [assert-type] -File "constructors_callable.py", line 142, in : Callable[[Any], Class6Any] [reveal-type] -File "constructors_callable.py", line 143, in : Function expects 1 arg(s), got 0 [wrong-arg-count] -File "constructors_callable.py", line 161, in : Callable[[Any], Class7] [reveal-type] -File "constructors_callable.py", line 164, in : Class7 [assert-type] -File "constructors_callable.py", line 165, in : Class7 [assert-type] -File "constructors_callable.py", line 182, in : Callable[[Any], Class8[nothing]] [reveal-type] -File "constructors_callable.py", line 183, in : Function expects 1 arg(s), got 2 [wrong-arg-count] -File "constructors_callable.py", line 183, in : Any [assert-type] -File "constructors_callable.py", line 184, in : Function expects 1 arg(s), got 2 [wrong-arg-count] -File "constructors_callable.py", line 193, in : Callable[[Any], Class9] [reveal-type] -File "constructors_callable.py", line 194, in : Function expects 1 arg(s), got 2 [wrong-arg-count] -File "constructors_callable.py", line 194, in : Any [assert-type] -File "constructors_callable.py", line 195, in : Function expects 1 arg(s), got 2 [wrong-arg-count] -""" diff --git a/conformance/results/pytype/constructors_consistency.toml b/conformance/results/pytype/constructors_consistency.toml deleted file mode 100644 index 100481a6b..000000000 --- a/conformance/results/pytype/constructors_consistency.toml +++ /dev/null @@ -1,9 +0,0 @@ -conformant = "Pass" -notes = """ -Does not report inconsistency between __new__ and __init__ (optional). -""" -errors_diff = """ -""" -output = """ - -""" diff --git a/conformance/results/pytype/dataclasses_descriptors.toml b/conformance/results/pytype/dataclasses_descriptors.toml deleted file mode 100644 index f27186ccd..000000000 --- a/conformance/results/pytype/dataclasses_descriptors.toml +++ /dev/null @@ -1,38 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not understand descriptor objects in dataclass. -""" -output = """ -File "dataclasses_descriptors.py", line 24, in __get__: bad return type [bad-return-type] -Called from (traceback): - line 38, in current file -File "dataclasses_descriptors.py", line 24, in __get__: bad return type [bad-return-type] -Called from (traceback): - line 37, in current file -File "dataclasses_descriptors.py", line 35, in : Function DC1.__init__ was called with the wrong arguments [wrong-arg-types] -File "dataclasses_descriptors.py", line 51, in __get__: bad return type [bad-return-type] -Called from (traceback): - line 68, in current file -File "dataclasses_descriptors.py", line 51, in __get__: bad return type [bad-return-type] -Called from (traceback): - line 67, in current file -File "dataclasses_descriptors.py", line 51, in __get__: bad return type [bad-return-type] -Called from (traceback): - line 66, in current file -File "dataclasses_descriptors.py", line 51, in __get__: bad return type [bad-return-type] -Called from (traceback): - line 63, in current file -File "dataclasses_descriptors.py", line 51, in __get__: bad return type [bad-return-type] -Called from (traceback): - line 62, in current file -File "dataclasses_descriptors.py", line 51, in __get__: bad return type [bad-return-type] -Called from (traceback): - line 61, in current file -File "dataclasses_descriptors.py", line 51, in __get__: bad return type [bad-return-type] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 24: Unexpected errors ['File "dataclasses_descriptors.py", line 24, in __get__: bad return type [bad-return-type]', 'File "dataclasses_descriptors.py", line 24, in __get__: bad return type [bad-return-type]'] -Line 35: Unexpected errors ['File "dataclasses_descriptors.py", line 35, in : Function DC1.__init__ was called with the wrong arguments [wrong-arg-types]'] -Line 51: Unexpected errors ['File "dataclasses_descriptors.py", line 51, in __get__: bad return type [bad-return-type]', 'File "dataclasses_descriptors.py", line 51, in __get__: bad return type [bad-return-type]', 'File "dataclasses_descriptors.py", line 51, in __get__: bad return type [bad-return-type]', 'File "dataclasses_descriptors.py", line 51, in __get__: bad return type [bad-return-type]', 'File "dataclasses_descriptors.py", line 51, in __get__: bad return type [bad-return-type]', 'File "dataclasses_descriptors.py", line 51, in __get__: bad return type [bad-return-type]', 'File "dataclasses_descriptors.py", line 51, in __get__: bad return type [bad-return-type]'] -""" diff --git a/conformance/results/pytype/dataclasses_final.toml b/conformance/results/pytype/dataclasses_final.toml deleted file mode 100644 index 3e6e604f3..000000000 --- a/conformance/results/pytype/dataclasses_final.toml +++ /dev/null @@ -1,17 +0,0 @@ -conformant = "Partial" -notes = """ -Doesn't handle Final nested inside ClassVar. -""" -errors_diff = """ -Line 27: Expected 1 errors -Line 35: Expected 1 errors -Line 37: Expected 1 errors -Line 18: Unexpected errors ['File "dataclasses_final.py", line 18, in D: Invalid use of typing.Final [final-error]', 'File "dataclasses_final.py", line 18, in D: Invalid type annotation \\'ClassVar[Final[int]]\\' [invalid-annotation]'] -""" -output = """ -File "dataclasses_final.py", line 18, in D: Invalid use of typing.Final [final-error] -File "dataclasses_final.py", line 18, in D: Invalid type annotation 'ClassVar[Final[int]]' [invalid-annotation] -File "dataclasses_final.py", line 36, in : Assigning to attribute final_with_default, which was annotated with Final [final-error] -File "dataclasses_final.py", line 38, in : Assigning to attribute final_with_default, which was annotated with Final [final-error] -""" -conformance_automated = "Fail" diff --git a/conformance/results/pytype/dataclasses_frozen.toml b/conformance/results/pytype/dataclasses_frozen.toml deleted file mode 100644 index ede4373af..000000000 --- a/conformance/results/pytype/dataclasses_frozen.toml +++ /dev/null @@ -1,16 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not report assignment to field within frozen dataclass instance. -Does not reject frozen dataclass inherited from non-frozen dataclass. -Does not reject non-frozen dataclass inherited from frozen dataclass. -""" -output = """ - -""" -conformance_automated = "Fail" -errors_diff = """ -Line 16: Expected 1 errors -Line 17: Expected 1 errors -Lines 22, 23: Expected error (tag 'DC2') -Lines 32, 33: Expected error (tag 'DC4') -""" diff --git a/conformance/results/pytype/dataclasses_hash.toml b/conformance/results/pytype/dataclasses_hash.toml deleted file mode 100644 index 379b0e691..000000000 --- a/conformance/results/pytype/dataclasses_hash.toml +++ /dev/null @@ -1,12 +0,0 @@ -conformant = "Partial" -notes = """ -Does not report when dataclass is not compatible with Hashable protocol. -""" -output = """ - -""" -conformance_automated = "Fail" -errors_diff = """ -Line 15: Expected 1 errors -Line 32: Expected 1 errors -""" diff --git a/conformance/results/pytype/dataclasses_inheritance.toml b/conformance/results/pytype/dataclasses_inheritance.toml deleted file mode 100644 index 88ec64ce2..000000000 --- a/conformance/results/pytype/dataclasses_inheritance.toml +++ /dev/null @@ -1,13 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject ClassVar that is overridden by instance variable. -Does not reject instance variable that is overridden by ClassVar. -""" -output = """ - -""" -conformance_automated = "Fail" -errors_diff = """ -Line 60: Expected 1 errors -Line 64: Expected 1 errors -""" diff --git a/conformance/results/pytype/dataclasses_kwonly.toml b/conformance/results/pytype/dataclasses_kwonly.toml deleted file mode 100644 index 76a22f8af..000000000 --- a/conformance/results/pytype/dataclasses_kwonly.toml +++ /dev/null @@ -1,21 +0,0 @@ -conformant = "Partial" -notes = """ -Incorrectly reports error when kw_only field has default value. -Incorrectly rejects kw_only field with default before positional field. -""" -output = """ -File "dataclasses_kwonly.py", line 23, in : Function DC1.__init__ expects 2 arg(s), got 3 [wrong-arg-count] -File "dataclasses_kwonly.py", line 38, in : Function DC2.__init__ expects 2 arg(s), got 3 [wrong-arg-count] -File "dataclasses_kwonly.py", line 47, in : Missing parameter 'a' in call to function DC3.__init__ [missing-parameter] -File "dataclasses_kwonly.py", line 50, in : Missing parameter 'a' in call to function DC3.__init__ [missing-parameter] -File "dataclasses_kwonly.py", line 53, in : Missing parameter 'a' in call to function DC3.__init__ [missing-parameter] -File "dataclasses_kwonly.py", line 56, in : In method __init__, non-default argument c follows default argument [invalid-function-definition] -File "dataclasses_kwonly.py", line 61, in : function DC4.__init__ got multiple values for keyword argument 'b' [duplicate-keyword-argument] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 47: Unexpected errors ['File "dataclasses_kwonly.py", line 47, in : Missing parameter \\'a\\' in call to function DC3.__init__ [missing-parameter]'] -Line 50: Unexpected errors ['File "dataclasses_kwonly.py", line 50, in : Missing parameter \\'a\\' in call to function DC3.__init__ [missing-parameter]'] -Line 56: Unexpected errors ['File "dataclasses_kwonly.py", line 56, in : In method __init__, non-default argument c follows default argument [invalid-function-definition]'] -Line 61: Unexpected errors ['File "dataclasses_kwonly.py", line 61, in : function DC4.__init__ got multiple values for keyword argument \\'b\\' [duplicate-keyword-argument]'] -""" diff --git a/conformance/results/pytype/dataclasses_order.toml b/conformance/results/pytype/dataclasses_order.toml deleted file mode 100644 index 154b02be2..000000000 --- a/conformance/results/pytype/dataclasses_order.toml +++ /dev/null @@ -1,11 +0,0 @@ -conformant = "Partial" -notes = """ -Does not report type incompatibility with comparison operator. -""" -output = """ - -""" -conformance_automated = "Fail" -errors_diff = """ -Line 50: Expected 1 errors -""" diff --git a/conformance/results/pytype/dataclasses_postinit.toml b/conformance/results/pytype/dataclasses_postinit.toml deleted file mode 100644 index cf8fa0720..000000000 --- a/conformance/results/pytype/dataclasses_postinit.toml +++ /dev/null @@ -1,16 +0,0 @@ -conformant = "Partial" -notes = """ -Does not validate `__post_init__` method. -Reports incorrect error for incompatible `__post_init__` method override. -""" -output = """ -File "dataclasses_postinit.py", line 28, in : No attribute 'x' on DC1 [attribute-error] -File "dataclasses_postinit.py", line 29, in : No attribute 'y' on DC1 [attribute-error] -File "dataclasses_postinit.py", line 54, in DC4: Overriding method signature mismatch [signature-mismatch] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 19: Expected 1 errors -Line 36: Expected 1 errors -Line 54: Unexpected errors ['File "dataclasses_postinit.py", line 54, in DC4: Overriding method signature mismatch [signature-mismatch]'] -""" diff --git a/conformance/results/pytype/dataclasses_slots.toml b/conformance/results/pytype/dataclasses_slots.toml deleted file mode 100644 index e9c80134a..000000000 --- a/conformance/results/pytype/dataclasses_slots.toml +++ /dev/null @@ -1,20 +0,0 @@ -conformant = "Partial" -notes = """ -Does not report error when `slots=True` is used with `__slots__` definition. -Does not reject write to instance variable that is not defined in __slots__. -Incorrectly reports error when accessing `__slots__` when `slots=True`. -""" -output = """ -File "dataclasses_slots.py", line 56, in : No attribute '__slots__' on Type[DC5] [attribute-error] -File "dataclasses_slots.py", line 57, in : No attribute '__slots__' on DC5 [attribute-error] -File "dataclasses_slots.py", line 66, in : No attribute '__slots__' on Type[DC6] [attribute-error] -File "dataclasses_slots.py", line 69, in : No attribute '__slots__' on DC6 [attribute-error] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 25: Expected 1 errors -Line 38: Expected 1 errors -Lines 10, 11: Expected error (tag 'DC1') -Line 56: Unexpected errors ['File "dataclasses_slots.py", line 56, in : No attribute \\'__slots__\\' on Type[DC5] [attribute-error]'] -Line 57: Unexpected errors ['File "dataclasses_slots.py", line 57, in : No attribute \\'__slots__\\' on DC5 [attribute-error]'] -""" diff --git a/conformance/results/pytype/dataclasses_transform_class.toml b/conformance/results/pytype/dataclasses_transform_class.toml deleted file mode 100644 index c68dac896..000000000 --- a/conformance/results/pytype/dataclasses_transform_class.toml +++ /dev/null @@ -1,25 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not understand @dataclass_transform. -""" -output = """ -File "dataclasses_transform_class.py", line 23, in : Arguments to dataclass_transform not supported yet [not-supported-yet] -File "dataclasses_transform_class.py", line 57, in : Invalid keyword argument other_name to function Customer1.__init__ [wrong-keyword-args] -File "dataclasses_transform_class.py", line 82, in : Arguments to dataclass_transform not supported yet [not-supported-yet] -File "dataclasses_transform_class.py", line 103, in : Invalid keyword argument id to function GenericCustomer.__init__ [wrong-keyword-args] -File "dataclasses_transform_class.py", line 106, in : Arguments to dataclass_transform not supported yet [not-supported-yet] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 48: Expected 1 errors -Line 60: Expected 1 errors -Line 63: Expected 1 errors -Line 69: Expected 1 errors -Line 79: Expected 1 errors -Line 119: Expected 1 errors -Line 23: Unexpected errors ['File "dataclasses_transform_class.py", line 23, in : Arguments to dataclass_transform not supported yet [not-supported-yet]'] -Line 57: Unexpected errors ['File "dataclasses_transform_class.py", line 57, in : Invalid keyword argument other_name to function Customer1.__init__ [wrong-keyword-args]'] -Line 82: Unexpected errors ['File "dataclasses_transform_class.py", line 82, in : Arguments to dataclass_transform not supported yet [not-supported-yet]'] -Line 103: Unexpected errors ['File "dataclasses_transform_class.py", line 103, in : Invalid keyword argument id to function GenericCustomer.__init__ [wrong-keyword-args]'] -Line 106: Unexpected errors ['File "dataclasses_transform_class.py", line 106, in : Arguments to dataclass_transform not supported yet [not-supported-yet]'] -""" diff --git a/conformance/results/pytype/dataclasses_transform_field.toml b/conformance/results/pytype/dataclasses_transform_field.toml deleted file mode 100644 index 26f330ebc..000000000 --- a/conformance/results/pytype/dataclasses_transform_field.toml +++ /dev/null @@ -1,15 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not understand @dataclass_transform. -""" -output = """ -File "dataclasses_transform_field.py", line 48, in : Arguments to dataclass_transform not supported yet [not-supported-yet] -File "dataclasses_transform_field.py", line 50, in create_model: bad return type [bad-return-type] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 64: Expected 1 errors -Line 75: Expected 1 errors -Line 48: Unexpected errors ['File "dataclasses_transform_field.py", line 48, in : Arguments to dataclass_transform not supported yet [not-supported-yet]'] -Line 50: Unexpected errors ['File "dataclasses_transform_field.py", line 50, in create_model: bad return type [bad-return-type]'] -""" diff --git a/conformance/results/pytype/dataclasses_transform_func.toml b/conformance/results/pytype/dataclasses_transform_func.toml deleted file mode 100644 index 89a1ae2ee..000000000 --- a/conformance/results/pytype/dataclasses_transform_func.toml +++ /dev/null @@ -1,32 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not understand @dataclass_transform. -""" -output = """ -File "dataclasses_transform_func.py", line 13, in : Arguments to dataclass_transform not supported yet [not-supported-yet] -File "dataclasses_transform_func.py", line 19, in : Arguments to dataclass_transform not supported yet [not-supported-yet] -File "dataclasses_transform_func.py", line 30, in create_model: bad return type [bad-return-type] -Called from (traceback): - line 89, in current file -File "dataclasses_transform_func.py", line 30, in create_model: bad return type [bad-return-type] -File "dataclasses_transform_func.py", line 50, in : Invalid keyword arguments (id, name) to function Customer1.__init__ [wrong-keyword-args] -File "dataclasses_transform_func.py", line 53, in : Function Customer1.__init__ expects 1 arg(s), got 3 [wrong-arg-count] -File "dataclasses_transform_func.py", line 57, in : Type annotation for name does not match type of assignment [annotation-type-mismatch] -File "dataclasses_transform_func.py", line 65, in : Invalid keyword arguments (id, name, salary) to function Customer1.__init__ [wrong-keyword-args] -File "dataclasses_transform_func.py", line 67, in : Invalid keyword arguments (id, name) to function Customer2.__init__ [wrong-keyword-args] -File "dataclasses_transform_func.py", line 71, in : Function Customer2.__init__ expects 1 arg(s), got 3 [wrong-arg-count] -File "dataclasses_transform_func.py", line 76, in : Arguments to dataclass_transform not supported yet [not-supported-yet] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 61: Expected 1 errors -Line 97: Expected 1 errors -Lines 89, 90: Expected error (tag 'Customer3Subclass') -Line 13: Unexpected errors ['File "dataclasses_transform_func.py", line 13, in : Arguments to dataclass_transform not supported yet [not-supported-yet]'] -Line 19: Unexpected errors ['File "dataclasses_transform_func.py", line 19, in : Arguments to dataclass_transform not supported yet [not-supported-yet]'] -Line 30: Unexpected errors ['File "dataclasses_transform_func.py", line 30, in create_model: bad return type [bad-return-type]', 'File "dataclasses_transform_func.py", line 30, in create_model: bad return type [bad-return-type]'] -Line 50: Unexpected errors ['File "dataclasses_transform_func.py", line 50, in : Invalid keyword arguments (id, name) to function Customer1.__init__ [wrong-keyword-args]'] -Line 53: Unexpected errors ['File "dataclasses_transform_func.py", line 53, in : Function Customer1.__init__ expects 1 arg(s), got 3 [wrong-arg-count]'] -Line 67: Unexpected errors ['File "dataclasses_transform_func.py", line 67, in : Invalid keyword arguments (id, name) to function Customer2.__init__ [wrong-keyword-args]'] -Line 76: Unexpected errors ['File "dataclasses_transform_func.py", line 76, in : Arguments to dataclass_transform not supported yet [not-supported-yet]'] -""" diff --git a/conformance/results/pytype/dataclasses_transform_meta.toml b/conformance/results/pytype/dataclasses_transform_meta.toml deleted file mode 100644 index e89e4f407..000000000 --- a/conformance/results/pytype/dataclasses_transform_meta.toml +++ /dev/null @@ -1,21 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not understand @dataclass_transform. -""" -output = """ -File "dataclasses_transform_meta.py", line 21, in : Arguments to dataclass_transform not supported yet [not-supported-yet] -File "dataclasses_transform_meta.py", line 57, in : Invalid keyword argument other_name to function Customer1.__init__ [wrong-keyword-args] -File "dataclasses_transform_meta.py", line 83, in : Arguments to dataclass_transform not supported yet [not-supported-yet] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 48: Expected 1 errors -Line 60: Expected 1 errors -Line 63: Expected 1 errors -Line 70: Expected 1 errors -Line 80: Expected 1 errors -Line 100: Expected 1 errors -Line 21: Unexpected errors ['File "dataclasses_transform_meta.py", line 21, in : Arguments to dataclass_transform not supported yet [not-supported-yet]'] -Line 57: Unexpected errors ['File "dataclasses_transform_meta.py", line 57, in : Invalid keyword argument other_name to function Customer1.__init__ [wrong-keyword-args]'] -Line 83: Unexpected errors ['File "dataclasses_transform_meta.py", line 83, in : Arguments to dataclass_transform not supported yet [not-supported-yet]'] -""" diff --git a/conformance/results/pytype/dataclasses_usage.toml b/conformance/results/pytype/dataclasses_usage.toml deleted file mode 100644 index 02ba41ee1..000000000 --- a/conformance/results/pytype/dataclasses_usage.toml +++ /dev/null @@ -1,17 +0,0 @@ -conformant = "Pass" -output = """ -File "dataclasses_usage.py", line 50, in : Missing parameter 'unit_price' in call to function InventoryItem.__init__ [missing-parameter] -File "dataclasses_usage.py", line 51, in : Function InventoryItem.__init__ was called with the wrong arguments [wrong-arg-types] -File "dataclasses_usage.py", line 52, in : Function InventoryItem.__init__ expects 3 arg(s), got 5 [wrong-arg-count] -File "dataclasses_usage.py", line 58, in : In method __init__, non-default argument b follows default argument [invalid-function-definition] -File "dataclasses_usage.py", line 64, in : In method __init__, non-default argument b follows default argument [invalid-function-definition] -File "dataclasses_usage.py", line 70, in : In method __init__, non-default argument b follows default argument [invalid-function-definition] -File "dataclasses_usage.py", line 83, in : Function DC4.__init__ expects 2 arg(s), got 3 [wrong-arg-count] -File "dataclasses_usage.py", line 88, in DC5: Type annotation for a does not match type of assignment [annotation-type-mismatch] -File "dataclasses_usage.py", line 126, in : Function DC7.__init__ expects 2 arg(s), got 3 [wrong-arg-count] -File "dataclasses_usage.py", line 129, in : Missing parameter 'y' in call to function DC8.__init__ [missing-parameter] -File "dataclasses_usage.py", line 178, in : Function DC13.__init__ expects 1 arg(s), got 2 [wrong-arg-count] -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pytype/directives_assert_type.toml b/conformance/results/pytype/directives_assert_type.toml deleted file mode 100644 index a77a3f9ec..000000000 --- a/conformance/results/pytype/directives_assert_type.toml +++ /dev/null @@ -1,15 +0,0 @@ -conformant = "Partial" -notes = """ -Incorrectly allows assert(x, int) where x is a Literal. -""" -output = """ -File "directives_assert_type.py", line 27, in func1: Union[int, str] [assert-type] -File "directives_assert_type.py", line 28, in func1: Any [assert-type] -File "directives_assert_type.py", line 31, in func1: Function assert_type expects 2 arg(s), got 0 [wrong-arg-count] -File "directives_assert_type.py", line 32, in func1: str [assert-type] -File "directives_assert_type.py", line 33, in func1: Function assert_type expects 2 arg(s), got 3 [wrong-arg-count] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 29: Expected 1 errors -""" diff --git a/conformance/results/pytype/directives_cast.toml b/conformance/results/pytype/directives_cast.toml deleted file mode 100644 index 28cc3470d..000000000 --- a/conformance/results/pytype/directives_cast.toml +++ /dev/null @@ -1,12 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject a call to "cast" with additional arguments. -""" -output = """ -File "directives_cast.py", line 15, in : Missing parameter 'typ' in call to function typing.cast [missing-parameter] -File "directives_cast.py", line 16, in : Invalid type annotation '1' for typing.cast [invalid-annotation] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 17: Expected 1 errors -""" diff --git a/conformance/results/pytype/directives_no_type_check.toml b/conformance/results/pytype/directives_no_type_check.toml deleted file mode 100644 index b90eb6f63..000000000 --- a/conformance/results/pytype/directives_no_type_check.toml +++ /dev/null @@ -1,14 +0,0 @@ -conformant = "Pass" -notes = """ -Does not honor @no_type_check decorator. -""" -output = """ -File "directives_no_type_check.py", line 15, in ClassA: Type annotation for x does not match type of assignment [annotation-type-mismatch] -File "directives_no_type_check.py", line 25, in func1: unsupported operand type(s) for +: int and str [unsupported-operands] -File "directives_no_type_check.py", line 26, in func1: bad return type [bad-return-type] -File "directives_no_type_check.py", line 29, in : Function func1 was called with the wrong arguments [wrong-arg-types] -File "directives_no_type_check.py", line 32, in : Missing parameter 'a' in call to function func1 [missing-parameter] -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pytype/directives_reveal_type.toml b/conformance/results/pytype/directives_reveal_type.toml deleted file mode 100644 index 38e08038c..000000000 --- a/conformance/results/pytype/directives_reveal_type.toml +++ /dev/null @@ -1,20 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject call to reveal_type with zero arguments. -Does not reject call to reveal_type with too many arguments. -""" -output = """ -File "directives_reveal_type.py", line 14, in func1: Union[int, str] [reveal-type] -File "directives_reveal_type.py", line 15, in func1: List[int] [reveal-type] -File "directives_reveal_type.py", line 16, in func1: Any [reveal-type] -File "directives_reveal_type.py", line 17, in func1: ForwardReference [reveal-type] -File "directives_reveal_type.py", line 20, in func1: Union[int, str] [reveal-type] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 19: Expected 1 errors -Line 14: Unexpected errors ['File "directives_reveal_type.py", line 14, in func1: Union[int, str] [reveal-type]'] -Line 15: Unexpected errors ['File "directives_reveal_type.py", line 15, in func1: List[int] [reveal-type]'] -Line 16: Unexpected errors ['File "directives_reveal_type.py", line 16, in func1: Any [reveal-type]'] -Line 17: Unexpected errors ['File "directives_reveal_type.py", line 17, in func1: ForwardReference [reveal-type]'] -""" diff --git a/conformance/results/pytype/directives_type_checking.toml b/conformance/results/pytype/directives_type_checking.toml deleted file mode 100644 index a339ad0a1..000000000 --- a/conformance/results/pytype/directives_type_checking.toml +++ /dev/null @@ -1,7 +0,0 @@ -conformant = "Pass" -output = """ - -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pytype/directives_type_ignore.toml b/conformance/results/pytype/directives_type_ignore.toml deleted file mode 100644 index 70b1732e5..000000000 --- a/conformance/results/pytype/directives_type_ignore.toml +++ /dev/null @@ -1,12 +0,0 @@ -conformant = "Partial" -notes = """ -Does not honor "# type: ignore" comment if comment includes additional text. -""" -output = """ -File "directives_type_ignore.py", line 11, in : Type annotation for y does not match type of assignment [annotation-type-mismatch] -File "directives_type_ignore.py", line 11: Stray type comment: ignore - additional stuff [ignored-type-comment] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 11: Unexpected errors ['File "directives_type_ignore.py", line 11, in : Type annotation for y does not match type of assignment [annotation-type-mismatch]', 'File "directives_type_ignore.py", line 11: Stray type comment: ignore - additional stuff [ignored-type-comment]'] -""" diff --git a/conformance/results/pytype/directives_type_ignore_file1.toml b/conformance/results/pytype/directives_type_ignore_file1.toml deleted file mode 100644 index a339ad0a1..000000000 --- a/conformance/results/pytype/directives_type_ignore_file1.toml +++ /dev/null @@ -1,7 +0,0 @@ -conformant = "Pass" -output = """ - -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pytype/directives_type_ignore_file2.toml b/conformance/results/pytype/directives_type_ignore_file2.toml deleted file mode 100644 index 0b11099d3..000000000 --- a/conformance/results/pytype/directives_type_ignore_file2.toml +++ /dev/null @@ -1,11 +0,0 @@ -conformant = "Partial" -notes = """ -Does not ignore `# type: ignore` if it occurs after docstrings in the file. -""" -output = """ - -""" -conformance_automated = "Fail" -errors_diff = """ -Line 14: Expected 1 errors -""" diff --git a/conformance/results/pytype/directives_version_platform.toml b/conformance/results/pytype/directives_version_platform.toml deleted file mode 100644 index 6d9473c7f..000000000 --- a/conformance/results/pytype/directives_version_platform.toml +++ /dev/null @@ -1,13 +0,0 @@ -conformant = "Pass" -notes = """ -Does not understand three-element form of sys.version checks. -Does not understand os.name checks. -""" -output = """ -File "directives_version_platform.py", line 27, in : Type annotation for val3 does not match type of assignment [annotation-type-mismatch] -File "directives_version_platform.py", line 40, in : Type annotation for val7 does not match type of assignment [annotation-type-mismatch] -File "directives_version_platform.py", line 45, in : Type annotation for val8 does not match type of assignment [annotation-type-mismatch] -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pytype/exceptions_context_managers.toml b/conformance/results/pytype/exceptions_context_managers.toml deleted file mode 100644 index 5abf283a5..000000000 --- a/conformance/results/pytype/exceptions_context_managers.toml +++ /dev/null @@ -1,13 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support code flow analysis. -""" -conformance_automated = "Fail" -errors_diff = """ -Line 50: Unexpected errors ['File "exceptions_context_managers.py", line 50, in suppress1: str [assert-type]'] -Line 57: Unexpected errors ['File "exceptions_context_managers.py", line 57, in suppress2: str [assert-type]'] -""" -output = """ -File "exceptions_context_managers.py", line 50, in suppress1: str [assert-type] -File "exceptions_context_managers.py", line 57, in suppress2: str [assert-type] -""" diff --git a/conformance/results/pytype/generics_base_class.toml b/conformance/results/pytype/generics_base_class.toml deleted file mode 100644 index b108aa62e..000000000 --- a/conformance/results/pytype/generics_base_class.toml +++ /dev/null @@ -1,16 +0,0 @@ -conformant = "Partial" -notes = """ -False negative on passing SymbolTable to dict[str, list[object]]. -Does not reject illegal use of Generic. -""" -output = """ -File "generics_base_class.py", line 29, in : Invalid type annotation 'T' [invalid-annotation] -File "generics_base_class.py", line 49, in : Invalid type annotation 'LinkedList[int, int]' [invalid-annotation] -File "generics_base_class.py", line 61, in : Invalid type annotation 'MyDict[int, int]' [invalid-annotation] -File "generics_base_class.py", line 68, in : Invalid type annotation 'Generic' [invalid-annotation] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 26: Expected 1 errors -Line 30: Expected 1 errors -""" diff --git a/conformance/results/pytype/generics_basic.toml b/conformance/results/pytype/generics_basic.toml deleted file mode 100644 index 2089cc5d7..000000000 --- a/conformance/results/pytype/generics_basic.toml +++ /dev/null @@ -1,30 +0,0 @@ -conformant = "Partial" -notes = """ -False positives in examples using constrained type variables. -False negative for generic metaclass. -""" -output = """ -File "generics_basic.py", line 34, in concat: bad return type [bad-return-type] -Called from (traceback): - line 67, in test_concat_subtype -File "generics_basic.py", line 40, in test_concat: Function concat was called with the wrong arguments [wrong-arg-types] -File "generics_basic.py", line 41, in test_concat: Function concat was called with the wrong arguments [wrong-arg-types] -File "generics_basic.py", line 49, in : Invalid TypeVar: the number of constraints must be 0 or more than 1 [invalid-typevar] -File "generics_basic.py", line 55, in Test: Invalid TypeVar: constraint cannot contain TypeVars [invalid-typevar] -File "generics_basic.py", line 67, in test_concat_subtype: MyStr [assert-type] -File "generics_basic.py", line 68, in test_concat_subtype: Function concat was called with the wrong arguments [wrong-arg-types] -File "generics_basic.py", line 68, in test_concat_subtype: Any [assert-type] -File "generics_basic.py", line 69, in test_concat_subtype: Function concat was called with the wrong arguments [wrong-arg-types] -File "generics_basic.py", line 121, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_basic.py", line 157, in test_my_map: unsupported operand type(s) for item retrieval: MyMap1[str, int] and int [unsupported-operands] -File "generics_basic.py", line 158, in test_my_map: unsupported operand type(s) for item retrieval: MyMap2[int, str] and int [unsupported-operands] -File "generics_basic.py", line 182, in test_my_iterable_any: Iterator[nothing] [assert-type] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 191: Expected 1 errors -Line 34: Unexpected errors ['File "generics_basic.py", line 34, in concat: bad return type [bad-return-type]'] -Line 67: Unexpected errors ['File "generics_basic.py", line 67, in test_concat_subtype: MyStr [assert-type]'] -Line 68: Unexpected errors ['File "generics_basic.py", line 68, in test_concat_subtype: Function concat was called with the wrong arguments [wrong-arg-types]', 'File "generics_basic.py", line 68, in test_concat_subtype: Any [assert-type]'] -Line 182: Unexpected errors ['File "generics_basic.py", line 182, in test_my_iterable_any: Iterator[nothing] [assert-type]'] -""" diff --git a/conformance/results/pytype/generics_defaults.toml b/conformance/results/pytype/generics_defaults.toml deleted file mode 100644 index 64fb88a2e..000000000 --- a/conformance/results/pytype/generics_defaults.toml +++ /dev/null @@ -1,98 +0,0 @@ -conformant = "Unsupported" -output = """ -File "generics_defaults.py", line 7, in : typing.Unpack not supported yet [not-supported-yet] -File "generics_defaults.py", line 8, in : typing_extensions.TypeVarTuple not supported yet [not-supported-yet] -File "generics_defaults.py", line 11, in : wrong arguments [invalid-typevar] -File "generics_defaults.py", line 12, in : wrong arguments [invalid-typevar] -File "generics_defaults.py", line 13, in : wrong arguments [invalid-typevar] -File "generics_defaults.py", line 24, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_defaults.py", line 27, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_defaults.py", line 30, in : class NoNonDefaults is not indexable [not-indexable] -File "generics_defaults.py", line 31, in : class NoNonDefaults is not indexable [not-indexable] -File "generics_defaults.py", line 32, in : class NoNonDefaults is not indexable [not-indexable] -File "generics_defaults.py", line 35, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_defaults.py", line 38, in : Invalid type annotation 'OneDefault[float, bool]' [invalid-annotation] -File "generics_defaults.py", line 39, in : Invalid type annotation 'OneDefault[float, bool]' [invalid-annotation] -File "generics_defaults.py", line 42, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_defaults.py", line 45, in : Invalid type annotation 'AllTheDefaults[Any, Any, str, int, bool]' [invalid-annotation] -File "generics_defaults.py", line 47, in : Invalid type annotation 'AllTheDefaults[int, complex, str, int, bool]' [invalid-annotation] -File "generics_defaults.py", line 50, in : Invalid type annotation 'AllTheDefaults[int]' [invalid-annotation] -File "generics_defaults.py", line 53, in : Invalid type annotation 'AllTheDefaults[int, complex, str, int, bool]' [invalid-annotation] -File "generics_defaults.py", line 56, in : Invalid type annotation 'AllTheDefaults[int, complex, str]' [invalid-annotation] -File "generics_defaults.py", line 57, in : Invalid type annotation 'AllTheDefaults[int, complex, str, int, bool]' [invalid-annotation] -File "generics_defaults.py", line 60, in : Invalid type annotation 'AllTheDefaults[int, complex, str, int]' [invalid-annotation] -File "generics_defaults.py", line 61, in : Invalid type annotation 'AllTheDefaults[int, complex, str, int, bool]' [invalid-annotation] -File "generics_defaults.py", line 64, in : Invalid type annotation 'AllTheDefaults[int, complex, str, int, bool]' [invalid-annotation] -File "generics_defaults.py", line 65, in : Invalid type annotation 'AllTheDefaults[int, complex, str, int, bool]' [invalid-annotation] -File "generics_defaults.py", line 73, in : wrong arguments [invalid-typevar] -File "generics_defaults.py", line 76, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_defaults.py", line 79, in : class Class_ParamSpec is not indexable [not-indexable] -File "generics_defaults.py", line 80, in : class Class_ParamSpec is not indexable [not-indexable] -File "generics_defaults.py", line 81, in : class Class_ParamSpec is not indexable [not-indexable] -File "generics_defaults.py", line 91, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_defaults.py", line 94, in : class Class_TypeVarTuple is not indexable [not-indexable] -File "generics_defaults.py", line 95, in : class Class_TypeVarTuple is not indexable [not-indexable] -File "generics_defaults.py", line 96, in : class Class_TypeVarTuple is not indexable [not-indexable] -File "generics_defaults.py", line 103, in : wrong arguments [invalid-typevar] -File "generics_defaults.py", line 104, in : wrong arguments [invalid-typevar] -File "generics_defaults.py", line 110, in : wrong arguments [invalid-typevar] -File "generics_defaults.py", line 111, in : wrong arguments [invalid-typevar] -File "generics_defaults.py", line 121, in : wrong arguments [invalid-typevar] -File "generics_defaults.py", line 127, in : Any [assert-type] -File "generics_defaults.py", line 135, in : wrong arguments [invalid-typevar] -File "generics_defaults.py", line 138, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_defaults.py", line 145, in : wrong arguments [invalid-typevar] -File "generics_defaults.py", line 148, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_defaults.py", line 151, in : class Foo6 is not indexable [not-indexable] -File "generics_defaults.py", line 152, in : class Foo6 is not indexable [not-indexable] -File "generics_defaults.py", line 159, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_defaults.py", line 166, in : class Foo7 is not indexable [not-indexable] -File "generics_defaults.py", line 166, in : Callable[[Any], Self] [assert-type] -File "generics_defaults.py", line 167, in : Any [assert-type] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 7: Unexpected errors ['File "generics_defaults.py", line 7, in : typing.Unpack not supported yet [not-supported-yet]'] -Line 8: Unexpected errors ['File "generics_defaults.py", line 8, in : typing_extensions.TypeVarTuple not supported yet [not-supported-yet]'] -Line 11: Unexpected errors ['File "generics_defaults.py", line 11, in : wrong arguments [invalid-typevar]'] -Line 12: Unexpected errors ['File "generics_defaults.py", line 12, in : wrong arguments [invalid-typevar]'] -Line 13: Unexpected errors ['File "generics_defaults.py", line 13, in : wrong arguments [invalid-typevar]'] -Line 27: Unexpected errors ['File "generics_defaults.py", line 27, in : Invalid type annotation \\'Generic\\' [invalid-annotation]'] -Line 30: Unexpected errors ['File "generics_defaults.py", line 30, in : class NoNonDefaults is not indexable [not-indexable]'] -Line 31: Unexpected errors ['File "generics_defaults.py", line 31, in : class NoNonDefaults is not indexable [not-indexable]'] -Line 32: Unexpected errors ['File "generics_defaults.py", line 32, in : class NoNonDefaults is not indexable [not-indexable]'] -Line 35: Unexpected errors ['File "generics_defaults.py", line 35, in : Invalid type annotation \\'Generic\\' [invalid-annotation]'] -Line 38: Unexpected errors ['File "generics_defaults.py", line 38, in : Invalid type annotation \\'OneDefault[float, bool]\\' [invalid-annotation]'] -Line 39: Unexpected errors ['File "generics_defaults.py", line 39, in : Invalid type annotation \\'OneDefault[float, bool]\\' [invalid-annotation]'] -Line 42: Unexpected errors ['File "generics_defaults.py", line 42, in : Invalid type annotation \\'Generic\\' [invalid-annotation]'] -Line 45: Unexpected errors ['File "generics_defaults.py", line 45, in : Invalid type annotation \\'AllTheDefaults[Any, Any, str, int, bool]\\' [invalid-annotation]'] -Line 47: Unexpected errors ['File "generics_defaults.py", line 47, in : Invalid type annotation \\'AllTheDefaults[int, complex, str, int, bool]\\' [invalid-annotation]'] -Line 53: Unexpected errors ['File "generics_defaults.py", line 53, in : Invalid type annotation \\'AllTheDefaults[int, complex, str, int, bool]\\' [invalid-annotation]'] -Line 56: Unexpected errors ['File "generics_defaults.py", line 56, in : Invalid type annotation \\'AllTheDefaults[int, complex, str]\\' [invalid-annotation]'] -Line 57: Unexpected errors ['File "generics_defaults.py", line 57, in : Invalid type annotation \\'AllTheDefaults[int, complex, str, int, bool]\\' [invalid-annotation]'] -Line 60: Unexpected errors ['File "generics_defaults.py", line 60, in : Invalid type annotation \\'AllTheDefaults[int, complex, str, int]\\' [invalid-annotation]'] -Line 61: Unexpected errors ['File "generics_defaults.py", line 61, in : Invalid type annotation \\'AllTheDefaults[int, complex, str, int, bool]\\' [invalid-annotation]'] -Line 64: Unexpected errors ['File "generics_defaults.py", line 64, in : Invalid type annotation \\'AllTheDefaults[int, complex, str, int, bool]\\' [invalid-annotation]'] -Line 65: Unexpected errors ['File "generics_defaults.py", line 65, in : Invalid type annotation \\'AllTheDefaults[int, complex, str, int, bool]\\' [invalid-annotation]'] -Line 73: Unexpected errors ['File "generics_defaults.py", line 73, in : wrong arguments [invalid-typevar]'] -Line 76: Unexpected errors ['File "generics_defaults.py", line 76, in : Invalid type annotation \\'Generic\\' [invalid-annotation]'] -Line 79: Unexpected errors ['File "generics_defaults.py", line 79, in : class Class_ParamSpec is not indexable [not-indexable]'] -Line 80: Unexpected errors ['File "generics_defaults.py", line 80, in : class Class_ParamSpec is not indexable [not-indexable]'] -Line 81: Unexpected errors ['File "generics_defaults.py", line 81, in : class Class_ParamSpec is not indexable [not-indexable]'] -Line 91: Unexpected errors ['File "generics_defaults.py", line 91, in : Invalid type annotation \\'Generic\\' [invalid-annotation]'] -Line 94: Unexpected errors ['File "generics_defaults.py", line 94, in : class Class_TypeVarTuple is not indexable [not-indexable]'] -Line 95: Unexpected errors ['File "generics_defaults.py", line 95, in : class Class_TypeVarTuple is not indexable [not-indexable]'] -Line 96: Unexpected errors ['File "generics_defaults.py", line 96, in : class Class_TypeVarTuple is not indexable [not-indexable]'] -Line 103: Unexpected errors ['File "generics_defaults.py", line 103, in : wrong arguments [invalid-typevar]'] -Line 110: Unexpected errors ['File "generics_defaults.py", line 110, in : wrong arguments [invalid-typevar]'] -Line 121: Unexpected errors ['File "generics_defaults.py", line 121, in : wrong arguments [invalid-typevar]'] -Line 127: Unexpected errors ['File "generics_defaults.py", line 127, in : Any [assert-type]'] -Line 135: Unexpected errors ['File "generics_defaults.py", line 135, in : wrong arguments [invalid-typevar]'] -Line 145: Unexpected errors ['File "generics_defaults.py", line 145, in : wrong arguments [invalid-typevar]'] -Line 148: Unexpected errors ['File "generics_defaults.py", line 148, in : Invalid type annotation \\'Generic\\' [invalid-annotation]'] -Line 151: Unexpected errors ['File "generics_defaults.py", line 151, in : class Foo6 is not indexable [not-indexable]'] -Line 152: Unexpected errors ['File "generics_defaults.py", line 152, in : class Foo6 is not indexable [not-indexable]'] -Line 159: Unexpected errors ['File "generics_defaults.py", line 159, in : Invalid type annotation \\'Generic\\' [invalid-annotation]'] -Line 166: Unexpected errors ['File "generics_defaults.py", line 166, in : class Foo7 is not indexable [not-indexable]', 'File "generics_defaults.py", line 166, in : Callable[[Any], Self] [assert-type]'] -Line 167: Unexpected errors ['File "generics_defaults.py", line 167, in : Any [assert-type]'] -""" diff --git a/conformance/results/pytype/generics_defaults_referential.toml b/conformance/results/pytype/generics_defaults_referential.toml deleted file mode 100644 index 133bd7943..000000000 --- a/conformance/results/pytype/generics_defaults_referential.toml +++ /dev/null @@ -1,65 +0,0 @@ -conformant = "Unsupported" -output = """ -File "generics_defaults_referential.py", line 14, in : wrong arguments [invalid-typevar] -File "generics_defaults_referential.py", line 15, in : wrong arguments [invalid-typevar] -File "generics_defaults_referential.py", line 16, in : wrong arguments [invalid-typevar] -File "generics_defaults_referential.py", line 17, in : wrong arguments [invalid-typevar] -File "generics_defaults_referential.py", line 20, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_defaults_referential.py", line 23, in : class slice is not indexable [not-indexable] -File "generics_defaults_referential.py", line 24, in : class slice is not indexable [not-indexable] -File "generics_defaults_referential.py", line 25, in : class slice is not indexable [not-indexable] -File "generics_defaults_referential.py", line 26, in : class slice is not indexable [not-indexable] -File "generics_defaults_referential.py", line 28, in : wrong arguments [invalid-typevar] -File "generics_defaults_referential.py", line 31, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_defaults_referential.py", line 35, in : class Foo is not indexable [not-indexable] -File "generics_defaults_referential.py", line 36, in : class Foo is not indexable [not-indexable] -File "generics_defaults_referential.py", line 37, in : class Foo is not indexable [not-indexable] -File "generics_defaults_referential.py", line 43, in : wrong arguments [invalid-typevar] -File "generics_defaults_referential.py", line 46, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_defaults_referential.py", line 49, in : wrong arguments [invalid-typevar] -File "generics_defaults_referential.py", line 50, in : wrong arguments [invalid-typevar] -File "generics_defaults_referential.py", line 53, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_defaults_referential.py", line 60, in Foo3: Invalid type annotation 'Generic' [invalid-annotation] -File "generics_defaults_referential.py", line 66, in : wrong arguments [invalid-typevar] -File "generics_defaults_referential.py", line 67, in : wrong arguments [invalid-typevar] -File "generics_defaults_referential.py", line 68, in : wrong arguments [invalid-typevar] -File "generics_defaults_referential.py", line 74, in : wrong arguments [invalid-typevar] -File "generics_defaults_referential.py", line 77, in : wrong arguments [invalid-typevar] -File "generics_defaults_referential.py", line 78, in : wrong arguments [invalid-typevar] -File "generics_defaults_referential.py", line 87, in : wrong arguments [invalid-typevar] -File "generics_defaults_referential.py", line 90, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_defaults_referential.py", line 94, in : Invalid type annotation 'Bar[Any, list]' [invalid-annotation] -File "generics_defaults_referential.py", line 95, in : Invalid type annotation 'Bar[int, List[int]]' [invalid-annotation] -File "generics_defaults_referential.py", line 96, in : Invalid type annotation 'Bar[int, List[int]]' [invalid-annotation] -File "generics_defaults_referential.py", line 97, in : Invalid type annotation 'Bar[int, List[str]]' [invalid-annotation] -File "generics_defaults_referential.py", line 98, in : Invalid type annotation 'Bar[int, str]' [invalid-annotation] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 14: Unexpected errors ['File "generics_defaults_referential.py", line 14, in : wrong arguments [invalid-typevar]'] -Line 15: Unexpected errors ['File "generics_defaults_referential.py", line 15, in : wrong arguments [invalid-typevar]'] -Line 16: Unexpected errors ['File "generics_defaults_referential.py", line 16, in : wrong arguments [invalid-typevar]'] -Line 17: Unexpected errors ['File "generics_defaults_referential.py", line 17, in : wrong arguments [invalid-typevar]'] -Line 20: Unexpected errors ['File "generics_defaults_referential.py", line 20, in : Invalid type annotation \\'Generic\\' [invalid-annotation]'] -Line 23: Unexpected errors ['File "generics_defaults_referential.py", line 23, in : class slice is not indexable [not-indexable]'] -Line 24: Unexpected errors ['File "generics_defaults_referential.py", line 24, in : class slice is not indexable [not-indexable]'] -Line 25: Unexpected errors ['File "generics_defaults_referential.py", line 25, in : class slice is not indexable [not-indexable]'] -Line 26: Unexpected errors ['File "generics_defaults_referential.py", line 26, in : class slice is not indexable [not-indexable]'] -Line 28: Unexpected errors ['File "generics_defaults_referential.py", line 28, in : wrong arguments [invalid-typevar]'] -Line 31: Unexpected errors ['File "generics_defaults_referential.py", line 31, in : Invalid type annotation \\'Generic\\' [invalid-annotation]'] -Line 35: Unexpected errors ['File "generics_defaults_referential.py", line 35, in : class Foo is not indexable [not-indexable]'] -Line 43: Unexpected errors ['File "generics_defaults_referential.py", line 43, in : wrong arguments [invalid-typevar]'] -Line 46: Unexpected errors ['File "generics_defaults_referential.py", line 46, in : Invalid type annotation \\'Generic\\' [invalid-annotation]'] -Line 49: Unexpected errors ['File "generics_defaults_referential.py", line 49, in : wrong arguments [invalid-typevar]'] -Line 50: Unexpected errors ['File "generics_defaults_referential.py", line 50, in : wrong arguments [invalid-typevar]'] -Line 66: Unexpected errors ['File "generics_defaults_referential.py", line 66, in : wrong arguments [invalid-typevar]'] -Line 67: Unexpected errors ['File "generics_defaults_referential.py", line 67, in : wrong arguments [invalid-typevar]'] -Line 77: Unexpected errors ['File "generics_defaults_referential.py", line 77, in : wrong arguments [invalid-typevar]'] -Line 87: Unexpected errors ['File "generics_defaults_referential.py", line 87, in : wrong arguments [invalid-typevar]'] -Line 90: Unexpected errors ['File "generics_defaults_referential.py", line 90, in : Invalid type annotation \\'Generic\\' [invalid-annotation]'] -Line 94: Unexpected errors ['File "generics_defaults_referential.py", line 94, in : Invalid type annotation \\'Bar[Any, list]\\' [invalid-annotation]'] -Line 95: Unexpected errors ['File "generics_defaults_referential.py", line 95, in : Invalid type annotation \\'Bar[int, List[int]]\\' [invalid-annotation]'] -Line 96: Unexpected errors ['File "generics_defaults_referential.py", line 96, in : Invalid type annotation \\'Bar[int, List[int]]\\' [invalid-annotation]'] -Line 97: Unexpected errors ['File "generics_defaults_referential.py", line 97, in : Invalid type annotation \\'Bar[int, List[str]]\\' [invalid-annotation]'] -Line 98: Unexpected errors ['File "generics_defaults_referential.py", line 98, in : Invalid type annotation \\'Bar[int, str]\\' [invalid-annotation]'] -""" diff --git a/conformance/results/pytype/generics_defaults_specialization.toml b/conformance/results/pytype/generics_defaults_specialization.toml deleted file mode 100644 index 2256fad5c..000000000 --- a/conformance/results/pytype/generics_defaults_specialization.toml +++ /dev/null @@ -1,35 +0,0 @@ -conformant = "Unsupported" -output = """ -File "generics_defaults_specialization.py", line 15, in : wrong arguments [invalid-typevar] -File "generics_defaults_specialization.py", line 16, in : wrong arguments [invalid-typevar] -File "generics_defaults_specialization.py", line 25, in : Invalid type annotation 'SomethingWithNoDefaults[int, Any][bool]' [invalid-annotation] -File "generics_defaults_specialization.py", line 26, in func1: SomethingWithNoDefaults[int, Any] [assert-type] -File "generics_defaults_specialization.py", line 27, in func1: SomethingWithNoDefaults[int, Any] [assert-type] -File "generics_defaults_specialization.py", line 30, in : Invalid type annotation 'SomethingWithNoDefaults[int, Any][bool, int]' [invalid-annotation] -File "generics_defaults_specialization.py", line 38, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_defaults_specialization.py", line 42, in : Invalid type annotation 'SubclassMe[int, Any]' [invalid-annotation] -File "generics_defaults_specialization.py", line 45, in : class Bar is not indexable [not-indexable] -File "generics_defaults_specialization.py", line 46, in : class Bar is not indexable [not-indexable] -File "generics_defaults_specialization.py", line 47, in : class Bar is not indexable [not-indexable] -File "generics_defaults_specialization.py", line 53, in : Any [assert-type] -File "generics_defaults_specialization.py", line 55, in : class Foo is not indexable [not-indexable] -File "generics_defaults_specialization.py", line 58, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_defaults_specialization.py", line 65, in : class Baz is not indexable [not-indexable] -File "generics_defaults_specialization.py", line 65, in : Invalid type annotation 'Baz[int, str]' [invalid-annotation] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 15: Unexpected errors ['File "generics_defaults_specialization.py", line 15, in : wrong arguments [invalid-typevar]'] -Line 16: Unexpected errors ['File "generics_defaults_specialization.py", line 16, in : wrong arguments [invalid-typevar]'] -Line 25: Unexpected errors ['File "generics_defaults_specialization.py", line 25, in : Invalid type annotation \\'SomethingWithNoDefaults[int, Any][bool]\\' [invalid-annotation]'] -Line 26: Unexpected errors ['File "generics_defaults_specialization.py", line 26, in func1: SomethingWithNoDefaults[int, Any] [assert-type]'] -Line 27: Unexpected errors ['File "generics_defaults_specialization.py", line 27, in func1: SomethingWithNoDefaults[int, Any] [assert-type]'] -Line 38: Unexpected errors ['File "generics_defaults_specialization.py", line 38, in : Invalid type annotation \\'Generic\\' [invalid-annotation]'] -Line 42: Unexpected errors ['File "generics_defaults_specialization.py", line 42, in : Invalid type annotation \\'SubclassMe[int, Any]\\' [invalid-annotation]'] -Line 45: Unexpected errors ['File "generics_defaults_specialization.py", line 45, in : class Bar is not indexable [not-indexable]'] -Line 46: Unexpected errors ['File "generics_defaults_specialization.py", line 46, in : class Bar is not indexable [not-indexable]'] -Line 47: Unexpected errors ['File "generics_defaults_specialization.py", line 47, in : class Bar is not indexable [not-indexable]'] -Line 53: Unexpected errors ['File "generics_defaults_specialization.py", line 53, in : Any [assert-type]'] -Line 58: Unexpected errors ['File "generics_defaults_specialization.py", line 58, in : Invalid type annotation \\'Generic\\' [invalid-annotation]'] -Line 65: Unexpected errors ['File "generics_defaults_specialization.py", line 65, in : class Baz is not indexable [not-indexable]', 'File "generics_defaults_specialization.py", line 65, in : Invalid type annotation \\'Baz[int, str]\\' [invalid-annotation]'] -""" diff --git a/conformance/results/pytype/generics_paramspec_basic.toml b/conformance/results/pytype/generics_paramspec_basic.toml deleted file mode 100644 index e57c04905..000000000 --- a/conformance/results/pytype/generics_paramspec_basic.toml +++ /dev/null @@ -1,17 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support ParamSpec. -""" -output = """ -AssertionError: -""" -conformance_automated = "Fail" -errors_diff = """ -Line 10: Expected 1 errors -Line 15: Expected 1 errors -Line 23: Expected 1 errors -Line 27: Expected 1 errors -Line 31: Expected 1 errors -Line 35: Expected 1 errors -Line 39: Expected 1 errors -""" diff --git a/conformance/results/pytype/generics_paramspec_components.toml b/conformance/results/pytype/generics_paramspec_components.toml deleted file mode 100644 index 247d208ed..000000000 --- a/conformance/results/pytype/generics_paramspec_components.toml +++ /dev/null @@ -1,26 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support ParamSpec. -""" -output = """ -NotImplementedError: ParamSpecArgs -""" -conformance_automated = "Fail" -errors_diff = """ -Line 17: Expected 1 errors -Line 20: Expected 1 errors -Line 23: Expected 1 errors -Line 26: Expected 1 errors -Line 30: Expected 1 errors -Line 35: Expected 1 errors -Line 36: Expected 1 errors -Line 38: Expected 1 errors -Line 41: Expected 1 errors -Line 49: Expected 1 errors -Line 51: Expected 1 errors -Line 60: Expected 1 errors -Line 70: Expected 1 errors -Line 72: Expected 1 errors -Line 83: Expected 1 errors -Line 98: Expected 1 errors -""" diff --git a/conformance/results/pytype/generics_paramspec_semantics.toml b/conformance/results/pytype/generics_paramspec_semantics.toml deleted file mode 100644 index 51f74c3c0..000000000 --- a/conformance/results/pytype/generics_paramspec_semantics.toml +++ /dev/null @@ -1,19 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support ParamSpec. -""" -output = """ -AssertionError: -""" -conformance_automated = "Fail" -errors_diff = """ -Line 26: Expected 1 errors -Line 27: Expected 1 errors -Line 61: Expected 1 errors -Line 97: Expected 1 errors -Line 107: Expected 1 errors -Line 119: Expected 1 errors -Line 126: Expected 1 errors -Line 131: Expected 1 errors -Line 136: Expected 1 errors -""" diff --git a/conformance/results/pytype/generics_paramspec_specialization.toml b/conformance/results/pytype/generics_paramspec_specialization.toml deleted file mode 100644 index 683e24760..000000000 --- a/conformance/results/pytype/generics_paramspec_specialization.toml +++ /dev/null @@ -1,31 +0,0 @@ -conformant = "Partial" -notes = """ -Rejects valid specialization of ParamSpec using list expression. -Does not reject invalid specialization of class with both TypeVar and ParamSpec. -Reports error for valid method call involving ParamSpec. -""" -output = """ -File "generics_paramspec_specialization.py", line 33, in : Invalid type annotation '[int, bool]' [invalid-annotation] -File "generics_paramspec_specialization.py", line 33, in : Invalid type annotation 'Ellipsis' [invalid-annotation] -File "generics_paramspec_specialization.py", line 37, in : Invalid type annotation 'Ellipsis' [invalid-annotation] -File "generics_paramspec_specialization.py", line 41, in : Invalid type annotation '[]' [invalid-annotation] -File "generics_paramspec_specialization.py", line 53, in : Invalid type annotation '[int, str, bool]' [invalid-annotation] -File "generics_paramspec_specialization.py", line 54, in func30: Function expects 1 arg(s), got 3 [wrong-arg-count] -File "generics_paramspec_specialization.py", line 55, in func30: Function expects 1 arg(s), got 3 [wrong-arg-count] -File "generics_paramspec_specialization.py", line 56, in func30: Function expects 1 arg(s), got 3 [wrong-arg-count] -File "generics_paramspec_specialization.py", line 59, in : Invalid type annotation 'ClassC[int, str, bool]' [invalid-annotation] -File "generics_paramspec_specialization.py", line 60, in func31: Function expects 1 arg(s), got 3 [wrong-arg-count] -File "generics_paramspec_specialization.py", line 61, in func31: Function expects 1 arg(s), got 3 [wrong-arg-count] -File "generics_paramspec_specialization.py", line 62, in func31: Function expects 1 arg(s), got 3 [wrong-arg-count] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 45: Expected 1 errors -Line 33: Unexpected errors ['File "generics_paramspec_specialization.py", line 33, in : Invalid type annotation \\'[int, bool]\\' [invalid-annotation]', 'File "generics_paramspec_specialization.py", line 33, in : Invalid type annotation \\'Ellipsis\\' [invalid-annotation]'] -Line 37: Unexpected errors ['File "generics_paramspec_specialization.py", line 37, in : Invalid type annotation \\'Ellipsis\\' [invalid-annotation]'] -Line 41: Unexpected errors ['File "generics_paramspec_specialization.py", line 41, in : Invalid type annotation \\'[]\\' [invalid-annotation]'] -Line 53: Unexpected errors ['File "generics_paramspec_specialization.py", line 53, in : Invalid type annotation \\'[int, str, bool]\\' [invalid-annotation]'] -Line 54: Unexpected errors ['File "generics_paramspec_specialization.py", line 54, in func30: Function expects 1 arg(s), got 3 [wrong-arg-count]'] -Line 59: Unexpected errors ['File "generics_paramspec_specialization.py", line 59, in : Invalid type annotation \\'ClassC[int, str, bool]\\' [invalid-annotation]'] -Line 60: Unexpected errors ['File "generics_paramspec_specialization.py", line 60, in func31: Function expects 1 arg(s), got 3 [wrong-arg-count]'] -""" diff --git a/conformance/results/pytype/generics_scoping.toml b/conformance/results/pytype/generics_scoping.toml deleted file mode 100644 index a31965cd4..000000000 --- a/conformance/results/pytype/generics_scoping.toml +++ /dev/null @@ -1,24 +0,0 @@ -conformant = "Partial" -notes = """ -Fails to reject type alias within generic class that uses class's type variable. -Fails to reject unbound type variable in constructor call in global scope. -""" -output = """ -File "generics_scoping.py", line 29, in : Function MyClass.meth_2 was called with the wrong arguments [wrong-arg-types] -File "generics_scoping.py", line 50, in fun_3: Invalid type annotation 'List[S]' for z [invalid-annotation] -File "generics_scoping.py", line 54, in Bar: Invalid type annotation 'List[S]' for an_attr [invalid-annotation] -File "generics_scoping.py", line 63, in fun_4: Invalid type annotation 'T' [invalid-annotation] -File "generics_scoping.py", line 74, in : Invalid type annotation 'Outer' [invalid-annotation] -File "generics_scoping.py", line 78, in AlsoBad: Invalid type annotation 'List[T]' for x [invalid-annotation] -File "generics_scoping.py", line 88, in : Invalid type annotation 'T' for global_var1 [invalid-annotation] -File "generics_scoping.py", line 89, in : Invalid type annotation 'List[T]' for global_var2 [invalid-annotation] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 65: Expected 1 errors -Line 75: Expected 1 errors -Line 84: Expected 1 errors -Line 90: Expected 1 errors -Line 63: Unexpected errors ['File "generics_scoping.py", line 63, in fun_4: Invalid type annotation \\'T\\' [invalid-annotation]'] -Line 74: Unexpected errors ['File "generics_scoping.py", line 74, in : Invalid type annotation \\'Outer\\' [invalid-annotation]'] -""" diff --git a/conformance/results/pytype/generics_self_advanced.toml b/conformance/results/pytype/generics_self_advanced.toml deleted file mode 100644 index 253ce01a6..000000000 --- a/conformance/results/pytype/generics_self_advanced.toml +++ /dev/null @@ -1,39 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not understand `Self` type. -""" -output = """ -File "generics_self_advanced.py", line 12, in prop1: bad return type [bad-return-type] -Called from (traceback): - line 19, in current file -File "generics_self_advanced.py", line 12, in prop1: bad return type [bad-return-type] -Called from (traceback): - line 18, in current file -File "generics_self_advanced.py", line 19, in : ParentA [assert-type] -File "generics_self_advanced.py", line 29, in method1: bad return type [bad-return-type] -Called from (traceback): - line 38, in method2 -File "generics_self_advanced.py", line 29, in method1: bad return type [bad-return-type] -File "generics_self_advanced.py", line 35, in method2: ChildB [assert-type] -File "generics_self_advanced.py", line 36, in method2: List[ChildB] [assert-type] -File "generics_self_advanced.py", line 37, in method2: ChildB [assert-type] -File "generics_self_advanced.py", line 38, in method2: ChildB [assert-type] -File "generics_self_advanced.py", line 42, in method3: Type[ChildB] [assert-type] -File "generics_self_advanced.py", line 43, in method3: List[ChildB] [assert-type] -File "generics_self_advanced.py", line 44, in method3: ChildB [assert-type] -File "generics_self_advanced.py", line 45, in method3: ChildB [assert-type] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 12: Unexpected errors ['File "generics_self_advanced.py", line 12, in prop1: bad return type [bad-return-type]', 'File "generics_self_advanced.py", line 12, in prop1: bad return type [bad-return-type]'] -Line 19: Unexpected errors ['File "generics_self_advanced.py", line 19, in : ParentA [assert-type]'] -Line 29: Unexpected errors ['File "generics_self_advanced.py", line 29, in method1: bad return type [bad-return-type]', 'File "generics_self_advanced.py", line 29, in method1: bad return type [bad-return-type]'] -Line 35: Unexpected errors ['File "generics_self_advanced.py", line 35, in method2: ChildB [assert-type]'] -Line 36: Unexpected errors ['File "generics_self_advanced.py", line 36, in method2: List[ChildB] [assert-type]'] -Line 37: Unexpected errors ['File "generics_self_advanced.py", line 37, in method2: ChildB [assert-type]'] -Line 38: Unexpected errors ['File "generics_self_advanced.py", line 38, in method2: ChildB [assert-type]'] -Line 42: Unexpected errors ['File "generics_self_advanced.py", line 42, in method3: Type[ChildB] [assert-type]'] -Line 43: Unexpected errors ['File "generics_self_advanced.py", line 43, in method3: List[ChildB] [assert-type]'] -Line 44: Unexpected errors ['File "generics_self_advanced.py", line 44, in method3: ChildB [assert-type]'] -Line 45: Unexpected errors ['File "generics_self_advanced.py", line 45, in method3: ChildB [assert-type]'] -""" diff --git a/conformance/results/pytype/generics_self_attributes.toml b/conformance/results/pytype/generics_self_attributes.toml deleted file mode 100644 index 940249455..000000000 --- a/conformance/results/pytype/generics_self_attributes.toml +++ /dev/null @@ -1,11 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not understand `Self` type. -""" -output = """ -File "generics_self_attributes.py", line 26, in : Function OrdinalLinkedList.__init__ was called with the wrong arguments [wrong-arg-types] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 32: Expected 1 errors -""" diff --git a/conformance/results/pytype/generics_self_basic.toml b/conformance/results/pytype/generics_self_basic.toml deleted file mode 100644 index f56e7ede2..000000000 --- a/conformance/results/pytype/generics_self_basic.toml +++ /dev/null @@ -1,34 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not understand `Self` type. -""" -output = """ -File "generics_self_basic.py", line 14, in set_scale: Shape [assert-type] -File "generics_self_basic.py", line 14, in set_scale: Circle [assert-type] -Called from (traceback): - line 52, in current file -File "generics_self_basic.py", line 27, in from_config: Type[Shape] [assert-type] -Called from (traceback): - line 54, in current file -File "generics_self_basic.py", line 27, in from_config: Type[Circle] [assert-type] -Called from (traceback): - line 55, in current file -File "generics_self_basic.py", line 40, in difference: Shape [assert-type] -File "generics_self_basic.py", line 61, in set_value: bad return type [bad-return-type] -Called from (traceback): - line 72, in object_with_concrete_type -File "generics_self_basic.py", line 61, in set_value: bad return type [bad-return-type] -Called from (traceback): - line 71, in object_with_concrete_type -File "generics_self_basic.py", line 61, in set_value: bad return type [bad-return-type] -File "generics_self_basic.py", line 64, in Container: unsupported operand type(s) for item retrieval: 'Self: TypeVar' and 'int: Type[int]' [unsupported-operands] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 20: Expected 1 errors -Line 33: Expected 1 errors -Line 14: Unexpected errors ['File "generics_self_basic.py", line 14, in set_scale: Shape [assert-type]', 'File "generics_self_basic.py", line 14, in set_scale: Circle [assert-type]'] -Line 27: Unexpected errors ['File "generics_self_basic.py", line 27, in from_config: Type[Shape] [assert-type]', 'File "generics_self_basic.py", line 27, in from_config: Type[Circle] [assert-type]'] -Line 40: Unexpected errors ['File "generics_self_basic.py", line 40, in difference: Shape [assert-type]'] -Line 61: Unexpected errors ['File "generics_self_basic.py", line 61, in set_value: bad return type [bad-return-type]', 'File "generics_self_basic.py", line 61, in set_value: bad return type [bad-return-type]', 'File "generics_self_basic.py", line 61, in set_value: bad return type [bad-return-type]'] -""" diff --git a/conformance/results/pytype/generics_self_protocols.toml b/conformance/results/pytype/generics_self_protocols.toml deleted file mode 100644 index 2f76c782b..000000000 --- a/conformance/results/pytype/generics_self_protocols.toml +++ /dev/null @@ -1,12 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject protocol compatibility due to method `Self` return type. -""" -output = """ - -""" -conformance_automated = "Fail" -errors_diff = """ -Line 61: Expected 1 errors -Line 64: Expected 1 errors -""" diff --git a/conformance/results/pytype/generics_self_usage.toml b/conformance/results/pytype/generics_self_usage.toml deleted file mode 100644 index d0a2b4aa4..000000000 --- a/conformance/results/pytype/generics_self_usage.toml +++ /dev/null @@ -1,28 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not understand `Self` type. -""" -output = """ -File "generics_self_usage.py", line 58, in foo: Invalid type annotation 'Self' [invalid-annotation] -File "generics_self_usage.py", line 73, in : Invalid type annotation 'Self' [invalid-annotation] -File "generics_self_usage.py", line 76, in : Invalid type annotation 'Self' for bar [invalid-annotation] -File "generics_self_usage.py", line 82, in has_existing_self_annotation: bad return type [bad-return-type] -File "generics_self_usage.py", line 86, in return_concrete_type: bad return type [bad-return-type] -Called from (traceback): - line 92, in child_method -File "generics_self_usage.py", line 103, in : Invalid base class: Self [base-class-error] -File "generics_self_usage.py", line 111, in Base: Invalid type annotation 'Self' [invalid-annotation] -File "generics_self_usage.py", line 116, in Base: Invalid type annotation 'Self' [invalid-annotation] -File "generics_self_usage.py", line 122, in __new__: bad return type [bad-return-type] -File "generics_self_usage.py", line 126, in __mul__: bad return type [bad-return-type] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 101: Expected 1 errors -Line 106: Expected 1 errors -Line 121: Expected 1 errors -Line 125: Expected 1 errors -Line 58: Unexpected errors ['File "generics_self_usage.py", line 58, in foo: Invalid type annotation \\'Self\\' [invalid-annotation]'] -Line 122: Unexpected errors ['File "generics_self_usage.py", line 122, in __new__: bad return type [bad-return-type]'] -Line 126: Unexpected errors ['File "generics_self_usage.py", line 126, in __mul__: bad return type [bad-return-type]'] -""" diff --git a/conformance/results/pytype/generics_syntax_compatibility.toml b/conformance/results/pytype/generics_syntax_compatibility.toml deleted file mode 100644 index 55006657c..000000000 --- a/conformance/results/pytype/generics_syntax_compatibility.toml +++ /dev/null @@ -1,12 +0,0 @@ -conformant = "Unsupported" -notes = """ -Type parameter syntax not yet support. -""" -output = """ -SyntaxError: Type parameter lists are only supported in Python 3.12 and greater (, line 14) -""" -conformance_automated = "Fail" -errors_diff = """ -Line 14: Expected 1 errors -Line 26: Expected 1 errors -""" diff --git a/conformance/results/pytype/generics_syntax_declarations.toml b/conformance/results/pytype/generics_syntax_declarations.toml deleted file mode 100644 index 3eeb56529..000000000 --- a/conformance/results/pytype/generics_syntax_declarations.toml +++ /dev/null @@ -1,20 +0,0 @@ -conformant = "Unsupported" -notes = """ -Type parameter syntax not yet support. -""" -output = """ -SyntaxError: Type parameter lists are only supported in Python 3.12 and greater (, line 13) -""" -conformance_automated = "Fail" -errors_diff = """ -Line 19: Expected 1 errors -Line 27: Expected 1 errors -Line 34: Expected 1 errors -Line 46: Expected 1 errors -Line 50: Expected 1 errors -Line 62: Expected 1 errors -Line 66: Expected 1 errors -Line 73: Expected 1 errors -Line 77: Expected 1 errors -Line 81: Expected 1 errors -""" diff --git a/conformance/results/pytype/generics_syntax_infer_variance.toml b/conformance/results/pytype/generics_syntax_infer_variance.toml deleted file mode 100644 index ba30a2890..000000000 --- a/conformance/results/pytype/generics_syntax_infer_variance.toml +++ /dev/null @@ -1,29 +0,0 @@ -conformant = "Unsupported" -notes = """ -Type parameter syntax not yet support. -""" -output = """ -SyntaxError: Type parameter lists are only supported in Python 3.12 and greater (, line 125) -""" -conformance_automated = "Fail" -errors_diff = """ -Line 15: Expected 1 errors -Line 17: Expected 1 errors -Line 29: Expected 1 errors -Line 37: Expected 1 errors -Line 46: Expected 1 errors -Line 55: Expected 1 errors -Line 68: Expected 1 errors -Line 79: Expected 1 errors -Line 95: Expected 1 errors -Line 96: Expected 1 errors -Line 110: Expected 1 errors -Line 111: Expected 1 errors -Line 118: Expected 1 errors -Line 119: Expected 1 errors -Line 120: Expected 1 errors -Line 121: Expected 1 errors -Line 129: Expected 1 errors -Line 137: Expected 1 errors -Line 148: Expected 1 errors -""" diff --git a/conformance/results/pytype/generics_syntax_scoping.toml b/conformance/results/pytype/generics_syntax_scoping.toml deleted file mode 100644 index 0e811a233..000000000 --- a/conformance/results/pytype/generics_syntax_scoping.toml +++ /dev/null @@ -1,17 +0,0 @@ -conformant = "Unsupported" -notes = """ -Type parameter syntax not yet support. -""" -output = """ -SyntaxError: Type parameter lists are only supported in Python 3.12 and greater (, line 14) -""" -conformance_automated = "Fail" -errors_diff = """ -Line 14: Expected 1 errors -Line 18: Expected 1 errors -Line 35: Expected 1 errors -Line 44: Expected 1 errors -Line 92: Expected 1 errors -Line 95: Expected 1 errors -Line 98: Expected 1 errors -""" diff --git a/conformance/results/pytype/generics_type_erasure.toml b/conformance/results/pytype/generics_type_erasure.toml deleted file mode 100644 index c49e01d34..000000000 --- a/conformance/results/pytype/generics_type_erasure.toml +++ /dev/null @@ -1,14 +0,0 @@ -conformant = "Unsupported" -output = """ -NotImplementedError: ParameterizedClass -""" -conformance_automated = "Fail" -errors_diff = """ -Line 36: Expected 1 errors -Line 38: Expected 1 errors -Line 40: Expected 1 errors -Line 41: Expected 1 errors -Line 42: Expected 1 errors -Line 43: Expected 1 errors -Line 44: Expected 1 errors -""" diff --git a/conformance/results/pytype/generics_typevartuple_args.toml b/conformance/results/pytype/generics_typevartuple_args.toml deleted file mode 100644 index f74bb0691..000000000 --- a/conformance/results/pytype/generics_typevartuple_args.toml +++ /dev/null @@ -1,52 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support TypeVarTuple. -""" -output = """ -File "generics_typevartuple_args.py", line 10, in : typing.TypeVarTuple not supported yet [not-supported-yet] -File "generics_typevartuple_args.py", line 13, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] -File "generics_typevartuple_args.py", line 16, in : No attribute '__iter__' on TypeVarTuple [attribute-error] -File "generics_typevartuple_args.py", line 16, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_args.py", line 17, in args_to_tuple: bad return type [bad-return-type] -Called from (traceback): - line 20, in current file -File "generics_typevartuple_args.py", line 20, in : Tuple[Any] [assert-type] -File "generics_typevartuple_args.py", line 27, in : Missing parameter 'self' in call to function tuple.__iter__ [missing-parameter] -File "generics_typevartuple_args.py", line 27, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_args.py", line 27, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_args.py", line 28, in exec_le: bad return type [bad-return-type] -Called from (traceback): - line 31, in current file -File "generics_typevartuple_args.py", line 31, in : Tuple[Any] [assert-type] -File "generics_typevartuple_args.py", line 32, in : Tuple[Any] [assert-type] -File "generics_typevartuple_args.py", line 42, in : Missing parameter 'self' in call to function tuple.__iter__ [missing-parameter] -File "generics_typevartuple_args.py", line 51, in : Missing parameter 'self' in call to function tuple.__iter__ [missing-parameter] -File "generics_typevartuple_args.py", line 51, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_args.py", line 62, in : Missing parameter 'self' in call to function tuple.__iter__ [missing-parameter] -File "generics_typevartuple_args.py", line 70, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_args.py", line 75, in : Function func4 was called with the wrong arguments [wrong-arg-types] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 33: Expected 1 errors -Line 34: Expected 1 errors -Line 48: Expected 1 errors -Line 57: Expected 1 errors -Line 58: Expected 1 errors -Line 59: Expected 1 errors -Line 67: Expected 1 errors -Line 76: Expected 1 errors -Line 10: Unexpected errors ['File "generics_typevartuple_args.py", line 10, in : typing.TypeVarTuple not supported yet [not-supported-yet]'] -Line 13: Unexpected errors ['File "generics_typevartuple_args.py", line 13, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count]'] -Line 16: Unexpected errors ['File "generics_typevartuple_args.py", line 16, in : No attribute \\'__iter__\\' on TypeVarTuple [attribute-error]', 'File "generics_typevartuple_args.py", line 16, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 17: Unexpected errors ['File "generics_typevartuple_args.py", line 17, in args_to_tuple: bad return type [bad-return-type]'] -Line 20: Unexpected errors ['File "generics_typevartuple_args.py", line 20, in : Tuple[Any] [assert-type]'] -Line 27: Unexpected errors ['File "generics_typevartuple_args.py", line 27, in : Missing parameter \\'self\\' in call to function tuple.__iter__ [missing-parameter]', 'File "generics_typevartuple_args.py", line 27, in : Invalid type annotation \\'\\' [invalid-annotation]', 'File "generics_typevartuple_args.py", line 27, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 28: Unexpected errors ['File "generics_typevartuple_args.py", line 28, in exec_le: bad return type [bad-return-type]'] -Line 31: Unexpected errors ['File "generics_typevartuple_args.py", line 31, in : Tuple[Any] [assert-type]'] -Line 32: Unexpected errors ['File "generics_typevartuple_args.py", line 32, in : Tuple[Any] [assert-type]'] -Line 42: Unexpected errors ['File "generics_typevartuple_args.py", line 42, in : Missing parameter \\'self\\' in call to function tuple.__iter__ [missing-parameter]'] -Line 51: Unexpected errors ['File "generics_typevartuple_args.py", line 51, in : Missing parameter \\'self\\' in call to function tuple.__iter__ [missing-parameter]', 'File "generics_typevartuple_args.py", line 51, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 62: Unexpected errors ['File "generics_typevartuple_args.py", line 62, in : Missing parameter \\'self\\' in call to function tuple.__iter__ [missing-parameter]'] -Line 70: Unexpected errors ['File "generics_typevartuple_args.py", line 70, in : Invalid type annotation \\'\\' [invalid-annotation]'] -""" diff --git a/conformance/results/pytype/generics_typevartuple_basic.toml b/conformance/results/pytype/generics_typevartuple_basic.toml deleted file mode 100644 index 3116b579d..000000000 --- a/conformance/results/pytype/generics_typevartuple_basic.toml +++ /dev/null @@ -1,80 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support TypeVarTuple. -""" -output = """ -File "generics_typevartuple_basic.py", line 7, in : typing.TypeVarTuple not supported yet [not-supported-yet] -File "generics_typevartuple_basic.py", line 9, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] -File "generics_typevartuple_basic.py", line 12, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_typevartuple_basic.py", line 16, in : No attribute '__iter__' on TypeVarTuple [attribute-error] -File "generics_typevartuple_basic.py", line 16, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_basic.py", line 17, in func1: bad return type [bad-return-type] -File "generics_typevartuple_basic.py", line 20, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] -File "generics_typevartuple_basic.py", line 23, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_typevartuple_basic.py", line 24, in Array: Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_basic.py", line 25, in __init__: Invalid type annotation 'tuple[*Shape,]' [invalid-annotation] -File "generics_typevartuple_basic.py", line 27, in Array: Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_basic.py", line 36, in : class Array is not indexable [not-indexable] -File "generics_typevartuple_basic.py", line 36, in : Invalid type annotation 'Array[Height, Width]' [invalid-annotation] -File "generics_typevartuple_basic.py", line 36, in : Function Array.__init__ was called with the wrong arguments [wrong-arg-types] -File "generics_typevartuple_basic.py", line 37, in : class Array is not indexable [not-indexable] -File "generics_typevartuple_basic.py", line 37, in : Invalid type annotation 'Array[Batch, Height, Width]' [invalid-annotation] -File "generics_typevartuple_basic.py", line 37, in : Function Array.__init__ was called with the wrong arguments [wrong-arg-types] -File "generics_typevartuple_basic.py", line 38, in : class Array is not indexable [not-indexable] -File "generics_typevartuple_basic.py", line 38, in : Invalid type annotation 'Array[Time, Batch, Height, Width]' [invalid-annotation] -File "generics_typevartuple_basic.py", line 38, in : Function Array.__init__ was called with the wrong arguments [wrong-arg-types] -File "generics_typevartuple_basic.py", line 42, in : class Array is not indexable [not-indexable] -File "generics_typevartuple_basic.py", line 42, in : Invalid type annotation 'Array[Height, Width]' [invalid-annotation] -File "generics_typevartuple_basic.py", line 42, in : Function Array.__init__ was called with the wrong arguments [wrong-arg-types] -File "generics_typevartuple_basic.py", line 43, in : class Array is not indexable [not-indexable] -File "generics_typevartuple_basic.py", line 43, in : Invalid type annotation 'Array[Batch, Height, Width]' [invalid-annotation] -File "generics_typevartuple_basic.py", line 43, in : Function Array.__init__ was called with the wrong arguments [wrong-arg-types] -File "generics_typevartuple_basic.py", line 44, in : class Array is not indexable [not-indexable] -File "generics_typevartuple_basic.py", line 44, in : Invalid type annotation 'Array[Time, Batch, Height, Width]' [invalid-annotation] -File "generics_typevartuple_basic.py", line 44, in : Function Array.__init__ was called with the wrong arguments [wrong-arg-types] -File "generics_typevartuple_basic.py", line 52, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_typevartuple_basic.py", line 53, in ClassA: Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_basic.py", line 54, in __init__: Invalid type annotation 'tuple[*Shape,]' [invalid-annotation] -File "generics_typevartuple_basic.py", line 56, in ClassA: Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_basic.py", line 59, in ClassA: Invalid type annotation '' for args [invalid-annotation] -File "generics_typevartuple_basic.py", line 65, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 3 [wrong-arg-count] -File "generics_typevartuple_basic.py", line 66, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 4 [wrong-arg-count] -File "generics_typevartuple_basic.py", line 67, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 3 [wrong-arg-count] -File "generics_typevartuple_basic.py", line 75, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_basic.py", line 76, in func2: bad return type [bad-return-type] -Called from (traceback): - line 84, in current file -File "generics_typevartuple_basic.py", line 84, in : Tuple[Any] [assert-type] -File "generics_typevartuple_basic.py", line 90, in : Function func2 was called with the wrong arguments [wrong-arg-types] -File "generics_typevartuple_basic.py", line 93, in : class Array is not indexable [not-indexable] -File "generics_typevartuple_basic.py", line 94, in multiply: bad return type [bad-return-type] -File "generics_typevartuple_basic.py", line 97, in : class Array is not indexable [not-indexable] -File "generics_typevartuple_basic.py", line 106, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_typevartuple_basic.py", line 106, in : Function list.extend was called with the wrong arguments [wrong-arg-types] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 89: Expected 1 errors -Line 99: Expected 1 errors -Line 100: Expected 1 errors -Line 7: Unexpected errors ['File "generics_typevartuple_basic.py", line 7, in : typing.TypeVarTuple not supported yet [not-supported-yet]'] -Line 9: Unexpected errors ['File "generics_typevartuple_basic.py", line 9, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count]'] -Line 12: Unexpected errors ['File "generics_typevartuple_basic.py", line 12, in : Invalid type annotation \\'Generic\\' [invalid-annotation]'] -Line 16: Unexpected errors ['File "generics_typevartuple_basic.py", line 16, in : No attribute \\'__iter__\\' on TypeVarTuple [attribute-error]', 'File "generics_typevartuple_basic.py", line 16, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 17: Unexpected errors ['File "generics_typevartuple_basic.py", line 17, in func1: bad return type [bad-return-type]'] -Line 20: Unexpected errors ['File "generics_typevartuple_basic.py", line 20, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count]'] -Line 23: Unexpected errors ['File "generics_typevartuple_basic.py", line 23, in : Invalid type annotation \\'Generic\\' [invalid-annotation]'] -Line 24: Unexpected errors ['File "generics_typevartuple_basic.py", line 24, in Array: Invalid type annotation \\'\\' [invalid-annotation]'] -Line 25: Unexpected errors ['File "generics_typevartuple_basic.py", line 25, in __init__: Invalid type annotation \\'tuple[*Shape,]\\' [invalid-annotation]'] -Line 27: Unexpected errors ['File "generics_typevartuple_basic.py", line 27, in Array: Invalid type annotation \\'\\' [invalid-annotation]'] -Line 36: Unexpected errors ['File "generics_typevartuple_basic.py", line 36, in : class Array is not indexable [not-indexable]', 'File "generics_typevartuple_basic.py", line 36, in : Invalid type annotation \\'Array[Height, Width]\\' [invalid-annotation]', 'File "generics_typevartuple_basic.py", line 36, in : Function Array.__init__ was called with the wrong arguments [wrong-arg-types]'] -Line 37: Unexpected errors ['File "generics_typevartuple_basic.py", line 37, in : class Array is not indexable [not-indexable]', 'File "generics_typevartuple_basic.py", line 37, in : Invalid type annotation \\'Array[Batch, Height, Width]\\' [invalid-annotation]', 'File "generics_typevartuple_basic.py", line 37, in : Function Array.__init__ was called with the wrong arguments [wrong-arg-types]'] -Line 38: Unexpected errors ['File "generics_typevartuple_basic.py", line 38, in : class Array is not indexable [not-indexable]', 'File "generics_typevartuple_basic.py", line 38, in : Invalid type annotation \\'Array[Time, Batch, Height, Width]\\' [invalid-annotation]', 'File "generics_typevartuple_basic.py", line 38, in : Function Array.__init__ was called with the wrong arguments [wrong-arg-types]'] -Line 54: Unexpected errors ['File "generics_typevartuple_basic.py", line 54, in __init__: Invalid type annotation \\'tuple[*Shape,]\\' [invalid-annotation]'] -Line 75: Unexpected errors ['File "generics_typevartuple_basic.py", line 75, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 76: Unexpected errors ['File "generics_typevartuple_basic.py", line 76, in func2: bad return type [bad-return-type]'] -Line 84: Unexpected errors ['File "generics_typevartuple_basic.py", line 84, in : Tuple[Any] [assert-type]'] -Line 93: Unexpected errors ['File "generics_typevartuple_basic.py", line 93, in : class Array is not indexable [not-indexable]'] -Line 94: Unexpected errors ['File "generics_typevartuple_basic.py", line 94, in multiply: bad return type [bad-return-type]'] -Line 97: Unexpected errors ['File "generics_typevartuple_basic.py", line 97, in : class Array is not indexable [not-indexable]'] -""" diff --git a/conformance/results/pytype/generics_typevartuple_callable.toml b/conformance/results/pytype/generics_typevartuple_callable.toml deleted file mode 100644 index 1d934a260..000000000 --- a/conformance/results/pytype/generics_typevartuple_callable.toml +++ /dev/null @@ -1,46 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support TypeVarTuple. -""" -output = """ -File "generics_typevartuple_callable.py", line 10, in : typing.TypeVarTuple not supported yet [not-supported-yet] -File "generics_typevartuple_callable.py", line 12, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] -File "generics_typevartuple_callable.py", line 17, in Process: Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_callable.py", line 17, in Process: Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_callable.py", line 25, in : Function Process.__init__ was called with the wrong arguments [wrong-arg-types] -File "generics_typevartuple_callable.py", line 26, in : Function Process.__init__ was called with the wrong arguments [wrong-arg-types] -File "generics_typevartuple_callable.py", line 29, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_callable.py", line 29, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_callable.py", line 29, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_callable.py", line 30, in func2: bad return type [bad-return-type] -Called from (traceback): - line 42, in current file -File "generics_typevartuple_callable.py", line 34, in callback1: bad return type [bad-return-type] -File "generics_typevartuple_callable.py", line 38, in callback2: bad return type [bad-return-type] -File "generics_typevartuple_callable.py", line 41, in : Function func2 was called with the wrong arguments [wrong-arg-types] -File "generics_typevartuple_callable.py", line 41, in : Any [assert-type] -File "generics_typevartuple_callable.py", line 42, in : Tuple[Any] [assert-type] -File "generics_typevartuple_callable.py", line 45, in : Missing parameter 'self' in call to function tuple.__iter__ [missing-parameter] -File "generics_typevartuple_callable.py", line 45, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_callable.py", line 45, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_callable.py", line 46, in func3: bad return type [bad-return-type] -Called from (traceback): - line 49, in current file -File "generics_typevartuple_callable.py", line 49, in : Tuple[Any] [assert-type] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 10: Unexpected errors ['File "generics_typevartuple_callable.py", line 10, in : typing.TypeVarTuple not supported yet [not-supported-yet]'] -Line 12: Unexpected errors ['File "generics_typevartuple_callable.py", line 12, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count]'] -Line 17: Unexpected errors ['File "generics_typevartuple_callable.py", line 17, in Process: Invalid type annotation \\'\\' [invalid-annotation]', 'File "generics_typevartuple_callable.py", line 17, in Process: Invalid type annotation \\'\\' [invalid-annotation]'] -Line 25: Unexpected errors ['File "generics_typevartuple_callable.py", line 25, in : Function Process.__init__ was called with the wrong arguments [wrong-arg-types]'] -Line 29: Unexpected errors ['File "generics_typevartuple_callable.py", line 29, in : Invalid type annotation \\'\\' [invalid-annotation]', 'File "generics_typevartuple_callable.py", line 29, in : Invalid type annotation \\'\\' [invalid-annotation]', 'File "generics_typevartuple_callable.py", line 29, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 30: Unexpected errors ['File "generics_typevartuple_callable.py", line 30, in func2: bad return type [bad-return-type]'] -Line 34: Unexpected errors ['File "generics_typevartuple_callable.py", line 34, in callback1: bad return type [bad-return-type]'] -Line 38: Unexpected errors ['File "generics_typevartuple_callable.py", line 38, in callback2: bad return type [bad-return-type]'] -Line 41: Unexpected errors ['File "generics_typevartuple_callable.py", line 41, in : Function func2 was called with the wrong arguments [wrong-arg-types]', 'File "generics_typevartuple_callable.py", line 41, in : Any [assert-type]'] -Line 42: Unexpected errors ['File "generics_typevartuple_callable.py", line 42, in : Tuple[Any] [assert-type]'] -Line 45: Unexpected errors ['File "generics_typevartuple_callable.py", line 45, in : Missing parameter \\'self\\' in call to function tuple.__iter__ [missing-parameter]', 'File "generics_typevartuple_callable.py", line 45, in : Invalid type annotation \\'\\' [invalid-annotation]', 'File "generics_typevartuple_callable.py", line 45, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 46: Unexpected errors ['File "generics_typevartuple_callable.py", line 46, in func3: bad return type [bad-return-type]'] -Line 49: Unexpected errors ['File "generics_typevartuple_callable.py", line 49, in : Tuple[Any] [assert-type]'] -""" diff --git a/conformance/results/pytype/generics_typevartuple_concat.toml b/conformance/results/pytype/generics_typevartuple_concat.toml deleted file mode 100644 index 2ec72d803..000000000 --- a/conformance/results/pytype/generics_typevartuple_concat.toml +++ /dev/null @@ -1,50 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support TypeVarTuple. -""" -output = """ -File "generics_typevartuple_concat.py", line 9, in : typing.TypeVarTuple not supported yet [not-supported-yet] -File "generics_typevartuple_concat.py", line 17, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] -File "generics_typevartuple_concat.py", line 18, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] -File "generics_typevartuple_concat.py", line 22, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_typevartuple_concat.py", line 26, in : class Array is not indexable [not-indexable] -File "generics_typevartuple_concat.py", line 27, in add_batch_axis: bad return type [bad-return-type] -File "generics_typevartuple_concat.py", line 30, in : class Array is not indexable [not-indexable] -File "generics_typevartuple_concat.py", line 31, in del_batch_axis: bad return type [bad-return-type] -File "generics_typevartuple_concat.py", line 34, in : class Array is not indexable [not-indexable] -File "generics_typevartuple_concat.py", line 35, in add_batch_channels: bad return type [bad-return-type] -File "generics_typevartuple_concat.py", line 38, in : class Array is not indexable [not-indexable] -File "generics_typevartuple_concat.py", line 40, in func1: class Array is not indexable [not-indexable] -File "generics_typevartuple_concat.py", line 42, in func1: class Array is not indexable [not-indexable] -File "generics_typevartuple_concat.py", line 44, in func1: class Array is not indexable [not-indexable] -File "generics_typevartuple_concat.py", line 47, in : Invalid type annotation 'T' [invalid-annotation] -File "generics_typevartuple_concat.py", line 47, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_concat.py", line 47, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_concat.py", line 48, in prefix_tuple: bad return type [bad-return-type] -File "generics_typevartuple_concat.py", line 51, in : Function prefix_tuple was called with the wrong arguments [wrong-arg-types] -File "generics_typevartuple_concat.py", line 52, in : Any [assert-type] -File "generics_typevartuple_concat.py", line 55, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_concat.py", line 55, in : Invalid type annotation '' [invalid-annotation] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 9: Unexpected errors ['File "generics_typevartuple_concat.py", line 9, in : typing.TypeVarTuple not supported yet [not-supported-yet]'] -Line 17: Unexpected errors ['File "generics_typevartuple_concat.py", line 17, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count]'] -Line 18: Unexpected errors ['File "generics_typevartuple_concat.py", line 18, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count]'] -Line 22: Unexpected errors ['File "generics_typevartuple_concat.py", line 22, in : Invalid type annotation \\'Generic\\' [invalid-annotation]'] -Line 26: Unexpected errors ['File "generics_typevartuple_concat.py", line 26, in : class Array is not indexable [not-indexable]'] -Line 27: Unexpected errors ['File "generics_typevartuple_concat.py", line 27, in add_batch_axis: bad return type [bad-return-type]'] -Line 30: Unexpected errors ['File "generics_typevartuple_concat.py", line 30, in : class Array is not indexable [not-indexable]'] -Line 31: Unexpected errors ['File "generics_typevartuple_concat.py", line 31, in del_batch_axis: bad return type [bad-return-type]'] -Line 34: Unexpected errors ['File "generics_typevartuple_concat.py", line 34, in : class Array is not indexable [not-indexable]'] -Line 35: Unexpected errors ['File "generics_typevartuple_concat.py", line 35, in add_batch_channels: bad return type [bad-return-type]'] -Line 38: Unexpected errors ['File "generics_typevartuple_concat.py", line 38, in : class Array is not indexable [not-indexable]'] -Line 40: Unexpected errors ['File "generics_typevartuple_concat.py", line 40, in func1: class Array is not indexable [not-indexable]'] -Line 42: Unexpected errors ['File "generics_typevartuple_concat.py", line 42, in func1: class Array is not indexable [not-indexable]'] -Line 44: Unexpected errors ['File "generics_typevartuple_concat.py", line 44, in func1: class Array is not indexable [not-indexable]'] -Line 47: Unexpected errors ['File "generics_typevartuple_concat.py", line 47, in : Invalid type annotation \\'T\\' [invalid-annotation]', 'File "generics_typevartuple_concat.py", line 47, in : Invalid type annotation \\'\\' [invalid-annotation]', 'File "generics_typevartuple_concat.py", line 47, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 48: Unexpected errors ['File "generics_typevartuple_concat.py", line 48, in prefix_tuple: bad return type [bad-return-type]'] -Line 51: Unexpected errors ['File "generics_typevartuple_concat.py", line 51, in : Function prefix_tuple was called with the wrong arguments [wrong-arg-types]'] -Line 52: Unexpected errors ['File "generics_typevartuple_concat.py", line 52, in : Any [assert-type]'] -Line 55: Unexpected errors ['File "generics_typevartuple_concat.py", line 55, in : Invalid type annotation \\'\\' [invalid-annotation]', 'File "generics_typevartuple_concat.py", line 55, in : Invalid type annotation \\'\\' [invalid-annotation]'] -""" diff --git a/conformance/results/pytype/generics_typevartuple_overloads.toml b/conformance/results/pytype/generics_typevartuple_overloads.toml deleted file mode 100644 index 0dd84622f..000000000 --- a/conformance/results/pytype/generics_typevartuple_overloads.toml +++ /dev/null @@ -1,27 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support TypeVarTuple. -""" -output = """ -File "generics_typevartuple_overloads.py", line 7, in : typing.TypeVarTuple not supported yet [not-supported-yet] -File "generics_typevartuple_overloads.py", line 10, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] -File "generics_typevartuple_overloads.py", line 16, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_typevartuple_overloads.py", line 18, in Array: class Array is not indexable [not-indexable] -File "generics_typevartuple_overloads.py", line 22, in Array: class Array is not indexable [not-indexable] -File "generics_typevartuple_overloads.py", line 26, in transpose: bad return type [bad-return-type] -File "generics_typevartuple_overloads.py", line 29, in : class Array is not indexable [not-indexable] -File "generics_typevartuple_overloads.py", line 30, in func1: class Array is not indexable [not-indexable] -File "generics_typevartuple_overloads.py", line 31, in func1: class Array is not indexable [not-indexable] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 7: Unexpected errors ['File "generics_typevartuple_overloads.py", line 7, in : typing.TypeVarTuple not supported yet [not-supported-yet]'] -Line 10: Unexpected errors ['File "generics_typevartuple_overloads.py", line 10, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count]'] -Line 16: Unexpected errors ['File "generics_typevartuple_overloads.py", line 16, in : Invalid type annotation \\'Generic\\' [invalid-annotation]'] -Line 18: Unexpected errors ['File "generics_typevartuple_overloads.py", line 18, in Array: class Array is not indexable [not-indexable]'] -Line 22: Unexpected errors ['File "generics_typevartuple_overloads.py", line 22, in Array: class Array is not indexable [not-indexable]'] -Line 26: Unexpected errors ['File "generics_typevartuple_overloads.py", line 26, in transpose: bad return type [bad-return-type]'] -Line 29: Unexpected errors ['File "generics_typevartuple_overloads.py", line 29, in : class Array is not indexable [not-indexable]'] -Line 30: Unexpected errors ['File "generics_typevartuple_overloads.py", line 30, in func1: class Array is not indexable [not-indexable]'] -Line 31: Unexpected errors ['File "generics_typevartuple_overloads.py", line 31, in func1: class Array is not indexable [not-indexable]'] -""" diff --git a/conformance/results/pytype/generics_typevartuple_specialization.toml b/conformance/results/pytype/generics_typevartuple_specialization.toml deleted file mode 100644 index a9d75caa2..000000000 --- a/conformance/results/pytype/generics_typevartuple_specialization.toml +++ /dev/null @@ -1,139 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support TypeVarTuple. -""" -output = """ -File "generics_typevartuple_specialization.py", line 7, in : typing.TypeVarTuple not supported yet [not-supported-yet] -File "generics_typevartuple_specialization.py", line 10, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] -File "generics_typevartuple_specialization.py", line 16, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 24, in : class Array is not indexable [not-indexable] -File "generics_typevartuple_specialization.py", line 28, in : class Array is not indexable [not-indexable] -File "generics_typevartuple_specialization.py", line 33, in : class Array is not indexable [not-indexable] -File "generics_typevartuple_specialization.py", line 41, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 42, in : class Array is not indexable [not-indexable] -File "generics_typevartuple_specialization.py", line 45, in : Invalid type annotation 'Tuple[str, Array][Height]' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 45, in : Invalid type annotation 'Tuple[Any][float, bool]' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 46, in func3: Tuple[Any] [assert-type] -File "generics_typevartuple_specialization.py", line 47, in func3: class Array is not indexable [not-indexable] -File "generics_typevartuple_specialization.py", line 51, in func4: Tuple[Any] [assert-type] -File "generics_typevartuple_specialization.py", line 55, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] -File "generics_typevartuple_specialization.py", line 59, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 63, in : class Array2 is not indexable [not-indexable] -File "generics_typevartuple_specialization.py", line 64, in : class Array2 is not indexable [not-indexable] -File "generics_typevartuple_specialization.py", line 67, in : class Array2 is not indexable [not-indexable] -File "generics_typevartuple_specialization.py", line 68, in func5_0: class Array2 is not indexable [not-indexable] -File "generics_typevartuple_specialization.py", line 69, in func5_0: class Array2 is not indexable [not-indexable] -File "generics_typevartuple_specialization.py", line 76, in : class Array2 is not indexable [not-indexable] -File "generics_typevartuple_specialization.py", line 80, in : class Array2 is not indexable [not-indexable] -File "generics_typevartuple_specialization.py", line 89, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 92, in : Invalid type annotation 'Tuple[Any][str, int]' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 92, in : Invalid type annotation 'Tuple[Any][float]' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 93, in func6: Tuple[Any] [assert-type] -File "generics_typevartuple_specialization.py", line 94, in func6: Tuple[Any] [assert-type] -File "generics_typevartuple_specialization.py", line 95, in func6: Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 98, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] -File "generics_typevartuple_specialization.py", line 99, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] -File "generics_typevartuple_specialization.py", line 101, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 102, in : Invalid type annotation 'Tuple[Any][]' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 103, in : Invalid type annotation 'Tuple[Any][]' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 109, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 110, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 117, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 118, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 119, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 120, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 121, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 121, in : Function list.extend was called with the wrong arguments [wrong-arg-types] -File "generics_typevartuple_specialization.py", line 122, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 122, in : Function list.extend was called with the wrong arguments [wrong-arg-types] -File "generics_typevartuple_specialization.py", line 125, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 127, in : Invalid type annotation 'Tuple[Any][int]' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 130, in : Invalid type annotation 'Tuple[Any][]' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 130, in : Invalid type annotation 'T2' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 130, in : Invalid type annotation 'T1' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 130, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 131, in func7: bad return type [bad-return-type] -File "generics_typevartuple_specialization.py", line 134, in : Invalid type annotation 'Tuple[Any][str, bool]' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 134, in : Invalid type annotation 'Tuple[Any][str, bool, float]' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 134, in : Invalid type annotation 'Tuple[Any][str, bool, float, int]' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 135, in func8: Tuple[Tuple[Any], Any, Any] [assert-type] -File "generics_typevartuple_specialization.py", line 136, in func8: Tuple[Tuple[Any], Any, Any] [assert-type] -File "generics_typevartuple_specialization.py", line 137, in func8: Tuple[Tuple[Any], Any, Any] [assert-type] -File "generics_typevartuple_specialization.py", line 140, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 143, in : Invalid type annotation 'Tuple[Any][]' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 143, in : Invalid type annotation 'T3' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 143, in : Invalid type annotation 'T2' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 143, in : Invalid type annotation 'T1' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 143, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 144, in func9: bad return type [bad-return-type] -File "generics_typevartuple_specialization.py", line 147, in : Invalid type annotation 'Tuple[Any][str, bool, float]' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 147, in : Invalid type annotation 'Tuple[Any][str, bool, float, int]' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 148, in func10: Tuple[Tuple[Any], Any, Any, Any] [assert-type] -File "generics_typevartuple_specialization.py", line 149, in func10: Tuple[Tuple[Any], Any, Any, Any] [assert-type] -File "generics_typevartuple_specialization.py", line 152, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 153, in : Invalid type annotation 'Tuple[Any][]' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 156, in : Invalid type annotation 'Tuple[Any][]' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 157, in func11: Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 158, in func11: Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 159, in func11: Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 162, in : Invalid type annotation '' [invalid-annotation] -File "generics_typevartuple_specialization.py", line 163, in : Invalid type annotation 'Tuple[Any][]' [invalid-annotation] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 7: Unexpected errors ['File "generics_typevartuple_specialization.py", line 7, in : typing.TypeVarTuple not supported yet [not-supported-yet]'] -Line 10: Unexpected errors ['File "generics_typevartuple_specialization.py", line 10, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count]'] -Line 16: Unexpected errors ['File "generics_typevartuple_specialization.py", line 16, in : Invalid type annotation \\'Generic\\' [invalid-annotation]'] -Line 24: Unexpected errors ['File "generics_typevartuple_specialization.py", line 24, in : class Array is not indexable [not-indexable]'] -Line 28: Unexpected errors ['File "generics_typevartuple_specialization.py", line 28, in : class Array is not indexable [not-indexable]'] -Line 33: Unexpected errors ['File "generics_typevartuple_specialization.py", line 33, in : class Array is not indexable [not-indexable]'] -Line 41: Unexpected errors ['File "generics_typevartuple_specialization.py", line 41, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 42: Unexpected errors ['File "generics_typevartuple_specialization.py", line 42, in : class Array is not indexable [not-indexable]'] -Line 45: Unexpected errors ['File "generics_typevartuple_specialization.py", line 45, in : Invalid type annotation \\'Tuple[str, Array][Height]\\' [invalid-annotation]', 'File "generics_typevartuple_specialization.py", line 45, in : Invalid type annotation \\'Tuple[Any][float, bool]\\' [invalid-annotation]'] -Line 46: Unexpected errors ['File "generics_typevartuple_specialization.py", line 46, in func3: Tuple[Any] [assert-type]'] -Line 47: Unexpected errors ['File "generics_typevartuple_specialization.py", line 47, in func3: class Array is not indexable [not-indexable]'] -Line 51: Unexpected errors ['File "generics_typevartuple_specialization.py", line 51, in func4: Tuple[Any] [assert-type]'] -Line 55: Unexpected errors ['File "generics_typevartuple_specialization.py", line 55, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count]'] -Line 59: Unexpected errors ['File "generics_typevartuple_specialization.py", line 59, in : Invalid type annotation \\'Generic\\' [invalid-annotation]'] -Line 63: Unexpected errors ['File "generics_typevartuple_specialization.py", line 63, in : class Array2 is not indexable [not-indexable]'] -Line 64: Unexpected errors ['File "generics_typevartuple_specialization.py", line 64, in : class Array2 is not indexable [not-indexable]'] -Line 67: Unexpected errors ['File "generics_typevartuple_specialization.py", line 67, in : class Array2 is not indexable [not-indexable]'] -Line 68: Unexpected errors ['File "generics_typevartuple_specialization.py", line 68, in func5_0: class Array2 is not indexable [not-indexable]'] -Line 69: Unexpected errors ['File "generics_typevartuple_specialization.py", line 69, in func5_0: class Array2 is not indexable [not-indexable]'] -Line 76: Unexpected errors ['File "generics_typevartuple_specialization.py", line 76, in : class Array2 is not indexable [not-indexable]'] -Line 80: Unexpected errors ['File "generics_typevartuple_specialization.py", line 80, in : class Array2 is not indexable [not-indexable]'] -Line 89: Unexpected errors ['File "generics_typevartuple_specialization.py", line 89, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 92: Unexpected errors ['File "generics_typevartuple_specialization.py", line 92, in : Invalid type annotation \\'Tuple[Any][str, int]\\' [invalid-annotation]', 'File "generics_typevartuple_specialization.py", line 92, in : Invalid type annotation \\'Tuple[Any][float]\\' [invalid-annotation]'] -Line 93: Unexpected errors ['File "generics_typevartuple_specialization.py", line 93, in func6: Tuple[Any] [assert-type]'] -Line 94: Unexpected errors ['File "generics_typevartuple_specialization.py", line 94, in func6: Tuple[Any] [assert-type]'] -Line 95: Unexpected errors ['File "generics_typevartuple_specialization.py", line 95, in func6: Invalid type annotation \\'\\' [invalid-annotation]'] -Line 98: Unexpected errors ['File "generics_typevartuple_specialization.py", line 98, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count]'] -Line 99: Unexpected errors ['File "generics_typevartuple_specialization.py", line 99, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count]'] -Line 101: Unexpected errors ['File "generics_typevartuple_specialization.py", line 101, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 102: Unexpected errors ['File "generics_typevartuple_specialization.py", line 102, in : Invalid type annotation \\'Tuple[Any][]\\' [invalid-annotation]'] -Line 103: Unexpected errors ['File "generics_typevartuple_specialization.py", line 103, in : Invalid type annotation \\'Tuple[Any][]\\' [invalid-annotation]'] -Line 117: Unexpected errors ['File "generics_typevartuple_specialization.py", line 117, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 118: Unexpected errors ['File "generics_typevartuple_specialization.py", line 118, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 119: Unexpected errors ['File "generics_typevartuple_specialization.py", line 119, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 120: Unexpected errors ['File "generics_typevartuple_specialization.py", line 120, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 125: Unexpected errors ['File "generics_typevartuple_specialization.py", line 125, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 130: Unexpected errors ['File "generics_typevartuple_specialization.py", line 130, in : Invalid type annotation \\'Tuple[Any][]\\' [invalid-annotation]', 'File "generics_typevartuple_specialization.py", line 130, in : Invalid type annotation \\'T2\\' [invalid-annotation]', 'File "generics_typevartuple_specialization.py", line 130, in : Invalid type annotation \\'T1\\' [invalid-annotation]', 'File "generics_typevartuple_specialization.py", line 130, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 131: Unexpected errors ['File "generics_typevartuple_specialization.py", line 131, in func7: bad return type [bad-return-type]'] -Line 134: Unexpected errors ['File "generics_typevartuple_specialization.py", line 134, in : Invalid type annotation \\'Tuple[Any][str, bool]\\' [invalid-annotation]', 'File "generics_typevartuple_specialization.py", line 134, in : Invalid type annotation \\'Tuple[Any][str, bool, float]\\' [invalid-annotation]', 'File "generics_typevartuple_specialization.py", line 134, in : Invalid type annotation \\'Tuple[Any][str, bool, float, int]\\' [invalid-annotation]'] -Line 135: Unexpected errors ['File "generics_typevartuple_specialization.py", line 135, in func8: Tuple[Tuple[Any], Any, Any] [assert-type]'] -Line 136: Unexpected errors ['File "generics_typevartuple_specialization.py", line 136, in func8: Tuple[Tuple[Any], Any, Any] [assert-type]'] -Line 137: Unexpected errors ['File "generics_typevartuple_specialization.py", line 137, in func8: Tuple[Tuple[Any], Any, Any] [assert-type]'] -Line 140: Unexpected errors ['File "generics_typevartuple_specialization.py", line 140, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 143: Unexpected errors ['File "generics_typevartuple_specialization.py", line 143, in : Invalid type annotation \\'Tuple[Any][]\\' [invalid-annotation]', 'File "generics_typevartuple_specialization.py", line 143, in : Invalid type annotation \\'T3\\' [invalid-annotation]', 'File "generics_typevartuple_specialization.py", line 143, in : Invalid type annotation \\'T2\\' [invalid-annotation]', 'File "generics_typevartuple_specialization.py", line 143, in : Invalid type annotation \\'T1\\' [invalid-annotation]', 'File "generics_typevartuple_specialization.py", line 143, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 144: Unexpected errors ['File "generics_typevartuple_specialization.py", line 144, in func9: bad return type [bad-return-type]'] -Line 147: Unexpected errors ['File "generics_typevartuple_specialization.py", line 147, in : Invalid type annotation \\'Tuple[Any][str, bool, float]\\' [invalid-annotation]', 'File "generics_typevartuple_specialization.py", line 147, in : Invalid type annotation \\'Tuple[Any][str, bool, float, int]\\' [invalid-annotation]'] -Line 148: Unexpected errors ['File "generics_typevartuple_specialization.py", line 148, in func10: Tuple[Tuple[Any], Any, Any, Any] [assert-type]'] -Line 149: Unexpected errors ['File "generics_typevartuple_specialization.py", line 149, in func10: Tuple[Tuple[Any], Any, Any, Any] [assert-type]'] -Line 152: Unexpected errors ['File "generics_typevartuple_specialization.py", line 152, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 153: Unexpected errors ['File "generics_typevartuple_specialization.py", line 153, in : Invalid type annotation \\'Tuple[Any][]\\' [invalid-annotation]'] -Line 156: Unexpected errors ['File "generics_typevartuple_specialization.py", line 156, in : Invalid type annotation \\'Tuple[Any][]\\' [invalid-annotation]'] -Line 157: Unexpected errors ['File "generics_typevartuple_specialization.py", line 157, in func11: Invalid type annotation \\'\\' [invalid-annotation]'] -Line 158: Unexpected errors ['File "generics_typevartuple_specialization.py", line 158, in func11: Invalid type annotation \\'\\' [invalid-annotation]'] -Line 159: Unexpected errors ['File "generics_typevartuple_specialization.py", line 159, in func11: Invalid type annotation \\'\\' [invalid-annotation]'] -Line 162: Unexpected errors ['File "generics_typevartuple_specialization.py", line 162, in : Invalid type annotation \\'\\' [invalid-annotation]'] -""" diff --git a/conformance/results/pytype/generics_typevartuple_unpack.toml b/conformance/results/pytype/generics_typevartuple_unpack.toml deleted file mode 100644 index 8a58f520b..000000000 --- a/conformance/results/pytype/generics_typevartuple_unpack.toml +++ /dev/null @@ -1,28 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support TypeVarTuple. -""" -output = """ -File "generics_typevartuple_unpack.py", line 7, in : typing.TypeVarTuple not supported yet [not-supported-yet] -File "generics_typevartuple_unpack.py", line 14, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] -File "generics_typevartuple_unpack.py", line 17, in : Invalid type annotation 'Generic' [invalid-annotation] -File "generics_typevartuple_unpack.py", line 21, in : class Array is not indexable [not-indexable] -File "generics_typevartuple_unpack.py", line 26, in : class Array is not indexable [not-indexable] -File "generics_typevartuple_unpack.py", line 33, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] -File "generics_typevartuple_unpack.py", line 36, in : class Array is not indexable [not-indexable] -File "generics_typevartuple_unpack.py", line 40, in : class Array is not indexable [not-indexable] -File "generics_typevartuple_unpack.py", line 44, in : class Array is not indexable [not-indexable] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 30: Expected 1 errors -Line 7: Unexpected errors ['File "generics_typevartuple_unpack.py", line 7, in : typing.TypeVarTuple not supported yet [not-supported-yet]'] -Line 14: Unexpected errors ['File "generics_typevartuple_unpack.py", line 14, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count]'] -Line 17: Unexpected errors ['File "generics_typevartuple_unpack.py", line 17, in : Invalid type annotation \\'Generic\\' [invalid-annotation]'] -Line 21: Unexpected errors ['File "generics_typevartuple_unpack.py", line 21, in : class Array is not indexable [not-indexable]'] -Line 26: Unexpected errors ['File "generics_typevartuple_unpack.py", line 26, in : class Array is not indexable [not-indexable]'] -Line 33: Unexpected errors ['File "generics_typevartuple_unpack.py", line 33, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count]'] -Line 36: Unexpected errors ['File "generics_typevartuple_unpack.py", line 36, in : class Array is not indexable [not-indexable]'] -Line 40: Unexpected errors ['File "generics_typevartuple_unpack.py", line 40, in : class Array is not indexable [not-indexable]'] -Line 44: Unexpected errors ['File "generics_typevartuple_unpack.py", line 44, in : class Array is not indexable [not-indexable]'] -""" diff --git a/conformance/results/pytype/generics_upper_bound.toml b/conformance/results/pytype/generics_upper_bound.toml deleted file mode 100644 index a999a23b4..000000000 --- a/conformance/results/pytype/generics_upper_bound.toml +++ /dev/null @@ -1,17 +0,0 @@ -conformant = "Partial" -notes = """ -Does not properly support assert_type. -""" -output = """ -File "generics_upper_bound.py", line 24, in Test: Invalid TypeVar: bound cannot contain TypeVars [invalid-typevar] -File "generics_upper_bound.py", line 37, in : list [assert-type] -File "generics_upper_bound.py", line 38, in : set [assert-type] -File "generics_upper_bound.py", line 43, in : Union[list, set] [assert-type] -File "generics_upper_bound.py", line 51, in : Function longer was called with the wrong arguments [wrong-arg-types] -File "generics_upper_bound.py", line 56, in : Invalid TypeVar: constraints and a bound are mutually exclusive [invalid-typevar] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 37: Unexpected errors ['File "generics_upper_bound.py", line 37, in : list [assert-type]'] -Line 38: Unexpected errors ['File "generics_upper_bound.py", line 38, in : set [assert-type]'] -""" diff --git a/conformance/results/pytype/generics_variance.toml b/conformance/results/pytype/generics_variance.toml deleted file mode 100644 index 71f928f3e..000000000 --- a/conformance/results/pytype/generics_variance.toml +++ /dev/null @@ -1,31 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support covariant or contravariant TypeVars. -""" -output = """ -File "generics_variance.py", line 14, in : argument "covariant" to TypeVar not supported yet [not-supported-yet] -File "generics_variance.py", line 14, in : argument "contravariant" to TypeVar not supported yet [not-supported-yet] -File "generics_variance.py", line 18, in : argument "covariant" to TypeVar not supported yet [not-supported-yet] -File "generics_variance.py", line 19, in : argument "contravariant" to TypeVar not supported yet [not-supported-yet] -File "generics_variance.py", line 27, in __iter__: bad return type [bad-return-type] -File "generics_variance.py", line 52, in : argument "covariant" to TypeVar not supported yet [not-supported-yet] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 77: Expected 1 errors -Line 81: Expected 1 errors -Line 93: Expected 1 errors -Line 105: Expected 1 errors -Line 113: Expected 1 errors -Line 126: Expected 1 errors -Line 132: Expected 1 errors -Line 142: Expected 1 errors -Line 163: Expected 1 errors -Line 167: Expected 1 errors -Line 191: Expected 1 errors -Line 196: Expected 1 errors -Line 18: Unexpected errors ['File "generics_variance.py", line 18, in : argument "covariant" to TypeVar not supported yet [not-supported-yet]'] -Line 19: Unexpected errors ['File "generics_variance.py", line 19, in : argument "contravariant" to TypeVar not supported yet [not-supported-yet]'] -Line 27: Unexpected errors ['File "generics_variance.py", line 27, in __iter__: bad return type [bad-return-type]'] -Line 52: Unexpected errors ['File "generics_variance.py", line 52, in : argument "covariant" to TypeVar not supported yet [not-supported-yet]'] -""" diff --git a/conformance/results/pytype/generics_variance_inference.toml b/conformance/results/pytype/generics_variance_inference.toml deleted file mode 100644 index 67937210c..000000000 --- a/conformance/results/pytype/generics_variance_inference.toml +++ /dev/null @@ -1,33 +0,0 @@ -conformant = "Unsupported" -notes = """ -Type parameter syntax not yet support. -""" -output = """ -SyntaxError: Type parameter lists are only supported in Python 3.12 and greater (, line 15) -""" -conformance_automated = "Fail" -errors_diff = """ -Line 24: Expected 1 errors -Line 25: Expected 1 errors -Line 28: Expected 1 errors -Line 41: Expected 1 errors -Line 49: Expected 1 errors -Line 58: Expected 1 errors -Line 67: Expected 1 errors -Line 80: Expected 1 errors -Line 96: Expected 1 errors -Line 97: Expected 1 errors -Line 111: Expected 1 errors -Line 112: Expected 1 errors -Line 119: Expected 1 errors -Line 120: Expected 1 errors -Line 121: Expected 1 errors -Line 122: Expected 1 errors -Line 130: Expected 1 errors -Line 138: Expected 1 errors -Line 149: Expected 1 errors -Line 169: Expected 1 errors -Line 170: Expected 1 errors -Line 181: Expected 1 errors -Line 194: Expected 1 errors -""" diff --git a/conformance/results/pytype/historical_positional.toml b/conformance/results/pytype/historical_positional.toml deleted file mode 100644 index 2c02fbd84..000000000 --- a/conformance/results/pytype/historical_positional.toml +++ /dev/null @@ -1,14 +0,0 @@ -conformant = "Partial" -notes = """ -Does not apply rules for pre-3.8 positional-only parameters in some cases. -Does not reject positional-only parameter after non-positional-only parameter. -""" -output = """ -File "historical_positional.py", line 43, in : Invalid keyword argument __x to function A.m1 [wrong-keyword-args] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 18: Expected 1 errors -Line 26: Expected 1 errors -Line 38: Expected 1 errors -""" diff --git a/conformance/results/pytype/literals_interactions.toml b/conformance/results/pytype/literals_interactions.toml deleted file mode 100644 index abe6af209..000000000 --- a/conformance/results/pytype/literals_interactions.toml +++ /dev/null @@ -1,43 +0,0 @@ -conformant = "Partial" -notes = """ -Incorrectly rejects some legal Literal annotations. -Does not reject some illegal Literal annotations. -Does not use Literal to distinguish overloads. -Does not narrow based on `x is Literal` type guard pattern. -Does not narrow based on `x == Literal` type guard pattern. -""" -output = """ -File "literals_interactions.py", line 11, in : Invalid type annotation 'Literal' [invalid-annotation] -File "literals_interactions.py", line 46, in open: bad return type [bad-return-type] -Called from (traceback): - line 51, in current file -File "literals_interactions.py", line 46, in open: bad return type [bad-return-type] -Called from (traceback): - line 50, in current file -File "literals_interactions.py", line 46, in open: bad return type [bad-return-type] -Called from (traceback): - line 49, in current file -File "literals_interactions.py", line 61, in __add__: bad return type [bad-return-type] -File "literals_interactions.py", line 64, in __matmul__: bad return type [bad-return-type] -File "literals_interactions.py", line 67, in transpose: bad return type [bad-return-type] -File "literals_interactions.py", line 72, in func2: Matrix[Any, int] [assert-type] -File "literals_interactions.py", line 93, in parse_status1: Union[Status, str] [assert-type] -File "literals_interactions.py", line 106, in parse_status2: Function expects_bad_status was called with the wrong arguments [wrong-arg-types] -File "literals_interactions.py", line 109, in parse_status2: Function expects_pending_status was called with the wrong arguments [wrong-arg-types] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 15: Expected 1 errors -Line 16: Expected 1 errors -Line 17: Expected 1 errors -Line 18: Expected 1 errors -Line 11: Unexpected errors ['File "literals_interactions.py", line 11, in : Invalid type annotation \\'Literal\\' [invalid-annotation]'] -Line 46: Unexpected errors ['File "literals_interactions.py", line 46, in open: bad return type [bad-return-type]', 'File "literals_interactions.py", line 46, in open: bad return type [bad-return-type]', 'File "literals_interactions.py", line 46, in open: bad return type [bad-return-type]'] -Line 61: Unexpected errors ['File "literals_interactions.py", line 61, in __add__: bad return type [bad-return-type]'] -Line 64: Unexpected errors ['File "literals_interactions.py", line 64, in __matmul__: bad return type [bad-return-type]'] -Line 67: Unexpected errors ['File "literals_interactions.py", line 67, in transpose: bad return type [bad-return-type]'] -Line 72: Unexpected errors ['File "literals_interactions.py", line 72, in func2: Matrix[Any, int] [assert-type]'] -Line 93: Unexpected errors ['File "literals_interactions.py", line 93, in parse_status1: Union[Status, str] [assert-type]'] -Line 106: Unexpected errors ['File "literals_interactions.py", line 106, in parse_status2: Function expects_bad_status was called with the wrong arguments [wrong-arg-types]'] -Line 109: Unexpected errors ['File "literals_interactions.py", line 109, in parse_status2: Function expects_pending_status was called with the wrong arguments [wrong-arg-types]'] -""" diff --git a/conformance/results/pytype/literals_literalstring.toml b/conformance/results/pytype/literals_literalstring.toml deleted file mode 100644 index 32d16477f..000000000 --- a/conformance/results/pytype/literals_literalstring.toml +++ /dev/null @@ -1,31 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not understand `LiteralString` special form. -""" -output = """ -File "literals_literalstring.py", line 8, in : typing.LiteralString not supported yet [not-supported-yet] -File "literals_literalstring.py", line 24, in my_function: bad return type [bad-return-type] -File "literals_literalstring.py", line 36, in : Invalid type annotation 'Literal' [invalid-annotation] -File "literals_literalstring.py", line 37, in : Invalid type annotation 'Literal' [invalid-annotation] -File "literals_literalstring.py", line 43, in func1: Type annotation for x2 does not match type of assignment [annotation-type-mismatch] -File "literals_literalstring.py", line 74, in func2: Type annotation for x3 does not match type of assignment [annotation-type-mismatch] -File "literals_literalstring.py", line 75, in func2: Type annotation for x4 does not match type of assignment [annotation-type-mismatch] -File "literals_literalstring.py", line 162, in func8: bad return type [bad-return-type] -Called from (traceback): - line 166, in current file -File "literals_literalstring.py", line 162, in func8: bad return type [bad-return-type] -Called from (traceback): - line 165, in current file -File "literals_literalstring.py", line 167, in : B [assert-type] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 66: Expected 1 errors -Line 120: Expected 1 errors -Line 134: Expected 1 errors -Line 171: Expected 1 errors -Line 8: Unexpected errors ['File "literals_literalstring.py", line 8, in : typing.LiteralString not supported yet [not-supported-yet]'] -Line 24: Unexpected errors ['File "literals_literalstring.py", line 24, in my_function: bad return type [bad-return-type]'] -Line 162: Unexpected errors ['File "literals_literalstring.py", line 162, in func8: bad return type [bad-return-type]', 'File "literals_literalstring.py", line 162, in func8: bad return type [bad-return-type]'] -Line 167: Unexpected errors ['File "literals_literalstring.py", line 167, in : B [assert-type]'] -""" diff --git a/conformance/results/pytype/literals_parameterizations.toml b/conformance/results/pytype/literals_parameterizations.toml deleted file mode 100644 index 1cc9d9b30..000000000 --- a/conformance/results/pytype/literals_parameterizations.toml +++ /dev/null @@ -1,37 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not understand `Literal` type annotation. -""" -output = """ -File "literals_parameterizations.py", line 17, in : Invalid type annotation 'Literal' [invalid-annotation] -File "literals_parameterizations.py", line 18, in : Invalid type annotation 'Literal' [invalid-annotation] -File "literals_parameterizations.py", line 19, in : Invalid type annotation 'Literal' [invalid-annotation] -File "literals_parameterizations.py", line 33, in : Invalid type annotation 'Literal' [invalid-annotation] -File "literals_parameterizations.py", line 35, in : Invalid type annotation 'Literal' [invalid-annotation] -File "literals_parameterizations.py", line 42, in : Invalid type annotation 'Literal' [invalid-annotation] -File "literals_parameterizations.py", line 43, in : Invalid type annotation 'Literal' [invalid-annotation] -File "literals_parameterizations.py", line 44, in : Invalid type annotation 'Literal' [invalid-annotation] -File "literals_parameterizations.py", line 47, in : Invalid type annotation 'Literal' [invalid-annotation] -File "literals_parameterizations.py", line 48, in : Invalid type annotation 'Literal' [invalid-annotation] -File "literals_parameterizations.py", line 50, in : Invalid type annotation 'Literal' [invalid-annotation] -File "literals_parameterizations.py", line 51, in : Invalid type annotation 'Literal' [invalid-annotation] -File "literals_parameterizations.py", line 53, in : Invalid type annotation 'Literal' [invalid-annotation] -File "literals_parameterizations.py", line 61, in : Invalid type annotation 'Literal[my_function]' [invalid-annotation] -File "literals_parameterizations.py", line 61, in : Invalid type annotation 'Literal' [invalid-annotation] -File "literals_parameterizations.py", line 65, in func2: Type annotation for x1 does not match type of assignment [annotation-type-mismatch] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 41: Expected 1 errors -Line 45: Expected 1 errors -Line 46: Expected 1 errors -Line 49: Expected 1 errors -Line 52: Expected 1 errors -Line 56: Expected 1 errors -Line 60: Expected 1 errors -Line 17: Unexpected errors ['File "literals_parameterizations.py", line 17, in : Invalid type annotation \\'Literal\\' [invalid-annotation]'] -Line 18: Unexpected errors ['File "literals_parameterizations.py", line 18, in : Invalid type annotation \\'Literal\\' [invalid-annotation]'] -Line 19: Unexpected errors ['File "literals_parameterizations.py", line 19, in : Invalid type annotation \\'Literal\\' [invalid-annotation]'] -Line 33: Unexpected errors ['File "literals_parameterizations.py", line 33, in : Invalid type annotation \\'Literal\\' [invalid-annotation]'] -Line 35: Unexpected errors ['File "literals_parameterizations.py", line 35, in : Invalid type annotation \\'Literal\\' [invalid-annotation]'] -""" diff --git a/conformance/results/pytype/literals_semantics.toml b/conformance/results/pytype/literals_semantics.toml deleted file mode 100644 index afe670975..000000000 --- a/conformance/results/pytype/literals_semantics.toml +++ /dev/null @@ -1,24 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not understand `Literal` type annotation. -""" -output = """ -File "literals_semantics.py", line 10, in : Type annotation for v2 does not match type of assignment [annotation-type-mismatch] -File "literals_semantics.py", line 12, in : Invalid type annotation 'Literal' [invalid-annotation] -File "literals_semantics.py", line 12, in : Invalid type annotation 'L[-3]' [invalid-annotation] -File "literals_semantics.py", line 16, in : Invalid type annotation 'Literal' [invalid-annotation] -File "literals_semantics.py", line 17, in func1: Invalid type annotation 'Literal[20]' [invalid-annotation] -File "literals_semantics.py", line 18, in func1: Invalid type annotation 'Literal[20]' [invalid-annotation] -File "literals_semantics.py", line 19, in func1: Invalid type annotation 'Literal[20]' [invalid-annotation] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 24: Expected 1 errors -Line 25: Expected 1 errors -Line 33: Expected 1 errors -Line 12: Unexpected errors ['File "literals_semantics.py", line 12, in : Invalid type annotation \\'Literal\\' [invalid-annotation]', 'File "literals_semantics.py", line 12, in : Invalid type annotation \\'L[-3]\\' [invalid-annotation]'] -Line 16: Unexpected errors ['File "literals_semantics.py", line 16, in : Invalid type annotation \\'Literal\\' [invalid-annotation]'] -Line 17: Unexpected errors ['File "literals_semantics.py", line 17, in func1: Invalid type annotation \\'Literal[20]\\' [invalid-annotation]'] -Line 18: Unexpected errors ['File "literals_semantics.py", line 18, in func1: Invalid type annotation \\'Literal[20]\\' [invalid-annotation]'] -Line 19: Unexpected errors ['File "literals_semantics.py", line 19, in func1: Invalid type annotation \\'Literal[20]\\' [invalid-annotation]'] -""" diff --git a/conformance/results/pytype/namedtuples_define_class.toml b/conformance/results/pytype/namedtuples_define_class.toml deleted file mode 100644 index 354819a99..000000000 --- a/conformance/results/pytype/namedtuples_define_class.toml +++ /dev/null @@ -1,37 +0,0 @@ -conformant = "Partial" -notes = """ -Incorrectly rejects valid index of named tuple instance when using a negative index. -Does not evaluate correct type for indexed named tuple instance with slice. -Does not reject named tuple element with no default value after one with a default. -Does not reject override of named tuple attribute in child class. -Evaluates incorrect type for named tuple entry with a generic type. -Does not reject incorrect argument type passed to specialized generic named tuple constructor. -Does not reject attempt to use NamedTuple with multiple inheritance. -""" -output = """ -File "namedtuples_define_class.py", line 27, in : Union[int, str] [assert-type] -File "namedtuples_define_class.py", line 28, in : Union[int, str] [assert-type] -File "namedtuples_define_class.py", line 29, in : Tuple[Union[int, str], ...] [assert-type] -File "namedtuples_define_class.py", line 30, in : Tuple[Union[int, str], ...] [assert-type] -File "namedtuples_define_class.py", line 44, in : Missing parameter 'y' in call to function Point.__new__ [missing-parameter] -File "namedtuples_define_class.py", line 45, in : Missing parameter 'y' in call to function Point.__new__ [missing-parameter] -File "namedtuples_define_class.py", line 46, in : Function Point.__new__ was called with the wrong arguments [wrong-arg-types] -File "namedtuples_define_class.py", line 47, in : Function Point.__new__ was called with the wrong arguments [wrong-arg-types] -File "namedtuples_define_class.py", line 48, in : Function Point.__new__ expects 3 arg(s), got 5 [wrong-arg-count] -File "namedtuples_define_class.py", line 49, in : Invalid keyword argument other to function Point.__new__ [wrong-keyword-args] -File "namedtuples_define_class.py", line 95, in : Any [assert-type] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 32: Expected 1 errors -Line 33: Expected 1 errors -Line 59: Expected 1 errors -Line 79: Expected 1 errors -Line 98: Expected 1 errors -Line 105: Expected 1 errors -Line 27: Unexpected errors ['File "namedtuples_define_class.py", line 27, in : Union[int, str] [assert-type]'] -Line 28: Unexpected errors ['File "namedtuples_define_class.py", line 28, in : Union[int, str] [assert-type]'] -Line 29: Unexpected errors ['File "namedtuples_define_class.py", line 29, in : Tuple[Union[int, str], ...] [assert-type]'] -Line 30: Unexpected errors ['File "namedtuples_define_class.py", line 30, in : Tuple[Union[int, str], ...] [assert-type]'] -Line 95: Unexpected errors ['File "namedtuples_define_class.py", line 95, in : Any [assert-type]'] -""" diff --git a/conformance/results/pytype/namedtuples_define_functional.toml b/conformance/results/pytype/namedtuples_define_functional.toml deleted file mode 100644 index ab1f06c02..000000000 --- a/conformance/results/pytype/namedtuples_define_functional.toml +++ /dev/null @@ -1,24 +0,0 @@ -conformant = "Partial" -notes = """ -Does not handle illegal named tuple names the same as runtime. -Does not support defaults in functional form. -""" -output = """ -File "namedtuples_define_functional.py", line 16, in : Missing parameter 'y' in call to function Point1.__new__ [missing-parameter] -File "namedtuples_define_functional.py", line 21, in : Missing parameter 'x' in call to function Point2.__new__ [missing-parameter] -File "namedtuples_define_functional.py", line 26, in : Function Point3.__new__ expects 3 arg(s), got 4 [wrong-arg-count] -File "namedtuples_define_functional.py", line 31, in : Invalid keyword argument z to function Point4.__new__ [wrong-keyword-args] -File "namedtuples_define_functional.py", line 36, in : Function Point5.__new__ was called with the wrong arguments [wrong-arg-types] -File "namedtuples_define_functional.py", line 37, in : Function Point5.__new__ expects 3 arg(s), got 4 [wrong-arg-count] -File "namedtuples_define_functional.py", line 42, in : Function Point6.__new__ was called with the wrong arguments [wrong-arg-types] -File "namedtuples_define_functional.py", line 43, in : Function Point6.__new__ was called with the wrong arguments [wrong-arg-types] -File "namedtuples_define_functional.py", line 52, in : collections.namedtuple argument 'a' is not a valid typename or field name. [invalid-namedtuple-arg] -File "namedtuples_define_functional.py", line 53, in : collections.namedtuple argument 'def' is not a valid typename or field name. [invalid-namedtuple-arg] -File "namedtuples_define_functional.py", line 54, in : collections.namedtuple argument 'def' is not a valid typename or field name. [invalid-namedtuple-arg] -File "namedtuples_define_functional.py", line 63, in : Function collections.namedtuple was called with the wrong arguments [wrong-arg-types] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 66: Expected 1 errors -Line 63: Unexpected errors ['File "namedtuples_define_functional.py", line 63, in : Function collections.namedtuple was called with the wrong arguments [wrong-arg-types]'] -""" diff --git a/conformance/results/pytype/namedtuples_type_compat.toml b/conformance/results/pytype/namedtuples_type_compat.toml deleted file mode 100644 index 240a90347..000000000 --- a/conformance/results/pytype/namedtuples_type_compat.toml +++ /dev/null @@ -1,8 +0,0 @@ -conformant = "Pass" -output = """ -File "namedtuples_type_compat.py", line 22, in : Type annotation for v3 does not match type of assignment [annotation-type-mismatch] -File "namedtuples_type_compat.py", line 23, in : Type annotation for v4 does not match type of assignment [annotation-type-mismatch] -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pytype/namedtuples_usage.toml b/conformance/results/pytype/namedtuples_usage.toml deleted file mode 100644 index d1a376f6b..000000000 --- a/conformance/results/pytype/namedtuples_usage.toml +++ /dev/null @@ -1,24 +0,0 @@ -conformant = "Partial" -notes = """ -Incorrectly rejects valid index of named tuple instance when using a negative index. -Does not report out-of-range index access with named tuple instance. -Does not reject attempt to overwrite named tuple entry by name. -Does not reject attempt to delete named tuple entry by name. -""" -output = """ -File "namedtuples_usage.py", line 31, in : Union[int, str] [assert-type] -File "namedtuples_usage.py", line 32, in : Union[int, str] [assert-type] -File "namedtuples_usage.py", line 41, in : unsupported operand type(s) for item assignment: Point [unsupported-operands] -File "namedtuples_usage.py", line 43, in : unsupported operand type(s) for item deletion: Point [unsupported-operands] -File "namedtuples_usage.py", line 52, in : Cannot unpack 3 values into 2 variables [bad-unpacking] -File "namedtuples_usage.py", line 53, in : Cannot unpack 3 values into 4 variables [bad-unpacking] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 34: Expected 1 errors -Line 35: Expected 1 errors -Line 40: Expected 1 errors -Line 42: Expected 1 errors -Line 31: Unexpected errors ['File "namedtuples_usage.py", line 31, in : Union[int, str] [assert-type]'] -Line 32: Unexpected errors ['File "namedtuples_usage.py", line 32, in : Union[int, str] [assert-type]'] -""" diff --git a/conformance/results/pytype/narrowing_typeguard.toml b/conformance/results/pytype/narrowing_typeguard.toml deleted file mode 100644 index a95dd8d5e..000000000 --- a/conformance/results/pytype/narrowing_typeguard.toml +++ /dev/null @@ -1,13 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject TypeGuard method with too few parameters. -""" -output = """ -File "narrowing_typeguard.py", line 128, in : Function takes_callable_str was called with the wrong arguments [wrong-arg-types] -File "narrowing_typeguard.py", line 148, in : Function takes_callable_str_proto was called with the wrong arguments [wrong-arg-types] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 102: Expected 1 errors -Line 107: Expected 1 errors -""" diff --git a/conformance/results/pytype/narrowing_typeis.toml b/conformance/results/pytype/narrowing_typeis.toml deleted file mode 100644 index 3af03cc86..000000000 --- a/conformance/results/pytype/narrowing_typeis.toml +++ /dev/null @@ -1,22 +0,0 @@ -conformant = "Partial" -notes = """ -Does not narrow correctly on generic tuple type. -Does not reject covariant use of TypeIs. -Does not reject TypeIs where return type is not consistent with input type due to variance. -""" -output = """ -File "narrowing_typeis.py", line 19, in func1: Tuple[str, ...] [assert-type] -File "narrowing_typeis.py", line 132, in : Function takes_callable_str was called with the wrong arguments [wrong-arg-types] -File "narrowing_typeis.py", line 152, in : Function takes_callable_str_proto was called with the wrong arguments [wrong-arg-types] -File "narrowing_typeis.py", line 169, in : Function takes_typeguard was called with the wrong arguments [wrong-arg-types] -File "narrowing_typeis.py", line 170, in : Function takes_typeis was called with the wrong arguments [wrong-arg-types] -File "narrowing_typeis.py", line 195, in : TypeIs[str] is not consistent with input type int [invalid-function-definition] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 105: Expected 1 errors -Line 110: Expected 1 errors -Line 191: Expected 1 errors -Line 199: Expected 1 errors -Line 19: Unexpected errors ['File "narrowing_typeis.py", line 19, in func1: Tuple[str, ...] [assert-type]'] -""" diff --git a/conformance/results/pytype/overloads_basic.toml b/conformance/results/pytype/overloads_basic.toml deleted file mode 100644 index 8d90cba20..000000000 --- a/conformance/results/pytype/overloads_basic.toml +++ /dev/null @@ -1,17 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject a function with a single @overload signature. -Does not reject a function with @overload signature but no implementation. -""" -output = """ -File "overloads_basic.py", line 31, in __getitem__: bad return type [bad-return-type] -File "overloads_basic.py", line 37, in : unsupported operand type(s) for item retrieval: Bytes and str [unsupported-operands] -File "overloads_basic.py", line 58, in map: bad return type [bad-return-type] -""" -conformance_automated = "Fail" -errors_diff = """ -Lines 62, 63: Expected error (tag 'func1') -Lines 74, 75: Expected error (tag 'func2') -Line 31: Unexpected errors ['File "overloads_basic.py", line 31, in __getitem__: bad return type [bad-return-type]'] -Line 58: Unexpected errors ['File "overloads_basic.py", line 58, in map: bad return type [bad-return-type]'] -""" diff --git a/conformance/results/pytype/protocols_class_objects.toml b/conformance/results/pytype/protocols_class_objects.toml deleted file mode 100644 index 7efa307ad..000000000 --- a/conformance/results/pytype/protocols_class_objects.toml +++ /dev/null @@ -1,21 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject protocol class assigned to type[Proto]. -Incorrectly reports some class objects as incompatible with a protocol. -Fails to report some class objects as incompatible with a protocol. -""" -output = """ -File "protocols_class_objects.py", line 50, in method1: bad return type [bad-return-type] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 29: Expected 1 errors -Line 34: Expected 1 errors -Line 58: Expected 1 errors -Line 74: Expected 1 errors -Line 101: Expected 1 errors -Line 103: Expected 1 errors -Line 104: Expected 1 errors -Line 105: Expected 1 errors -Line 50: Unexpected errors ['File "protocols_class_objects.py", line 50, in method1: bad return type [bad-return-type]'] -""" diff --git a/conformance/results/pytype/protocols_definition.toml b/conformance/results/pytype/protocols_definition.toml deleted file mode 100644 index a50220bbd..000000000 --- a/conformance/results/pytype/protocols_definition.toml +++ /dev/null @@ -1,45 +0,0 @@ -conformant = "Partial" -notes = """ -Reports errors for protocol static method with "..." implementation. -Does not report error when instance variable is set through "self" access in protocol class. -Does not report protocol mismatch when concrete class has attribute with covariant type and protocol attribute is mutable. -Does not reject ClassVar in concrete class when attribute in protocol is not ClassVar. -Does not reject read-only property in concrete class when attribute in protocol is mutable. -Does not reject covariant attribute type when protocol attribute is mutable. -Does not detect protocol mismatch if concrete method is missing annotations. -Does not detect protocol mismatch if concrete method's parameters are keyword-only. -Does not detect protocol mismatch if concrete method's parameters are position-only. -Does not detect protocol mismatch if concrete method is a classmethod. -Does not detect protocol mismatch if concrete method is a staticmethod. -Does not reject read-only property in concrete class when protocol has settable property. -Does not reject immutable named tuple attribute in concrete class when protocol attribute is mutable. -Does not reject immutable frozen dataclass attribute in concrete class when protocol attribute is mutable. -""" -output = """ -File "protocols_definition.py", line 30, in : Function close_all was called with the wrong arguments [wrong-arg-types] -File "protocols_definition.py", line 45, in third: bad return type [bad-return-type] -File "protocols_definition.py", line 114, in : Type annotation for v2_bad1 does not match type of assignment [annotation-type-mismatch] -File "protocols_definition.py", line 115, in : Type annotation for v2_bad2 does not match type of assignment [annotation-type-mismatch] -File "protocols_definition.py", line 156, in : Type annotation for v3_bad1 does not match type of assignment [annotation-type-mismatch] -File "protocols_definition.py", line 159, in : Type annotation for v3_bad4 does not match type of assignment [annotation-type-mismatch] -File "protocols_definition.py", line 218, in : Type annotation for v4_bad1 does not match type of assignment [annotation-type-mismatch] -File "protocols_definition.py", line 219, in : Type annotation for v4_bad2 does not match type of assignment [annotation-type-mismatch] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 67: Expected 1 errors -Line 116: Expected 1 errors -Line 117: Expected 1 errors -Line 157: Expected 1 errors -Line 158: Expected 1 errors -Line 160: Expected 1 errors -Line 285: Expected 1 errors -Line 286: Expected 1 errors -Line 287: Expected 1 errors -Line 288: Expected 1 errors -Line 289: Expected 1 errors -Line 339: Expected 1 errors -Line 340: Expected 1 errors -Line 341: Expected 1 errors -Line 45: Unexpected errors ['File "protocols_definition.py", line 45, in third: bad return type [bad-return-type]'] -""" diff --git a/conformance/results/pytype/protocols_explicit.toml b/conformance/results/pytype/protocols_explicit.toml deleted file mode 100644 index 0cbb6f139..000000000 --- a/conformance/results/pytype/protocols_explicit.toml +++ /dev/null @@ -1,24 +0,0 @@ -conformant = "Partial" -notes = """ -Reports errors for protocol static method with "..." implementation. -Does not report error when calling unimplemented protocol method from derived class. -Does not report type incompatibility when assigning to attribute defined in protocol. -Does not reject instantiation of class that derives from protocol but doesn't implement attribute. -Does not report instantiation of class that derives from protocol but doesn't implement method. -""" -output = """ -File "protocols_explicit.py", line 14, in draw: bad return type [bad-return-type] -Called from (traceback): - line 27, in draw -File "protocols_explicit.py", line 59, in : Can't instantiate Point with abstract methods intensity [not-instantiable] -File "protocols_explicit.py", line 159, in : Can't instantiate Concrete7A with abstract methods method1 [not-instantiable] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 27: Expected 1 errors -Line 56: Expected 1 errors -Line 86: Expected 1 errors -Line 104: Expected 1 errors -Line 129: Expected 1 errors -Line 14: Unexpected errors ['File "protocols_explicit.py", line 14, in draw: bad return type [bad-return-type]'] -""" diff --git a/conformance/results/pytype/protocols_generic.toml b/conformance/results/pytype/protocols_generic.toml deleted file mode 100644 index c2d3728ac..000000000 --- a/conformance/results/pytype/protocols_generic.toml +++ /dev/null @@ -1,25 +0,0 @@ -conformant = "Partial" -notes = """ -Does not correctly enforce contravariance in protocol type compatibility tests. -Does not correctly enforce invariance in protocol type compatibility tests. -Does not detect protocol mismatch when method-scoped TypeVar is used in protocol. -""" -output = """ -File "protocols_generic.py", line 12, in : argument "covariant" to TypeVar not supported yet [not-supported-yet] -File "protocols_generic.py", line 13, in : argument "contravariant" to TypeVar not supported yet [not-supported-yet] -File "protocols_generic.py", line 40, in : Type annotation for p2 does not match type of assignment [annotation-type-mismatch] -File "protocols_generic.py", line 44, in : Invalid type annotation 'Proto2' [invalid-annotation] -File "protocols_generic.py", line 56, in func1: Type annotation for v2 does not match type of assignment [annotation-type-mismatch] -File "protocols_generic.py", line 65, in func2: Type annotation for v1 does not match type of assignment [annotation-type-mismatch] -File "protocols_generic.py", line 75, in func3: Type annotation for v2 does not match type of assignment [annotation-type-mismatch] -File "protocols_generic.py", line 146, in : Type annotation for hp3 does not match type of assignment [annotation-type-mismatch] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 66: Expected 1 errors -Line 74: Expected 1 errors -Line 147: Expected 1 errors -Line 12: Unexpected errors ['File "protocols_generic.py", line 12, in : argument "covariant" to TypeVar not supported yet [not-supported-yet]'] -Line 13: Unexpected errors ['File "protocols_generic.py", line 13, in : argument "contravariant" to TypeVar not supported yet [not-supported-yet]'] -Line 65: Unexpected errors ['File "protocols_generic.py", line 65, in func2: Type annotation for v1 does not match type of assignment [annotation-type-mismatch]'] -""" diff --git a/conformance/results/pytype/protocols_merging.toml b/conformance/results/pytype/protocols_merging.toml deleted file mode 100644 index bf9e4eab4..000000000 --- a/conformance/results/pytype/protocols_merging.toml +++ /dev/null @@ -1,16 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject a protocol class that derives from a non-protocol class. -Does not report attempt to instantiate abstract class downgraded from protocol class. -""" -output = """ -File "protocols_merging.py", line 52, in : Type annotation for s6 does not match type of assignment [annotation-type-mismatch] -File "protocols_merging.py", line 53, in : Type annotation for s7 does not match type of assignment [annotation-type-mismatch] -File "protocols_merging.py", line 54, in : Type annotation for s8 does not match type of assignment [annotation-type-mismatch] -File "protocols_merging.py", line 82, in : Can't instantiate SizedAndClosable4 with abstract methods close [not-instantiable] -File "protocols_merging.py", line 83, in : Type annotation for y does not match type of assignment [annotation-type-mismatch] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 67: Expected 1 errors -""" diff --git a/conformance/results/pytype/protocols_modules.toml b/conformance/results/pytype/protocols_modules.toml deleted file mode 100644 index 1c5af9060..000000000 --- a/conformance/results/pytype/protocols_modules.toml +++ /dev/null @@ -1,16 +0,0 @@ -conformant = "Partial" -notes = """ -Does not report incompatibilities for protocol methods. -""" -output = """ -File "protocols_modules.py", line 10, in : Can't find module '_protocols_modules1'. [import-error] -File "protocols_modules.py", line 11, in : Can't find module '_protocols_modules2'. [import-error] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 26: Expected 1 errors -Line 48: Expected 1 errors -Line 49: Expected 1 errors -Line 10: Unexpected errors ['File "protocols_modules.py", line 10, in : Can\\'t find module \\'_protocols_modules1\\'. [import-error]'] -Line 11: Unexpected errors ['File "protocols_modules.py", line 11, in : Can\\'t find module \\'_protocols_modules2\\'. [import-error]'] -""" diff --git a/conformance/results/pytype/protocols_recursive.toml b/conformance/results/pytype/protocols_recursive.toml deleted file mode 100644 index 05142931d..000000000 --- a/conformance/results/pytype/protocols_recursive.toml +++ /dev/null @@ -1,15 +0,0 @@ -conformant = "Partial" -notes = """ -Incorrectly reports type error for some recursive protocols. -""" -output = """ -File "protocols_recursive.py", line 11, in : argument "covariant" to TypeVar not supported yet [not-supported-yet] -File "protocols_recursive.py", line 12, in : argument "contravariant" to TypeVar not supported yet [not-supported-yet] -File "protocols_recursive.py", line 81, in : Any [assert-type] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 11: Unexpected errors ['File "protocols_recursive.py", line 11, in : argument "covariant" to TypeVar not supported yet [not-supported-yet]'] -Line 12: Unexpected errors ['File "protocols_recursive.py", line 12, in : argument "contravariant" to TypeVar not supported yet [not-supported-yet]'] -Line 81: Unexpected errors ['File "protocols_recursive.py", line 81, in : Any [assert-type]'] -""" diff --git a/conformance/results/pytype/protocols_runtime_checkable.toml b/conformance/results/pytype/protocols_runtime_checkable.toml deleted file mode 100644 index 259caef2e..000000000 --- a/conformance/results/pytype/protocols_runtime_checkable.toml +++ /dev/null @@ -1,18 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not reject isinstance or issubclass call for protocol that is not runtime_checkable. -Does not reject issubclass call for data protocol. -Does not report unsafe overlap for runtime_checkable protocol. -""" -output = """ - -""" -conformance_automated = "Fail" -errors_diff = """ -Line 23: Expected 1 errors -Line 55: Expected 1 errors -Line 61: Expected 1 errors -Line 88: Expected 1 errors -Line 92: Expected 1 errors -Line 96: Expected 1 errors -""" diff --git a/conformance/results/pytype/protocols_self.toml b/conformance/results/pytype/protocols_self.toml deleted file mode 100644 index ec7dd2b3e..000000000 --- a/conformance/results/pytype/protocols_self.toml +++ /dev/null @@ -1,17 +0,0 @@ -conformant = "Partial" -notes = """ -Does not properly handle Self type within a protocol. -""" -output = """ -File "protocols_self.py", line 36, in : argument "covariant" to TypeVar not supported yet [not-supported-yet] -File "protocols_self.py", line 37, in : argument "covariant" to TypeVar not supported yet [not-supported-yet] -File "protocols_self.py", line 72, in : Type annotation for a2 does not match type of assignment [annotation-type-mismatch] -File "protocols_self.py", line 73, in : Type annotation for b2 does not match type of assignment [annotation-type-mismatch] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 36: Unexpected errors ['File "protocols_self.py", line 36, in : argument "covariant" to TypeVar not supported yet [not-supported-yet]'] -Line 37: Unexpected errors ['File "protocols_self.py", line 37, in : argument "covariant" to TypeVar not supported yet [not-supported-yet]'] -Line 72: Unexpected errors ['File "protocols_self.py", line 72, in : Type annotation for a2 does not match type of assignment [annotation-type-mismatch]'] -Line 73: Unexpected errors ['File "protocols_self.py", line 73, in : Type annotation for b2 does not match type of assignment [annotation-type-mismatch]'] -""" diff --git a/conformance/results/pytype/protocols_subtyping.toml b/conformance/results/pytype/protocols_subtyping.toml deleted file mode 100644 index c364fc59a..000000000 --- a/conformance/results/pytype/protocols_subtyping.toml +++ /dev/null @@ -1,21 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject attempt to instantiate protocol class. -Does not report some protocol type compatibility violations involving contravariance. -""" -output = """ -File "protocols_subtyping.py", line 38, in func1: Type annotation for v2 does not match type of assignment [annotation-type-mismatch] -File "protocols_subtyping.py", line 55, in func2: Type annotation for v2 does not match type of assignment [annotation-type-mismatch] -File "protocols_subtyping.py", line 83, in : argument "covariant" to TypeVar not supported yet [not-supported-yet] -File "protocols_subtyping.py", line 84, in : argument "contravariant" to TypeVar not supported yet [not-supported-yet] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 16: Expected 1 errors -Line 79: Expected 1 errors -Line 80: Expected 1 errors -Line 102: Expected 1 errors -Line 103: Expected 1 errors -Line 83: Unexpected errors ['File "protocols_subtyping.py", line 83, in : argument "covariant" to TypeVar not supported yet [not-supported-yet]'] -Line 84: Unexpected errors ['File "protocols_subtyping.py", line 84, in : argument "contravariant" to TypeVar not supported yet [not-supported-yet]'] -""" diff --git a/conformance/results/pytype/protocols_variance.toml b/conformance/results/pytype/protocols_variance.toml deleted file mode 100644 index 9eb9e2845..000000000 --- a/conformance/results/pytype/protocols_variance.toml +++ /dev/null @@ -1,22 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not detect incorrect TypeVar variance within generic protocols. -""" -output = """ -File "protocols_variance.py", line 12, in : argument "covariant" to TypeVar not supported yet [not-supported-yet] -File "protocols_variance.py", line 13, in : argument "contravariant" to TypeVar not supported yet [not-supported-yet] -File "protocols_variance.py", line 15, in : argument "covariant" to TypeVar not supported yet [not-supported-yet] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 21: Expected 1 errors -Line 40: Expected 1 errors -Line 56: Expected 1 errors -Line 61: Expected 1 errors -Line 66: Expected 1 errors -Line 71: Expected 1 errors -Line 104: Expected 1 errors -Line 12: Unexpected errors ['File "protocols_variance.py", line 12, in : argument "covariant" to TypeVar not supported yet [not-supported-yet]'] -Line 13: Unexpected errors ['File "protocols_variance.py", line 13, in : argument "contravariant" to TypeVar not supported yet [not-supported-yet]'] -Line 15: Unexpected errors ['File "protocols_variance.py", line 15, in : argument "covariant" to TypeVar not supported yet [not-supported-yet]'] -""" diff --git a/conformance/results/pytype/qualifiers_annotated.toml b/conformance/results/pytype/qualifiers_annotated.toml deleted file mode 100644 index 9a0642022..000000000 --- a/conformance/results/pytype/qualifiers_annotated.toml +++ /dev/null @@ -1,34 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject some illegal type expression forms used in Annotated. -Does not report type incompatibility between Annotated and type[T]. -Does not reject call of Annotated. -Does not allow TypeVar to be used in type alias when wrapped with Annotated. -""" -output = """ -File "qualifiers_annotated.py", line 43, in : Invalid type annotation '[int, str]' for Bad1 [invalid-annotation] -File "qualifiers_annotated.py", line 44, in : Invalid type annotation '((int, str),)' for Bad2 [invalid-annotation] -File "qualifiers_annotated.py", line 45, in : Invalid type annotation '' for Bad3 [invalid-annotation] -File "qualifiers_annotated.py", line 46, in : Invalid type annotation "{'a': 'b'}" for Bad4 [invalid-annotation] -File "qualifiers_annotated.py", line 50, in : Name 'var1' is not defined [name-error] -File "qualifiers_annotated.py", line 51, in : Invalid type annotation 'True' for Bad9 [invalid-annotation] -File "qualifiers_annotated.py", line 52, in : Invalid type annotation '1' for Bad10 [invalid-annotation] -File "qualifiers_annotated.py", line 54, in : Invalid type annotation '' for Bad12 [invalid-annotation] -File "qualifiers_annotated.py", line 64, in : Invalid type annotation 'Annotated' [invalid-annotation] -File "qualifiers_annotated.py", line 91, in : 'Annotated' object is not callable [not-callable] -File "qualifiers_annotated.py", line 121, in : Invalid TypeVar: TypeVar('T') must be stored as 'T', not 'TA3' [invalid-typevar] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 47: Expected 1 errors -Line 48: Expected 1 errors -Line 49: Expected 1 errors -Line 53: Expected 1 errors -Line 76: Expected 1 errors -Line 77: Expected 1 errors -Line 84: Expected 1 errors -Line 85: Expected 1 errors -Line 92: Expected 1 errors -Line 93: Expected 1 errors -Line 121: Unexpected errors ['File "qualifiers_annotated.py", line 121, in : Invalid TypeVar: TypeVar(\\'T\\') must be stored as \\'T\\', not \\'TA3\\' [invalid-typevar]'] -""" diff --git a/conformance/results/pytype/qualifiers_final_annotation.toml b/conformance/results/pytype/qualifiers_final_annotation.toml deleted file mode 100644 index 9d3a3d450..000000000 --- a/conformance/results/pytype/qualifiers_final_annotation.toml +++ /dev/null @@ -1,42 +0,0 @@ -conformant = "Partial" -notes = """ -Does not report Final variable with missing initialization. -Does not reject Final instance variable declared outside of __init__ method. -Does not reject modification of global variable declared Final. -Does not reject modification of local variable declared Final. -""" -output = """ -File "qualifiers_final_annotation.py", line 18, in : Invalid type annotation 'Final[str, int]' [invalid-annotation] -File "qualifiers_final_annotation.py", line 18, in : Invalid type annotation 'Final' [invalid-annotation] -File "qualifiers_final_annotation.py", line 54, in __init__: Assigning to attribute ID5, which was annotated with Final [final-error] -File "qualifiers_final_annotation.py", line 65, in method1: Assigning to attribute ID7, which was annotated with Final [final-error] -File "qualifiers_final_annotation.py", line 67, in method1: Assigning to attribute ID7, which was annotated with Final [final-error] -File "qualifiers_final_annotation.py", line 71, in : Assigning to variable RATE, which was annotated with Final [final-error] -File "qualifiers_final_annotation.py", line 81, in : Assigning to attribute DEFAULT_ID, which was annotated with Final [final-error] -File "qualifiers_final_annotation.py", line 93, in : Class ClassCChild overrides final class attribute BORDER_WIDTH, defined in base class ClassC [final-error] -File "qualifiers_final_annotation.py", line 107, in ClassD: Type annotation for VALUE2 does not match type of assignment [annotation-type-mismatch] -File "qualifiers_final_annotation.py", line 107, in ClassD: Invalid use of typing.Final [final-error] -File "qualifiers_final_annotation.py", line 107, in ClassD: Invalid type annotation 'ClassVar[Final]' [invalid-annotation] -File "qualifiers_final_annotation.py", line 108, in ClassD: Type annotation for VALUE3 does not match type of assignment [annotation-type-mismatch] -File "qualifiers_final_annotation.py", line 118, in : Invalid use of typing.Final [final-error] -File "qualifiers_final_annotation.py", line 118, in : Invalid type annotation 'list[Final[int]]' [invalid-annotation] -File "qualifiers_final_annotation.py", line 121, in : Invalid use of typing.Final [final-error] -File "qualifiers_final_annotation.py", line 134, in : Invalid keyword argument a to function N.__new__ [wrong-keyword-args] -File "qualifiers_final_annotation.py", line 135, in : Function N.__new__ was called with the wrong arguments [wrong-arg-types] -File "qualifiers_final_annotation.py", line 145, in func2: Assigning to variable x, which was annotated with Final [final-error] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 16: Expected 1 errors -Line 34: Expected 1 errors -Line 38: Expected 1 errors -Line 62: Expected 1 errors -Line 63: Expected 1 errors -Line 94: Expected 1 errors -Line 141: Expected 1 errors -Line 147: Expected 1 errors -Line 149: Expected 1 errors -Line 152: Expected 1 errors -Line 155: Expected 1 errors -Line 93: Unexpected errors ['File "qualifiers_final_annotation.py", line 93, in : Class ClassCChild overrides final class attribute BORDER_WIDTH, defined in base class ClassC [final-error]'] -""" diff --git a/conformance/results/pytype/qualifiers_final_decorator.toml b/conformance/results/pytype/qualifiers_final_decorator.toml deleted file mode 100644 index ca2fa29cd..000000000 --- a/conformance/results/pytype/qualifiers_final_decorator.toml +++ /dev/null @@ -1,37 +0,0 @@ -conformant = "Partial" -notes = """ -Does not report error for overloaded @final method defined in stub file. -Does not report error for overload that is marked @final when implementation is not. -""" -output = """ -File "qualifiers_final_decorator.py", line 8, in : Couldn't import pyi for '_qualifiers_final_decorator' [pyi-error] -File "qualifiers_final_decorator.py", line 21, in : Cannot subclass final class: Base1 [final-error] -File "qualifiers_final_decorator.py", line 52, in method4: bad return type [bad-return-type] -File "qualifiers_final_decorator.py", line 55, in : Class Derived2 overrides final method method4, defined in base class Base2 [final-error] -File "qualifiers_final_decorator.py", line 55, in : Class Derived2 overrides final method method3, defined in base class Base2 [final-error] -File "qualifiers_final_decorator.py", line 55, in : Class Derived2 overrides final method method2, defined in base class Base2 [final-error] -File "qualifiers_final_decorator.py", line 55, in : Class Derived2 overrides final method method1, defined in base class Base2 [final-error] -File "qualifiers_final_decorator.py", line 76, in method4: bad return type [bad-return-type] -File "qualifiers_final_decorator.py", line 90, in method: bad return type [bad-return-type] -File "qualifiers_final_decorator.py", line 103, in method: bad return type [bad-return-type] -File "qualifiers_final_decorator.py", line 117, in : Class Derived5 overrides final method method, defined in base class Base5_2 [final-error] -File "qualifiers_final_decorator.py", line 118, in Derived5: Overriding method signature mismatch [signature-mismatch] -File "qualifiers_final_decorator.py", line 125, in : Cannot apply @final decorator to func1 [final-error] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 56: Expected 1 errors -Lines 59, 60: Expected error (tag 'method2') -Lines 63, 64: Expected error (tag 'method3') -Lines 67, 75: Expected error (tag 'method4') -Lines 80, 89: Expected error (tag 'Derived3') -Lines 84, 85, 86: Expected error (tag 'Derived3-2') -Lines 94, 102: Expected error (tag 'Derived4') -Line 8: Unexpected errors ['File "qualifiers_final_decorator.py", line 8, in : Couldn\\'t import pyi for \\'_qualifiers_final_decorator\\' [pyi-error]'] -Line 52: Unexpected errors ['File "qualifiers_final_decorator.py", line 52, in method4: bad return type [bad-return-type]'] -Line 55: Unexpected errors ['File "qualifiers_final_decorator.py", line 55, in : Class Derived2 overrides final method method4, defined in base class Base2 [final-error]', 'File "qualifiers_final_decorator.py", line 55, in : Class Derived2 overrides final method method3, defined in base class Base2 [final-error]', 'File "qualifiers_final_decorator.py", line 55, in : Class Derived2 overrides final method method2, defined in base class Base2 [final-error]', 'File "qualifiers_final_decorator.py", line 55, in : Class Derived2 overrides final method method1, defined in base class Base2 [final-error]'] -Line 76: Unexpected errors ['File "qualifiers_final_decorator.py", line 76, in method4: bad return type [bad-return-type]'] -Line 90: Unexpected errors ['File "qualifiers_final_decorator.py", line 90, in method: bad return type [bad-return-type]'] -Line 103: Unexpected errors ['File "qualifiers_final_decorator.py", line 103, in method: bad return type [bad-return-type]'] -Line 117: Unexpected errors ['File "qualifiers_final_decorator.py", line 117, in : Class Derived5 overrides final method method, defined in base class Base5_2 [final-error]'] -""" diff --git a/conformance/results/pytype/specialtypes_any.toml b/conformance/results/pytype/specialtypes_any.toml deleted file mode 100644 index a339ad0a1..000000000 --- a/conformance/results/pytype/specialtypes_any.toml +++ /dev/null @@ -1,7 +0,0 @@ -conformant = "Pass" -output = """ - -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pytype/specialtypes_never.toml b/conformance/results/pytype/specialtypes_never.toml deleted file mode 100644 index b2cb37252..000000000 --- a/conformance/results/pytype/specialtypes_never.toml +++ /dev/null @@ -1,22 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not understand NoReturn or Never. -""" -output = """ -File "specialtypes_never.py", line 11, in : argument "covariant" to TypeVar not supported yet [not-supported-yet] -File "specialtypes_never.py", line 21, in func1: bad return type [bad-return-type] -File "specialtypes_never.py", line 64, in func6: Type annotation for v1 does not match type of assignment [annotation-type-mismatch] -File "specialtypes_never.py", line 65, in func6: Type annotation for v2 does not match type of assignment [annotation-type-mismatch] -File "specialtypes_never.py", line 66, in func6: Type annotation for v3 does not match type of assignment [annotation-type-mismatch] -File "specialtypes_never.py", line 82, in func8: Type annotation for v3 does not match type of assignment [annotation-type-mismatch] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 19: Expected 1 errors -Line 101: Expected 1 errors -Line 11: Unexpected errors ['File "specialtypes_never.py", line 11, in : argument "covariant" to TypeVar not supported yet [not-supported-yet]'] -Line 21: Unexpected errors ['File "specialtypes_never.py", line 21, in func1: bad return type [bad-return-type]'] -Line 64: Unexpected errors ['File "specialtypes_never.py", line 64, in func6: Type annotation for v1 does not match type of assignment [annotation-type-mismatch]'] -Line 65: Unexpected errors ['File "specialtypes_never.py", line 65, in func6: Type annotation for v2 does not match type of assignment [annotation-type-mismatch]'] -Line 66: Unexpected errors ['File "specialtypes_never.py", line 66, in func6: Type annotation for v3 does not match type of assignment [annotation-type-mismatch]'] -""" diff --git a/conformance/results/pytype/specialtypes_none.toml b/conformance/results/pytype/specialtypes_none.toml deleted file mode 100644 index 1c1b30f21..000000000 --- a/conformance/results/pytype/specialtypes_none.toml +++ /dev/null @@ -1,13 +0,0 @@ -conformant = "Partial" -notes = """ -Does not detect type incompatibility between None and type[None]. -Does not detect type incompatibility between None and incompatible protocol. -""" -output = """ -File "specialtypes_none.py", line 21, in : Function func1 was called with the wrong arguments [wrong-arg-types] -File "specialtypes_none.py", line 41, in : Function func2 was called with the wrong arguments [wrong-arg-types] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 27: Expected 1 errors -""" diff --git a/conformance/results/pytype/specialtypes_promotions.toml b/conformance/results/pytype/specialtypes_promotions.toml deleted file mode 100644 index dc20943f2..000000000 --- a/conformance/results/pytype/specialtypes_promotions.toml +++ /dev/null @@ -1,7 +0,0 @@ -conformant = "Pass" -output = """ -File "specialtypes_promotions.py", line 13, in func1: No attribute 'numerator' on float [attribute-error] -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pytype/specialtypes_type.toml b/conformance/results/pytype/specialtypes_type.toml deleted file mode 100644 index 3a00c1aa9..000000000 --- a/conformance/results/pytype/specialtypes_type.toml +++ /dev/null @@ -1,29 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject Callable when passed to type[T]. -Does not allow access to known attributes from object of type `type[Any]`. -""" -output = """ -File "specialtypes_type.py", line 56, in : Function func4 was called with the wrong arguments [wrong-arg-types] -File "specialtypes_type.py", line 64, in : Invalid type annotation 'T' [invalid-annotation] -File "specialtypes_type.py", line 76, in : Invalid type annotation 'type[int, str]' [invalid-annotation] -File "specialtypes_type.py", line 98, in func7: Any [assert-type] -File "specialtypes_type.py", line 102, in func7: Any [assert-type] -File "specialtypes_type.py", line 106, in func7: Any [assert-type] -File "specialtypes_type.py", line 110, in func7: Any [assert-type] -File "specialtypes_type.py", line 117, in func8: No attribute 'unknown' on Type[object] [attribute-error] -File "specialtypes_type.py", line 120, in func8: No attribute 'unknown' on Type[object] [attribute-error] -File "specialtypes_type.py", line 143, in : No attribute 'unknown' on Type[type] [attribute-error] -File "specialtypes_type.py", line 144, in : No attribute 'unknown' on Type[type] [attribute-error] -File "specialtypes_type.py", line 145, in : No attribute 'unknown' on Type[type] [attribute-error] -File "specialtypes_type.py", line 146, in : No attribute 'unknown' on Type[type] [attribute-error] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 70: Expected 1 errors -Line 64: Unexpected errors ['File "specialtypes_type.py", line 64, in : Invalid type annotation \\'T\\' [invalid-annotation]'] -Line 98: Unexpected errors ['File "specialtypes_type.py", line 98, in func7: Any [assert-type]'] -Line 102: Unexpected errors ['File "specialtypes_type.py", line 102, in func7: Any [assert-type]'] -Line 106: Unexpected errors ['File "specialtypes_type.py", line 106, in func7: Any [assert-type]'] -Line 110: Unexpected errors ['File "specialtypes_type.py", line 110, in func7: Any [assert-type]'] -""" diff --git a/conformance/results/pytype/tuples_type_compat.toml b/conformance/results/pytype/tuples_type_compat.toml deleted file mode 100644 index 638c5bf2e..000000000 --- a/conformance/results/pytype/tuples_type_compat.toml +++ /dev/null @@ -1,100 +0,0 @@ -conformant = "Partial" -notes = """ -Does not support unpacked tuple forms. -Does not report type violation when assigning `tuple[int, ...]` to `tuple[int]`. -Does not support tuple narrowing based on `len()` type guard (optional). -""" -output = """ -File "tuples_type_compat.py", line 15, in func1: Type annotation for v2 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 22, in : Invalid type annotation '' [invalid-annotation] -File "tuples_type_compat.py", line 27, in func2: Invalid type annotation 'tuple[int, *tuple[int, ...]]' [invalid-annotation] -File "tuples_type_compat.py", line 47, in func3: Invalid type annotation 'tuple[int, *tuple[str, ...]]' [invalid-annotation] -File "tuples_type_compat.py", line 71, in : Invalid type annotation '' [invalid-annotation] -File "tuples_type_compat.py", line 74, in func5: tuple [assert-type] -File "tuples_type_compat.py", line 78, in func5: tuple [assert-type] -File "tuples_type_compat.py", line 82, in func5: tuple [assert-type] -File "tuples_type_compat.py", line 91, in : Invalid type annotation '' [invalid-annotation] -File "tuples_type_compat.py", line 115, in func7: Tuple[Union[int, str], Union[int, str]] [assert-type] -File "tuples_type_compat.py", line 117, in func7: Tuple[Union[int, str], Union[int, str]] [assert-type] -File "tuples_type_compat.py", line 134, in : Invalid type annotation '' [invalid-annotation] -File "tuples_type_compat.py", line 139, in func8: Sequence [assert-type] -File "tuples_type_compat.py", line 140, in func8: Sequence [assert-type] -File "tuples_type_compat.py", line 143, in : Type annotation for t1 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 143, in : Invalid type annotation 'tuple[int, *tuple[str]]' [invalid-annotation] -File "tuples_type_compat.py", line 143, in : Invalid type annotation '' [invalid-annotation] -File "tuples_type_compat.py", line 144, in : Type annotation for t1 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 146, in : Invalid type annotation 'tuple[int, *tuple[str, ...]]' [invalid-annotation] -File "tuples_type_compat.py", line 146, in : Invalid type annotation '' [invalid-annotation] -File "tuples_type_compat.py", line 147, in : Type annotation for t2 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 148, in : Type annotation for t2 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 149, in : Type annotation for t2 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 150, in : Type annotation for t2 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 153, in : Type annotation for t3 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 153, in : Invalid type annotation 'tuple[int, *tuple[str, ...], int]' [invalid-annotation] -File "tuples_type_compat.py", line 153, in : Invalid type annotation '' [invalid-annotation] -File "tuples_type_compat.py", line 154, in : Type annotation for t3 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 155, in : Type annotation for t3 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 156, in : Type annotation for t3 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 157, in : Type annotation for t3 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 159, in : Invalid type annotation 'tuple[*tuple[str, ...], int]' [invalid-annotation] -File "tuples_type_compat.py", line 159, in : Invalid type annotation '' [invalid-annotation] -File "tuples_type_compat.py", line 160, in : Type annotation for t4 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 161, in : Type annotation for t4 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 162, in : Type annotation for t4 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 163, in : Type annotation for t4 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 167, in func9: Type annotation for t1 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 167, in func9: Invalid type annotation 'tuple[str, str, *tuple[int, ...]]' [invalid-annotation] -File "tuples_type_compat.py", line 168, in func9: Type annotation for t2 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 168, in func9: Invalid type annotation 'tuple[str, str, *tuple[int]]' [invalid-annotation] -File "tuples_type_compat.py", line 169, in func9: Type annotation for t3 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 169, in func9: Invalid type annotation 'tuple[str, *tuple[str, ...]]' [invalid-annotation] -File "tuples_type_compat.py", line 170, in func9: Type annotation for t4 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 170, in func9: Invalid type annotation 'tuple[str, str, *tuple[str, ...]]' [invalid-annotation] -File "tuples_type_compat.py", line 171, in func9: Type annotation for t5 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 171, in func9: Invalid type annotation 'tuple[str, str, str, *tuple[str, ...]]' [invalid-annotation] -File "tuples_type_compat.py", line 172, in func9: Type annotation for t6 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 172, in func9: Invalid type annotation 'tuple[str, *tuple[int, ...], str]' [invalid-annotation] -File "tuples_type_compat.py", line 173, in func9: Type annotation for t7 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 173, in func9: Invalid type annotation 'tuple[*tuple[str, ...], str]' [invalid-annotation] -File "tuples_type_compat.py", line 174, in func9: Type annotation for t8 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 174, in func9: Invalid type annotation 'tuple[*tuple[str, ...], str]' [invalid-annotation] -File "tuples_type_compat.py", line 175, in func9: Type annotation for t9 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_compat.py", line 175, in func9: Invalid type annotation 'tuple[*tuple[str, ...], str, str, str]' [invalid-annotation] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 29: Expected 1 errors -Line 32: Expected 1 errors -Line 33: Expected 1 errors -Line 43: Expected 1 errors -Line 62: Expected 1 errors -Line 22: Unexpected errors ['File "tuples_type_compat.py", line 22, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 27: Unexpected errors ['File "tuples_type_compat.py", line 27, in func2: Invalid type annotation \\'tuple[int, *tuple[int, ...]]\\' [invalid-annotation]'] -Line 47: Unexpected errors ['File "tuples_type_compat.py", line 47, in func3: Invalid type annotation \\'tuple[int, *tuple[str, ...]]\\' [invalid-annotation]'] -Line 71: Unexpected errors ['File "tuples_type_compat.py", line 71, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 74: Unexpected errors ['File "tuples_type_compat.py", line 74, in func5: tuple [assert-type]'] -Line 78: Unexpected errors ['File "tuples_type_compat.py", line 78, in func5: tuple [assert-type]'] -Line 82: Unexpected errors ['File "tuples_type_compat.py", line 82, in func5: tuple [assert-type]'] -Line 91: Unexpected errors ['File "tuples_type_compat.py", line 91, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 115: Unexpected errors ['File "tuples_type_compat.py", line 115, in func7: Tuple[Union[int, str], Union[int, str]] [assert-type]'] -Line 117: Unexpected errors ['File "tuples_type_compat.py", line 117, in func7: Tuple[Union[int, str], Union[int, str]] [assert-type]'] -Line 134: Unexpected errors ['File "tuples_type_compat.py", line 134, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 139: Unexpected errors ['File "tuples_type_compat.py", line 139, in func8: Sequence [assert-type]'] -Line 140: Unexpected errors ['File "tuples_type_compat.py", line 140, in func8: Sequence [assert-type]'] -Line 143: Unexpected errors ['File "tuples_type_compat.py", line 143, in : Type annotation for t1 does not match type of assignment [annotation-type-mismatch]', 'File "tuples_type_compat.py", line 143, in : Invalid type annotation \\'tuple[int, *tuple[str]]\\' [invalid-annotation]', 'File "tuples_type_compat.py", line 143, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 146: Unexpected errors ['File "tuples_type_compat.py", line 146, in : Invalid type annotation \\'tuple[int, *tuple[str, ...]]\\' [invalid-annotation]', 'File "tuples_type_compat.py", line 146, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 147: Unexpected errors ['File "tuples_type_compat.py", line 147, in : Type annotation for t2 does not match type of assignment [annotation-type-mismatch]'] -Line 148: Unexpected errors ['File "tuples_type_compat.py", line 148, in : Type annotation for t2 does not match type of assignment [annotation-type-mismatch]'] -Line 153: Unexpected errors ['File "tuples_type_compat.py", line 153, in : Type annotation for t3 does not match type of assignment [annotation-type-mismatch]', 'File "tuples_type_compat.py", line 153, in : Invalid type annotation \\'tuple[int, *tuple[str, ...], int]\\' [invalid-annotation]', 'File "tuples_type_compat.py", line 153, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 154: Unexpected errors ['File "tuples_type_compat.py", line 154, in : Type annotation for t3 does not match type of assignment [annotation-type-mismatch]'] -Line 155: Unexpected errors ['File "tuples_type_compat.py", line 155, in : Type annotation for t3 does not match type of assignment [annotation-type-mismatch]'] -Line 159: Unexpected errors ['File "tuples_type_compat.py", line 159, in : Invalid type annotation \\'tuple[*tuple[str, ...], int]\\' [invalid-annotation]', 'File "tuples_type_compat.py", line 159, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 160: Unexpected errors ['File "tuples_type_compat.py", line 160, in : Type annotation for t4 does not match type of assignment [annotation-type-mismatch]'] -Line 161: Unexpected errors ['File "tuples_type_compat.py", line 161, in : Type annotation for t4 does not match type of assignment [annotation-type-mismatch]'] -Line 167: Unexpected errors ['File "tuples_type_compat.py", line 167, in func9: Type annotation for t1 does not match type of assignment [annotation-type-mismatch]', 'File "tuples_type_compat.py", line 167, in func9: Invalid type annotation \\'tuple[str, str, *tuple[int, ...]]\\' [invalid-annotation]'] -Line 169: Unexpected errors ['File "tuples_type_compat.py", line 169, in func9: Type annotation for t3 does not match type of assignment [annotation-type-mismatch]', 'File "tuples_type_compat.py", line 169, in func9: Invalid type annotation \\'tuple[str, *tuple[str, ...]]\\' [invalid-annotation]'] -Line 170: Unexpected errors ['File "tuples_type_compat.py", line 170, in func9: Type annotation for t4 does not match type of assignment [annotation-type-mismatch]', 'File "tuples_type_compat.py", line 170, in func9: Invalid type annotation \\'tuple[str, str, *tuple[str, ...]]\\' [invalid-annotation]'] -Line 172: Unexpected errors ['File "tuples_type_compat.py", line 172, in func9: Type annotation for t6 does not match type of assignment [annotation-type-mismatch]', 'File "tuples_type_compat.py", line 172, in func9: Invalid type annotation \\'tuple[str, *tuple[int, ...], str]\\' [invalid-annotation]'] -Line 173: Unexpected errors ['File "tuples_type_compat.py", line 173, in func9: Type annotation for t7 does not match type of assignment [annotation-type-mismatch]', 'File "tuples_type_compat.py", line 173, in func9: Invalid type annotation \\'tuple[*tuple[str, ...], str]\\' [invalid-annotation]'] -Line 174: Unexpected errors ['File "tuples_type_compat.py", line 174, in func9: Type annotation for t8 does not match type of assignment [annotation-type-mismatch]', 'File "tuples_type_compat.py", line 174, in func9: Invalid type annotation \\'tuple[*tuple[str, ...], str]\\' [invalid-annotation]'] -""" diff --git a/conformance/results/pytype/tuples_type_form.toml b/conformance/results/pytype/tuples_type_form.toml deleted file mode 100644 index f8bb94391..000000000 --- a/conformance/results/pytype/tuples_type_form.toml +++ /dev/null @@ -1,19 +0,0 @@ -conformant = "Pass" -output = """ -File "tuples_type_form.py", line 12, in : Type annotation for t1 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_form.py", line 14, in : Type annotation for t2 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_form.py", line 15, in : Type annotation for t2 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_form.py", line 25, in : Type annotation for t10 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_form.py", line 36, in : Type annotation for t20 does not match type of assignment [annotation-type-mismatch] -File "tuples_type_form.py", line 40, in : Invalid type annotation 'tuple[int, int, Any]' [invalid-annotation] -File "tuples_type_form.py", line 41, in : Invalid type annotation 'Ellipsis' [invalid-annotation] -File "tuples_type_form.py", line 42, in : Invalid type annotation 'tuple[Any, int]' [invalid-annotation] -File "tuples_type_form.py", line 42, in : Invalid type annotation 'Ellipsis' [invalid-annotation] -File "tuples_type_form.py", line 43, in : Invalid type annotation 'tuple[int, Any, int]' [invalid-annotation] -File "tuples_type_form.py", line 43, in : Invalid type annotation 'Ellipsis' [invalid-annotation] -File "tuples_type_form.py", line 44, in : Invalid type annotation '' [invalid-annotation] -File "tuples_type_form.py", line 45, in : Invalid type annotation '' [invalid-annotation] -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pytype/tuples_unpacked.toml b/conformance/results/pytype/tuples_unpacked.toml deleted file mode 100644 index ff0e3854f..000000000 --- a/conformance/results/pytype/tuples_unpacked.toml +++ /dev/null @@ -1,53 +0,0 @@ -conformant = "Unsupported" -notes = """ -Does not support `typing.Unpack`. -Does not support unpacked tuples within a tuple type form. -""" -output = """ -File "tuples_unpacked.py", line 13, in : typing.Unpack not supported yet [not-supported-yet] -File "tuples_unpacked.py", line 13, in : typing.TypeVarTuple not supported yet [not-supported-yet] -File "tuples_unpacked.py", line 16, in : Invalid type annotation '' [invalid-annotation] -File "tuples_unpacked.py", line 17, in func1: Tuple[Any] [assert-type] -File "tuples_unpacked.py", line 18, in func1: Invalid type annotation '' [invalid-annotation] -File "tuples_unpacked.py", line 19, in func1: Invalid type annotation '' [invalid-annotation] -File "tuples_unpacked.py", line 25, in : Invalid type annotation '' [invalid-annotation] -File "tuples_unpacked.py", line 26, in func2: Invalid type annotation '' [invalid-annotation] -File "tuples_unpacked.py", line 31, in : Type annotation for u1 does not match type of assignment [annotation-type-mismatch] -File "tuples_unpacked.py", line 31, in : Invalid type annotation 'tuple[*tuple[int], *tuple[int]]' [invalid-annotation] -File "tuples_unpacked.py", line 31, in : Invalid type annotation '' [invalid-annotation] -File "tuples_unpacked.py", line 31, in : Function list.extend was called with the wrong arguments [wrong-arg-types] -File "tuples_unpacked.py", line 32, in : Tuple[Any] [assert-type] -File "tuples_unpacked.py", line 33, in : Invalid type annotation '' [invalid-annotation] -File "tuples_unpacked.py", line 33, in : Function list.extend was called with the wrong arguments [wrong-arg-types] -File "tuples_unpacked.py", line 38, in : Invalid type annotation '' [invalid-annotation] -File "tuples_unpacked.py", line 38, in : Function list.extend was called with the wrong arguments [wrong-arg-types] -File "tuples_unpacked.py", line 39, in : Invalid type annotation '' [invalid-annotation] -File "tuples_unpacked.py", line 40, in : Invalid type annotation '' [invalid-annotation] -File "tuples_unpacked.py", line 40, in : Function list.extend was called with the wrong arguments [wrong-arg-types] -File "tuples_unpacked.py", line 41, in : Invalid type annotation '' [invalid-annotation] -File "tuples_unpacked.py", line 41, in : Function list.extend was called with the wrong arguments [wrong-arg-types] -File "tuples_unpacked.py", line 46, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] -File "tuples_unpacked.py", line 49, in : Invalid type annotation '' [invalid-annotation] -File "tuples_unpacked.py", line 50, in func3: Invalid type annotation 'tuple[*tuple[str], *Ts]' [invalid-annotation] -File "tuples_unpacked.py", line 51, in func3: Invalid type annotation 'tuple[*tuple[str, ...], *Ts]' [invalid-annotation] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 59: Expected 1 errors -Line 61: Expected 1 errors -Line 13: Unexpected errors ['File "tuples_unpacked.py", line 13, in : typing.Unpack not supported yet [not-supported-yet]', 'File "tuples_unpacked.py", line 13, in : typing.TypeVarTuple not supported yet [not-supported-yet]'] -Line 16: Unexpected errors ['File "tuples_unpacked.py", line 16, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 17: Unexpected errors ['File "tuples_unpacked.py", line 17, in func1: Tuple[Any] [assert-type]'] -Line 18: Unexpected errors ['File "tuples_unpacked.py", line 18, in func1: Invalid type annotation \\'\\' [invalid-annotation]'] -Line 19: Unexpected errors ['File "tuples_unpacked.py", line 19, in func1: Invalid type annotation \\'\\' [invalid-annotation]'] -Line 25: Unexpected errors ['File "tuples_unpacked.py", line 25, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 26: Unexpected errors ['File "tuples_unpacked.py", line 26, in func2: Invalid type annotation \\'\\' [invalid-annotation]'] -Line 31: Unexpected errors ['File "tuples_unpacked.py", line 31, in : Type annotation for u1 does not match type of assignment [annotation-type-mismatch]', 'File "tuples_unpacked.py", line 31, in : Invalid type annotation \\'tuple[*tuple[int], *tuple[int]]\\' [invalid-annotation]', 'File "tuples_unpacked.py", line 31, in : Invalid type annotation \\'\\' [invalid-annotation]', 'File "tuples_unpacked.py", line 31, in : Function list.extend was called with the wrong arguments [wrong-arg-types]'] -Line 32: Unexpected errors ['File "tuples_unpacked.py", line 32, in : Tuple[Any] [assert-type]'] -Line 33: Unexpected errors ['File "tuples_unpacked.py", line 33, in : Invalid type annotation \\'\\' [invalid-annotation]', 'File "tuples_unpacked.py", line 33, in : Function list.extend was called with the wrong arguments [wrong-arg-types]'] -Line 38: Unexpected errors ['File "tuples_unpacked.py", line 38, in : Invalid type annotation \\'\\' [invalid-annotation]', 'File "tuples_unpacked.py", line 38, in : Function list.extend was called with the wrong arguments [wrong-arg-types]'] -Line 39: Unexpected errors ['File "tuples_unpacked.py", line 39, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 46: Unexpected errors ['File "tuples_unpacked.py", line 46, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count]'] -Line 49: Unexpected errors ['File "tuples_unpacked.py", line 49, in : Invalid type annotation \\'\\' [invalid-annotation]'] -Line 50: Unexpected errors ['File "tuples_unpacked.py", line 50, in func3: Invalid type annotation \\'tuple[*tuple[str], *Ts]\\' [invalid-annotation]'] -""" diff --git a/conformance/results/pytype/typeddicts_alt_syntax.toml b/conformance/results/pytype/typeddicts_alt_syntax.toml deleted file mode 100644 index cb4b223d3..000000000 --- a/conformance/results/pytype/typeddicts_alt_syntax.toml +++ /dev/null @@ -1,17 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject use of variable as second argument to `TypedDict` call. -Does not report when name of TypedDict doesn't match assigned identifier name. -Does not support keyword-argument form of alternative syntax (deprecated in 3.11). -""" -output = """ -File "typeddicts_alt_syntax.py", line 27, in : Function typing.TypedDict was called with the wrong arguments [wrong-arg-types] -File "typeddicts_alt_syntax.py", line 41, in : Function typing.TypedDict expects 2 arg(s), got 3 [wrong-arg-count] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 23: Expected 1 errors -Line 31: Expected 1 errors -Line 35: Expected 1 errors -Line 45: Expected 1 errors -""" diff --git a/conformance/results/pytype/typeddicts_class_syntax.toml b/conformance/results/pytype/typeddicts_class_syntax.toml deleted file mode 100644 index c6ebfda80..000000000 --- a/conformance/results/pytype/typeddicts_class_syntax.toml +++ /dev/null @@ -1,17 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject methods within TypedDict class. -Does not report when metaclass is provided. -Does not report when other keyword argument is provided. -""" -output = """ - -""" -conformance_automated = "Fail" -errors_diff = """ -Line 29: Expected 1 errors -Line 33: Expected 1 errors -Line 38: Expected 1 errors -Line 44: Expected 1 errors -Line 49: Expected 1 errors -""" diff --git a/conformance/results/pytype/typeddicts_final.toml b/conformance/results/pytype/typeddicts_final.toml deleted file mode 100644 index a339ad0a1..000000000 --- a/conformance/results/pytype/typeddicts_final.toml +++ /dev/null @@ -1,7 +0,0 @@ -conformant = "Pass" -output = """ - -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pytype/typeddicts_inheritance.toml b/conformance/results/pytype/typeddicts_inheritance.toml deleted file mode 100644 index 12f674766..000000000 --- a/conformance/results/pytype/typeddicts_inheritance.toml +++ /dev/null @@ -1,9 +0,0 @@ -conformant = "Pass" -output = """ -File "typeddicts_inheritance.py", line 44, in : Invalid base class: NonTypedDict [base-class-error] -File "typeddicts_inheritance.py", line 54, in : Invalid base class: X1 [base-class-error] -File "typeddicts_inheritance.py", line 65, in : Invalid base class: Y2 [base-class-error] -""" -conformance_automated = "Pass" -errors_diff = """ -""" diff --git a/conformance/results/pytype/typeddicts_operations.toml b/conformance/results/pytype/typeddicts_operations.toml deleted file mode 100644 index 8ed3fcdc5..000000000 --- a/conformance/results/pytype/typeddicts_operations.toml +++ /dev/null @@ -1,25 +0,0 @@ -conformant = "Partial" -notes = """ -Does not report type violation with TypedDict value assignment. -Does not report reference to unknown key in TypedDict. -Does not reject `clear` method on TypedDict with required keys. -Does not reject delete operation for required key in TypedDict. -""" -output = """ -File "typeddicts_operations.py", line 28, in : Type annotation for movie does not match type of assignment [annotation-type-mismatch] -File "typeddicts_operations.py", line 29, in : Type annotation for movie does not match type of assignment [annotation-type-mismatch] -File "typeddicts_operations.py", line 32, in : Type annotation for movie does not match type of assignment [annotation-type-mismatch] -File "typeddicts_operations.py", line 37, in func1: Type annotation for movie does not match type of assignment [annotation-type-mismatch] -File "typeddicts_operations.py", line 60, in : str [assert-type] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 22: Expected 1 errors -Line 23: Expected 1 errors -Line 24: Expected 1 errors -Line 26: Expected 1 errors -Line 47: Expected 1 errors -Line 49: Expected 1 errors -Line 62: Expected 1 errors -Line 60: Unexpected errors ['File "typeddicts_operations.py", line 60, in : str [assert-type]'] -""" diff --git a/conformance/results/pytype/typeddicts_readonly.toml b/conformance/results/pytype/typeddicts_readonly.toml deleted file mode 100644 index 6dc215d71..000000000 --- a/conformance/results/pytype/typeddicts_readonly.toml +++ /dev/null @@ -1,14 +0,0 @@ -conformant = "Unsupported" -output = """ -File "typeddicts_readonly.py", line 8, in : typing_extensions.ReadOnly not supported yet [not-supported-yet] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 24: Expected 1 errors -Line 36: Expected 1 errors -Line 50: Expected 1 errors -Line 51: Expected 1 errors -Line 60: Expected 1 errors -Line 61: Expected 1 errors -Line 8: Unexpected errors ['File "typeddicts_readonly.py", line 8, in : typing_extensions.ReadOnly not supported yet [not-supported-yet]'] -""" diff --git a/conformance/results/pytype/typeddicts_readonly_consistency.toml b/conformance/results/pytype/typeddicts_readonly_consistency.toml deleted file mode 100644 index 6d3b171ff..000000000 --- a/conformance/results/pytype/typeddicts_readonly_consistency.toml +++ /dev/null @@ -1,19 +0,0 @@ -conformant = "Unsupported" -output = """ -File "typeddicts_readonly_consistency.py", line 8, in : typing_extensions.ReadOnly not supported yet [not-supported-yet] -File "typeddicts_readonly_consistency.py", line 34, in func1: Type annotation for v1 does not match type of assignment [annotation-type-mismatch] -File "typeddicts_readonly_consistency.py", line 35, in func1: Type annotation for v2 does not match type of assignment [annotation-type-mismatch] -File "typeddicts_readonly_consistency.py", line 40, in func1: Type annotation for v5 does not match type of assignment [annotation-type-mismatch] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 37: Expected 1 errors -Line 38: Expected 1 errors -Line 81: Expected 1 errors -Line 82: Expected 1 errors -Line 84: Expected 1 errors -Line 85: Expected 1 errors -Line 8: Unexpected errors ['File "typeddicts_readonly_consistency.py", line 8, in : typing_extensions.ReadOnly not supported yet [not-supported-yet]'] -Line 34: Unexpected errors ['File "typeddicts_readonly_consistency.py", line 34, in func1: Type annotation for v1 does not match type of assignment [annotation-type-mismatch]'] -Line 35: Unexpected errors ['File "typeddicts_readonly_consistency.py", line 35, in func1: Type annotation for v2 does not match type of assignment [annotation-type-mismatch]'] -""" diff --git a/conformance/results/pytype/typeddicts_readonly_inheritance.toml b/conformance/results/pytype/typeddicts_readonly_inheritance.toml deleted file mode 100644 index 83fb06ba8..000000000 --- a/conformance/results/pytype/typeddicts_readonly_inheritance.toml +++ /dev/null @@ -1,38 +0,0 @@ -conformant = "Unsupported" -output = """ -File "typeddicts_readonly_inheritance.py", line 8, in : typing_extensions.ReadOnly not supported yet [not-supported-yet] -File "typeddicts_readonly_inheritance.py", line 18, in : Invalid base class: NamedDict [base-class-error] -File "typeddicts_readonly_inheritance.py", line 47, in : Invalid base class: AlbumCollection [base-class-error] -File "typeddicts_readonly_inheritance.py", line 47, in : Invalid base class: AlbumCollection [base-class-error] -File "typeddicts_readonly_inheritance.py", line 61, in : Invalid base class: OptionalName [base-class-error] -File "typeddicts_readonly_inheritance.py", line 65, in : Type annotation for d does not match type of assignment [annotation-type-mismatch] -File "typeddicts_readonly_inheritance.py", line 75, in : Invalid base class: OptionalIdent [base-class-error] -File "typeddicts_readonly_inheritance.py", line 83, in : Type annotation for u does not match type of assignment [annotation-type-mismatch] -File "typeddicts_readonly_inheritance.py", line 84, in : Type annotation for u does not match type of assignment [annotation-type-mismatch] -File "typeddicts_readonly_inheritance.py", line 93, in : Invalid base class: F1 [base-class-error] -File "typeddicts_readonly_inheritance.py", line 97, in : Invalid base class: F1 [base-class-error] -File "typeddicts_readonly_inheritance.py", line 101, in : Invalid base class: F1 [base-class-error] -File "typeddicts_readonly_inheritance.py", line 105, in : Invalid base class: F1 [base-class-error] -File "typeddicts_readonly_inheritance.py", line 119, in : Invalid base class: TD_A2 [base-class-error] -File "typeddicts_readonly_inheritance.py", line 119, in : Invalid base class: TD_A2 [base-class-error] -File "typeddicts_readonly_inheritance.py", line 132, in : Invalid base class: TD_B2 [base-class-error] -File "typeddicts_readonly_inheritance.py", line 132, in : Invalid base class: TD_B2 [base-class-error] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 36: Expected 1 errors -Line 50: Expected 1 errors -Line 82: Expected 1 errors -Line 94: Expected 1 errors -Line 98: Expected 1 errors -Line 106: Expected 1 errors -Line 8: Unexpected errors ['File "typeddicts_readonly_inheritance.py", line 8, in : typing_extensions.ReadOnly not supported yet [not-supported-yet]'] -Line 18: Unexpected errors ['File "typeddicts_readonly_inheritance.py", line 18, in : Invalid base class: NamedDict [base-class-error]'] -Line 47: Unexpected errors ['File "typeddicts_readonly_inheritance.py", line 47, in : Invalid base class: AlbumCollection [base-class-error]', 'File "typeddicts_readonly_inheritance.py", line 47, in : Invalid base class: AlbumCollection [base-class-error]'] -Line 61: Unexpected errors ['File "typeddicts_readonly_inheritance.py", line 61, in : Invalid base class: OptionalName [base-class-error]'] -Line 75: Unexpected errors ['File "typeddicts_readonly_inheritance.py", line 75, in : Invalid base class: OptionalIdent [base-class-error]'] -Line 93: Unexpected errors ['File "typeddicts_readonly_inheritance.py", line 93, in : Invalid base class: F1 [base-class-error]'] -Line 97: Unexpected errors ['File "typeddicts_readonly_inheritance.py", line 97, in : Invalid base class: F1 [base-class-error]'] -Line 101: Unexpected errors ['File "typeddicts_readonly_inheritance.py", line 101, in : Invalid base class: F1 [base-class-error]'] -Line 105: Unexpected errors ['File "typeddicts_readonly_inheritance.py", line 105, in : Invalid base class: F1 [base-class-error]'] -""" diff --git a/conformance/results/pytype/typeddicts_readonly_kwargs.toml b/conformance/results/pytype/typeddicts_readonly_kwargs.toml deleted file mode 100644 index 891f4fb7b..000000000 --- a/conformance/results/pytype/typeddicts_readonly_kwargs.toml +++ /dev/null @@ -1,11 +0,0 @@ -conformant = "Unsupported" -output = """ -File "typeddicts_readonly_kwargs.py", line 8, in : typing.Unpack not supported yet [not-supported-yet] -File "typeddicts_readonly_kwargs.py", line 9, in : typing_extensions.ReadOnly not supported yet [not-supported-yet] -File "typeddicts_readonly_kwargs.py", line 33, in impl: New container type for kwargs does not match type annotation [container-type-mismatch] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 8: Unexpected errors ['File "typeddicts_readonly_kwargs.py", line 8, in : typing.Unpack not supported yet [not-supported-yet]'] -Line 9: Unexpected errors ['File "typeddicts_readonly_kwargs.py", line 9, in : typing_extensions.ReadOnly not supported yet [not-supported-yet]'] -""" diff --git a/conformance/results/pytype/typeddicts_readonly_update.toml b/conformance/results/pytype/typeddicts_readonly_update.toml deleted file mode 100644 index 0ffc04761..000000000 --- a/conformance/results/pytype/typeddicts_readonly_update.toml +++ /dev/null @@ -1,9 +0,0 @@ -conformant = "Unsupported" -output = """ -File "typeddicts_readonly_update.py", line 9, in : typing_extensions.ReadOnly not supported yet [not-supported-yet] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 23: Expected 1 errors -Line 9: Unexpected errors ['File "typeddicts_readonly_update.py", line 9, in : typing_extensions.ReadOnly not supported yet [not-supported-yet]'] -""" diff --git a/conformance/results/pytype/typeddicts_required.toml b/conformance/results/pytype/typeddicts_required.toml deleted file mode 100644 index 117006670..000000000 --- a/conformance/results/pytype/typeddicts_required.toml +++ /dev/null @@ -1,16 +0,0 @@ -conformant = "Partial" -notes = """ -Does not reject use of `Required` in non-TypedDict class. -Does not reject use of `Required` in function parameter annotation. -Does not reject nested use of `Required` in type annotation. -""" -output = """ -RecursionError: maximum recursion depth exceeded -""" -conformance_automated = "Fail" -errors_diff = """ -Line 12: Expected 1 errors -Line 16: Expected 1 errors -Line 59: Expected 1 errors -Line 60: Expected 1 errors -""" diff --git a/conformance/results/pytype/typeddicts_type_consistency.toml b/conformance/results/pytype/typeddicts_type_consistency.toml deleted file mode 100644 index 24d50b716..000000000 --- a/conformance/results/pytype/typeddicts_type_consistency.toml +++ /dev/null @@ -1,22 +0,0 @@ -conformant = "Partial" -notes = """ -Does not report some type violations for TypedDict type compatibility. -Incorrectly reports type violation in cases where there is none. -Does not report type incompatibility between TypedDict and `dict[str, Any]`. -""" -output = """ -File "typeddicts_type_consistency.py", line 62, in : Type annotation for a3 does not match type of assignment [annotation-type-mismatch] -File "typeddicts_type_consistency.py", line 65, in : Type annotation for b3 does not match type of assignment [annotation-type-mismatch] -File "typeddicts_type_consistency.py", line 69, in : Type annotation for a3_1 does not match type of assignment [annotation-type-mismatch] -File "typeddicts_type_consistency.py", line 126, in : Type annotation for o2 does not match type of assignment [annotation-type-mismatch] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 21: Expected 1 errors -Line 38: Expected 1 errors -Line 76: Expected 1 errors -Line 77: Expected 1 errors -Line 78: Expected 1 errors -Line 82: Expected 1 errors -Line 62: Unexpected errors ['File "typeddicts_type_consistency.py", line 62, in : Type annotation for a3 does not match type of assignment [annotation-type-mismatch]'] -""" diff --git a/conformance/results/pytype/typeddicts_usage.toml b/conformance/results/pytype/typeddicts_usage.toml deleted file mode 100644 index 746ab3414..000000000 --- a/conformance/results/pytype/typeddicts_usage.toml +++ /dev/null @@ -1,15 +0,0 @@ -conformant = "Partial" -notes = """ -Does not report errant use of TypedDict in `isinstance` call. -Does not reject use of TypedDict as TypeVar bound. -""" -output = """ -File "typeddicts_usage.py", line 23, in : TypedDict Movie does not contain key director [typed-dict-error] -File "typeddicts_usage.py", line 24, in : Type annotation for key year in TypedDict Movie does not match type of assignment [annotation-type-mismatch] -File "typeddicts_usage.py", line 28, in : Type annotation for movie2 does not match type of assignment [annotation-type-mismatch] -""" -conformance_automated = "Fail" -errors_diff = """ -Line 35: Expected 1 errors -Line 40: Expected 1 errors -""" diff --git a/conformance/results/pytype/version.toml b/conformance/results/pytype/version.toml deleted file mode 100644 index 68b8ac608..000000000 --- a/conformance/results/pytype/version.toml +++ /dev/null @@ -1,2 +0,0 @@ -version = "pytype 2024.04.11" -test_duration = 30.1 diff --git a/conformance/results/results.html b/conformance/results/results.html index 9693b2e83..94a105325 100644 --- a/conformance/results/results.html +++ b/conformance/results/results.html @@ -1,999 +1,2555 @@ - + + + + + + + Python Type System Conformance Test Results + - - - -
+ --conformant: rgb(203, 255, 203); + --partially-conformant: rgb(251, 244, 166); + --not-conformant: rgb(242, 171, 171); + + color-scheme: light dark; + &:has(#color-scheme option[value="light"]:checked) { + color-scheme: light; + } + &:has(#color-scheme option[value="dark"]:checked) { + color-scheme: dark; + } + } + + * { + box-sizing: border-box; + } + + ::selection { + background: light-dark(var(--light-selection-bg), var(--dark-selection-bg)); + color: light-dark(var(--dark-main-fg), var(--light-main-fg)); + } + + html { + background: light-dark(var(--light-main-bg), var(--dark-main-bg)); + color: light-dark(var(--light-main-fg), var(--dark-main-fg)); + font-family: "system-ui", "Segoe UI", Helvetica, Arial, sans-serif; + font-size: 0.85rem; + } + + body { + margin: 0; + padding: 0; + } + + header { + background-color: #2b5b84; + box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.03), inset 0 0 20px rgba(0, 0, 0, 0.03); + color: #fff; + padding: 1em; + text-align: center; + } + + main { + padding: 2em; + } + + a { + text-underline-offset: 2px; + } + + code { + background: light-dark(#eee, #666); + border: 1px solid light-dark(#ddd, #888); + border-radius: 3px; + padding: 0 2px; + } + + table { + border-collapse: collapse; + inline-size: 100%; + margin: 0; + padding: 0; + } + + th, + td { + border-color: transparent; + border-style: solid; + border-width: 0 10px; + margin: 0; + padding: 3px; + position: relative; + text-align: start; + + &:not(:first-child) { + text-align: center; + } + } + + thead { + background: light-dark(var(--light-main-bg), var(--dark-main-bg)); + inset-block-start: 0; + position: sticky; + z-index: 3; + & > tr > th { + padding-block: 1em; + } + } + + tbody > tr > th:not([colspan]) { + font-weight: normal; + padding-inline-start: 2em; + } + + tbody > tr.summary { + color: light-dark(var(--light-muted-fg), var(--dark-muted-fg)); + } + + tfoot td { + font-weight: bold; + padding-block-start: 1em; + } + + .col1 { + inline-size: 30%; + } + + .col2 { + inline-size: calc(70% / 6); + } + + .conformant { + background-color: var(--conformant); + color: var(--light-main-fg); + } + + .partially-conformant { + background-color: var(--partially-conformant); + color: var(--light-main-fg); + } + + .not-conformant { + background-color: var(--not-conformant); + color: var(--light-main-fg); + } + + tbody > tr:hover { + th:not([colspan]) { + background-color: light-dark(#eee, #444); + border-color: light-dark(#eee, #444); + } + th:not([colspan]) ~ td { + border-color: light-dark(#eee, #444); + } + .conformant { + background-color: hsl(from var(--conformant) h s calc(l - 5)); + } + .partially-conformant { + background-color: hsl(from var(--partially-conformant) h s calc(l - 5)); + } + .not-conformant { + background-color: hsl(from var(--not-conformant) h s calc(l - 5)); + } + } + + .tooltip { + cursor: help; + + /* Add an asterisk if there are notes to display for a "Pass". */ + &.conformant::after { + content: "*"; + position: absolute; + } + + .notes { + background-color: light-dark(var(--light-main-bg), var(--dark-main-bg)); + border-radius: 5px; + box-shadow: 0 0 3px light-dark(var(--light-shadow), var(--dark-shadow)); + color: light-dark(var(--light-main-fg), var(--dark-main-fg)); + cursor: default; + font-size: .8em; + inset-block-start: calc(50% - 5px); + inset-inline-end: 50%; + line-height: 1.6; + list-style-position: inside; + min-inline-size: 500px; + padding: 10px 15px; + position: absolute; + text-align: start; + visibility: hidden; + z-index: 2; + & > li { + padding: 3px 0; + text-indent: 1.3em hanging; + } + } + + &:hover .notes { + visibility: visible; + } + } + + .disclaimer { + color: var(--dark-muted-fg); + font-size: 0.9rem; + font-weight: normal; + line-height: 1.4; + margin: 1rem auto; + max-inline-size: 720px; + } + + form:has(#color-scheme) { + background: inherit; + inset-block-start: 1rem; + inset-inline-end: 1rem; + position: absolute; + } + + #color-scheme { + appearance: none; + background: inherit; + border-color: var(--dark-muted-fg); + border-radius: 5px; + border-style: solid; + border-width: 1px; + color: inherit; + padding: 0.5rem; + &:focus { + border-color: inherit; + outline: none; + } + &:hover { + border-color: inherit; + } + } + + + + +
-

Python Type System Conformance Test Results

+

Python Type System Conformance Test Results

+

+ While specification conformance is important for the ecosystem, we don't recommend + using it as the primary basis for choosing a type checker. It is not representative + of many of the things users typically care about. +

+
+ + +
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
mypy 1.10.0
-
1.4sec
-
pyright 1.1.364
-
1.4sec
-
pyre 0.9.21
-
3.4sec
-
pytype 2024.04.11
-
30.1sec
-
-Type annotations -
     annotations_coroutinesPassPassPass
Partial

Does not evaluate correct type for async function.

     annotations_forward_refs
Partial

Does not report error for a forward reference that is not enclosed in quotes.

Does not report error for use of quoted type with "|" operator (runtime error).

Incorrectly generates error for quoted type defined in class scope.

Pass
Partial

Does not report error for a forward reference that is not enclosed in quotes.

Does not report error for use of quoted type with "|" operator (runtime error).

Does not reject f-string in quoted type annotation.

Incorrectly generates error for quoted type defined in class scope.

Does not generate error for unquoted type defined in class scope.

Does not treat triple-quoted forward reference annotation as implicitly parenthesized.

Partial

Does not reject some illegal type expression forms when quoted.

Incorrectly generates error for quoted type defined in class scope.

Evaluates incorrect type for class variable annotated with quoted type expression.

Does not treat triple-quoted forward reference annotation as implicitly parenthesized.

     annotations_generators
Partial

Does not report incompatible Generator type in `yield from` statement.

Pass
Partial

Does not report invalid return type for generator when function implicitly returns None.

Incorrectly evaluates type of call to async generator.

Partial

Does not report invalid return type for generator when function implicitly returns None.

Reports invalid error when return type of generator is annotated as a compatible protocol.

Does not report type violation in `yield from` statement.

     annotations_methods
Pass*

Type evaluation differs from other type checkers because of ambiguity in the spec related to method bindings.

Pass*

Type evaluation differs from other type checkers because of ambiguity in the spec related to method bindings.

Pass*

Type evaluation differs from other type checkers because of ambiguity in the spec related to method bindings.

Pass*

Type evaluation differs from other type checkers because of ambiguity in the spec related to method bindings.

     annotations_typeexprPassPassPass
Partial

Does not reject call expressions in type annotation.

Does not reject call lambda expression in type annotation.

Does not reject list expression in type annotation.

Does not reject ternary expression in type annotation.

Does not reject f-string in type annotation.

Does not reject module in type annotation.

-Special types in annotations -
     specialtypes_anyPassPass
Partial

Does not support Any as a base class.

Pass
     specialtypes_neverPassPass
Partial

Does not treat Never as compatible with all other types.

Unsupported

Does not understand NoReturn or Never.

     specialtypes_nonePassPassPass
Partial

Does not detect type incompatibility between None and type[None].

Does not detect type incompatibility between None and incompatible protocol.

     specialtypes_promotionsPassPass
Partial

Does not reject use of attribute that is compatible only with float.

Pass
     specialtypes_type
Partial

Does not treat `type` same as `type[Any]` for assert_type.

Does not allow access to unknown attributes from object of type `type[Any]`.

Pass
Partial

Does not reject Callable when passed to type[T].

Does not treat `type` same as `type[Any]` for assert_type.

Does not allow access to unknown attributes from object of type `type[Any]`.

Does not reject access to unknown attributes from object of type `Type[object]`.

Reports type incompatibility between `type` and `Callable[..., Any]`.

Partial

Does not reject Callable when passed to type[T].

Does not allow access to known attributes from object of type `type[Any]`.

-Generics -
     generics_base_classPassPass
Partial

Does not reject illegal use of Generic.

Does not allow using generic in assert_type expression.

Partial

False negative on passing SymbolTable to dict[str, list[object]].

Does not reject illegal use of Generic.

     generics_basic
Partial

Does not reject the use of a constraint parameterized by another type variable.

Pass
Partial

False positives in examples using constrained type variables.

False negative for constraint parameterized by a type variable.

False negative in custom map example.

False positive using `iter`.

False negative for generic metaclass.

Partial

False positives in examples using constrained type variables.

False negative for generic metaclass.

     generics_defaultsUnsupportedPass
Unsupported

Does not support generic defaults.

Unsupported
     generics_defaults_referentialUnsupportedPassUnsupportedUnsupported
     generics_defaults_specializationUnsupportedPass
Unsupported

Does not support generic defaults.

Unsupported
     generics_paramspec_basic
Partial

Does not reject ParamSpec when used "bare" in type alias definition.

Pass
Partial

Does not enforce name consistency for ParamSpec assigned to identifier.

Incorrectly reports error for legitimate use of ParamSpec in generic type alias.

Does not reject ParamSpec when used in various invalid locations.

Unsupported

Does not support ParamSpec.

     generics_paramspec_components
Partial

Does not report illegal use of "P.args" on normal parameter.

Does not report error when P.args is specified but P.kwargs is missing.

Does not report error when P is out of scope and P.args and P.kwargs is used.

Does not report error when keyword argument is specified between P.args and P.kwargs.

Does not report error when calling callable and argument is missing for concatenated parameters.

Pass
Partial

Does not report illegal use of "P.args" on normal parameter.

Does not report error when P.args is specified but P.kwargs is missing.

Does not report error when P is out of scope and P.args and P.kwargs is used.

Does not report error when calling callback defined with ParamSpec with incorrect arguments.

Does not report error when keyword argument is specified between P.args and P.kwargs.

Does not report error when calling callable and argument is missing for concatenated parameters.

Unsupported

Does not support ParamSpec.

     generics_paramspec_semanticsPass
Pass*

Constraint solver doesn't find common type for two signatures captured by a single ParamSpec (allowed).

Pass
Unsupported

Does not support ParamSpec.

     generics_paramspec_specializationPassPass
Partial

Reports error for legitimate use of `...` to specialize ParamSpec

Partial

Rejects valid specialization of ParamSpec using list expression.

Does not reject invalid specialization of class with both TypeVar and ParamSpec.

Reports error for valid method call involving ParamSpec.

     generics_scoping
Partial

False negative on generic class nested within generic class with same type variable.

Pass
Partial

False negative on generic class nested within generic function with same type variable.

False negative on generic class nested within generic class with same type variable.

Partial

Fails to reject type alias within generic class that uses class's type variable.

Fails to reject unbound type variable in constructor call in global scope.

     generics_self_advanced
Partial

Does not infer the type of an unannotated `self` parameter to be type `Self`.

Does not retain `Self` when calling method that returns `Self`.

Does not infer the type of an unannotated `cls` parameter to be type `type[Self]`.

Does not retain `Self` when accessing attribute through `type[Self]`.

Pass
Partial

Does not handle use of `Self` within class body correctly.

Unsupported

Does not understand `Self` type.

     generics_self_attributesPassPass
Unsupported

Does not understand `Self` type.

Unsupported

Does not understand `Self` type.

     generics_self_basicPassPass
Partial

Does not handle use of `Self` as a generic type.

Unsupported

Does not understand `Self` type.

     generics_self_protocolsPassPass
Partial

Does not reject protocol compatibility due to method `Self` return type.

Partial

Does not reject protocol compatibility due to method `Self` return type.

     generics_self_usagePassPass
Partial

Complains in some cases when `self: Self` is used explicitly.

Does not complain when `Self` is used on a function outside any class definition.

Does not complain when `self` is annotated explicitly (without `Self`) and `Self` is returned.

Does not complain on inheritance involving `Self`.

Does not complain on use of `Self` in static methods.

Does not complain on use of `Self` in metaclasses.

Unsupported

Does not understand `Self` type.

     generics_syntax_compatibility
Unsupported

Type parameter syntax not yet support.

Pass
Unsupported

Type parameter syntax not yet support.

Unsupported

Type parameter syntax not yet support.

     generics_syntax_declarations
Unsupported

Type parameter syntax not yet support.

Pass
Unsupported

Type parameter syntax not yet support.

Unsupported

Type parameter syntax not yet support.

     generics_syntax_infer_variance
Unsupported

Type parameter syntax not yet support.

Pass
Unsupported

Type parameter syntax not yet support.

Unsupported

Type parameter syntax not yet support.

     generics_syntax_scoping
Unsupported

Type parameter syntax not yet support.

Pass
Unsupported

Type parameter syntax not yet support.

Unsupported

Type parameter syntax not yet support.

     generics_type_erasure
Partial

Infers Node[Never] instead of Node[Any] when argument is not provided.

False negative on instance attribute access on type(node).

Pass
Partial

Does not erase unspecified type variables to `Any` prior to `assert_type` handling.

False negatives on instance attribute access on the type.

Does not infer type of `DefaultDict` with explicit type parameters on constructor.

Unsupported
     generics_typevartuple_args
Partial

Does not enforce that tuples captured by TypeVarTuple are same type.

Pass
Unsupported

Does not support star expressions for `Unpack`.

Unsupported

Does not support TypeVarTuple.

     generics_typevartuple_basic
Partial

Does not enforce that tuples captured by TypeVarTuple are same length.

Does not enforce that tuples captured by TypeVarTuple are same type.

Pass
Unsupported

Does not support TypeVarTuple.

Unsupported

Does not support TypeVarTuple.

     generics_typevartuple_callablePassPass
Unsupported

Does not support TypeVarTuple.

Unsupported

Does not support TypeVarTuple.

     generics_typevartuple_concatPassPass
Unsupported

Does not support TypeVarTuple.

Unsupported

Does not support TypeVarTuple.

     generics_typevartuple_overloadsPassPass
Unsupported

Does not support star expressions for `Unpack`.

Unsupported

Does not support TypeVarTuple.

     generics_typevartuple_specialization
Partial

Incorrectly specializes generic alias that includes a TypeVar and TypeVarTuple if no type arguments are provided.

Rejects specialization of generic type alias defined as a tuple containing a TypeVar.

"More than one Unpack" error message has no line number.

Pass
Unsupported

Does not support star expressions for `Unpack`.

Unsupported

Does not support TypeVarTuple.

     generics_typevartuple_unpackPassPass
Unsupported

Does not support star expressions for `Unpack`.

Unsupported

Does not support TypeVarTuple.

     generics_upper_bound
Partial

Does not reject use of type variable within an upper bound.

Pass
Partial

False positives on valid type expression (`list[T]`) in `bound`.

Does not complain when bound is used alongside type constraints.

Partial

Does not properly support assert_type.

     generics_variance
Partial

Does not reject use of class-scoped TypeVar used in a base class when variance is incompatible.

Pass
Partial

Does not reject a TypeVar that is defined as both covariant and contravariant.

Does not reject use of class-scoped TypeVar used in a base class when variance is incompatible.

Unsupported

Does not support covariant or contravariant TypeVars.

     generics_variance_inference
Unsupported

Type parameter syntax not yet support.

Pass
Unsupported

Type parameter syntax not yet support.

Unsupported

Type parameter syntax not yet support.

-Type qualifiers -
     qualifiers_annotated
Partial

Does not allow ClassVar to be nested within Annotated.

Does not allow Final to be nested within Annotated.

Does not allow Required and NotRequired to be nested within Annotated.

Does not reject type[T] compatibility for type alias defined with Annotated.

Does not reject call of type alias defined with Annotated.

Pass
Partial

Does not reject Annotated with a single parameter.

Does not reject call of Annotated with no type arguments.

Partial

Does not reject some illegal type expression forms used in Annotated.

Does not report type incompatibility between Annotated and type[T].

Does not reject call of Annotated.

Does not allow TypeVar to be used in type alias when wrapped with Annotated.

     qualifiers_final_annotation
Partial

Does not treat use of Final name as if it was replaced by the literal in NamedTuple definition.

Does not allow conditional assignment of Final instance variable in __init__ method.

Does not allow redefinition of private class variable that is marked Final in parent class.

Does not report modification of local Final variable via "for" statement.

Pass
Partial

Does not report Final variable with missing initialization in module scope.

Does not report error for invalid nesting of Final and ClassVar.

Does not treat use of Final name as if it was replaced by the literal in NamedTuple definition.

Partial

Does not report Final variable with missing initialization.

Does not reject Final instance variable declared outside of __init__ method.

Does not reject modification of global variable declared Final.

Does not reject modification of local variable declared Final.

     qualifiers_final_decoratorPassPass
Partial

Reports error for overloaded method implementation marked @final if its overloads do not.

Does not report error for overloaded @final method defined in stub file.

Reports misleading error when overload is marked @final but implementation is not.

Partial

Does not report error for overloaded @final method defined in stub file.

Does not report error for overload that is marked @final when implementation is not.

-Class type compatibility -
     classes_classvar
Partial

Internal error if TypeVarTuple is used in ClassVar.

Does not reject use of ParamSpec in ClassVar.

Rejects ClassVar nested in Annotated.

Does not reject use of ClassVar in TypeAlias definition.

Does not infer type of ClassVar from assignment if no type is provided.

Pass
Partial

Does not reject use of TypeVar in ClassVar.

Does not reject use of ParamSpec in ClassVar.

Does not reject use of ClassVar as a generic type argument.

Does not reject use of ClassVar in parameter type annotation.

Does not reject use of ClassVar in local variable annotation.

Does not reject use of ClassVar in instance variable annotation.

Does not reject use of ClassVar in return type annotation.

Does not reject use of ClassVar in type alias definition.

Does not infer type from initialization for bare ClassVar.

Partial

Does not reject use of TypeVar in ClassVar.

Does not reject use of ParamSpec in ClassVar.

Does not reject use of ClassVar as a generic type argument.

Rejects initialization of ClassVar if no type argument is provided.

Does not reject use of ClassVar in parameter type annotation.

Does not reject use of ClassVar in local variable annotation.

Does not reject use of ClassVar in instance variable annotation.

Does not reject use of ClassVar in return type annotation.

Does not reject use of ClassVar in type alias definition.

Does not reject assignment of ClassVar through instance of class.

     classes_override
Partial

Does not handle case where parent class derives from Any.

Pass
Partial

Does not allow Any as a base class, leading to false positives.

Unsupported

Does not yet support the @override decorator.

-Type aliases -
     aliases_explicit
Partial

Does not reject specialization of type alias that has already been implicitly specialized.

Pass
Partial

Incorrectly reports error for type alias defined with ParamSpec.

Incorrectly rejects some valid type aliases when used in annotations.

Incorrectly evaluates generic type alias with ParamSpec with missing type argument.

Does not report some illegal annotation forms as invalid type aliases.

Does not report invalid specialization of generic type aliases.

Incorrectly rejects import alias of `TypeAlias` when used to define type alias.

Does not report invalid specialization of already-specialized generic type alias.

Partial

Incorrectly reports error for type alias defined with ParamSpec.

Does not report invalid specialization of generic type alias with bound TypeVar.

Incorrectly evaluates generic type alias with ParamSpec with missing type argument.

Does not report some illegal annotation forms as invalid type aliases.

Does not report invalid specialization of already-specialized generic type alias.

     aliases_implicitPassPass
Partial

Incorrectly reports error for type alias defined with ParamSpec.

Incorrectly rejects some valid type aliases when used in annotations.

Incorrectly evaluates generic type alias with ParamSpec with missing type argument.

Does not report invalid specialization of generic type aliases.

Does not report error for attempt to instantiate union type alias.

Does not report invalid specialization of already-specialized generic type alias.

Partial

Incorrectly reports error for type alias defined with ParamSpec.

Does not report invalid specialization of generic type alias with bound TypeVar.

Incorrectly evaluates generic type alias with ParamSpec with missing type argument.

Allows some illegal annotation forms to be interpreted as valid type aliases.

Does not report invalid specialization of already-specialized generic type alias.

     aliases_newtypePassPass
Partial

Does not reject use of NewType in `isinstance` call.

Does not reject use of NewType in class definition statement.

Does not report inconsistency between name of NewType and assigned identifier name.

Does not reject use of NewType with generic class with TypeVar.

Does not reject use of NewType with protocol class.

Does not reject use of NewType with TypedDict class.

Does not reject use of NewType with Any.

Partial

Does not reject use of NewType in `isinstance` call.

Does not reject use of NewType in class definition statement.

Does not report inconsistency between name of NewType and assigned identifier name.

Does not reject use of NewType with generic class with TypeVar.

Does not reject use of NewType with protocol class.

Does not reject use of NewType with TypedDict class.

Does not reject use of NewType with Any.

     aliases_recursivePassPass
Partial

Does not properly handle some recursive type aliases.

Does not properly handle specialization of generic recursive type aliases.

Partial

Does not detect type violation for some deeply-nested types.

Does not properly handle `|` for unions in some recursive type alias definitions.

Does not detect cyclical references in recursive type alias definition.

     aliases_type_statement
Unsupported

Does not support `type` statement.

Pass
Unsupported

Does not support `type` statement.

Unsupported

Does not support `type` statement.

     aliases_typealiastype
Partial

Incorrectly rejects some recursive type aliases using TypeAliasType.

Incorrectly rejects the use of a class-scoped TypeVar in a TypeAliasType definition.

Generates error when accessing `__value__` attribute of TypeAliasType.

Pass
Unsupported

Support for TypeAliasType is not implemented.

Unsupported

Support for TypeAliasType is not implemented.

     aliases_variancePassPassPass
Unsupported

Does not detect variance incompatibility.

-Literals -
     literals_interactions
Partial

Does not narrow type of `x` with `x in Literal` type guard pattern.

Pass
Partial

Does not detect out-of-bound tuple literal index.

Does not perform exhaustiveness checks on enums.

Does not narrow type of `x` with `x in Literal` type guard pattern.

Does not narrow type of `x` with `x == Literal` type guard pattern.

Partial

Incorrectly rejects some legal Literal annotations.

Does not reject some illegal Literal annotations.

Does not use Literal to distinguish overloads.

Does not narrow based on `x is Literal` type guard pattern.

Does not narrow based on `x == Literal` type guard pattern.

     literals_literalstring
Unsupported

Support for `LiteralString` is not implemented.

Pass
Partial

Incorrectly infers `str` rather than `LiteralString` when literal string `join` is used.

Unsupported

Does not understand `LiteralString` special form.

     literals_parameterizations
Partial

Does not reject tuple within Literal.

Pass
Partial

Does not support type aliases in Literal type expression.

Does not support nested Literal type expression.

Does not reject tuple in Literal type expression.

Does not reject "bare" Literal in type expression.

Unsupported

Does not understand `Literal` type annotation.

     literals_semanticsPassPass
Partial

Does not reject augmented operation that modifies literal value.

Unsupported

Does not understand `Literal` type annotation.

-Protocols -
     protocols_class_objectsPassPass
Partial

Does not reject protocol class assigned to type[Proto].

Incorrectly reports some class objects as incompatible with a protocol.

Fails to report some class objects as incompatible with a protocol.

Partial

Does not reject protocol class assigned to type[Proto].

Incorrectly reports some class objects as incompatible with a protocol.

Fails to report some class objects as incompatible with a protocol.

     protocols_definition
Partial

Does not detect protocol mismatch if concrete method is missing annotations.

Does not detect protocol mismatch if concrete method's parameters are position-only.

Pass
Partial

Does not reject ClassVar in concrete class when attribute in protocol is not ClassVar or vice versa.

Does not reject read-only property in concrete class when attribute in protocol is mutable.

Does not reject covariant attribute type when protocol attribute is mutable.

Does not reject read-only property in concrete class when protocol has settable property.

Does not reject immutable named tuple attribute in concrete class when protocol attribute is mutable.

Does not reject immutable frozen dataclass attribute in concrete class when protocol attribute is mutable.

Partial

Reports errors for protocol static method with "..." implementation.

Does not report error when instance variable is set through "self" access in protocol class.

Does not report protocol mismatch when concrete class has attribute with covariant type and protocol attribute is mutable.

Does not reject ClassVar in concrete class when attribute in protocol is not ClassVar.

Does not reject read-only property in concrete class when attribute in protocol is mutable.

Does not reject covariant attribute type when protocol attribute is mutable.

Does not detect protocol mismatch if concrete method is missing annotations.

Does not detect protocol mismatch if concrete method's parameters are keyword-only.

Does not detect protocol mismatch if concrete method's parameters are position-only.

Does not detect protocol mismatch if concrete method is a classmethod.

Does not detect protocol mismatch if concrete method is a staticmethod.

Does not reject read-only property in concrete class when protocol has settable property.

Does not reject immutable named tuple attribute in concrete class when protocol attribute is mutable.

Does not reject immutable frozen dataclass attribute in concrete class when protocol attribute is mutable.

     protocols_explicit
Pass*

Does not report unimplemented attributes for class that explicitly derives from protocol until it is instantiated.

Pass
Partial

Does not report error when calling unimplemented protocol method from derived class.

Does not report error when method is not implemented in derived class.

Partial

Reports errors for protocol static method with "..." implementation.

Does not report error when calling unimplemented protocol method from derived class.

Does not report type incompatibility when assigning to attribute defined in protocol.

Does not reject instantiation of class that derives from protocol but doesn't implement attribute.

Does not report instantiation of class that derives from protocol but doesn't implement method.

     protocols_generic
Partial

Fails protocol matching when method-scoped TypeVar is used in protocol.

Pass
Partial

Does not reject the use of Protocol and Generic together as base classes.

Does not detect protocol mismatch when method-scoped TypeVar is used in protocol.

Partial

Does not correctly enforce contravariance in protocol type compatibility tests.

Does not correctly enforce invariance in protocol type compatibility tests.

Does not detect protocol mismatch when method-scoped TypeVar is used in protocol.

     protocols_mergingPassPass
Partial

Does not reject a protocol class that derives from a non-protocol class.

Partial

Does not reject a protocol class that derives from a non-protocol class.

Does not report attempt to instantiate abstract class downgraded from protocol class.

     protocols_modulesPassPass
Unsupported

Does not perform protocol checks for modules.

Partial

Does not report incompatibilities for protocol methods.

     protocols_recursivePassPassPass
Partial

Incorrectly reports type error for some recursive protocols.

     protocols_runtime_checkable
Partial

Does not report unsafe overlap for runtime_checkable protocol.

Pass
Unsupported

Does not reject isinstance or issubclass call for protocol that is not runtime_checkable.

Does not reject issubclass call for data protocol.

Does not report unsafe overlap for runtime_checkable protocol.

Unsupported

Does not reject isinstance or issubclass call for protocol that is not runtime_checkable.

Does not reject issubclass call for data protocol.

Does not report unsafe overlap for runtime_checkable protocol.

     protocols_selfPassPassPass
Partial

Does not properly handle Self type within a protocol.

     protocols_subtypingPassPassPass
Partial

Does not reject attempt to instantiate protocol class.

Does not report some protocol type compatibility violations involving contravariance.

     protocols_variancePassPass
Unsupported

Does not detect incorrect TypeVar variance within generic protocols.

Unsupported

Does not detect incorrect TypeVar variance within generic protocols.

-Callables -
     callables_annotation
Partial

Incorrectly treats "*args: T, **kwargs: T" as "..." when T is specialized to Any.

Does not treat "*args: Any, **kargs: Any" as "..." when separated by keyword parameter.

Pass
Partial

Does not evaluate correct type for `*args: int` parameter.

Does not reject illegal form `Callable[[...], int]`.

Does not correctly implement type compatibility rules for "...".

Does not treat "*args: Any, **kwargs: Any" as "...".

Partial

Does not support Concatenate.

Does not treat "*args: Any, **kwargs: Any" as "...".

     callables_kwargsPassPass
Unsupported

Does not understand Unpack in the context of **kwargs annotation.

Unsupported

Does not understand Unpack in the context of **kwargs annotation.

     callables_protocolPassPass
Partial

Does not correctly handle callback protocol that declares attributes in all functions.

Does not report type incompatibility for callback protocol with positional-only parameters.

Incorrectly reports type compatibility error with callback that has *args and **kwargs.

Does not report type incompatibility for callback missing a default argument for positional parameter.

Does not report type incompatibility for callback missing a default argument for keyword parameter.

Unsupported

Does not properly handle type compatibility checks with callback protocols.

     callables_subtypingPassPass
Partial

Rejects standard parameter as incompatible with keyword-only parameter.

Rejects use of Callable with ParamSpec in TypeAlias definition.

Partial

Does not detect many subtyping rule violations for callables.

Does not correctly handle type alias parameterized by ParamSpec.

-Constructors -
     constructors_call_init
Partial

Does not report errors during binding to self parameter of __init__ method.

Does not support function-scoped TypeVars in self annotation in __init__ method.

Does not reject use of class-scoped type variables in annotation of self parameter in __init__ method.

Pass
Partial

Does not infer type of Self for self parameter of __init__ method.

Does not report errors during binding to self parameter of __init__ method.

Does not reject use of class-scoped type variables in annotation of self parameter in __init__ method.

Partial

Does not report errors during binding to self parameter of __init__ method.

Does not infer type of Self for self parameter of __init__ method.

Rejects valid type annotation for self parameter in __init__ method.

Does not support function-scoped TypeVars in self annotation in __init__ method.

Does not reject use of class-scoped type variables in annotation of self parameter in __init__ method.

     constructors_call_metaclass
Unupported

Does not honor metaclass __call__ method when evaluating constructor call.

Does not skip evaluation of __new__ and __init__ if custom metaclass call returns non-class.

Pass
Partial

Does not evaluate __new__ if metaclass __call__ is defined.

Unupported

Does not honor metaclass __call__ method when evaluating constructor call.

     constructors_call_new
Partial

Does not support __new__ return type that is not a subclass of the class being constructed.

Does not skip evaluation of __init__ based on __new__ return type.

Does not report errors during binding to cls parameter of __new__ method.

Pass
Partial

Does not support __new__ return type that is not a subclass of the class being constructed.

Does not report errors during binding to cls parameter of __new__ method.

Partial

Does not honor explicit specialization of generic class when used in constructor call.

Does not support __new__ return type that is not a subclass of the class being constructed.

Does not skip evaluation of __init__ based on __new__ return type.

     constructors_call_type
Partial

Does not validate call to custom metaclass __call__ method through type[T].

PassPass
Partial

Does not validate call to custom metaclass __call__ method through type[T].

     constructors_callable
Partial

Does not generate a union type for __new__ and __init__ when converting class to callable.

Does not ignore __init__ based on __new__ return type when converting class to callable.

Does not support __new__ return type that is different from class being constructed.

Pass
Partial

Does not generate a union type for __new__ and __init__ when converting class to callable.

Does not ignore __init__ based on __new__ return type when converting class to callable.

Does not support __new__ return type that is different from class being constructed.

Does not use annotated type of self in __init__ method to generate return type of callable.

Partial

Does not generate a union type for __new__ and __init__ when converting class to callable.

Does not ignore __init__ based on __new__ return type when converting class to callable.

Does not support __new__ return type that is different from class being constructed.

Does not use annotated type of self in __init__ method to generate return type of callable.

     constructors_consistency
Pass*

Does not report inconsistency between __new__ and __init__ (optional).

Pass
Pass*

Does not report inconsistency between __new__ and __init__ (optional).

Pass*

Does not report inconsistency between __new__ and __init__ (optional).

-Overloads -
     overloads_basicPassPass
Partial

Does not reject a function with a single @overload signature.

Partial

Does not reject a function with a single @overload signature.

Does not reject a function with @overload signature but no implementation.

-Exceptions -
     exceptions_context_managersPassPass
Unsupported

Does not understand context manager exception rules.

Unsupported

Does not support code flow analysis.

-Dataclasses -
     dataclasses_descriptors
Partial

Does not correctly evaluate type of descriptor access.

Pass
Partial

Incorrectly generates error when calling constructor of dataclass with descriptor.

Unsupported

Does not understand descriptor objects in dataclass.

     dataclasses_final
Partial

Wrongly requires a Final dataclass field to be initialized at class level.

Doesn't support Final nested inside ClassVar.

Pass
Partial

Mis-handles Final nested inside ClassVar.

Partial

Doesn't handle Final nested inside ClassVar.

     dataclasses_frozenPassPass
Partial

Does not reject frozen dataclass inherited from non-frozen dataclass.

Does not reject non-frozen dataclass inherited from frozen dataclass.

Unsupported

Does not report assignment to field within frozen dataclass instance.

Does not reject frozen dataclass inherited from non-frozen dataclass.

Does not reject non-frozen dataclass inherited from frozen dataclass.

     dataclasses_hash
Partial

Does not report when dataclass is not compatible with Hashable protocol.

Pass
Partial

Does not report when dataclass is not compatible with Hashable protocol.

Partial

Does not report when dataclass is not compatible with Hashable protocol.

     dataclasses_inheritancePassPass
Partial

Does not reject ClassVar that is overridden by instance variable.

Does not reject instance variable that is overridden by ClassVar.

Partial

Does not reject ClassVar that is overridden by instance variable.

Does not reject instance variable that is overridden by ClassVar.

     dataclasses_kwonly
Partial

Incorrectly rejects kw_only field with default before positional field.

PassPass
Partial

Incorrectly reports error when kw_only field has default value.

Incorrectly rejects kw_only field with default before positional field.

     dataclasses_orderPassPassPass
Partial

Does not report type incompatibility with comparison operator.

     dataclasses_postinitPassPass
Partial

Does not perform validation of `__post_init__` method.

Incorrectly complains on the assignment of `InitVar` in class bodies.

Partial

Does not validate `__post_init__` method.

Reports incorrect error for incompatible `__post_init__` method override.

     dataclasses_slots
Partial

Does not reject write to instance variable that is not defined in __slots__.

Pass
Partial

Does not report error when `slots=True` is used with `__slots__` definition.

Does not reject write to instance variable that is not defined in __slots__.

Does not reject access to `__slots__` from dataclass instance when `slots=False`.

Partial

Does not report error when `slots=True` is used with `__slots__` definition.

Does not reject write to instance variable that is not defined in __slots__.

Incorrectly reports error when accessing `__slots__` when `slots=True`.

     dataclasses_transform_classPassPass
Partial

Does not validate when a non-frozen model derives from a frozen one.

Does not support field specifiers.

Unsupported

Does not understand @dataclass_transform.

     dataclasses_transform_field
Partial

Does not properly handle field constructor that has default value for `kw_only` or `init` parameter.

Pass
Unsupported

Does not understand dataclass transform field specifiers.

Unsupported

Does not understand @dataclass_transform.

     dataclasses_transform_func
Partial

Does not handle `kw_only=False` override when `kw_only_default=True`.

Does not report error when `order=False` and comparison operators are used.

Pass
Partial

Does not understand @dataclass_transform when it is

applied only to overloads of a decorator but not the

definition.

Unsupported

Does not understand @dataclass_transform.

     dataclasses_transform_metaPassPass
Partial

Does not understand custom field specifiers.

Unsupported

Does not understand @dataclass_transform.

     dataclasses_usage
Pass*

Does not detect unannotated usage of `dataclasses.field()`.

Pass
Partial

Does not report error when field with no default follows field with default.

Incorrectly reports error with InitVar that has default value.

Complains on `assert_type` when used for bound methods vs `Callable`.

Does not understand `__dataclass_fields__`.

Pass
-Typed dictionaries -
     typeddicts_alt_syntax
Pass*

Does not support keyword-argument form of alternative syntax (deprecated in 3.11).

Pass
Partial

Does not report when name of TypedDict doesn't match assigned identifier name.

Does not support keyword-argument form of alternative syntax (deprecated in 3.11).

Partial

Does not reject use of variable as second argument to `TypedDict` call.

Does not report when name of TypedDict doesn't match assigned identifier name.

Does not support keyword-argument form of alternative syntax (deprecated in 3.11).

     typeddicts_class_syntaxPassPass
Partial

Does not reject methods within TypedDict class.

Does not report when metaclass is provided.

Does not report when other keyword argument is provided.

Does not support generic TypedDict class.

Partial

Does not reject methods within TypedDict class.

Does not report when metaclass is provided.

Does not report when other keyword argument is provided.

     typeddicts_finalPassPass
Partial

Does not handle value with literal type as index to TypedDict object.

Pass
     typeddicts_inheritancePassPass
Partial

Does not reject TypedDict class that inherits from non-TypedDict class.

Pass
     typeddicts_operationsPassPass
Partial

Does not reject `del` of required key.

Partial

Does not report type violation with TypedDict value assignment.

Does not report reference to unknown key in TypedDict.

Does not reject `clear` method on TypedDict with required keys.

Does not reject delete operation for required key in TypedDict.

     typeddicts_readonlyUnsupportedPassUnsupportedUnsupported
     typeddicts_readonly_consistencyUnsupportedPassUnsupportedUnsupported
     typeddicts_readonly_inheritanceUnsupportedPassUnsupportedUnsupported
     typeddicts_readonly_kwargsUnsupportedPassUnsupportedUnsupported
     typeddicts_readonly_updateUnsupportedPassUnsupportedUnsupported
     typeddicts_required
Partial

Does not support nesting of `Annotated` and `Required` or `NotRequired`.

Pass
Partial

Does not reject use of `Required` in function parameter annotation.

Does not reject nested use of `Required` in type annotation.

Does not support recursive TypedDict definitions.

Incorrectly complains about uninitialized attributes on TypedDict definitions.

Partial

Does not reject use of `Required` in non-TypedDict class.

Does not reject use of `Required` in function parameter annotation.

Does not reject nested use of `Required` in type annotation.

     typeddicts_type_consistencyPassPass
Partial

Does not reject assignment of TypedDict with missing key.

Does not return non-Optional value from `get` method for required key.

Does not properly handle nested TypedDicts.

Partial

Does not report some type violations for TypedDict type compatibility.

Incorrectly reports type violation in cases where there is none.

Does not report type incompatibility between TypedDict and `dict[str, Any]`.

     typeddicts_usagePassPass
Partial

Does not report errant use of TypedDict in `isinstance` call.

Does not reject use of TypedDict as TypeVar bound.

Partial

Does not report errant use of TypedDict in `isinstance` call.

Does not reject use of TypedDict as TypeVar bound.

-Tuples -
     tuples_type_compat
Partial

Does not support tuple narrowing based on `len()` type guard (optional).

Incorrectly narrows tuple based on sequence patterns.

Pass
Partial

Does not support some unpacked tuple forms.

Does not report type violation when assigning `tuple[int, ...]` to `tuple[int]`.

Does not support tuple narrowing based on `len()` type guard (optional).

Does not correctly evaluate `Sequence[Never]` for `tuple[()]`.

Partial

Does not support unpacked tuple forms.

Does not report type violation when assigning `tuple[int, ...]` to `tuple[int]`.

Does not support tuple narrowing based on `len()` type guard (optional).

     tuples_type_formPassPass
Partial

Does not reject some invalid tuple forms involving ellipsis.

Pass
     tuples_unpacked
Partial

"More than one unpack" error is missing a line number.

Pass
Partial

Does not understand star syntax for `Unpack`.

Unsupported

Does not support `typing.Unpack`.

Does not support unpacked tuples within a tuple type form.

-Named tuples -
     namedtuples_define_class
Partial

Does not reject override of named tuple attribute in child class.

Pass
Partial

Does not evaluate correct type for indexed named tuple instance with integer.

Does not evaluate correct type for indexed named tuple instance with slice.

Does not report out-of-range index access with named tuple instance.

Does not reject named tuple element with no default value after one with a default.

Incorrectly rejects assignment of named tuple to a tuple with compatible type.

Does not reject attempt to use NamedTuple with multiple inheritance.

Partial

Incorrectly rejects valid index of named tuple instance when using a negative index.

Does not evaluate correct type for indexed named tuple instance with slice.

Does not reject named tuple element with no default value after one with a default.

Does not reject override of named tuple attribute in child class.

Evaluates incorrect type for named tuple entry with a generic type.

Does not reject incorrect argument type passed to specialized generic named tuple constructor.

Does not reject attempt to use NamedTuple with multiple inheritance.

     namedtuples_define_functional
Pass*

Does not handle illegal named tuple names the same as runtime.

Pass
Partial

Does not reject duplicate field names in functional form.

Does not handle illegal named tuple names the same as runtime.

Does not handle defined fields correctly when extra flags like `rename` or `default` are used.

Does not support defaults in functional form.

Partial

Does not handle illegal named tuple names the same as runtime.

Does not support defaults in functional form.

     namedtuples_type_compatPassPass
Unsupported

Rejects valid type compatibility between named tuple and tuple.

Pass
     namedtuples_usage
Partial

Does not reject attempt to delete named tuple field by name.

Pass
Partial

Does not report out-of-range index access with named tuple instance.

Does not reject attempt to delete named tuple field by name.

Does not reject attempt to delete named tuple field by index.

Incorrectly handles subclasses of named tuples that add more attributes.

Does not handle unpacking of named tuples.

Partial

Incorrectly rejects valid index of named tuple instance when using a negative index.

Does not report out-of-range index access with named tuple instance.

Does not reject attempt to overwrite named tuple entry by name.

Does not reject attempt to delete named tuple entry by name.

-Type narrowing -
     narrowing_typeguardPassPass
Partial

Does not reject TypeGuard method with too few parameters.

Partial

Does not reject TypeGuard method with too few parameters.

     narrowing_typeisPassPassUnsupported
Partial

Does not narrow correctly on generic tuple type.

Does not reject covariant use of TypeIs.

Does not reject TypeIs where return type is not consistent with input type due to variance.

-Type checker directives -
     directives_assert_typePassPass
Pass*

Does not weaken literal types in `assert_type`, which some (other) tests rely on.

Partial

Incorrectly allows assert(x, int) where x is a Literal.

     directives_castPassPassPass
Partial

Does not reject a call to "cast" with additional arguments.

     directives_no_type_check
Partial

Does not honor `@no_type_check` class decorator (allowed).

Does not reject invalid call of `@no_type_check` function.

Pass*

Does not honor `@no_type_check` class decorator (allowed).

Pass*

Does not honor @no_type_check decorator.

Pass*

Does not honor @no_type_check decorator.

     directives_reveal_typePassPass
Partial

"

Produces errors rather than warnings on `reveal_type`.

Partial

Does not reject call to reveal_type with zero arguments.

Does not reject call to reveal_type with too many arguments.

     directives_type_checkingPassPassPassPass
     directives_type_ignore
Partial

Does not honor "# type: ignore" comment if comment includes additional text.

PassPass
Partial

Does not honor "# type: ignore" comment if comment includes additional text.

     directives_type_ignore_file1PassPass
Unsupported

Does not support file-level `#type: ignore` comment.

Pass
     directives_type_ignore_file2PassPassPass
Partial

Does not ignore `# type: ignore` if it occurs after docstrings in the file.

     directives_version_platform
Pass*

Does not understand three-element form of sys.version checks.

Does not understand os.name checks.

Pass
Partial

Does not support sys.platform checks.

Does not support os.name checks.

Pass*

Does not understand three-element form of sys.version checks.

Does not understand os.name checks.

-Historical and deprecated features -
     historical_positional
Partial

Does not reject positional-only parameter after non-positional-only parameter.

Treats keyword-only parameter as positional-only.

Applies legacy positional-only rules when PEP 570 syntax is used.

Pass
Partial

Does not reject positional-only parameter after non-positional-only parameter.

Incorrectly applies legacy positional-only rules when explicit *args are used.

Incorrectly applies legacy positional-only rules when PEP 570 syntax is used.

Partial

Does not apply rules for pre-3.8 positional-only parameters in some cases.

Does not reject positional-only parameter after non-positional-only parameter.

- - -
- +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
mypy 2.4.0pycroscope 0.5.0pyrefly 1.4.0pyright 1.1.414ty 0.0.93zuban 0.10.2
+ Type annotations +
annotations_coroutinesPassPassPassPassPassPass
annotations_forward_refs + Partial +
    +
  • Does not report error for a forward reference that is not enclosed in quotes.
  • +
  • Does not report error for use of quoted type with | operator (runtime error).
  • +
  • Resolves some forward references in type annotations in classes at the point of definition instead of end-of-scope
  • +
+
+ Partial +
    +
  • Fails to reject "x" | int annotations that fail at runtime.
  • +
  • Resolves forward references in type annotations in classes at the point of definition instead of end-of-scope
  • +
  • Rejects some valid quoted annotations.
  • +
+
+ Partial +
    +
  • Resolves forward references in type annotations in classes at the point of definition instead of end-of-scope
  • +
  • Fails to resolve a forward reference to a nested class
  • +
+
+ Partial +
    +
  • Prefers to resolve forward references in classes outside of the class instead of end-of-scope
  • +
+
PassPass
annotations_future_import + Partial +
    +
  • Resolves some forward references in type annotations in classes at the point of definition instead of end-of-scope
  • +
+
+ Partial +
    +
  • Forward references to nested classes are not resolved
  • +
  • Nested classes are resolved, but its type is Any
  • +
  • Resolves some class annotations to outer names instead of shadowing class bindings
  • +
+
+ Partial +
    +
  • Forward references to nested classes are not resolved
  • +
  • Resolves forward references in type annotations in classes at the point of definition instead of end-of-scope
  • +
+
+ Partial +
    +
  • Prefers to resolve forward references in classes outside of the class instead of end-of-scope
  • +
+
PassPass
annotations_generators + Partial +
    +
  • Does not report incompatible Generator type in yield from statement.
  • +
+
PassPassPassPassPass
annotations_methods + Pass +
    +
  • Type evaluation differs from other type checkers because of ambiguity in the spec related to method bindings.
  • +
+
PassPass + Pass +
    +
  • Type evaluation differs from other type checkers because of ambiguity in the spec related to method bindings.
  • +
+
PassPass
annotations_typeexprPass + Partial +
    +
  • Fails to reject various weird annotations
  • +
+
PassPassPassPass
4.5 / 6 • 75.0%4.5 / 6 • 75.0%5 / 6 • 83.3%5 / 6 • 83.3%6 / 6 • 100.0%6 / 6 • 100.0%
+ Type forms +
typeforms_typeform + Partial +
    +
  • Does not support assigning Union and GenericAlias objects to their runtime types.
  • +
+
+ Partial +
    +
  • Fails to reject various weird annotations
  • +
+
PassPassPassPass
0.5 / 1 • 50.0%0.5 / 1 • 50.0%1 / 1 • 100.0%1 / 1 • 100.0%1 / 1 • 100.0%1 / 1 • 100.0%
+ Special types in annotations +
specialtypes_anyPassPassPassPassPassPass
specialtypes_neverPass + Partial +
    +
  • Does not enforce invariance in some contexts
  • +
  • Does not allow Any to be assigned to Never
  • +
+
PassPassPassPass
specialtypes_nonePassPassPassPassPassPass
specialtypes_promotionsPassPassPassPassPassPass
specialtypes_sentinelsPassPassPass + Partial +
    +
  • Requires the string passed to Sentinel to match the assigned variable name.
  • +
  • This causes valid sentinel types and narrowing operations to be rejected.
  • +
+
PassPass
specialtypes_type + Partial +
    +
  • Does not treat type same as type[Any] for assert_type.
  • +
  • Does not allow access to unknown attributes from object of type type[Any].
  • +
+
PassPassPass + Partial +
    +
  • Treats type equivalently to type[object] rather than type[typing.Any].
  • +
+
Pass
5.5 / 6 • 91.7%5.5 / 6 • 91.7%6 / 6 • 100.0%5.5 / 6 • 91.7%5.5 / 6 • 91.7%6 / 6 • 100.0%
+ Generics +
generics_base_class + Partial +
    +
  • Does not detect inconsistent type variable ordering.
  • +
+
PassPassPassPassPass
generics_basicPassPassPassPassPassPass
generics_defaults + Partial +
    +
  • Does not detect a TypeVar with a default used after a TypeVarTuple.
  • +
  • Does not fully support defaults on TypeVarTuple and ParamSpec.
  • +
+
PassPassPass + Partial +
    +
  • Does not forbid a TypeVar immediately following a TypeVarTuple in a parameter list from having a default.
  • +
  • Does not accept a TypeVarTuple default that unpacks another in-scope TypeVarTuple.
  • +
  • Does not correctly specialize a generic that combines a TypeVarTuple with a defaulted ParamSpec.
  • +
+
Pass
generics_defaults_referential + Partial +
    +
  • Does not correctly handle defaults referencing other TypeVars.
  • +
+
PassPassPassPassPass
generics_defaults_specializationPassPassPassPassPassPass
generics_mixed_variance_inferencePassPassPassUnsupportedPassPass
generics_paramspec_basicPassPassPassPassPassPass
generics_paramspec_componentsPassPassPassPassPassPass
generics_paramspec_semanticsPassPassPass + Pass +
    +
  • Constraint solver doesn't find common type for two signatures captured by a single ParamSpec (allowed).
  • +
+
PassPass
generics_paramspec_specializationPassPassPassPassPassPass
generics_paramspec_varianceUnsupportedPassUnsupportedUnsupportedPassPass
generics_scopingPassPassPassPassPassPass
generics_self_advanced + Partial +
    +
  • Does not infer the type of an unannotated self parameter to be type Self.
  • +
  • Does not retain Self when calling method that returns Self.
  • +
  • Does not infer the type of an unannotated cls parameter to be type type[Self].
  • +
  • Does not retain Self when accessing attribute through type[Self].
  • +
+
Pass + Pass +
    +
  • Treats attributes not initialized on the class as instance-only.
  • +
+
PassPassPass
generics_self_attributesPassPassPassPassPassPass
generics_self_basicPassPassPassPassPassPass
generics_self_protocolsPassPassPassPassPassPass
generics_self_usagePassPassPassPassPassPass
generics_syntax_compatibilityPassPassPassPassPassPass
generics_syntax_declarations + Partial +
    +
  • Doesn't flag TypeVar with empty constraints.
  • +
+
PassPassPassPassPass
generics_syntax_infer_variance + Unsupported +
    +
  • Type parameter syntax not yet supported.
  • +
+
PassPassPassPassPass
generics_syntax_scoping + Partial +
    +
  • Does not following runtime scoping rules for type parameters in all cases.
  • +
+
PassPassPassPassPass
generics_type_erasure + Partial +
    +
  • Infers Node[Never] instead of Node[Any] when argument is not provided.
  • +
+
PassPassPassPassPass
generics_typevartuple_args + Partial +
    +
  • Does not enforce that tuples captured by TypeVarTuple are of the same length.
  • +
+
PassPassPassPassPass
generics_typevartuple_basic + Partial +
    +
  • Does not enforce that tuples captured by TypeVarTuple are same length.
  • +
+
PassPassPassPassPass
generics_typevartuple_callablePassPassPassPassPassPass
generics_typevartuple_concatPassPassPassPassPassPass
generics_typevartuple_overloadsPassPassPassPassPassPass
generics_typevartuple_specialization + Partial +
    +
  • Incorrectly specializes generic alias that includes a TypeVar and TypeVarTuple if no type arguments are provided.
  • +
  • Rejects specialization of generic type alias defined as a tuple containing a TypeVar.
  • +
+
PassPassPassPassPass
generics_typevartuple_unpackPassPassPassPassPassPass
generics_typevartuple_varianceUnsupportedPassUnsupportedUnsupportedPassPass
generics_upper_bound + Partial +
    +
  • Does not reject use of type variable within an upper bound.
  • +
+
PassPassPassPassPass
generics_variance + Partial +
    +
  • Does not reject use of class-scoped TypeVar used in a base class when variance is incompatible.
  • +
+
PassPassPassPassPass
generics_variance_inference + Partial +
    +
  • polymorphic functions with bound self type influence variance inference,
  • +
  • which is not part of the variance inference algorithm as described in the spec.
  • +
  • See gh-2281 for details.
  • +
+
PassPassPassPassPass
23.5 / 33 • 71.2%33 / 33 • 100.0%31 / 33 • 93.9%30 / 33 • 90.9%32.5 / 33 • 98.5%33 / 33 • 100.0%
+ Type qualifiers +
qualifiers_annotated + Partial +
    +
  • Does not allow ClassVar to be nested within Annotated.
  • +
  • Does not allow Final to be nested within Annotated.
  • +
  • Does not allow Required and NotRequired to be nested within Annotated.
  • +
  • Does not reject type[T] compatibility for type alias defined with Annotated.
  • +
  • Does not reject call of type alias defined with Annotated.
  • +
+
+ Partial +
    +
  • Fails to reject various weird annotations.
  • +
  • False positive on lambda in Annotated.
  • +
+
PassPassPassPass
qualifiers_final_annotation + Partial +
    +
  • Does not treat use of Final name as if it was replaced by the literal in NamedTuple definition.
  • +
  • Does not allow conditional assignment of Final instance variable in __init__ method.
  • +
  • Does not allow redefinition of private class variable that is marked Final in parent class.
  • +
  • Does not report modification of local Final variable via for statement.
  • +
+
PassPassPassPassPass
qualifiers_final_decoratorPassPassPassPassPassPass
2 / 3 • 66.7%2.5 / 3 • 83.3%3 / 3 • 100.0%3 / 3 • 100.0%3 / 3 • 100.0%3 / 3 • 100.0%
+ Class type compatibility +
classes_classvar + Partial +
    +
  • Internal error if TypeVarTuple is used in ClassVar.
  • +
  • Does not reject use of ParamSpec in ClassVar.
  • +
  • Rejects ClassVar nested in Annotated.
  • +
  • Does not reject use of ClassVar in TypeAlias definition.
  • +
+
PassPassPassPassPass
classes_override + Partial +
    +
  • Does not honor @override compatibility checks for __init__ and __new__:
  • +
  • the incompatible constructor overrides in ChildC2 are not flagged.
  • +
+
PassPass + Partial +
    +
  • Does not honor @override compatibility checks for __init__ and __new__:
  • +
  • the incompatible constructor overrides in ChildC2 are not flagged.
  • +
+
PassPass
1 / 2 • 50.0%2 / 2 • 100.0%2 / 2 • 100.0%1.5 / 2 • 75.0%2 / 2 • 100.0%2 / 2 • 100.0%
+ Type aliases +
aliases_explicit + Partial +
    +
  • Does not reject specialization of type alias that has already been implicitly specialized.
  • +
+
PassPassPassPassPass
aliases_implicitPass + Partial +
    +
  • Fails to handle various weird annotations.
  • +
  • Various bugs with resolving generic aliases.
  • +
+
PassPassPassPass
aliases_newtype + Partial +
    +
  • NewTypes are incorrectly considered to be classes.
  • +
+
PassPassPassPassPass
aliases_recursivePassPassPassPassPassPass
aliases_type_statementPass + Partial +
    +
  • Fails to reject various weird annotations.
  • +
  • Rejects a valid recursive generic type alias.
  • +
+
PassPassPassPass
aliases_typealiastype + Partial +
    +
  • Incorrectly rejects some recursive type aliases using TypeAliasType.
  • +
  • Incorrectly rejects the use of a class-scoped TypeVar in a TypeAliasType definition.
  • +
+
PassPassPassPassPass
aliases_variancePassPassPassPassPassPass
5.5 / 7 • 78.6%6 / 7 • 85.7%7 / 7 • 100.0%7 / 7 • 100.0%7 / 7 • 100.0%7 / 7 • 100.0%
+ Literals +
literals_interactions + Pass +
    +
  • Does not narrow str or LiteralString types to Literal string types via equality or containment checks.
  • +
+
PassPassPassPassPass
literals_literalstring + Unsupported +
    +
  • Support for LiteralString is not implemented.
  • +
+
PassPassPassPassPass
literals_parameterizations + Partial +
    +
  • Does not reject tuple within Literal.
  • +
+
+ Partial +
    +
  • Fails to reject various invalid literal parameterizations.
  • +
+
PassPassPassPass
literals_semanticsPassPassPassPassPassPass
2.5 / 4 • 62.5%3.5 / 4 • 87.5%4 / 4 • 100.0%4 / 4 • 100.0%4 / 4 • 100.0%4 / 4 • 100.0%
+ Protocols +
protocols_class_objectsPass + Partial +
    +
  • Abstract type[Proto] still allows protocol class objects in some paths.
  • +
+
PassPass + Partial +
    +
  • Does not reject protocol classes where type[Proto] requires a concrete class.
  • +
  • Incorrectly considers instance attributes as satisfying protocol members on class objects.
  • +
+
Pass
protocols_definition + Partial +
    +
  • Does not detect protocol mismatch if concrete method is missing annotations.
  • +
  • Does not detect protocol mismatch if concrete method's parameters are position-only.
  • +
+
PassPassPassPassPass
protocols_explicit + Pass +
    +
  • Does not report unimplemented attributes for class that explicitly derives from protocol until it is instantiated.
  • +
+
PassPassPass + Partial +
    +
  • Allows abstract protocol methods with no default implementation to be called via super() on a protocol subclass.
  • +
  • Allows instantiation of protocol subclasses with uninitialized ClassVar members.
  • +
+
Pass
protocols_genericPass + Partial +
    +
  • Treats global object as a literal.
  • +
+
PassPass + Partial +
    +
  • Does not reject incompatible non-generic implementations of generic protocol methods.
  • +
+
Pass
protocols_mergingPassPassPassPassPassPass
protocols_modulesPassPassPassPassPassPass
protocols_recursivePassPassPassPass + Partial +
    +
  • Fails to solve a type variable involving a recursive generic protocol.
  • +
+
Pass
protocols_runtime_checkable + Partial +
    +
  • Does not report unsafe overlap for runtime_checkable protocol.
  • +
+
PassPassPass + Partial +
    +
  • Does not reject isinstance() or issubclass() calls against runtime-checkable protocols where there is an unsafe overlap between the type of the first argument and the protocol.
  • +
+
Pass
protocols_selfPassPassPassPassPassPass
protocols_subtypingPassPassPassPassPassPass
protocols_variance + Partial +
    +
  • False report of ParamSpec variance keywords.
  • +
+
Pass + Partial +
    +
  • Doesn't support variance keywords to ParamSpec
  • +
+
+ Partial +
    +
  • Doesn't support variance keyword arguments to ParamSpec.
  • +
+
PassPass
9.5 / 11 • 86.4%10 / 11 • 90.9%10.5 / 11 • 95.5%10.5 / 11 • 95.5%8.5 / 11 • 77.3%11 / 11 • 100.0%
+ Callables +
callables_annotation + Partial +
    +
  • Incorrectly treats *args: T, **kwargs: T as ... when T is specialized to Any.
  • +
  • Does not treat *args: Any, **kargs: Any as ... when separated by keyword parameter.
  • +
+
PassPassPassPassPass
callables_kwargs + Partial +
    +
  • Allows callable without kwargs to be assigned to callable with unpacked kwargs.
  • +
+
PassPassPassPassPass
callables_protocolPassPassPassPassPassPass
callables_subtypingPassPassPassPassPassPass
3 / 4 • 75.0%4 / 4 • 100.0%4 / 4 • 100.0%4 / 4 • 100.0%4 / 4 • 100.0%4 / 4 • 100.0%
+ Constructors +
constructors_call_init + Partial +
    +
  • Does not report errors during binding to self parameter of __init__ method.
  • +
  • Does not reject use of class-scoped type variables in annotation of self parameter in __init__ method.
  • +
+
PassPassPass + Partial +
    +
  • Does not reject invalid argument types to an inherited constructor in a specialized subclass of a generic superclass.
  • +
+
Pass
constructors_call_metaclass + Unsupported +
    +
  • Does not honor metaclass __call__ method when evaluating constructor call.
  • +
  • Does not skip evaluation of __new__ and __init__ if custom metaclass call returns non-class.
  • +
+
PassPassPassPassPass
constructors_call_new + Partial +
    +
  • Does not support __new__ return type that is not a subclass of the class being constructed.
  • +
  • Does not skip evaluation of __init__ based on __new__ return type.
  • +
  • Does not report errors during binding to cls parameter of __new__ method.
  • +
+
PassPassPassPassPass
constructors_call_type + Partial +
    +
  • Does not validate call to custom metaclass __call__ method through type[T].
  • +
+
PassPassPassPassPass
constructors_callable + Partial +
    +
  • Does not generate a union type for __new__ and __init__ when converting class to callable.
  • +
  • Does not ignore __init__ based on __new__ return type when converting class to callable.
  • +
  • Does not support __new__ return type that is different from class being constructed.
  • +
+
PassPassPass + Partial +
    +
  • Does not include __init__ when __new__ returns Self.
  • +
  • Does not ignore __init__ when __new__ returns Any.
  • +
  • Unions overload return types.
  • +
+
Pass
constructors_consistency + Pass +
    +
  • Does not report inconsistency between __new__ and __init__ (optional).
  • +
+
PassPassPassPassPass
3 / 6 • 50.0%6 / 6 • 100.0%6 / 6 • 100.0%6 / 6 • 100.0%5 / 6 • 83.3%6 / 6 • 100.0%
+ Overloads +
overloads_basicPass + Partial +
    +
  • Does less literal promotion than the test asks for.
  • +
+
PassPassPassPass
overloads_consistencyPassPassPassPassPassPass
overloads_definitions + Partial +
    +
  • Allows @override to be on all overloads and implementation, instead of just implementation.
  • +
+
PassPassPassPassPass
overloads_definitions_stub + Partial +
    +
  • Allows @override to appear in a stub file not on the first overload.
  • +
+
+ Unsupported +
    +
  • Does not support checking stubs.
  • +
+
PassPassPassPass
overloads_evaluation + Partial +
    +
  • Does not expand boolean arguments to Literal[True] and Literal[False].
  • +
  • Does not expand enum arguments to literal variants.
  • +
  • Does not expand tuple arguments to possible combinations.
  • +
  • Evaluates Any in some cases where overload is not ambiguous.
  • +
+
PassPassPassPassPass
3.5 / 5 • 70.0%3.5 / 5 • 70.0%5 / 5 • 100.0%5 / 5 • 100.0%5 / 5 • 100.0%5 / 5 • 100.0%
+ Exceptions +
exceptions_context_managersPassPassPassPassPassPass
1 / 1 • 100.0%1 / 1 • 100.0%1 / 1 • 100.0%1 / 1 • 100.0%1 / 1 • 100.0%1 / 1 • 100.0%
+ Dataclasses +
dataclasses_descriptors + Partial +
    +
  • Assumes descriptor behavior only when field is assigned in class body.
  • +
  • Does not correctly evaluate type of descriptor access.
  • +
+
+ Partial + + + Partial +
    +
  • Assumes descriptor behavior only when field is assigned in class body
  • +
  • Doesn't allow non-data descriptors or data descriptors with differing __get__ and __set__ types
  • +
+
Pass + Partial +
    +
  • Only infers a descriptor __get__ method as being called when a descriptor attribute is accessed on an instance if the descriptor attribute is present in the class namespace.
  • +
+
Pass
dataclasses_final + Partial +
    +
  • Wrongly requires a Final dataclass field to be initialized at class level.
  • +
  • Doesn't support Final nested inside ClassVar.
  • +
+
PassPassPassPassPass
dataclasses_frozenPassPassPassPassPassPass
dataclasses_hash + Unsupported +
    +
  • Does not synthesize __hash__ = None as a class attribute for unhashable dataclasses.
  • +
  • Does not report when an unhashable dataclass has __hash__ called directly on an instance.
  • +
  • Does not report when dataclass is not compatible with Hashable protocol.
  • +
+
PassPassPassPassPass
dataclasses_inheritancePassPassPassPassPassPass
dataclasses_kwonlyPassPassPassPassPassPass
dataclasses_match_argsPassPassPassPassPassPass
dataclasses_orderPassPassPassPassPassPass
dataclasses_postinitPassPassPassPassPassPass
dataclasses_slots + Partial +
    +
  • Does not reject write to instance variable that is not defined in __slots__.
  • +
+
PassPassPassPassPass
dataclasses_transform_classPassPassPassPassPassPass
dataclasses_transform_converter + Unsupported +
    +
  • Converter parameter not yet supported.
  • +
+
PassPassPassPassPass
dataclasses_transform_field + Partial +
    +
  • Does not properly handle field constructor that has default value for kw_only or init parameter.
  • +
+
PassPassPassPassPass
dataclasses_transform_func + Partial +
    +
  • Does not handle kw_only=False override when kw_only_default=True.
  • +
  • Does not report error when order=False and comparison operators are used.
  • +
+
PassPassPassPassPass
dataclasses_transform_metaPassPassPassPassPassPass
dataclasses_usage + Pass +
    +
  • Does not detect unannotated usage of dataclasses.field().
  • +
+
PassPassPassPassPass
11.5 / 16 • 71.9%15.5 / 16 • 96.9%15.5 / 16 • 96.9%16 / 16 • 100.0%15.5 / 16 • 96.9%16 / 16 • 100.0%
+ Typed dictionaries +
typeddicts_alt_syntax + Pass +
    +
  • Does not support keyword-argument form of alternative syntax (deprecated in 3.11).
  • +
+
PassPassPassPassPass
typeddicts_class_syntax + Partial +
    +
  • Does not support version-conditional items in TypedDict definitions.
  • +
+
PassPassPassPassPass
typeddicts_extra_itemsUnsupportedPassPassPassPassPass
typeddicts_finalPassPassPassPassPassPass
typeddicts_inheritancePassPassPassPassPassPass
typeddicts_operationsPassPassPassPassPassPass
typeddicts_readonlyPassPassPassPassPassPass
typeddicts_readonly_consistencyPassPassPassPassPassPass
typeddicts_readonly_inheritance + Partial +
    +
  • Incorrectly rejects non-ReadOnly override of ReadOnly item.
  • +
  • Incorrectly rejects override of ReadOnly item with another ReadOnly item with narrower type.
  • +
  • Incorrectly rejects override of NotRequired ReadOnly item with a Required ReadOnly item.
  • +
+
PassPassPassPassPass
typeddicts_readonly_kwargsPassPassPassPassPassPass
typeddicts_readonly_update + Partial +
    +
  • Incorrectly allows update of ReadOnly item.
  • +
  • Incorrectly rejects update involving an item with Never type.
  • +
+
PassPassPassPassPass
typeddicts_requiredPassPassPassPassPassPass
typeddicts_type_consistencyPassPassPassPassPassPass
typeddicts_usagePassPassPassPassPassPass
11.5 / 14 • 82.1%14 / 14 • 100.0%14 / 14 • 100.0%14 / 14 • 100.0%14 / 14 • 100.0%14 / 14 • 100.0%
+ Tuples +
tuples_type_compat + Partial +
    +
  • Does not support tuple narrowing based on len() type guard (optional).
  • +
  • Incorrectly marks a match case as unreachable.
  • +
+
PassPassPassPassPass
tuples_type_formPassPassPassPassPassPass
tuples_unpacked + Partial +
    +
  • "More than one unpack" error is missing in some cases.
  • +
+
PassPassPassPassPass
2 / 3 • 66.7%3 / 3 • 100.0%3 / 3 • 100.0%3 / 3 • 100.0%3 / 3 • 100.0%3 / 3 • 100.0%
+ Named tuples +
namedtuples_define_class + Partial +
    +
  • Does not reject override of named tuple attribute in child class.
  • +
  • Does not support version-conditional fields.
  • +
+
PassPassPassPassPass
namedtuples_define_functionalPassPassPassPassPassPass
namedtuples_type_compatPassPassPassPassPassPass
namedtuples_usage + Partial +
    +
  • Does not reject attempt to delete named tuple field by name.
  • +
+
PassPassPassPassPass
3 / 4 • 75.0%4 / 4 • 100.0%4 / 4 • 100.0%4 / 4 • 100.0%4 / 4 • 100.0%4 / 4 • 100.0%
+ Enumerations +
enums_behaviorsPassPassPassPassPassPass
enums_definitionPassPassPassPassPassPass
enums_expansion + Partial +
    +
  • Improperly applies narrowing to Flag subclass.
  • +
+
PassPassPassPassPass
enums_member_names + Pass +
    +
  • Does not support special-cased handling of member name literal types in some cases (optional).
  • +
+
PassPassPassPassPass
enums_member_values + Partial +
    +
  • Does not enforce declared type of _value_.
  • +
  • Does not enforce assigned tuple types for enum members (optional).
  • +
+
PassPassPassPassPass
enums_members + Partial +
    +
  • Does not treat attribute with annotation and no assignment as non-member.
  • +
  • Does not treat callables as non-members.
  • +
  • Does not honor enum.member as method decorator.
  • +
  • Does not properly handle aliased enum members.
  • +
  • Does not support _ignore_ mechanism (optional).
  • +
  • Does not treat attributes with private names as non-members.
  • +
+
PassPass + Pass +
    +
  • Does not support _ignore_ mechanism (optional).
  • +
+
PassPass
4.5 / 6 • 75.0%6 / 6 • 100.0%6 / 6 • 100.0%6 / 6 • 100.0%6 / 6 • 100.0%6 / 6 • 100.0%
+ Type narrowing +
narrowing_typeguardPassPassPassPassPassPass
narrowing_typeisPassPassPassPassPassPass
2 / 2 • 100.0%2 / 2 • 100.0%2 / 2 • 100.0%2 / 2 • 100.0%2 / 2 • 100.0%2 / 2 • 100.0%
+ Type checker directives +
directives_assert_typePassPassPassPassPassPass
directives_castPassPassPassPassPassPass
directives_deprecatedPassPassPassPassPassPass
directives_disjoint_basePassPassPassPassPassPass
directives_no_type_check + Partial +
    +
  • Does not honor @no_type_check class decorator (allowed).
  • +
  • Does not reject invalid call of @no_type_check function.
  • +
+
PassPass + Pass +
    +
  • Does not honor @no_type_check class decorator (allowed).
  • +
+
PassPass
directives_reveal_typePassPassPassPassPassPass
directives_type_checkingPassPassPassPassPassPass
directives_type_ignore + Partial +
    +
  • Does not honor # type: ignore comment if comment includes additional text.
  • +
+
PassPassPassPassPass
directives_type_ignore_file1PassPassPassPassPassPass
directives_type_ignore_file2PassPassPassPassPassPass
directives_version_platform + Pass +
    +
  • Does not understand three-element form of sys.version checks.
  • +
  • Does not understand os.name checks.
  • +
+
PassPassPassPassPass
10 / 11 • 90.9%11 / 11 • 100.0%11 / 11 • 100.0%11 / 11 • 100.0%11 / 11 • 100.0%11 / 11 • 100.0%
+ Historical and deprecated features +
historical_positional + Partial +
    +
  • Does not reject positional-only parameter after non-positional-only parameter.
  • +
  • Treats keyword-only parameter as positional-only.
  • +
  • Applies legacy positional-only rules when PEP 570 syntax is used.
  • +
+
PassPassPassPassPass
0.5 / 1 • 50.0%1 / 1 • 100.0%1 / 1 • 100.0%1 / 1 • 100.0%1 / 1 • 100.0%1 / 1 • 100.0%
110 / 146 • 75.3%138.5 / 146 • 94.9%142 / 146 • 97.3%140.5 / 146 • 96.2%141 / 146 • 96.6%146 / 146 • 100.0%
+
+ + diff --git a/conformance/results/ty/aliases_explicit.toml b/conformance/results/ty/aliases_explicit.toml new file mode 100644 index 000000000..3c0a12246 --- /dev/null +++ b/conformance/results/ty/aliases_explicit.toml @@ -0,0 +1,26 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +aliases_explicit.py:67:9: error[not-subscriptable] Cannot subscript non-generic type `int | None` +aliases_explicit.py:68:9: error[not-subscriptable] Cannot subscript non-generic type `list[int | None]` +aliases_explicit.py:69:29: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +aliases_explicit.py:70:29: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +aliases_explicit.py:71:24: error[invalid-type-arguments] Type argument for `ParamSpec` must be either a list of types, `ParamSpec`, `Concatenate`, or `...` +aliases_explicit.py:79:21: error[invalid-type-form] Function calls are not allowed in type alias definitions +aliases_explicit.py:80:21: error[invalid-type-form] List literals are not allowed in this context in a type alias definition +aliases_explicit.py:81:21: error[invalid-type-form] Tuple literals are not allowed in this context in a type alias definition +aliases_explicit.py:82:21: error[invalid-type-form] List comprehensions are not allowed in type alias definitions +aliases_explicit.py:83:21: error[invalid-type-form] Dict literals are not allowed in type alias definitions +aliases_explicit.py:84:21: error[invalid-type-form] Function calls are not allowed in type alias definitions +aliases_explicit.py:85:21: error[invalid-type-form] Only simple names and dotted names can be subscripted in type alias definitions +aliases_explicit.py:86:21: error[invalid-type-form] `if` expressions are not allowed in type alias definitions +aliases_explicit.py:87:21: error[invalid-type-form] Variable `var1` cannot be used as a type: Variable of type `Literal[3]` is not allowed in a type alias definition +aliases_explicit.py:88:22: error[invalid-type-form] Boolean literals are not allowed in this context in a type alias definition: Did you mean `typing.Literal[True]`? +aliases_explicit.py:89:22: error[invalid-type-form] Int literals are not allowed in this context in a type alias definition: Did you mean `typing.Literal[1]`? +aliases_explicit.py:90:22: error[invalid-type-form] Boolean operations are not allowed in type alias definitions +aliases_explicit.py:91:22: error[invalid-type-form] F-strings are not allowed in type alias definitions +aliases_explicit.py:100:5: error[not-subscriptable] Cannot subscript non-generic type `list[Unknown]` +aliases_explicit.py:101:6: error[call-non-callable] Object of type `UnionType` is not callable +aliases_explicit.py:102:5: error[not-subscriptable] Cannot subscript non-generic type `list[Unknown] | set[Unknown]` +""" diff --git a/conformance/results/ty/aliases_implicit.toml b/conformance/results/ty/aliases_implicit.toml new file mode 100644 index 000000000..740ed43de --- /dev/null +++ b/conformance/results/ty/aliases_implicit.toml @@ -0,0 +1,27 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +aliases_implicit.py:76:9: error[not-subscriptable] Cannot subscript non-generic type `int | None` +aliases_implicit.py:77:9: error[not-subscriptable] Cannot subscript non-generic type `list[int | None]` +aliases_implicit.py:78:29: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +aliases_implicit.py:79:29: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +aliases_implicit.py:80:24: error[invalid-type-arguments] Type argument for `ParamSpec` must be either a list of types, `ParamSpec`, `Concatenate`, or `...` +aliases_implicit.py:81:25: error[invalid-type-arguments] Type `str` is not assignable to upper bound `float` of type variable `TFloat@GoodTypeAlias12` +aliases_implicit.py:106:9: error[invalid-type-form] Variable `BadTypeAlias1` cannot be used as a type +aliases_implicit.py:107:9: error[invalid-type-form] Variable `BadTypeAlias2` cannot be used as a type: Variable of type `list[ | ]` is not allowed in a parameter annotation +aliases_implicit.py:108:9: error[invalid-type-form] Variable `BadTypeAlias3` cannot be used as a type: Variable of type `tuple[tuple[, ]]` is not allowed in a parameter annotation +aliases_implicit.py:109:9: error[invalid-type-form] Variable `BadTypeAlias4` cannot be used as a type: Variable of type `list[]` is not allowed in a parameter annotation +aliases_implicit.py:110:9: error[invalid-type-form] Variable `BadTypeAlias5` cannot be used as a type: Variable of type `dict[str, str]` is not allowed in a parameter annotation +aliases_implicit.py:111:9: error[invalid-type-form] Variable `BadTypeAlias6` cannot be used as a type +aliases_implicit.py:112:9: error[invalid-type-form] Variable `BadTypeAlias7` cannot be used as a type +aliases_implicit.py:113:9: error[invalid-type-form] Variable `BadTypeAlias8` cannot be used as a type +aliases_implicit.py:114:9: error[invalid-type-form] Variable `BadTypeAlias9` cannot be used as a type +aliases_implicit.py:115:10: error[invalid-type-form] Variable `BadTypeAlias10` cannot be used as a type: Variable of type `Literal[True]` is not allowed in a parameter annotation +aliases_implicit.py:116:10: error[invalid-type-form] Variable `BadTypeAlias11` cannot be used as a type: Variable of type `Literal[1]` is not allowed in a parameter annotation +aliases_implicit.py:117:10: error[invalid-type-form] Variable `BadTypeAlias12` cannot be used as a type +aliases_implicit.py:118:10: error[invalid-type-form] Variable `BadTypeAlias13` cannot be used as a type: Variable of type `Literal["int"]` is not allowed in a parameter annotation +aliases_implicit.py:119:10: error[invalid-type-form] Variable of type `Literal["int | str"]` is not allowed in a parameter annotation +aliases_implicit.py:133:6: error[call-non-callable] Object of type `UnionType` is not callable +aliases_implicit.py:135:5: error[not-subscriptable] Cannot subscript non-generic type `list[Unknown] | set[Unknown]` +""" diff --git a/conformance/results/ty/aliases_newtype.toml b/conformance/results/ty/aliases_newtype.toml new file mode 100644 index 000000000..5c846860c --- /dev/null +++ b/conformance/results/ty/aliases_newtype.toml @@ -0,0 +1,19 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +aliases_newtype.py:11:8: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `Literal["user"]` +aliases_newtype.py:12:14: error[invalid-assignment] Object of type `Literal[42]` is not assignable to `UserId` +aliases_newtype.py:18:11: error[invalid-assignment] Object of type `` is not assignable to `type` +aliases_newtype.py:23:16: error[invalid-argument-type] Argument to function `isinstance` is incorrect: Expected `_ClassInfo`, found `` +aliases_newtype.py:26:21: error[invalid-base] Cannot subclass an instance of NewType +aliases_newtype.py:35:20: error[mismatched-type-name] The name passed to `NewType` must match the variable it is assigned to: Expected "GoodName", got "BadName" +aliases_newtype.py:41:6: error[invalid-type-form] `GoodNewType1` is a `NewType` and cannot be specialized +aliases_newtype.py:47:38: error[invalid-newtype] invalid base for `typing.NewType`: type `int | str` +aliases_newtype.py:50:38: error[invalid-newtype] invalid base for `typing.NewType`: A `NewType` base cannot be generic +aliases_newtype.py:52:38: error[invalid-newtype] invalid base for `typing.NewType`: type `Hashable` +aliases_newtype.py:54:38: error[invalid-newtype] invalid base for `typing.NewType`: type `Literal[7]` +aliases_newtype.py:61:38: error[invalid-newtype] invalid base for `typing.NewType`: type `TD1` +aliases_newtype.py:63:15: error[invalid-newtype] Wrong number of arguments in `NewType` creation: expected 2, found 3 +aliases_newtype.py:65:38: error[invalid-newtype] invalid base for `typing.NewType`: type `Any` +""" diff --git a/conformance/results/ty/aliases_recursive.toml b/conformance/results/ty/aliases_recursive.toml new file mode 100644 index 000000000..c7e470092 --- /dev/null +++ b/conformance/results/ty/aliases_recursive.toml @@ -0,0 +1,17 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +aliases_recursive.py:19:12: error[invalid-assignment] Object of type `dict[str, None | complex | str | list[Json] | dict[str, Json]]` is not assignable to `Json` +aliases_recursive.py:20:12: error[invalid-assignment] Object of type `list[None | complex | str | list[Json] | dict[str, Json]]` is not assignable to `Json` +aliases_recursive.py:38:22: error[invalid-assignment] Object of type `tuple[Literal[1], tuple[Literal["1"], Literal[1]], tuple[Literal[1], tuple[Literal[1], list[int]]]]` is not assignable to `RecursiveTuple` +aliases_recursive.py:39:22: error[invalid-assignment] Object of type `tuple[Literal[1], list[int]]` is not assignable to `RecursiveTuple` +aliases_recursive.py:50:24: error[invalid-assignment] Object of type `dict[str, list[int]]` is not assignable to `RecursiveMapping` +aliases_recursive.py:51:24: error[invalid-assignment] Object of type `dict[str, str | int | list[int]]` is not assignable to `RecursiveMapping` +aliases_recursive.py:52:24: error[invalid-assignment] Object of type `dict[str, str | int | dict[str, str | int | list[int]]]` is not assignable to `RecursiveMapping` +aliases_recursive.py:63:30: error[invalid-assignment] Object of type `list[list[GenericTypeAlias1[str] | str] | str | list[list[GenericTypeAlias1[str] | str] | str | float]]` is not assignable to `GenericTypeAlias1[str]` +aliases_recursive.py:69:35: error[invalid-assignment] Object of type `list[list[GenericTypeAlias2[str, int] | str | int] | str | int | list[list[GenericTypeAlias2[str, int] | str | int] | str | int | list[list[GenericTypeAlias2[str, int] | str | int] | str | int | list[list[GenericTypeAlias2[str, int] | str | int] | str | float]]]]` is not assignable to `GenericTypeAlias2[str, int]` +aliases_recursive.py:72:29: error[cyclic-type-alias-definition] Type alias `RecursiveUnion` has a circular definition +aliases_recursive.py:75:31: error[cyclic-type-alias-definition] Type alias `MutualReference1` has a circular definition +aliases_recursive.py:75:93: error[cyclic-type-alias-definition] Type alias `MutualReference2` has a circular definition +""" diff --git a/conformance/results/ty/aliases_type_statement.toml b/conformance/results/ty/aliases_type_statement.toml new file mode 100644 index 000000000..3ad6d2304 --- /dev/null +++ b/conformance/results/ty/aliases_type_statement.toml @@ -0,0 +1,31 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +aliases_type_statement.py:17:1: error[unresolved-attribute] Object of type `TypeAliasType` has no attribute `bit_count` +aliases_type_statement.py:19:1: error[call-non-callable] Object of type `TypeAliasType` is not callable +aliases_type_statement.py:23:7: error[unresolved-attribute] Object of type `TypeAliasType` has no attribute `other_attrib` +aliases_type_statement.py:26:18: error[invalid-base] Invalid class base with type `TypeAliasType` +aliases_type_statement.py:31:22: error[invalid-argument-type] Argument to function `isinstance` is incorrect: Expected `_ClassInfo`, found `TypeAliasType` +aliases_type_statement.py:37:22: error[invalid-type-form] Function calls are not allowed in type alias definitions +aliases_type_statement.py:38:22: error[invalid-type-form] List literals are not allowed in this context in a type alias definition +aliases_type_statement.py:39:22: error[invalid-type-form] Tuple literals are not allowed in this context in a type alias definition +aliases_type_statement.py:40:22: error[invalid-type-form] List comprehensions are not allowed in type alias definitions +aliases_type_statement.py:41:22: error[invalid-type-form] Dict literals are not allowed in type alias definitions +aliases_type_statement.py:42:22: error[invalid-type-form] Function calls are not allowed in type alias definitions +aliases_type_statement.py:43:22: error[invalid-type-form] Only simple names and dotted names can be subscripted in type alias definitions +aliases_type_statement.py:44:22: error[invalid-type-form] `if` expressions are not allowed in type alias definitions +aliases_type_statement.py:45:22: error[invalid-type-form] Variable `var1` cannot be used as a type: Variable of type `Literal[1]` is not allowed in a type alias definition +aliases_type_statement.py:46:23: error[invalid-type-form] Boolean literals are not allowed in this context in a type alias definition: Did you mean `typing.Literal[True]`? +aliases_type_statement.py:47:23: error[invalid-type-form] Int literals are not allowed in this context in a type alias definition: Did you mean `typing.Literal[1]`? +aliases_type_statement.py:48:23: error[invalid-type-form] Boolean operations are not allowed in type alias definitions +aliases_type_statement.py:49:23: error[invalid-type-form] F-strings are not allowed in type alias definitions +aliases_type_statement.py:53:23: error[unbound-type-variable] Type variable `V` is not bound to any outer generic context +aliases_type_statement.py:58:17: error[unbound-type-variable] Type variable `T1` is not bound to any outer generic context +aliases_type_statement.py:68:27: error[invalid-type-arguments] Type `str` is not assignable to upper bound `int` of type variable `S@RecursiveTypeAlias2` +aliases_type_statement.py:70:32: error[invalid-type-arguments] Type `int` is not assignable to upper bound `str` of type variable `T@RecursiveTypeAlias2` +aliases_type_statement.py:73:28: error[cyclic-type-alias-definition] Type alias `RecursiveTypeAlias3` has a circular definition +aliases_type_statement.py:75:31: error[cyclic-type-alias-definition] Type alias `RecursiveTypeAlias4` has a circular definition +aliases_type_statement.py:79:28: error[cyclic-type-alias-definition] Type alias `RecursiveTypeAlias6` has a circular definition +aliases_type_statement.py:80:28: error[cyclic-type-alias-definition] Type alias `RecursiveTypeAlias7` has a circular definition +""" diff --git a/conformance/results/ty/aliases_typealiastype.toml b/conformance/results/ty/aliases_typealiastype.toml new file mode 100644 index 000000000..db6cdc7c4 --- /dev/null +++ b/conformance/results/ty/aliases_typealiastype.toml @@ -0,0 +1,28 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +aliases_typealiastype.py:32:7: error[unresolved-attribute] Object of type `TypeAliasType` has no attribute `other_attrib` +aliases_typealiastype.py:40:21: error[invalid-type-arguments] Type `int` is not assignable to upper bound `str` of type variable `TStr@GoodAlias5` +aliases_typealiastype.py:43:40: error[invalid-type-alias-type] Type parameter `S` used in the alias value must be included in `type_params` +aliases_typealiastype.py:44:40: error[invalid-type-alias-type] Type parameter `S` used in the alias value must be included in `type_params` +aliases_typealiastype.py:45:57: error[invalid-type-alias-type] The `type_params` argument to `TypeAliasType` must be a tuple literal +aliases_typealiastype.py:46:40: error[cyclic-type-alias-definition] Type alias `BadAlias4` has a circular definition +aliases_typealiastype.py:47:40: error[cyclic-type-alias-definition] Type alias `BadAlias5` has a circular definition +aliases_typealiastype.py:48:40: error[cyclic-type-alias-definition] Type alias `BadAlias6` has a circular definition +aliases_typealiastype.py:49:40: error[cyclic-type-alias-definition] Type alias `BadAlias7` has a circular definition +aliases_typealiastype.py:52:40: error[invalid-type-form] Function calls are not allowed in type expressions +aliases_typealiastype.py:53:40: error[invalid-type-form] List literals are not allowed in this context in a type expression +aliases_typealiastype.py:54:42: error[invalid-type-form] Tuple literals are not allowed in this context in a type expression +aliases_typealiastype.py:55:42: error[invalid-type-form] List comprehensions are not allowed in type expressions +aliases_typealiastype.py:56:42: error[invalid-type-form] Dict literals are not allowed in type expressions +aliases_typealiastype.py:57:42: error[invalid-type-form] Function calls are not allowed in type expressions +aliases_typealiastype.py:58:42: error[invalid-type-form] Only simple names and dotted names can be subscripted in type expressions +aliases_typealiastype.py:59:42: error[invalid-type-form] `if` expressions are not allowed in type expressions +aliases_typealiastype.py:60:42: error[invalid-type-form] Variable `var1` cannot be used as a type: Variable of type `Literal[3]` is not allowed in a type expression +aliases_typealiastype.py:61:42: error[invalid-type-form] Boolean literals are not allowed in this context in a type expression: Did you mean `typing.Literal[True]`? +aliases_typealiastype.py:62:42: error[invalid-type-form] Int literals are not allowed in this context in a type expression: Did you mean `typing.Literal[1]`? +aliases_typealiastype.py:63:42: error[invalid-type-form] Boolean operations are not allowed in type expressions +aliases_typealiastype.py:64:42: error[invalid-type-form] F-strings are not allowed in type expressions +aliases_typealiastype.py:66:47: error[unresolved-reference] Name `BadAlias21` used when not defined +""" diff --git a/conformance/results/ty/aliases_variance.toml b/conformance/results/ty/aliases_variance.toml new file mode 100644 index 000000000..9b8afdb53 --- /dev/null +++ b/conformance/results/ty/aliases_variance.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +aliases_variance.py:24:16: error[invalid-generic-class] Variance of type variable `T_co` is incompatible with base class `ClassA` +aliases_variance.py:28:16: error[invalid-generic-class] Variance of type variable `T_co` is incompatible with base class `ClassA` +aliases_variance.py:32:16: error[invalid-generic-class] Variance of type variable `T_co` is incompatible with base class `ClassA` +aliases_variance.py:44:16: error[invalid-generic-class] Variance of type variable `T_contra` is incompatible with base class `ClassB` +""" diff --git a/conformance/results/ty/annotations_coroutines.toml b/conformance/results/ty/annotations_coroutines.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/ty/annotations_coroutines.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/ty/annotations_forward_refs.toml b/conformance/results/ty/annotations_forward_refs.toml new file mode 100644 index 000000000..5d067ef53 --- /dev/null +++ b/conformance/results/ty/annotations_forward_refs.toml @@ -0,0 +1,32 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +annotations_forward_refs.py:22:7: error[unresolved-reference] Name `ClassA` used when not defined +annotations_forward_refs.py:23:12: error[unresolved-reference] Name `ClassA` used when not defined +annotations_forward_refs.py:24:7: error[unsupported-operator] Operator `|` is unsupported between objects of type `Literal["ClassA"]` and `` +annotations_forward_refs.py:25:7: error[unsupported-operator] Operator `|` is unsupported between objects of type `` and `Literal["ClassA"]` +annotations_forward_refs.py:41:10: error[invalid-type-form] Function calls are not allowed in parameter annotations +annotations_forward_refs.py:42:10: error[invalid-type-form] List literals are not allowed in this context in a parameter annotation +annotations_forward_refs.py:43:10: error[invalid-type-form] Tuple literals are not allowed in this context in a parameter annotation: Did you mean `tuple[int, str]`? +annotations_forward_refs.py:44:10: error[invalid-type-form] List comprehensions are not allowed in parameter annotations +annotations_forward_refs.py:45:10: error[invalid-type-form] Dict literals are not allowed in parameter annotations +annotations_forward_refs.py:46:10: error[invalid-type-form] Function calls are not allowed in parameter annotations +annotations_forward_refs.py:47:10: error[invalid-type-form] Only simple names and dotted names can be subscripted in parameter annotations +annotations_forward_refs.py:48:10: error[invalid-type-form] `if` expressions are not allowed in parameter annotations +annotations_forward_refs.py:49:10: error[invalid-type-form] Variable `var1` cannot be used as a type: Variable of type `Literal[1]` is not allowed in a parameter annotation +annotations_forward_refs.py:50:11: error[invalid-type-form] Boolean literals are not allowed in this context in a parameter annotation: Did you mean `typing.Literal[True]`? +annotations_forward_refs.py:51:11: error[invalid-type-form] Int literals are not allowed in this context in a parameter annotation: Did you mean `typing.Literal[1]`? +annotations_forward_refs.py:52:11: error[invalid-type-form] Unary operations are not allowed in parameter annotations +annotations_forward_refs.py:53:11: error[invalid-type-form] Boolean operations are not allowed in parameter annotations +annotations_forward_refs.py:54:11: error[invalid-type-form] F-strings are not allowed in parameter annotations +annotations_forward_refs.py:55:11: error[invalid-type-form] Module `types` is not valid in a parameter annotation +annotations_forward_refs.py:65:26: error[unresolved-reference] Name `ClassB` used when not defined +annotations_forward_refs.py:83:13: error[unresolved-reference] Name `ClassInner` used when not defined +annotations_forward_refs.py:92:14: error[unresolved-reference] Name `ClassF` used when not defined +annotations_forward_refs.py:94:11: error[invalid-type-form] Variable of type `Literal[""]` is not allowed in a type expression +annotations_forward_refs.py:96:9: error[invalid-type-form] Function `int` is not valid in a type expression +annotations_forward_refs.py:101:8: error[invalid-type-form] Function `int` is not valid in a type expression +annotations_forward_refs.py:103:9: error[invalid-type-form] Function `int` is not valid in a type expression +annotations_forward_refs.py:111:5: error[type-assertion-failure] Type `Unknown` does not match asserted type `ClassInner` +""" diff --git a/conformance/results/ty/annotations_future_import.toml b/conformance/results/ty/annotations_future_import.toml new file mode 100644 index 000000000..73fabcb97 --- /dev/null +++ b/conformance/results/ty/annotations_future_import.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +annotations_future_import.py:37:10: error[invalid-type-form] Variable of type `Literal[""]` is not allowed in a type expression +annotations_future_import.py:39:8: error[invalid-type-form] Function `int` is not valid in a type expression +annotations_future_import.py:44:8: error[invalid-type-form] Function `int` is not valid in a type expression +annotations_future_import.py:46:9: error[invalid-type-form] Function `int` is not valid in a type expression +""" diff --git a/conformance/results/ty/annotations_generators.toml b/conformance/results/ty/annotations_generators.toml new file mode 100644 index 000000000..1f05f0b0b --- /dev/null +++ b/conformance/results/ty/annotations_generators.toml @@ -0,0 +1,15 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +annotations_generators.py:51:21: error[invalid-return-type] Function can implicitly return `None`, which is not assignable to return type `C` +annotations_generators.py:54:16: error[invalid-return-type] Return type does not match returned value: expected `C`, found `Literal[False]` +annotations_generators.py:57:15: error[invalid-yield] Yield type `Literal[3]` does not match annotated yield type `A` +annotations_generators.py:66:15: error[invalid-yield] Yield type `Literal[3]` does not match annotated yield type `A` +annotations_generators.py:75:11: error[invalid-yield] Yield type `B` does not match annotated yield type `A` +annotations_generators.py:86:21: error[invalid-return-type] Return type does not match returned value: expected `int`, found `types.GeneratorType` +annotations_generators.py:91:27: error[invalid-return-type] Return type does not match returned value: expected `int`, found `types.AsyncGeneratorType` +annotations_generators.py:118:16: error[invalid-yield] Yield type `A` does not match annotated yield type `B` +annotations_generators.py:119:16: error[invalid-yield] Yield type `int` does not match annotated yield type `B` +annotations_generators.py:135:16: error[invalid-yield] Send type `int` does not match annotated send type `str` +""" diff --git a/conformance/results/ty/annotations_methods.toml b/conformance/results/ty/annotations_methods.toml new file mode 100644 index 000000000..5800c037c --- /dev/null +++ b/conformance/results/ty/annotations_methods.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +annotations_methods.py:42:1: error[type-assertion-failure] Type `B` does not match asserted type `A` +""" diff --git a/conformance/results/ty/annotations_typeexpr.toml b/conformance/results/ty/annotations_typeexpr.toml new file mode 100644 index 000000000..0242d5dc9 --- /dev/null +++ b/conformance/results/ty/annotations_typeexpr.toml @@ -0,0 +1,20 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +annotations_typeexpr.py:88:9: error[invalid-type-form] Function calls are not allowed in parameter annotations +annotations_typeexpr.py:89:9: error[invalid-type-form] List literals are not allowed in this context in a parameter annotation +annotations_typeexpr.py:90:9: error[invalid-type-form] Tuple literals are not allowed in this context in a parameter annotation: Did you mean `tuple[int, str]`? +annotations_typeexpr.py:91:9: error[invalid-type-form] List comprehensions are not allowed in parameter annotations +annotations_typeexpr.py:92:9: error[invalid-type-form] Dict literals are not allowed in parameter annotations +annotations_typeexpr.py:93:9: error[invalid-type-form] Function calls are not allowed in parameter annotations +annotations_typeexpr.py:94:9: error[invalid-type-form] Only simple names and dotted names can be subscripted in parameter annotations +annotations_typeexpr.py:95:9: error[invalid-type-form] `if` expressions are not allowed in parameter annotations +annotations_typeexpr.py:96:9: error[invalid-type-form] Variable `var1` cannot be used as a type: Variable of type `Literal[3]` is not allowed in a parameter annotation +annotations_typeexpr.py:97:10: error[invalid-type-form] Boolean literals are not allowed in this context in a parameter annotation: Did you mean `typing.Literal[True]`? +annotations_typeexpr.py:98:10: error[invalid-type-form] Int literals are not allowed in this context in a parameter annotation: Did you mean `typing.Literal[1]`? +annotations_typeexpr.py:99:10: error[invalid-type-form] Unary operations are not allowed in parameter annotations +annotations_typeexpr.py:100:10: error[invalid-type-form] Boolean operations are not allowed in parameter annotations +annotations_typeexpr.py:101:10: error[invalid-type-form] F-strings are not allowed in parameter annotations +annotations_typeexpr.py:102:10: error[invalid-type-form] Module `types` is not valid in a parameter annotation +""" diff --git a/conformance/results/ty/callables_annotation.toml b/conformance/results/ty/callables_annotation.toml new file mode 100644 index 000000000..5f68e9f54 --- /dev/null +++ b/conformance/results/ty/callables_annotation.toml @@ -0,0 +1,25 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +callables_annotation.py:25:5: error[missing-argument] No argument provided for required parameter 2 +callables_annotation.py:26:11: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `Literal[2]` +callables_annotation.py:27:15: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 +callables_annotation.py:29:5: error[missing-argument] No arguments provided for required parameters 1, 2 +callables_annotation.py:29:8: error[unknown-argument] Argument `a` does not match any known parameter +callables_annotation.py:29:13: error[unknown-argument] Argument `b` does not match any known parameter +callables_annotation.py:35:8: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 1 +callables_annotation.py:55:5: error[invalid-type-form] Special form `Callable` expected exactly two arguments (parameter types and return type) +callables_annotation.py:55:14: error[invalid-type-form] The first argument to `Callable` must be either a list of types, ParamSpec, Concatenate, or `...` +callables_annotation.py:56:14: error[invalid-type-form] The first argument to `Callable` must be either a list of types, ParamSpec, Concatenate, or `...` +callables_annotation.py:57:18: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[int]`? +callables_annotation.py:58:5: error[invalid-type-form] Special form `Callable` expected exactly two arguments (parameter types and return type) +callables_annotation.py:58:14: error[invalid-type-form] The first argument to `Callable` must be either a list of types, ParamSpec, Concatenate, or `...` +callables_annotation.py:59:14: error[invalid-type-form] `[...]` is not a valid parameter list for `Callable`: Did you mean `Callable[..., int]`? +callables_annotation.py:91:7: error[invalid-assignment] Object of type `def test_cb2() -> str` is not assignable to `(int, /, *args: Any, **kwargs: Any) -> str` +callables_annotation.py:93:7: error[invalid-assignment] Object of type `def test_cb4(*, a: int) -> str` is not assignable to `(int, /, *args: Any, **kwargs: Any) -> str` +callables_annotation.py:159:25: error[invalid-assignment] Object of type `Proto8` is not assignable to `Proto5[Any]` +callables_annotation.py:172:26: error[invalid-assignment] Object of type `() -> str` is not assignable to `(int, /, *args: Any, **kwargs: Any) -> str` +callables_annotation.py:187:48: error[invalid-assignment] Object of type `(int, str, /) -> str` is not assignable to `(str, /, *args: Any, **kwargs: Any) -> str` +callables_annotation.py:189:32: error[invalid-assignment] Object of type `(int, str, /) -> str` is not assignable to `(str, /, *args: Any, **kwargs: Any) -> str` +""" diff --git a/conformance/results/ty/callables_kwargs.toml b/conformance/results/ty/callables_kwargs.toml new file mode 100644 index 000000000..3318d6bb6 --- /dev/null +++ b/conformance/results/ty/callables_kwargs.toml @@ -0,0 +1,20 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +callables_kwargs.py:46:5: error[missing-argument] No arguments provided for required parameters `v1`, `v3` of function `func1` +callables_kwargs.py:52:5: error[missing-argument] No arguments provided for required parameters `v1`, `v3` of function `func1` +callables_kwargs.py:52:11: error[too-many-positional-arguments] Too many positional arguments to function `func1`: expected 0, got 3 +callables_kwargs.py:58:11: error[invalid-argument-type] Argument to function `func1` is incorrect: Expected `int`, found `str` +callables_kwargs.py:61:11: error[invalid-argument-type] Argument to function `func1` is incorrect: Expected `str`, found `int | str` +callables_kwargs.py:63:17: error[parameter-already-assigned] Multiple values provided for parameter `v1` of function `func1` +callables_kwargs.py:64:11: error[invalid-argument-type] Argument to function `func2` is incorrect: Expected `str`, found `Literal[1]` +callables_kwargs.py:64:14: error[parameter-already-assigned] Multiple values provided for parameter `v3` of function `func2` +callables_kwargs.py:65:17: error[parameter-already-assigned] Multiple values provided for parameter `v1` of function `func2` +callables_kwargs.py:101:19: error[invalid-assignment] Object of type `def func1(*, v1: int, v2: str = ..., v3: str, **kwargs: object) -> None` is not assignable to `TDProtocol3` +callables_kwargs.py:102:19: error[invalid-assignment] Object of type `def func1(*, v1: int, v2: str = ..., v3: str, **kwargs: object) -> None` is not assignable to `TDProtocol4` +callables_kwargs.py:103:19: error[invalid-assignment] Object of type `def func1(*, v1: int, v2: str = ..., v3: str, **kwargs: object) -> None` is not assignable to `TDProtocol5` +callables_kwargs.py:111:20: error[invalid-type-form] Parameter `v1` overlaps with unpacked TypedDict key in `**kwargs` annotation +callables_kwargs.py:122:21: error[invalid-type-form] Unpacked value for `**kwargs` must be a TypedDict, not `T@func6` +callables_kwargs.py:134:19: error[invalid-assignment] Object of type `def func7(*, v1: int, v3: str, v2: str = "") -> None` is not assignable to `TDProtocol6` +""" diff --git a/conformance/results/ty/callables_protocol.toml b/conformance/results/ty/callables_protocol.toml new file mode 100644 index 000000000..cab2ecce2 --- /dev/null +++ b/conformance/results/ty/callables_protocol.toml @@ -0,0 +1,22 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +callables_protocol.py:35:7: error[invalid-assignment] Object of type `def cb1_bad1(*vals: bytes, max_items: int | None) -> list[bytes]` is not assignable to `Proto1` +callables_protocol.py:36:7: error[invalid-assignment] Object of type `def cb1_bad2(*vals: bytes) -> list[bytes]` is not assignable to `Proto1` +callables_protocol.py:37:7: error[invalid-assignment] Object of type `def cb1_bad3(*vals: bytes, max_len: str | None) -> list[bytes]` is not assignable to `Proto1` +callables_protocol.py:67:7: error[invalid-assignment] Object of type `def cb2_bad1(*a: bytes) -> Unknown` is not assignable to `Proto2` +callables_protocol.py:68:7: error[invalid-assignment] Object of type `def cb2_bad2(*a: str, **b: str) -> Unknown` is not assignable to `Proto2` +callables_protocol.py:69:7: error[invalid-assignment] Object of type `def cb2_bad3(*a: bytes, **b: bytes) -> Unknown` is not assignable to `Proto2` +callables_protocol.py:70:7: error[invalid-assignment] Object of type `def cb2_bad4(**b: str) -> Unknown` is not assignable to `Proto2` +callables_protocol.py:97:16: error[invalid-assignment] Object of type `def cb4_bad1(x: int) -> None` is not assignable to `Proto4` +callables_protocol.py:121:18: error[invalid-assignment] Object of type `def cb6_bad1(*vals: bytes, max_len: int | None = None) -> list[bytes]` is not assignable to `NotProto6` +callables_protocol.py:169:7: error[invalid-assignment] Object of type `def cb8_bad1(x: int) -> Any` is not assignable to `Proto8` +callables_protocol.py:186:5: error[invalid-assignment] Object of type `Literal["str"]` is not assignable to attribute `other_attribute` of type `int` +callables_protocol.py:187:5: error[unresolved-attribute] Unresolved attribute `xxx` on type `Proto9[P@decorator1, R@decorator1]` +callables_protocol.py:197:7: error[unresolved-attribute] Object of type `Proto9[(x: int), str]` has no attribute `other_attribute2` +callables_protocol.py:238:8: error[invalid-assignment] Object of type `def cb11_bad1(x: int, y: str, /) -> Any` is not assignable to `Proto11` +callables_protocol.py:260:8: error[invalid-assignment] Object of type `def cb12_bad1(*args: Any, kwarg0: Any) -> None` is not assignable to `Proto12` +callables_protocol.py:284:27: error[invalid-assignment] Object of type `def cb13_no_default(path: str) -> str` is not assignable to `Proto13_Default` +callables_protocol.py:311:27: error[invalid-assignment] Object of type `def cb14_no_default(*, path: str) -> str` is not assignable to `Proto14_Default` +""" diff --git a/conformance/results/ty/callables_subtyping.toml b/conformance/results/ty/callables_subtyping.toml new file mode 100644 index 000000000..b5cf55fac --- /dev/null +++ b/conformance/results/ty/callables_subtyping.toml @@ -0,0 +1,37 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +callables_subtyping.py:26:36: error[invalid-assignment] Object of type `(int, /) -> int` is not assignable to `(float, /) -> float` +callables_subtyping.py:29:32: error[invalid-assignment] Object of type `(float, /) -> float` is not assignable to `(int, /) -> int` +callables_subtyping.py:51:21: error[invalid-assignment] Object of type `PosOnly2` is not assignable to `Standard2` +callables_subtyping.py:52:21: error[invalid-assignment] Object of type `KwOnly2` is not assignable to `Standard2` +callables_subtyping.py:55:20: error[invalid-assignment] Object of type `KwOnly2` is not assignable to `PosOnly2` +callables_subtyping.py:58:19: error[invalid-assignment] Object of type `PosOnly2` is not assignable to `KwOnly2` +callables_subtyping.py:82:20: error[invalid-assignment] Object of type `NoArgs3` is not assignable to `IntArgs3` +callables_subtyping.py:85:22: error[invalid-assignment] Object of type `NoArgs3` is not assignable to `FloatArgs3` +callables_subtyping.py:86:22: error[invalid-assignment] Object of type `IntArgs3` is not assignable to `FloatArgs3` +callables_subtyping.py:116:20: error[invalid-assignment] Object of type `IntArgs4` is not assignable to `PosOnly4` +callables_subtyping.py:119:23: error[invalid-assignment] Object of type `StrArgs4` is not assignable to `IntStrArgs4` +callables_subtyping.py:120:23: error[invalid-assignment] Object of type `IntArgs4` is not assignable to `IntStrArgs4` +callables_subtyping.py:122:20: error[invalid-assignment] Object of type `IntArgs4` is not assignable to `StrArgs4` +callables_subtyping.py:124:20: error[invalid-assignment] Object of type `StrArgs4` is not assignable to `IntArgs4` +callables_subtyping.py:125:22: error[invalid-assignment] Object of type `IntStrArgs4` is not assignable to `Standard4` +callables_subtyping.py:126:22: error[invalid-assignment] Object of type `StrArgs4` is not assignable to `Standard4` +callables_subtyping.py:151:22: error[invalid-assignment] Object of type `NoKwargs5` is not assignable to `IntKwargs5` +callables_subtyping.py:154:24: error[invalid-assignment] Object of type `NoKwargs5` is not assignable to `FloatKwargs5` +callables_subtyping.py:155:24: error[invalid-assignment] Object of type `IntKwargs5` is not assignable to `FloatKwargs5` +callables_subtyping.py:187:19: error[invalid-assignment] Object of type `IntKwargs6` is not assignable to `KwOnly6` +callables_subtyping.py:190:25: error[invalid-assignment] Object of type `StrKwargs6` is not assignable to `IntStrKwargs6` +callables_subtyping.py:191:25: error[invalid-assignment] Object of type `IntKwargs6` is not assignable to `IntStrKwargs6` +callables_subtyping.py:193:22: error[invalid-assignment] Object of type `IntKwargs6` is not assignable to `StrKwargs6` +callables_subtyping.py:195:22: error[invalid-assignment] Object of type `StrKwargs6` is not assignable to `IntKwargs6` +callables_subtyping.py:196:22: error[invalid-assignment] Object of type `IntStrKwargs6` is not assignable to `Standard6` +callables_subtyping.py:197:22: error[invalid-assignment] Object of type `StrKwargs6` is not assignable to `Standard6` +callables_subtyping.py:236:23: error[invalid-assignment] Object of type `NoDefaultArg8` is not assignable to `DefaultArg8` +callables_subtyping.py:237:23: error[invalid-assignment] Object of type `NoX8` is not assignable to `DefaultArg8` +callables_subtyping.py:240:25: error[invalid-assignment] Object of type `NoX8` is not assignable to `NoDefaultArg8` +callables_subtyping.py:243:16: error[invalid-assignment] Object of type `NoDefaultArg8` is not assignable to `NoX8` +callables_subtyping.py:273:21: error[invalid-assignment] Object of type `Overloaded9` is not assignable to `FloatArg9` +callables_subtyping.py:297:24: error[invalid-assignment] Object of type `StrArg10` is not assignable to `Overloaded10` +""" diff --git a/conformance/results/ty/classes_classvar.toml b/conformance/results/ty/classes_classvar.toml new file mode 100644 index 000000000..253329806 --- /dev/null +++ b/conformance/results/ty/classes_classvar.toml @@ -0,0 +1,24 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +classes_classvar.py:40:11: error[invalid-type-form] Type qualifier `typing.ClassVar` expected exactly 1 argument, got 2 +classes_classvar.py:41:14: error[invalid-type-form] Int literals are not allowed in this context in a type expression: Did you mean `typing.Literal[3]`? +classes_classvar.py:42:14: error[unresolved-reference] Name `var` used when not defined +classes_classvar.py:47:11: error[invalid-type-form] `ClassVar` cannot contain type variables +classes_classvar.py:48:11: error[invalid-type-form] `ClassVar` cannot contain type variables +classes_classvar.py:49:11: error[invalid-type-form] `ClassVar` cannot contain type variables +classes_classvar.py:54:33: error[invalid-assignment] Object of type `dict[Unknown, Unknown]` is not assignable to `list[str]` +classes_classvar.py:56:11: error[redundant-final-classvar] `Combining `ClassVar` and `Final` is redundant +classes_classvar.py:57:17: error[invalid-type-form] Type qualifier `typing.ClassVar` is not allowed in type expressions (only in annotation expressions) +classes_classvar.py:71:26: error[invalid-type-form] Type qualifier `typing.ClassVar` is not allowed in parameter annotations +classes_classvar.py:72:12: error[invalid-type-form] `ClassVar` is only allowed in class bodies +classes_classvar.py:73:18: error[invalid-type-form] `ClassVar` annotations are not allowed for non-name targets +classes_classvar.py:75:26: error[invalid-type-form] Type qualifier `typing.ClassVar` is not allowed in return type annotations +classes_classvar.py:79:8: error[invalid-type-form] `ClassVar` is only allowed in class bodies +classes_classvar.py:80:20: error[invalid-type-form] Type qualifier `typing.ClassVar` is not allowed in type alias definitions +classes_classvar.py:89:8: error[invalid-type-form] `ClassVar` is not allowed in TypedDict fields +classes_classvar.py:94:5: error[invalid-named-tuple] Type qualifier `ClassVar` is not allowed on NamedTuple field `b` +classes_classvar.py:127:1: error[invalid-attribute-access] Cannot assign to ClassVar `stats` from an instance of type `Starship` +classes_classvar.py:156:13: error[invalid-assignment] Object of type `ProtoAImpl` is not assignable to `ProtoA` +""" diff --git a/conformance/results/ty/classes_override.toml b/conformance/results/ty/classes_override.toml new file mode 100644 index 000000000..4da491953 --- /dev/null +++ b/conformance/results/ty/classes_override.toml @@ -0,0 +1,12 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +classes_override.py:53:9: error[invalid-explicit-override] Method `method3` is decorated with `@override` but does not override anything +classes_override.py:65:9: error[invalid-explicit-override] Method `method4` is decorated with `@override` but does not override anything +classes_override.py:79:9: error[invalid-explicit-override] Method `static_method1` is decorated with `@override` but does not override anything +classes_override.py:84:9: error[invalid-explicit-override] Method `class_method1` is decorated with `@override` but does not override anything +classes_override.py:89:9: error[invalid-explicit-override] Method `property1` is decorated with `@override` but does not override anything +classes_override.py:135:9: error[invalid-method-override] Invalid override of method `__init__`: Definition is incompatible with `ParentC.__init__` +classes_override.py:138:9: error[invalid-method-override] Invalid override of method `__new__`: Definition is incompatible with `ParentC.__new__` +""" diff --git a/conformance/results/ty/constructors_call_init.toml b/conformance/results/ty/constructors_call_init.toml new file mode 100644 index 000000000..c6b0eb40a --- /dev/null +++ b/conformance/results/ty/constructors_call_init.toml @@ -0,0 +1,15 @@ +conformance_automated = "Fail" +conformant = "Partial" +notes = """ +Does not reject invalid argument types to an inherited constructor in a specialized subclass of a generic superclass. +""" +errors_diff = """ +Line 42: Expected 1 errors +""" +output = """ +constructors_call_init.py:21:13: error[invalid-argument-type] Argument to `Class1.__init__` is incorrect: Expected `int`, found `float*` +constructors_call_init.py:56:1: error[invalid-argument-type] Argument to `Class4.__init__` is incorrect: Expected `Class4[int]`, found `Class4[str]` +constructors_call_init.py:107:32: error[invalid-init-type-variable] First parameter of `__init__` cannot use type variable `T2` from an outer scope +constructors_call_init.py:107:36: error[invalid-init-type-variable] First parameter of `__init__` cannot use type variable `T1` from an outer scope +constructors_call_init.py:130:9: error[too-many-positional-arguments] Too many positional arguments to `object.__init__`: expected 1, got 2 +""" diff --git a/conformance/results/ty/constructors_call_metaclass.toml b/conformance/results/ty/constructors_call_metaclass.toml new file mode 100644 index 000000000..f7e30d6f0 --- /dev/null +++ b/conformance/results/ty/constructors_call_metaclass.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +conformant = "Pass" +notes = """ +""" +errors_diff = """ +""" +output = """ +constructors_call_metaclass.py:54:1: error[missing-argument] No argument provided for required parameter `x` of constructor `Class3.__new__` +constructors_call_metaclass.py:68:1: error[missing-argument] No argument provided for required parameter `x` of constructor `Class4.__new__` +""" diff --git a/conformance/results/ty/constructors_call_new.toml b/conformance/results/ty/constructors_call_new.toml new file mode 100644 index 000000000..c3424c736 --- /dev/null +++ b/conformance/results/ty/constructors_call_new.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +constructors_call_new.py:21:13: error[invalid-argument-type] Argument to constructor `Class1.__new__` is incorrect: Expected `int`, found `float*` +constructors_call_new.py:148:1: error[invalid-argument-type] Argument to constructor `Class11.__new__` is incorrect: Expected `type[Class11[int]]`, found `` +""" diff --git a/conformance/results/ty/constructors_call_type.toml b/conformance/results/ty/constructors_call_type.toml new file mode 100644 index 000000000..3d3e7f8b5 --- /dev/null +++ b/conformance/results/ty/constructors_call_type.toml @@ -0,0 +1,14 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +constructors_call_type.py:19:55: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive +constructors_call_type.py:30:5: error[missing-argument] No arguments provided for required parameters `x`, `y` of bound method `Meta1.__call__` +constructors_call_type.py:40:5: error[missing-argument] No arguments provided for required parameters `x`, `y` of constructor `Class2.__new__` +constructors_call_type.py:50:5: error[missing-argument] No arguments provided for required parameters `x`, `y` of `Class3.__init__` +constructors_call_type.py:59:9: error[too-many-positional-arguments] Too many positional arguments to `object.__init__`: expected 1, got 2 +constructors_call_type.py:64:9: error[too-many-positional-arguments] Too many positional arguments to `type[T]`: expected 0, got 1 +constructors_call_type.py:72:5: error[missing-argument] No arguments provided for required parameters `x`, `y` of bound method `Meta1.__call__` +constructors_call_type.py:81:5: error[missing-argument] No argument provided for required parameter `y` of constructor `Class2.__new__` +constructors_call_type.py:82:12: error[invalid-argument-type] Argument to constructor `Class2.__new__` is incorrect: Expected `str`, found `Literal[2]` +""" diff --git a/conformance/results/ty/constructors_callable.toml b/conformance/results/ty/constructors_callable.toml new file mode 100644 index 000000000..7f22bcaae --- /dev/null +++ b/conformance/results/ty/constructors_callable.toml @@ -0,0 +1,43 @@ +conformance_automated = "Fail" +conformant = "Partial" +notes = """ +Does not include `__init__` when `__new__` returns `Self`. +Does not ignore `__init__` when `__new__` returns `Any`. +Unions overload return types. +""" +errors_diff = """ +Line 66: Expected 1 errors +Line 67: Expected 1 errors +Line 68: Expected 1 errors +Line 143: Unexpected errors ["constructors_callable.py:143:27: error[invalid-argument-type] Argument to function `accepts_callable` is incorrect: Expected `() -> Any | Class6Any`, found ``"] +Line 145: Unexpected errors ['constructors_callable.py:145:1: error[type-assertion-failure] Type `Any | Class6Any` does not match asserted type `Any`'] +Line 166: Unexpected errors ['constructors_callable.py:166:1: error[type-assertion-failure] Type `Class7[int] | Class7[str]` does not match asserted type `Class7[int]`'] +Line 167: Unexpected errors ['constructors_callable.py:167:1: error[type-assertion-failure] Type `Class7[int] | Class7[str]` does not match asserted type `Class7[str]`'] +""" +output = """ +constructors_callable.py:36:13: info[revealed-type] Revealed type: `(x: int) -> Class1` +constructors_callable.py:38:1: error[missing-argument] No argument provided for required parameter `x` +constructors_callable.py:39:1: error[missing-argument] No argument provided for required parameter `x` +constructors_callable.py:39:4: error[unknown-argument] Argument `y` does not match any known parameter +constructors_callable.py:49:13: info[revealed-type] Revealed type: `() -> Class2` +constructors_callable.py:51:4: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 1 +constructors_callable.py:64:13: info[revealed-type] Revealed type: `(...) -> Class3` +constructors_callable.py:79:13: info[revealed-type] Revealed type: `(x: int) -> int` +constructors_callable.py:81:1: error[missing-argument] No argument provided for required parameter `x` +constructors_callable.py:82:1: error[missing-argument] No argument provided for required parameter `x` +constructors_callable.py:82:4: error[unknown-argument] Argument `y` does not match any known parameter +constructors_callable.py:99:13: info[revealed-type] Revealed type: `(...) -> Never` +constructors_callable.py:127:13: info[revealed-type] Revealed type: `() -> Class6Proxy` +constructors_callable.py:129:4: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 1 +constructors_callable.py:143:27: error[invalid-argument-type] Argument to function `accepts_callable` is incorrect: Expected `() -> Any | Class6Any`, found `` +constructors_callable.py:144:13: info[revealed-type] Revealed type: `() -> Any | Class6Any` +constructors_callable.py:145:1: error[type-assertion-failure] Type `Any | Class6Any` does not match asserted type `Any` +constructors_callable.py:146:8: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 1 +constructors_callable.py:164:5: info[revealed-type] Revealed type: `Overload[[T](x: int) -> Class7[int] | Class7[str], [T](x: str) -> Class7[int] | Class7[str]]` +constructors_callable.py:166:1: error[type-assertion-failure] Type `Class7[int] | Class7[str]` does not match asserted type `Class7[int]` +constructors_callable.py:167:1: error[type-assertion-failure] Type `Class7[int] | Class7[str]` does not match asserted type `Class7[str]` +constructors_callable.py:184:13: info[revealed-type] Revealed type: `[T](x: list[T], y: list[T]) -> Class8[T]` +constructors_callable.py:185:10: error[invalid-argument-type] Argument is incorrect: Expected `list[str]`, found `Literal["not a list"]` +constructors_callable.py:196:13: info[revealed-type] Revealed type: `[T](x: list[T], y: list[T]) -> Class9` +constructors_callable.py:197:10: error[invalid-argument-type] Argument is incorrect: Expected `list[str]`, found `Literal["not a list"]` +""" diff --git a/conformance/results/ty/constructors_consistency.toml b/conformance/results/ty/constructors_consistency.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/ty/constructors_consistency.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/ty/dataclasses_descriptors.toml b/conformance/results/ty/dataclasses_descriptors.toml new file mode 100644 index 000000000..91ad20b90 --- /dev/null +++ b/conformance/results/ty/dataclasses_descriptors.toml @@ -0,0 +1,13 @@ +conformance_automated = "Fail" +conformant = "Partial" +notes = """ +Only infers a descriptor `__get__` method as being called when a descriptor attribute is accessed on an instance if the descriptor attribute is present in the class namespace. +""" +errors_diff = """ +Line 66: Unexpected errors ['dataclasses_descriptors.py:66:1: error[type-assertion-failure] Type `int | Desc2[int]` does not match asserted type `int`'] +Line 67: Unexpected errors ['dataclasses_descriptors.py:67:1: error[type-assertion-failure] Type `str | Desc2[str]` does not match asserted type `str`'] +""" +output = """ +dataclasses_descriptors.py:66:1: error[type-assertion-failure] Type `int | Desc2[int]` does not match asserted type `int` +dataclasses_descriptors.py:67:1: error[type-assertion-failure] Type `str | Desc2[str]` does not match asserted type `str` +""" diff --git a/conformance/results/ty/dataclasses_final.toml b/conformance/results/ty/dataclasses_final.toml new file mode 100644 index 000000000..aea48b761 --- /dev/null +++ b/conformance/results/ty/dataclasses_final.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_final.py:27:1: error[invalid-assignment] Cannot assign to final attribute `final_classvar` on type ``: `Final` attributes can only be assigned in the class body, `__init__`, or `__post_init__` on dataclass-like classes +dataclasses_final.py:35:1: error[invalid-assignment] Cannot assign to final attribute `final_no_default` on type `D`: `Final` attributes can only be assigned in the class body, `__init__`, or `__post_init__` on dataclass-like classes +dataclasses_final.py:36:1: error[invalid-assignment] Cannot assign to final attribute `final_with_default` on type `D`: `Final` attributes can only be assigned in the class body, `__init__`, or `__post_init__` on dataclass-like classes +dataclasses_final.py:37:1: error[invalid-assignment] Cannot assign to final attribute `final_no_default` on type ``: `Final` attributes can only be assigned in the class body, `__init__`, or `__post_init__` on dataclass-like classes +dataclasses_final.py:38:1: error[invalid-assignment] Cannot assign to final attribute `final_with_default` on type ``: `Final` attributes can only be assigned in the class body, `__init__`, or `__post_init__` on dataclass-like classes +""" diff --git a/conformance/results/ty/dataclasses_frozen.toml b/conformance/results/ty/dataclasses_frozen.toml new file mode 100644 index 000000000..410316402 --- /dev/null +++ b/conformance/results/ty/dataclasses_frozen.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_frozen.py:16:1: error[invalid-assignment] Property `a` defined in `DC1` is read-only +dataclasses_frozen.py:17:1: error[invalid-assignment] Property `b` defined in `DC1` is read-only +dataclasses_frozen.py:23:7: error[invalid-frozen-dataclass-subclass] Non-frozen dataclass `DC2` cannot inherit from frozen dataclass `DC1` +dataclasses_frozen.py:33:7: error[invalid-frozen-dataclass-subclass] Frozen dataclass `DC4` cannot inherit from non-frozen dataclass `DC3` +""" diff --git a/conformance/results/ty/dataclasses_hash.toml b/conformance/results/ty/dataclasses_hash.toml new file mode 100644 index 000000000..dc083d25b --- /dev/null +++ b/conformance/results/ty/dataclasses_hash.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_hash.py:17:1: error[call-non-callable] Object of type `None` is not callable +dataclasses_hash.py:18:16: error[invalid-assignment] Object of type `DC1` is not assignable to `Hashable` +dataclasses_hash.py:39:1: error[call-non-callable] Object of type `None` is not callable +dataclasses_hash.py:40:16: error[invalid-assignment] Object of type `DC3` is not assignable to `Hashable` +""" diff --git a/conformance/results/ty/dataclasses_inheritance.toml b/conformance/results/ty/dataclasses_inheritance.toml new file mode 100644 index 000000000..fa6332619 --- /dev/null +++ b/conformance/results/ty/dataclasses_inheritance.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_inheritance.py:62:5: error[invalid-attribute-override] Invalid override of attribute `x`: class variable cannot override instance variable `DC6.x` +dataclasses_inheritance.py:66:5: error[invalid-attribute-override] Invalid override of attribute `y`: instance variable cannot override class variable `DC6.y` +""" diff --git a/conformance/results/ty/dataclasses_kwonly.toml b/conformance/results/ty/dataclasses_kwonly.toml new file mode 100644 index 000000000..902795f6f --- /dev/null +++ b/conformance/results/ty/dataclasses_kwonly.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_kwonly.py:23:11: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 +dataclasses_kwonly.py:38:11: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 +dataclasses_kwonly.py:53:11: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 +""" diff --git a/conformance/results/ty/dataclasses_match_args.toml b/conformance/results/ty/dataclasses_match_args.toml new file mode 100644 index 000000000..2b13c1886 --- /dev/null +++ b/conformance/results/ty/dataclasses_match_args.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_match_args.py:42:1: error[unresolved-attribute] Class `DC4` has no attribute `__match_args__` +""" diff --git a/conformance/results/ty/dataclasses_order.toml b/conformance/results/ty/dataclasses_order.toml new file mode 100644 index 000000000..cd0a0cb47 --- /dev/null +++ b/conformance/results/ty/dataclasses_order.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_order.py:50:4: error[unsupported-operator] Operator `<` is not supported between objects of type `DC1` and `DC2` +""" diff --git a/conformance/results/ty/dataclasses_postinit.toml b/conformance/results/ty/dataclasses_postinit.toml new file mode 100644 index 000000000..83f2f2416 --- /dev/null +++ b/conformance/results/ty/dataclasses_postinit.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_postinit.py:19:9: error[invalid-dataclass] Invalid `__post_init__` signature for dataclass `DC1` +dataclasses_postinit.py:28:7: error[unresolved-attribute] Object of type `DC1` has no attribute `x` +dataclasses_postinit.py:29:7: error[unresolved-attribute] Object of type `DC1` has no attribute `y` +dataclasses_postinit.py:36:9: error[invalid-dataclass] Invalid `__post_init__` signature for dataclass `DC2` +""" diff --git a/conformance/results/ty/dataclasses_slots.toml b/conformance/results/ty/dataclasses_slots.toml new file mode 100644 index 000000000..916d88e0e --- /dev/null +++ b/conformance/results/ty/dataclasses_slots.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_slots.py:11:7: error[invalid-dataclass] Dataclass `DC1` cannot combine `slots=True` with manually assigned `__slots__` +dataclasses_slots.py:25:9: error[unresolved-attribute] Unresolved attribute `y` on type `Self@__init__` +dataclasses_slots.py:38:9: error[unresolved-attribute] Unresolved attribute `y` on type `Self@__init__` +dataclasses_slots.py:66:1: error[unresolved-attribute] Class `DC6` has no attribute `__slots__` +dataclasses_slots.py:69:1: error[unresolved-attribute] Object of type `DC6` has no attribute `__slots__` +""" diff --git a/conformance/results/ty/dataclasses_transform_class.toml b/conformance/results/ty/dataclasses_transform_class.toml new file mode 100644 index 000000000..5756e69dc --- /dev/null +++ b/conformance/results/ty/dataclasses_transform_class.toml @@ -0,0 +1,13 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_transform_class.py:51:7: error[invalid-frozen-dataclass-subclass] Non-frozen dataclass `Customer1Subclass` cannot inherit from frozen dataclass `Customer1` +dataclasses_transform_class.py:63:1: error[invalid-assignment] Property `id` defined in `Customer1` is read-only +dataclasses_transform_class.py:66:8: error[missing-argument] No arguments provided for required parameters `id`, `name` +dataclasses_transform_class.py:66:18: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 2 +dataclasses_transform_class.py:72:6: error[unsupported-operator] Operator `<` is not supported between two objects of type `Customer1` +dataclasses_transform_class.py:82:8: error[missing-argument] No argument provided for required parameter `id` +dataclasses_transform_class.py:82:18: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 2 +dataclasses_transform_class.py:122:1: error[invalid-assignment] Property `id` defined in `Customer3` is read-only +""" diff --git a/conformance/results/ty/dataclasses_transform_converter.toml b/conformance/results/ty/dataclasses_transform_converter.toml new file mode 100644 index 000000000..a327291ff --- /dev/null +++ b/conformance/results/ty/dataclasses_transform_converter.toml @@ -0,0 +1,14 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_transform_converter.py:48:31: error[invalid-argument-type] Argument to function `model_field` is incorrect: Expected `(Unknown, /) -> Unknown`, found `def bad_converter1() -> int` +dataclasses_transform_converter.py:49:31: error[invalid-argument-type] Argument to function `model_field` is incorrect: Expected `(Unknown, /) -> Unknown`, found `def bad_converter2(*, x: int) -> int` +dataclasses_transform_converter.py:107:5: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `Literal[1]` +dataclasses_transform_converter.py:108:23: error[invalid-argument-type] Argument is incorrect: Expected `str | bytes`, found `Literal[1]` +dataclasses_transform_converter.py:109:29: error[invalid-argument-type] Argument is incorrect: Expected `str | list[str]`, found `complex*` +dataclasses_transform_converter.py:118:1: error[invalid-assignment] Object of type `Literal[1]` is not assignable to attribute `field0` of type `str` +dataclasses_transform_converter.py:119:1: error[invalid-assignment] Object of type `Literal[1]` is not assignable to attribute `field3` of type `str | bytes` +dataclasses_transform_converter.py:130:31: error[invalid-argument-type] Argument to function `model_field` is incorrect: Expected `(str | Literal[1], /) -> int`, found `def converter_simple(s: str) -> int` +dataclasses_transform_converter.py:133:31: error[invalid-argument-type] Argument to function `model_field` is incorrect: Expected `(str | int, /) -> int`, found `def converter_simple(s: str) -> int` +""" diff --git a/conformance/results/ty/dataclasses_transform_field.toml b/conformance/results/ty/dataclasses_transform_field.toml new file mode 100644 index 000000000..62ef62792 --- /dev/null +++ b/conformance/results/ty/dataclasses_transform_field.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_transform_field.py:64:16: error[unknown-argument] Argument `id` does not match any known parameter +dataclasses_transform_field.py:75:1: error[missing-argument] No argument provided for required parameter `name` +dataclasses_transform_field.py:75:16: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 1 +""" diff --git a/conformance/results/ty/dataclasses_transform_func.toml b/conformance/results/ty/dataclasses_transform_func.toml new file mode 100644 index 000000000..2355c3387 --- /dev/null +++ b/conformance/results/ty/dataclasses_transform_func.toml @@ -0,0 +1,12 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_transform_func.py:56:1: error[invalid-assignment] Object of type `Literal[3]` is not assignable to attribute `name` of type `str` +dataclasses_transform_func.py:60:6: error[unsupported-operator] Operator `<` is not supported between two objects of type `Customer1` +dataclasses_transform_func.py:64:36: error[unknown-argument] Argument `salary` does not match any known parameter +dataclasses_transform_func.py:70:8: error[missing-argument] No arguments provided for required parameters `id`, `name` +dataclasses_transform_func.py:70:18: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 2 +dataclasses_transform_func.py:89:7: error[invalid-frozen-dataclass-subclass] Non-frozen dataclass `Customer3Subclass` cannot inherit from frozen dataclass `Customer3` +dataclasses_transform_func.py:96:1: error[invalid-assignment] Property `id` defined in `Customer3` is read-only +""" diff --git a/conformance/results/ty/dataclasses_transform_meta.toml b/conformance/results/ty/dataclasses_transform_meta.toml new file mode 100644 index 000000000..a2c5e5028 --- /dev/null +++ b/conformance/results/ty/dataclasses_transform_meta.toml @@ -0,0 +1,13 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_transform_meta.py:51:7: error[invalid-frozen-dataclass-subclass] Non-frozen dataclass `Customer1Subclass` cannot inherit from frozen dataclass `Customer1` +dataclasses_transform_meta.py:63:1: error[invalid-assignment] Property `id` defined in `Customer1` is read-only +dataclasses_transform_meta.py:66:8: error[missing-argument] No arguments provided for required parameters `id`, `name` +dataclasses_transform_meta.py:66:18: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 2 +dataclasses_transform_meta.py:73:6: error[unsupported-operator] Operator `<` is not supported between two objects of type `Customer1` +dataclasses_transform_meta.py:83:8: error[missing-argument] No argument provided for required parameter `id` +dataclasses_transform_meta.py:83:18: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 2 +dataclasses_transform_meta.py:103:1: error[invalid-assignment] Property `id` defined in `Customer3` is read-only +""" diff --git a/conformance/results/ty/dataclasses_usage.toml b/conformance/results/ty/dataclasses_usage.toml new file mode 100644 index 000000000..253fe101d --- /dev/null +++ b/conformance/results/ty/dataclasses_usage.toml @@ -0,0 +1,17 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_usage.py:51:6: error[missing-argument] No argument provided for required parameter `unit_price` +dataclasses_usage.py:52:28: error[invalid-argument-type] Argument is incorrect: Expected `float`, found `Literal["price"]` +dataclasses_usage.py:53:36: error[too-many-positional-arguments] Too many positional arguments: expected 3, got 4 +dataclasses_usage.py:62:5: error[dataclass-field-order] Required field `b` cannot be defined after fields with default values +dataclasses_usage.py:68:5: error[dataclass-field-order] Required field `b` cannot be defined after fields with default values +dataclasses_usage.py:74:5: error[dataclass-field-order] Required field `b` cannot be defined after fields with default values +dataclasses_usage.py:84:13: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 +dataclasses_usage.py:89:14: error[invalid-assignment] Object of type `dataclasses.Field[str]` is not assignable to `int` +dataclasses_usage.py:128:8: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 +dataclasses_usage.py:131:1: error[missing-argument] No argument provided for required parameter `y` of `DC8.__init__` +dataclasses_usage.py:180:6: error[too-many-positional-arguments] Too many positional arguments to `object.__init__`: expected 1, got 2 +dataclasses_usage.py:246:12: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 +""" diff --git a/conformance/results/ty/directives_assert_type.toml b/conformance/results/ty/directives_assert_type.toml new file mode 100644 index 000000000..75907e11e --- /dev/null +++ b/conformance/results/ty/directives_assert_type.toml @@ -0,0 +1,12 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +directives_assert_type.py:27:5: error[type-assertion-failure] Type `int | str` does not match asserted type `int` +directives_assert_type.py:28:5: error[type-assertion-failure] Type `int | str` does not match asserted type `Any` +directives_assert_type.py:29:5: error[type-assertion-failure] Type `Any` does not match asserted type `int` +directives_assert_type.py:30:5: error[type-assertion-failure] Type `Literal[4]` does not match asserted type `int` +directives_assert_type.py:32:5: error[missing-argument] No arguments provided for required parameters `value`, `type` of function `assert_type` +directives_assert_type.py:33:5: error[type-assertion-failure] Type `Literal[""]` does not match asserted type `int` +directives_assert_type.py:34:31: error[too-many-positional-arguments] Too many positional arguments to function `assert_type`: expected 2, got 3 +""" diff --git a/conformance/results/ty/directives_cast.toml b/conformance/results/ty/directives_cast.toml new file mode 100644 index 000000000..614f1f93c --- /dev/null +++ b/conformance/results/ty/directives_cast.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +directives_cast.py:15:8: error[missing-argument] No arguments provided for required parameters `typ`, `val` of function `cast` +directives_cast.py:16:13: error[invalid-type-form] Int literals are not allowed in this context in a type expression: Did you mean `typing.Literal[1]`? +directives_cast.py:17:22: error[too-many-positional-arguments] Too many positional arguments to function `cast`: expected 2, got 3 +""" diff --git a/conformance/results/ty/directives_deprecated.toml b/conformance/results/ty/directives_deprecated.toml new file mode 100644 index 000000000..501efb1e3 --- /dev/null +++ b/conformance/results/ty/directives_deprecated.toml @@ -0,0 +1,18 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +directives_deprecated.py:18:44: error[deprecated] The class `Ham` is deprecated: Use Spam instead +directives_deprecated.py:24:9: error[deprecated] The function `norwegian_blue` is deprecated: It is pining for the fjords +directives_deprecated.py:25:13: error[deprecated] The function `norwegian_blue` is deprecated: It is pining for the fjords +directives_deprecated.py:30:1: error[deprecated] The overload of `foo` is deprecated: Only str will be allowed +directives_deprecated.py:34:7: error[deprecated] The class `Ham` is deprecated: Use Spam instead +directives_deprecated.py:41:5: error[deprecated] The function `__add__` is deprecated: There is enough spam in the world +directives_deprecated.py:42:1: error[deprecated] The function `__add__` is deprecated: There is enough spam in the world +directives_deprecated.py:44:6: error[deprecated] The function `greasy` is deprecated: All spam will be equally greasy +directives_deprecated.py:47:6: error[deprecated] The function `shape` is deprecated: Shapes are becoming immutable +directives_deprecated.py:48:6: error[deprecated] The function `shape` is deprecated: Shapes are becoming immutable +directives_deprecated.py:58:1: error[deprecated] The function `__call__` is deprecated: Deprecated +directives_deprecated.py:69:1: error[deprecated] The function `lorem` is deprecated: Deprecated +directives_deprecated.py:98:7: error[deprecated] The function `foo` is deprecated: Deprecated +""" diff --git a/conformance/results/ty/directives_disjoint_base.toml b/conformance/results/ty/directives_disjoint_base.toml new file mode 100644 index 000000000..91204fd31 --- /dev/null +++ b/conformance/results/ty/directives_disjoint_base.toml @@ -0,0 +1,16 @@ +conformance_automated = "Pass" +conformant = "Pass" +notes = """ +""" +errors_diff = """ +""" +output = """ +directives_disjoint_base.py:69:7: error[instance-layout-conflict] Class will raise `TypeError` at runtime due to incompatible bases: Bases `Left` and `Right` cannot be combined in multiple inheritance +directives_disjoint_base.py:73:7: error[instance-layout-conflict] Class will raise `TypeError` at runtime due to incompatible bases: Bases `LeftChild` and `Right` cannot be combined in multiple inheritance +directives_disjoint_base.py:77:7: error[instance-layout-conflict] Class will raise `TypeError` at runtime due to incompatible bases: Bases `LeftAndPlain` and `Right` cannot be combined in multiple inheritance +directives_disjoint_base.py:81:7: error[instance-layout-conflict] Class will raise `TypeError` at runtime due to incompatible bases: Bases `Left` and `Record` cannot be combined in multiple inheritance +directives_disjoint_base.py:105:7: error[instance-layout-conflict] Class will raise `TypeError` at runtime due to incompatible bases: Bases `SlotBase1` and `SlotBase2` cannot be combined in multiple inheritance +directives_disjoint_base.py:113:1: error[invalid-argument-type] Argument to function `disjoint_base` is incorrect: Argument type `def func() -> None` does not satisfy upper bound `type` of type variable `_TC` +directives_disjoint_base.py:118:1: error[invalid-typed-dict-header] `@disjoint_base` cannot be used with `TypedDict` class `Movie` +directives_disjoint_base.py:123:1: error[invalid-protocol] `@disjoint_base` cannot be used with protocol class `SupportsClose` +""" diff --git a/conformance/results/ty/directives_no_type_check.toml b/conformance/results/ty/directives_no_type_check.toml new file mode 100644 index 000000000..bbaa658bc --- /dev/null +++ b/conformance/results/ty/directives_no_type_check.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +directives_no_type_check.py:15:14: error[invalid-assignment] Object of type `Literal[""]` is not assignable to `int` +directives_no_type_check.py:29:7: error[invalid-argument-type] Argument to function `func1` is incorrect: Expected `int`, found `Literal[b"invalid"]` +directives_no_type_check.py:29:19: error[invalid-argument-type] Argument to function `func1` is incorrect: Expected `str`, found `Literal[b"arguments"]` +directives_no_type_check.py:32:1: error[missing-argument] No arguments provided for required parameters `a`, `b` of function `func1` +""" diff --git a/conformance/results/ty/directives_reveal_type.toml b/conformance/results/ty/directives_reveal_type.toml new file mode 100644 index 000000000..aa525cb4c --- /dev/null +++ b/conformance/results/ty/directives_reveal_type.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +directives_reveal_type.py:14:17: info[revealed-type] Revealed type: `int | str` +directives_reveal_type.py:15:17: info[revealed-type] Revealed type: `list[int]` +directives_reveal_type.py:16:17: info[revealed-type] Revealed type: `Any` +directives_reveal_type.py:17:17: info[revealed-type] Revealed type: `ForwardReference` +directives_reveal_type.py:19:5: error[missing-argument] No argument provided for required parameter `obj` of function `reveal_type` +directives_reveal_type.py:20:20: error[too-many-positional-arguments] Too many positional arguments to function `reveal_type`: expected 1, got 2 +""" diff --git a/conformance/results/ty/directives_type_checking.toml b/conformance/results/ty/directives_type_checking.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/ty/directives_type_checking.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/ty/directives_type_ignore.toml b/conformance/results/ty/directives_type_ignore.toml new file mode 100644 index 000000000..d4a44dd67 --- /dev/null +++ b/conformance/results/ty/directives_type_ignore.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +directives_type_ignore.py:16:10: error[invalid-assignment] Object of type `Literal[""]` is not assignable to `int` +""" diff --git a/conformance/results/ty/directives_type_ignore_file1.toml b/conformance/results/ty/directives_type_ignore_file1.toml new file mode 100644 index 000000000..4c7c7e858 --- /dev/null +++ b/conformance/results/ty/directives_type_ignore_file1.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +directives_type_ignore_file1.py:11:7: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive +directives_type_ignore_file1.py:14:17: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive +""" diff --git a/conformance/results/ty/directives_type_ignore_file2.toml b/conformance/results/ty/directives_type_ignore_file2.toml new file mode 100644 index 000000000..76fb1fde2 --- /dev/null +++ b/conformance/results/ty/directives_type_ignore_file2.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +directives_type_ignore_file2.py:7:1: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive +directives_type_ignore_file2.py:9:7: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive +directives_type_ignore_file2.py:12:17: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive +directives_type_ignore_file2.py:14:10: error[invalid-assignment] Object of type `Literal[""]` is not assignable to `int` +""" diff --git a/conformance/results/ty/directives_version_platform.toml b/conformance/results/ty/directives_version_platform.toml new file mode 100644 index 000000000..c74b90393 --- /dev/null +++ b/conformance/results/ty/directives_version_platform.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +directives_version_platform.py:33:19: error[unresolved-reference] Name `val3` used when not defined +directives_version_platform.py:50:19: error[unresolved-reference] Name `val6` used when not defined +directives_version_platform.py:59:19: error[unresolved-reference] Name `val9` used when not defined +directives_version_platform.py:66:19: error[unresolved-reference] Name `val10` used when not defined +directives_version_platform.py:75:19: error[unresolved-reference] Name `val13` used when not defined +""" diff --git a/conformance/results/ty/enums_behaviors.toml b/conformance/results/ty/enums_behaviors.toml new file mode 100644 index 000000000..2a9f002be --- /dev/null +++ b/conformance/results/ty/enums_behaviors.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +enums_behaviors.py:28:1: error[type-assertion-failure] Type `Color` does not match asserted type `Literal[Color.RED]` +enums_behaviors.py:32:1: error[type-assertion-failure] Type `Color` does not match asserted type `Literal[Color.BLUE]` +enums_behaviors.py:44:21: error[subclass-of-final-class] Class `ExtendedShape` cannot inherit from final class `Shape` +""" diff --git a/conformance/results/ty/enums_definition.toml b/conformance/results/ty/enums_definition.toml new file mode 100644 index 000000000..09271fcdf --- /dev/null +++ b/conformance/results/ty/enums_definition.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +enums_definition.py:25:32: error[too-many-positional-arguments] Too many positional arguments to function `Enum`: expected 2, got 4 +enums_definition.py:34:33: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member +enums_definition.py:92:1: error[unresolved-attribute] Class `Color12` has no attribute `BLUE` +""" diff --git a/conformance/results/ty/enums_expansion.toml b/conformance/results/ty/enums_expansion.toml new file mode 100644 index 000000000..0cc979f4e --- /dev/null +++ b/conformance/results/ty/enums_expansion.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +enums_expansion.py:56:9: error[type-assertion-failure] Type `CustomFlags & ~Literal[CustomFlags.FLAG1] & ~Literal[CustomFlags.FLAG2]` does not match asserted type `Literal[CustomFlags.FLAG3]` +""" diff --git a/conformance/results/ty/enums_member_names.toml b/conformance/results/ty/enums_member_names.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/ty/enums_member_names.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/ty/enums_member_values.toml b/conformance/results/ty/enums_member_values.toml new file mode 100644 index 000000000..2686347f9 --- /dev/null +++ b/conformance/results/ty/enums_member_values.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +enums_member_values.py:50:5: error[invalid-assignment] Enum member `MARS` is incompatible with `__init__` +enums_member_values.py:51:5: error[invalid-assignment] Enum member `JUPITER` is incompatible with `__init__` +enums_member_values.py:54:1: error[type-assertion-failure] Type `Any` does not match asserted type `Literal[1]` +enums_member_values.py:78:5: error[invalid-assignment] Enum member `GREEN` value is not assignable to expected type +enums_member_values.py:85:9: error[invalid-assignment] Object of type `int` is not assignable to attribute `_value_` of type `str` +""" diff --git a/conformance/results/ty/enums_members.toml b/conformance/results/ty/enums_members.toml new file mode 100644 index 000000000..26dff7c35 --- /dev/null +++ b/conformance/results/ty/enums_members.toml @@ -0,0 +1,15 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +enums_members.py:54:10: error[invalid-enum-member-annotation] Type annotation on enum member `DOG` is not allowed +enums_members.py:86:20: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member +enums_members.py:87:20: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member +enums_members.py:88:18: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member +enums_members.py:89:16: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member +enums_members.py:120:1: error[type-assertion-failure] Type `int` does not match asserted type `Unknown` +enums_members.py:120:32: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member +enums_members.py:132:21: info[revealed-type] Revealed type: `int` +enums_members.py:133:9: error[type-assertion-failure] Type `int` does not match asserted type `Unknown` +enums_members.py:133:43: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member +""" diff --git a/conformance/results/ty/exceptions_context_managers.toml b/conformance/results/ty/exceptions_context_managers.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/ty/exceptions_context_managers.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/ty/generics_base_class.toml b/conformance/results/ty/generics_base_class.toml new file mode 100644 index 000000000..a76b7a8bf --- /dev/null +++ b/conformance/results/ty/generics_base_class.toml @@ -0,0 +1,12 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_base_class.py:26:26: error[invalid-argument-type] Argument to function `takes_dict_incorrect` is incorrect: Expected `dict[str, list[object]]`, found `SymbolTable` +generics_base_class.py:29:14: error[invalid-type-form] `typing.Generic` is not allowed in parameter annotations +generics_base_class.py:30:8: error[invalid-type-form] `typing.Generic` is not allowed in type expressions +generics_base_class.py:49:38: error[invalid-type-arguments] Too many type arguments to class `LinkedList`: expected 1, got 2 +generics_base_class.py:61:30: error[invalid-type-arguments] Too many type arguments to class `MyDict`: expected 1, got 2 +generics_base_class.py:68:17: error[invalid-generic-class] Type parameter `T` cannot appear multiple times in `Generic` subscription +generics_base_class.py:98:7: error[invalid-generic-class] Inconsistent type arguments: class cannot inherit from both `Grandparent[T2@BadChild, T1@BadChild]` and `Grandparent[T1@BadChild, T2@BadChild]` +""" diff --git a/conformance/results/ty/generics_basic.toml b/conformance/results/ty/generics_basic.toml new file mode 100644 index 000000000..b700f0fd5 --- /dev/null +++ b/conformance/results/ty/generics_basic.toml @@ -0,0 +1,24 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_basic.py:40:5: error[invalid-argument-type] Argument to function `concat` is incorrect: Inferred lower bound `str | bytes` does not satisfy constraints (`str`, `bytes`) of type variable `AnyStr` +generics_basic.py:41:5: error[invalid-argument-type] Argument to function `concat` is incorrect: Inferred lower bound `bytes | str` does not satisfy constraints (`str`, `bytes`) of type variable `AnyStr` +generics_basic.py:49:44: error[invalid-legacy-type-variable] A `TypeVar` cannot have exactly one constraint +generics_basic.py:55:53: error[invalid-type-variable-constraints] TypeVar constraint cannot be generic +generics_basic.py:69:5: error[invalid-argument-type] Argument to function `concat` is incorrect: Inferred lower bound `MyStr | bytes` does not satisfy constraints (`str`, `bytes`) of type variable `AnyStr` +generics_basic.py:121:13: error[invalid-generic-class] Type parameter `T` cannot appear multiple times in `Generic` subscription +generics_basic.py:157:5: error[invalid-argument-type] Method `__getitem__` of type `bound method MyMap1[str, int].__getitem__(key: str, /) -> int` cannot be called with key of type `Literal[0]` on object of type `MyMap1[str, int]` +generics_basic.py:158:5: error[invalid-argument-type] Method `__getitem__` of type `bound method MyMap2[int, str].__getitem__(key: str, /) -> int` cannot be called with key of type `Literal[0]` on object of type `MyMap2[int, str]` +generics_basic.py:162:12: error[invalid-argument-type] `` is not a valid argument to `Generic` +generics_basic.py:163:12: error[invalid-argument-type] `` is not a valid argument to `Protocol` +generics_basic.py:171:1: error[invalid-generic-class] `Generic` base class must include all type variables used in other base classes +generics_basic.py:172:1: error[invalid-generic-class] `Generic` base class must include all type variables used in other base classes +generics_basic.py:208:27: error[invalid-metaclass] Generic metaclasses are not supported +generics_basic.py:223:22: error[invalid-argument-type] Argument to function `takes_two_lists` is incorrect: Expected `list[int]`, found `Literal["not a list"]` +generics_basic.py:232:21: error[invalid-argument-type] Argument to function `takes_two_lists` is incorrect: Expected `list[int | str]`, found `list[int]` +generics_basic.py:232:24: error[invalid-argument-type] Argument to function `takes_two_lists` is incorrect: Expected `list[int | str]`, found `list[str]` +generics_basic.py:240:26: error[invalid-argument-type] Argument to function `takes_two_int_lists` is incorrect: Expected `list[int]`, found `Literal["not a list"]` +generics_basic.py:241:26: error[invalid-argument-type] Argument to function `takes_two_int_lists` is incorrect: Argument type `int | str` does not satisfy upper bound `int` of type variable `T_int` +generics_basic.py:251:28: error[invalid-argument-type] Argument to function `takes_two_int_lists` is incorrect: Expected `list[int]`, found `list[bool]` +""" diff --git a/conformance/results/ty/generics_defaults.toml b/conformance/results/ty/generics_defaults.toml new file mode 100644 index 000000000..8a265a5d2 --- /dev/null +++ b/conformance/results/ty/generics_defaults.toml @@ -0,0 +1,25 @@ +conformance_automated = "Fail" +conformant = "Partial" +notes = """ +Does not forbid a `TypeVar` immediately following a `TypeVarTuple` in a parameter list from having a default. +Does not accept a `TypeVarTuple` default that unpacks another in-scope `TypeVarTuple`. +Does not correctly specialize a generic that combines a `TypeVarTuple` with a defaulted `ParamSpec`. +""" +errors_diff = """ +Line 188: Expected 1 errors +Line 144: Unexpected errors ['generics_defaults.py:144:61: error[invalid-type-form] `Unpack` can only unpack a tuple type or `TypeVarTuple`'] +Line 203: Unexpected errors ['generics_defaults.py:203:28: error[invalid-type-arguments] Type argument for `ParamSpec` must be either a list of types, `ParamSpec`, `Concatenate`, or `...`'] +Line 204: Unexpected errors ['generics_defaults.py:204:5: error[type-assertion-failure] Type `tuple[int]` does not match asserted type `tuple[int, str]`'] +Line 205: Unexpected errors ['generics_defaults.py:205:5: error[type-assertion-failure] Type `(...) -> None` does not match asserted type `(float, bool, /) -> None`'] +""" +output = """ +generics_defaults.py:24:40: error[invalid-generic-class] Type parameter `T` without a default cannot follow earlier parameter `DefaultStrT` with a default +generics_defaults.py:66:8: error[invalid-type-arguments] No type argument provided for required type variable `T2` of class `AllTheDefaults` +generics_defaults.py:144:61: error[invalid-type-form] `Unpack` can only unpack a tuple type or `TypeVarTuple` +generics_defaults.py:152:51: error[invalid-type-variable-default] TypeVar default is not assignable to the TypeVar's upper bound +generics_defaults.py:159:52: error[invalid-type-variable-default] TypeVar default is inconsistent with the TypeVar's constraints: `int` is not one of the constraints of `Invalid2` +generics_defaults.py:177:1: error[type-assertion-failure] Type `int` does not match asserted type `Any` +generics_defaults.py:203:28: error[invalid-type-arguments] Type argument for `ParamSpec` must be either a list of types, `ParamSpec`, `Concatenate`, or `...` +generics_defaults.py:204:5: error[type-assertion-failure] Type `tuple[int]` does not match asserted type `tuple[int, str]` +generics_defaults.py:205:5: error[type-assertion-failure] Type `(...) -> None` does not match asserted type `(float, bool, /) -> None` +""" diff --git a/conformance/results/ty/generics_defaults_referential.toml b/conformance/results/ty/generics_defaults_referential.toml new file mode 100644 index 000000000..69e9ba4cd --- /dev/null +++ b/conformance/results/ty/generics_defaults_referential.toml @@ -0,0 +1,12 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_defaults_referential.py:36:17: error[invalid-argument-type] Argument to `Foo.__init__` is incorrect: Expected `int`, found `str` +generics_defaults_referential.py:37:14: error[invalid-argument-type] Argument to `Foo.__init__` is incorrect: Expected `int`, found `str` +generics_defaults_referential.py:53:7: error[invalid-generic-class] Default of `Start2T` cannot reference out-of-scope type variable `StopT` +generics_defaults_referential.py:60:11: error[invalid-generic-class] Default of `S2` cannot reference out-of-scope type variable `S1` +generics_defaults_referential.py:68:40: error[invalid-type-variable-default] Default `X1` of TypeVar `Invalid1` is not assignable to upper bound `str` of `Invalid1` because its upper bound `int` is not assignable to `str` +generics_defaults_referential.py:74:52: error[invalid-type-variable-default] TypeVar default is inconsistent with the TypeVar's constraints: Bounded TypeVar cannot be used as the default for a constrained TypeVar +generics_defaults_referential.py:78:63: error[invalid-type-variable-default] Default `Y2` of TypeVar `AlsoInvalid2` is inconsistent with its constraints `AlsoInvalid2` because constraint `int` of `Y2` is not one of the constraints of `AlsoInvalid2` +""" diff --git a/conformance/results/ty/generics_defaults_specialization.toml b/conformance/results/ty/generics_defaults_specialization.toml new file mode 100644 index 000000000..4e121cd3d --- /dev/null +++ b/conformance/results/ty/generics_defaults_specialization.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_defaults_specialization.py:30:15: error[invalid-type-arguments] Too many type arguments: expected between 0 and 1, got 2 +generics_defaults_specialization.py:58:1: error[not-subscriptable] Cannot specialize non-generic class `Foo` +""" diff --git a/conformance/results/ty/generics_mixed_variance_inference.toml b/conformance/results/ty/generics_mixed_variance_inference.toml new file mode 100644 index 000000000..03796e1e0 --- /dev/null +++ b/conformance/results/ty/generics_mixed_variance_inference.toml @@ -0,0 +1,9 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_mixed_variance_inference.py:13:22: error[invalid-assignment] Object of type `Mixed[bool, ()]` is not assignable to `Mixed[int, ()]` +generics_mixed_variance_inference.py:16:27: error[invalid-assignment] Object of type `Mixed[int, object, ()]` is not assignable to `Mixed[int, int, ()]` +generics_mixed_variance_inference.py:21:25: error[invalid-assignment] Object of type `Mixed[int, (bool, /)]` is not assignable to `Mixed[int, (int, /)]` +""" diff --git a/conformance/results/ty/generics_paramspec_basic.toml b/conformance/results/ty/generics_paramspec_basic.toml new file mode 100644 index 000000000..8f572fd57 --- /dev/null +++ b/conformance/results/ty/generics_paramspec_basic.toml @@ -0,0 +1,14 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_paramspec_basic.py:10:23: error[mismatched-type-name] The name passed to `ParamSpec` must match the variable it is assigned to: Expected "WrongName", got "NotIt" +generics_paramspec_basic.py:15:18: error[invalid-type-form] Bare ParamSpec `P` is not valid in this context in a type alias definition +generics_paramspec_basic.py:23:14: error[invalid-type-form] Bare ParamSpec `P` is not valid in this context in a parameter annotation +generics_paramspec_basic.py:23:20: error[invalid-type-form] Bare ParamSpec `P` is not valid in this context in a return type annotation +generics_paramspec_basic.py:27:14: error[invalid-type-form] `typing.Concatenate` is not allowed in this context in a parameter annotation +generics_paramspec_basic.py:31:19: error[invalid-type-arguments] ParamSpec `P` cannot be used to specialize type variable `_T` +generics_paramspec_basic.py:35:35: error[invalid-type-form] Bare ParamSpec `P` is not valid in this context in a parameter annotation +generics_paramspec_basic.py:39:18: error[invalid-type-form] Bare ParamSpec `P` is not valid in this context in a parameter annotation +generics_paramspec_basic.py:39:31: error[invalid-type-form] Bare ParamSpec `P` is not valid in this context in a parameter annotation +""" diff --git a/conformance/results/ty/generics_paramspec_components.toml b/conformance/results/ty/generics_paramspec_components.toml new file mode 100644 index 000000000..ee8fe254b --- /dev/null +++ b/conformance/results/ty/generics_paramspec_components.toml @@ -0,0 +1,27 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_paramspec_components.py:17:25: error[invalid-type-form] `P.kwargs` is valid only in `**kwargs` annotation: Did you mean `P.args`? +generics_paramspec_components.py:17:45: error[invalid-type-form] `P.args` is valid only in `*args` annotation: Did you mean `P.kwargs`? +generics_paramspec_components.py:20:23: error[invalid-paramspec] `P.args` is only valid for annotating `*args` +generics_paramspec_components.py:23:46: error[invalid-paramspec] `*args: P.args` must be accompanied by `**kwargs: P.kwargs` +generics_paramspec_components.py:23:46: error[invalid-type-form] `P.args` is valid only in `*args` annotation: Did you mean `P.kwargs`? +generics_paramspec_components.py:26:46: error[invalid-paramspec] `*args: P.args` must be accompanied by `**kwargs: P.kwargs` +generics_paramspec_components.py:30:25: error[unbound-type-variable] ParamSpec `P` is not in scope +generics_paramspec_components.py:35:18: error[invalid-paramspec] `P.args` is only valid for annotating `*args` function parameters +generics_paramspec_components.py:36:20: error[invalid-paramspec] `P.kwargs` is only valid for annotating `**kwargs` function parameters +generics_paramspec_components.py:38:26: error[invalid-paramspec] `*args: P.args` must be accompanied by `**kwargs: P.kwargs` +generics_paramspec_components.py:41:31: error[invalid-paramspec] `**kwargs: P.kwargs` must be accompanied by `*args: P.args` +generics_paramspec_components.py:49:11: error[invalid-argument-type] Argument is incorrect: Expected `P@decorator.args`, found `P@decorator.kwargs` +generics_paramspec_components.py:49:20: error[invalid-argument-type] Argument is incorrect: Expected `P@decorator.kwargs`, found `P@decorator.args` +generics_paramspec_components.py:51:11: error[invalid-argument-type] Argument is incorrect: Expected `P@decorator.args`, found `Literal[1]` +generics_paramspec_components.py:60:28: error[invalid-paramspec] No parameters may appear between `*args: P.args` and `**kwargs: P.kwargs` +generics_paramspec_components.py:70:11: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `P@remove.args` +generics_paramspec_components.py:70:18: error[invalid-argument-type] Argument is incorrect: Expected `P@remove.args`, found `Literal[1]` +generics_paramspec_components.py:72:11: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `P@remove.args` +generics_paramspec_components.py:83:18: error[invalid-argument-type] Argument to function `foo` is incorrect: Expected `int`, found `P@outer.args` +generics_paramspec_components.py:83:18: error[parameter-already-assigned] Multiple values provided for parameter 1 (`x`) of function `foo` +generics_paramspec_components.py:98:20: error[invalid-argument-type] Argument to function `twice` is incorrect: Expected `int`, found `Literal["A"]` +generics_paramspec_components.py:98:25: error[invalid-argument-type] Argument to function `twice` is incorrect: Expected `str`, found `Literal[1]` +""" diff --git a/conformance/results/ty/generics_paramspec_semantics.toml b/conformance/results/ty/generics_paramspec_semantics.toml new file mode 100644 index 000000000..2a84cbc37 --- /dev/null +++ b/conformance/results/ty/generics_paramspec_semantics.toml @@ -0,0 +1,16 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_paramspec_semantics.py:26:4: error[positional-only-parameter-as-kwarg] Positional-only parameter 1 (`a`) passed as keyword argument +generics_paramspec_semantics.py:26:11: error[positional-only-parameter-as-kwarg] Positional-only parameter 2 (`b`) passed as keyword argument +generics_paramspec_semantics.py:27:9: error[invalid-argument-type] Argument is incorrect: Expected `bool`, found `Literal["A"]` +generics_paramspec_semantics.py:46:17: error[invalid-argument-type] Argument to function `func1` is incorrect: Expected `(x: int, y: str) -> int`, found `def y_x(y: int, x: str) -> int` +generics_paramspec_semantics.py:61:23: error[invalid-argument-type] Argument to function `func1` is incorrect: Expected `(*, x: int) -> int`, found `def keyword_only_y(*, y: int) -> int` +generics_paramspec_semantics.py:98:4: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `Literal[1]` +generics_paramspec_semantics.py:108:4: error[invalid-argument-type] Argument is incorrect: Expected `bool`, found `Literal[1]` +generics_paramspec_semantics.py:120:4: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `Literal[1]` +generics_paramspec_semantics.py:127:1: error[invalid-argument-type] Argument to function `expects_int_first` is incorrect: Expected `(int, /, *args: Unknown, **kwargs: Unknown) -> int`, found `def one(x: str) -> int` +generics_paramspec_semantics.py:132:1: error[invalid-argument-type] Argument to function `expects_int_first` is incorrect: Expected `(int, /, *args: Unknown, **kwargs: Unknown) -> int`, found `def two(*, x: int) -> int` +generics_paramspec_semantics.py:137:1: error[invalid-argument-type] Argument to function `expects_int_first` is incorrect: Expected `(int, /, *args: Unknown, **kwargs: Unknown) -> int`, found `def three(**kwargs: int) -> int` +""" diff --git a/conformance/results/ty/generics_paramspec_specialization.toml b/conformance/results/ty/generics_paramspec_specialization.toml new file mode 100644 index 000000000..b95502032 --- /dev/null +++ b/conformance/results/ty/generics_paramspec_specialization.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_paramspec_specialization.py:44:27: error[invalid-type-arguments] Type argument for `ParamSpec` must be either a list of types, `ParamSpec`, `Concatenate`, or `...` +generics_paramspec_specialization.py:54:9: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `Literal[""]` +generics_paramspec_specialization.py:55:16: error[invalid-argument-type] Argument is incorrect: Expected `bool`, found `Literal[""]` +generics_paramspec_specialization.py:60:9: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `Literal[""]` +generics_paramspec_specialization.py:61:16: error[invalid-argument-type] Argument is incorrect: Expected `bool`, found `Literal[""]` +""" diff --git a/conformance/results/ty/generics_paramspec_variance.toml b/conformance/results/ty/generics_paramspec_variance.toml new file mode 100644 index 000000000..6abc5f5b4 --- /dev/null +++ b/conformance/results/ty/generics_paramspec_variance.toml @@ -0,0 +1,27 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_paramspec_variance.py:14:42: error[invalid-assignment] Object of type `InvariantParamSpec[(int, /)]` is not assignable to `InvariantParamSpec[(object, /)]` +generics_paramspec_variance.py:15:39: error[invalid-assignment] Object of type `InvariantParamSpec[(object, /)]` is not assignable to `InvariantParamSpec[(int, /)]` +generics_paramspec_variance.py:21:42: error[invalid-assignment] Object of type `ContravariantParamSpec[(int, /)]` is not assignable to `ContravariantParamSpec[(object, /)]` +generics_paramspec_variance.py:30:36: error[invalid-assignment] Object of type `CovariantParamSpec[(object, /)]` is not assignable to `CovariantParamSpec[(int, /)]` +generics_paramspec_variance.py:61:1: error[invalid-assignment] Object of type `InitP[(*, a: int)]` is not assignable to attribute `t` of type `InitP[(a: int)]` +generics_paramspec_variance.py:63:1: error[invalid-assignment] Object of type `InitP[(a: int, /)]` is not assignable to attribute `t` of type `InitP[(a: int)]` +generics_paramspec_variance.py:65:1: error[invalid-assignment] Object of type `InitP[(b: int)]` is not assignable to attribute `t` of type `InitP[(a: int)]` +generics_paramspec_variance.py:69:1: error[invalid-assignment] Object of type `InitP[(a: int, b: str)]` is not assignable to attribute `t` of type `InitP[(a: int)]` +generics_paramspec_variance.py:88:1: error[invalid-assignment] Object of type `OutitP[(b: int)]` is not assignable to attribute `t` of type `OutitP[(a: int)]` +generics_paramspec_variance.py:90:1: error[invalid-assignment] Object of type `OutitP[(a: int = 1)]` is not assignable to attribute `t` of type `OutitP[(a: int)]` +generics_paramspec_variance.py:92:1: error[invalid-assignment] Object of type `OutitP[(a: int, b: str)]` is not assignable to attribute `t` of type `OutitP[(a: int)]` +generics_paramspec_variance.py:100:9: error[invalid-paramspec] A `ParamSpec` cannot be both covariant and contravariant +generics_paramspec_variance.py:101:9: error[invalid-paramspec] A `ParamSpec` cannot specify variance when `infer_variance=True` +generics_paramspec_variance.py:102:9: error[invalid-paramspec] A `ParamSpec` cannot specify variance when `infer_variance=True` +generics_paramspec_variance.py:110:14: error[invalid-assignment] Object of type `InvariantParamSpecOld[(bool, /)]` is not assignable to `InvariantParamSpecOld[(int, /)]` +generics_paramspec_variance.py:111:14: error[invalid-assignment] Object of type `InvariantParamSpecOld[(object, /)]` is not assignable to `InvariantParamSpecOld[(int, /)]` +generics_paramspec_variance.py:117:25: error[invalid-generic-class] Variance of type variable `InP` is incompatible with method `out_f` +generics_paramspec_variance.py:121:49: error[invalid-assignment] Object of type `ContravariantParamSpecOld[(int, /)]` is not assignable to `ContravariantParamSpecOld[(object, /)]` +generics_paramspec_variance.py:126:23: error[invalid-generic-class] Variance of type variable `OutP` is incompatible with method `in_f` +generics_paramspec_variance.py:132:43: error[invalid-assignment] Object of type `CovariantParamSpecOld[(object, /)]` is not assignable to `CovariantParamSpecOld[(int, /)]` +generics_paramspec_variance.py:142:63: error[invalid-assignment] Object of type `InferredContravariantParamSpecOld[(int, /)]` is not assignable to `InferredContravariantParamSpecOld[(object, /)]` +generics_paramspec_variance.py:151:57: error[invalid-assignment] Object of type `InferredCovariantParamSpecOld[(object, /)]` is not assignable to `InferredCovariantParamSpecOld[(int, /)]` +""" diff --git a/conformance/results/ty/generics_scoping.toml b/conformance/results/ty/generics_scoping.toml new file mode 100644 index 000000000..996b0dca3 --- /dev/null +++ b/conformance/results/ty/generics_scoping.toml @@ -0,0 +1,20 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_scoping.py:15:1: error[type-assertion-failure] Type `Literal[1]` does not match asserted type `int` +generics_scoping.py:19:1: error[type-assertion-failure] Type `Literal["a"]` does not match asserted type `str` +generics_scoping.py:34:10: error[invalid-argument-type] Argument to bound method `MyClass.meth_2` is incorrect: Expected `int`, found `Literal["a"]` +generics_scoping.py:49:1: error[type-assertion-failure] Type `Literal["abc"]` does not match asserted type `str` +generics_scoping.py:53:1: error[type-assertion-failure] Type `Literal[b"abc"]` does not match asserted type `bytes` +generics_scoping.py:61:13: error[unbound-type-variable] Type variable `S` is not bound to any outer generic context +generics_scoping.py:65:19: error[unbound-type-variable] Type variable `S` is not bound to any outer generic context +generics_scoping.py:76:11: error[shadowed-type-variable] Generic class `MyGeneric` uses type variable `T` already bound by an enclosing scope +generics_scoping.py:76:11: error[shadowed-type-variable] Generic class `MyGeneric` uses type variable `T` already bound by an enclosing scope +generics_scoping.py:86:11: error[shadowed-type-variable] Generic class `Bad` uses type variable `T` already bound by an enclosing scope +generics_scoping.py:89:17: error[unbound-type-variable] Type variable `T` is not bound to any outer generic context +generics_scoping.py:98:29: error[invalid-type-form] Type alias cannot capture class-scoped type variable `T` +generics_scoping.py:105:14: error[unbound-type-variable] Type variable `T` is not bound to any outer generic context +generics_scoping.py:106:19: error[unbound-type-variable] Type variable `T` is not bound to any outer generic context +generics_scoping.py:107:6: error[unbound-type-variable] Type variable `T` is not bound to any outer generic context +""" diff --git a/conformance/results/ty/generics_self_advanced.toml b/conformance/results/ty/generics_self_advanced.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/ty/generics_self_advanced.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/ty/generics_self_attributes.toml b/conformance/results/ty/generics_self_attributes.toml new file mode 100644 index 000000000..cca34273e --- /dev/null +++ b/conformance/results/ty/generics_self_attributes.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_self_attributes.py:26:33: error[invalid-argument-type] Argument is incorrect: Expected `OrdinalLinkedList | None`, found `LinkedList[int]` +generics_self_attributes.py:32:5: error[invalid-assignment] Object of type `LinkedList[int]` is not assignable to attribute `next` of type `OrdinalLinkedList | None` +""" diff --git a/conformance/results/ty/generics_self_basic.toml b/conformance/results/ty/generics_self_basic.toml new file mode 100644 index 000000000..7e56f458c --- /dev/null +++ b/conformance/results/ty/generics_self_basic.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_self_basic.py:20:16: error[invalid-return-type] Return type does not match returned value: expected `Self@method2`, found `Shape` +generics_self_basic.py:33:16: error[invalid-return-type] Return type does not match returned value: expected `Self@cls_method2`, found `Shape` +generics_self_basic.py:68:26: error[invalid-type-form] Special form `typing.Self` expected no type parameter +""" diff --git a/conformance/results/ty/generics_self_protocols.toml b/conformance/results/ty/generics_self_protocols.toml new file mode 100644 index 000000000..5d9cc9a00 --- /dev/null +++ b/conformance/results/ty/generics_self_protocols.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_self_protocols.py:61:19: error[invalid-argument-type] Argument to function `accepts_shape` is incorrect: Expected `ShapeProtocol`, found `BadReturnType` +generics_self_protocols.py:64:19: error[invalid-argument-type] Argument to function `accepts_shape` is incorrect: Expected `ShapeProtocol`, found `ReturnDifferentClass` +""" diff --git a/conformance/results/ty/generics_self_usage.toml b/conformance/results/ty/generics_self_usage.toml new file mode 100644 index 000000000..2433bb63b --- /dev/null +++ b/conformance/results/ty/generics_self_usage.toml @@ -0,0 +1,18 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_self_usage.py:73:14: error[invalid-type-form] Variable of type `` is not allowed in a parameter annotation +generics_self_usage.py:73:23: error[invalid-type-form] Variable of type `` is not allowed in a return type annotation +generics_self_usage.py:76:6: error[invalid-type-form] Variable of type `` is not allowed in a type expression +generics_self_usage.py:82:54: error[invalid-type-form] `Self` requires `self: Self` or `cls: type[Self]` for annotated receivers +generics_self_usage.py:87:16: error[invalid-return-type] Return type does not match returned value: expected `Self@return_concrete_type`, found `Foo3` +generics_self_usage.py:103:15: error[invalid-type-form] Variable of type `` is not allowed in a type expression +generics_self_usage.py:105:12: error[invalid-base] Invalid class base with type `` +generics_self_usage.py:108:30: error[invalid-type-form] Variable of type `` is not allowed in a type expression +generics_self_usage.py:113:19: error[invalid-type-form] `Self` cannot be used in a static method +generics_self_usage.py:118:31: error[invalid-type-form] `Self` cannot be used in a static method +generics_self_usage.py:118:40: error[invalid-type-form] `Self` cannot be used in a static method +generics_self_usage.py:123:37: error[invalid-type-form] `Self` cannot be used in a metaclass +generics_self_usage.py:127:42: error[invalid-type-form] `Self` cannot be used in a metaclass +""" diff --git a/conformance/results/ty/generics_syntax_compatibility.toml b/conformance/results/ty/generics_syntax_compatibility.toml new file mode 100644 index 000000000..d11f9eb8b --- /dev/null +++ b/conformance/results/ty/generics_syntax_compatibility.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_syntax_compatibility.py:14:1: error[invalid-generic-class] Legacy type variable `K` cannot be used in a PEP 695 class base +generics_syntax_compatibility.py:26:35: error[unbound-type-variable] Legacy type variable `K` cannot be used in a function with PEP 695 type parameters +""" diff --git a/conformance/results/ty/generics_syntax_declarations.toml b/conformance/results/ty/generics_syntax_declarations.toml new file mode 100644 index 000000000..5d2978814 --- /dev/null +++ b/conformance/results/ty/generics_syntax_declarations.toml @@ -0,0 +1,15 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_syntax_declarations.py:17:1: error[invalid-generic-class] Cannot both inherit from `typing.Generic` and use PEP 695 type variables +generics_syntax_declarations.py:25:20: error[invalid-generic-class] Cannot both inherit from subscripted `Protocol` and use PEP 695 type variables +generics_syntax_declarations.py:32:9: error[unresolved-attribute] Object of type `T@ClassD` has no attribute `is_integer` +generics_syntax_declarations.py:44:21: error[invalid-type-variable-bound] TypeVar upper bound cannot be generic +generics_syntax_declarations.py:48:17: error[invalid-type-form] List literals are not allowed in this context in a type expression +generics_syntax_declarations.py:60:17: error[invalid-type-variable-constraints] TypeVar must have at least two constrained types +generics_syntax_declarations.py:64:17: error[invalid-type-variable-constraints] TypeVar must have at least two constrained types +generics_syntax_declarations.py:71:17: error[invalid-type-form] Variable `t1` cannot be used as a type: Variable of type `tuple[, ]` is not allowed in a type expression +generics_syntax_declarations.py:75:18: error[invalid-type-form] Int literals are not allowed in this context in a type expression: Did you mean `typing.Literal[3]`? +generics_syntax_declarations.py:79:23: error[unresolved-reference] Name `S` used when not defined +""" diff --git a/conformance/results/ty/generics_syntax_infer_variance.toml b/conformance/results/ty/generics_syntax_infer_variance.toml new file mode 100644 index 000000000..6bfde6a3c --- /dev/null +++ b/conformance/results/ty/generics_syntax_infer_variance.toml @@ -0,0 +1,23 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_syntax_infer_variance.py:15:6: error[invalid-legacy-type-variable] A `TypeVar` cannot specify variance when `infer_variance=True` +generics_syntax_infer_variance.py:17:6: error[invalid-legacy-type-variable] A `TypeVar` cannot specify variance when `infer_variance=True` +generics_syntax_infer_variance.py:29:35: error[invalid-assignment] Object of type `ShouldBeCovariant1[float]` is not assignable to `ShouldBeCovariant1[int]` +generics_syntax_infer_variance.py:47:35: error[invalid-assignment] Object of type `ShouldBeCovariant2[float]` is not assignable to `ShouldBeCovariant2[int]` +generics_syntax_infer_variance.py:56:35: error[invalid-assignment] Object of type `ShouldBeCovariant3[float]` is not assignable to `ShouldBeCovariant3[int]` +generics_syntax_infer_variance.py:85:34: error[invalid-assignment] Object of type `ShouldBeCovariant5[float]` is not assignable to `ShouldBeCovariant5[int]` +generics_syntax_infer_variance.py:96:34: error[invalid-assignment] Object of type `ShouldBeCovariant6[float]` is not assignable to `ShouldBeCovariant6[int]` +generics_syntax_infer_variance.py:112:38: error[invalid-assignment] Object of type `ShouldBeInvariant1[int]` is not assignable to `ShouldBeInvariant1[float]` +generics_syntax_infer_variance.py:113:36: error[invalid-assignment] Object of type `ShouldBeInvariant1[float]` is not assignable to `ShouldBeInvariant1[int]` +generics_syntax_infer_variance.py:127:38: error[invalid-assignment] Object of type `ShouldBeInvariant2[int]` is not assignable to `ShouldBeInvariant2[float]` +generics_syntax_infer_variance.py:128:36: error[invalid-assignment] Object of type `ShouldBeInvariant2[float]` is not assignable to `ShouldBeInvariant2[int]` +generics_syntax_infer_variance.py:135:43: error[invalid-assignment] Object of type `ShouldBeInvariant3[int, str]` is not assignable to `ShouldBeInvariant3[float, str]` +generics_syntax_infer_variance.py:136:41: error[invalid-assignment] Object of type `ShouldBeInvariant3[float, str]` is not assignable to `ShouldBeInvariant3[int, str]` +generics_syntax_infer_variance.py:137:43: error[invalid-assignment] Object of type `ShouldBeInvariant3[str, int]` is not assignable to `ShouldBeInvariant3[str, float]` +generics_syntax_infer_variance.py:138:41: error[invalid-assignment] Object of type `ShouldBeInvariant3[str, float]` is not assignable to `ShouldBeInvariant3[str, int]` +generics_syntax_infer_variance.py:146:38: error[invalid-assignment] Object of type `ShouldBeInvariant4[int]` is not assignable to `ShouldBeInvariant4[float]` +generics_syntax_infer_variance.py:154:38: error[invalid-assignment] Object of type `ShouldBeInvariant5[int]` is not assignable to `ShouldBeInvariant5[float]` +generics_syntax_infer_variance.py:165:45: error[invalid-assignment] Object of type `ShouldBeContravariant1[int]` is not assignable to `ShouldBeContravariant1[float]` +""" diff --git a/conformance/results/ty/generics_syntax_scoping.toml b/conformance/results/ty/generics_syntax_scoping.toml new file mode 100644 index 000000000..b40a2f622 --- /dev/null +++ b/conformance/results/ty/generics_syntax_scoping.toml @@ -0,0 +1,12 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_syntax_scoping.py:14:20: error[invalid-type-variable-bound] TypeVar upper bound cannot be generic +generics_syntax_scoping.py:18:17: error[invalid-type-variable-bound] TypeVar upper bound cannot be generic +generics_syntax_scoping.py:26:7: error[unresolved-reference] Name `T` used when not defined +generics_syntax_scoping.py:35:17: error[unresolved-reference] Name `T` used when not defined +generics_syntax_scoping.py:83:9: error[shadowed-type-variable] Generic function `method1` uses type variable `T` already bound by an enclosing scope +generics_syntax_scoping.py:86:9: error[shadowed-type-variable] Generic function `method2` uses type variable `T` already bound by an enclosing scope +generics_syntax_scoping.py:89:9: error[shadowed-type-variable] Generic function `method3` uses type variable `T` already bound by an enclosing scope +""" diff --git a/conformance/results/ty/generics_type_erasure.toml b/conformance/results/ty/generics_type_erasure.toml new file mode 100644 index 000000000..2d4625c5b --- /dev/null +++ b/conformance/results/ty/generics_type_erasure.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_type_erasure.py:38:16: error[invalid-argument-type] Argument to `Node.__init__` is incorrect: Expected `int | None`, found `Literal[""]` +generics_type_erasure.py:40:16: error[invalid-argument-type] Argument to `Node.__init__` is incorrect: Expected `str | None`, found `Literal[0]` +generics_type_erasure.py:42:1: error[invalid-attribute-access] Cannot access generic instance attribute `label` through a class +generics_type_erasure.py:43:1: error[invalid-attribute-access] Cannot access generic instance attribute `label` through a class +generics_type_erasure.py:44:1: error[invalid-attribute-access] Cannot access generic instance attribute `label` through a class +generics_type_erasure.py:45:1: error[invalid-attribute-access] Cannot access generic instance attribute `label` through a class +""" diff --git a/conformance/results/ty/generics_typevartuple_args.toml b/conformance/results/ty/generics_typevartuple_args.toml new file mode 100644 index 000000000..1ed98ead3 --- /dev/null +++ b/conformance/results/ty/generics_typevartuple_args.toml @@ -0,0 +1,13 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_typevartuple_args.py:33:20: error[invalid-argument-type] Argument to function `exec_le` is incorrect: Expected `Env`, found `Literal[""]` +generics_typevartuple_args.py:34:20: error[invalid-argument-type] Argument to function `exec_le` is incorrect: Expected `Env`, found `Literal[""]` +generics_typevartuple_args.py:48:10: error[invalid-argument-type] Argument to function `func1` is incorrect: Expected `int`, found `Literal["2"]` +generics_typevartuple_args.py:57:10: error[invalid-argument-type] Argument to function `func2` is incorrect: Expected `str`, found `Literal[1]` +generics_typevartuple_args.py:58:1: error[missing-argument] No argument provided for required parameter `*args` of function `func2` +generics_typevartuple_args.py:59:1: error[missing-argument] No argument provided for required parameter `*args` of function `func2` +generics_typevartuple_args.py:67:1: error[missing-argument] No argument provided for required parameter `*args` of function `func3` +generics_typevartuple_args.py:75:13: error[invalid-argument-type] Argument to function `func4` is incorrect: Expected `tuple[Literal[0]]`, found `tuple[Literal[1], Literal[2]]` +""" diff --git a/conformance/results/ty/generics_typevartuple_basic.toml b/conformance/results/ty/generics_typevartuple_basic.toml new file mode 100644 index 000000000..ffb88837a --- /dev/null +++ b/conformance/results/ty/generics_typevartuple_basic.toml @@ -0,0 +1,21 @@ +conformance_automated = "Pass" +conformant = "Pass" +errors_diff = """ +""" +output = """ +generics_typevartuple_basic.py:43:34: error[invalid-argument-type] Argument to `Array.__init__` is incorrect: Expected `tuple[Height, Width]`, found `Height` +generics_typevartuple_basic.py:44:41: error[invalid-argument-type] Argument to `Array.__init__` is incorrect: Expected `tuple[Batch, Height, Width]`, found `tuple[Batch, Width]` +generics_typevartuple_basic.py:45:41: error[invalid-assignment] Object of type `Array[Time, Batch, Width, Height]` is not assignable to `Array[Time, Batch, Height, Width]` +generics_typevartuple_basic.py:53:14: error[invalid-generic-class] `TypeVarTuple` must be unpacked with `*` or `Unpack[]` when used as an argument to `Generic` +generics_typevartuple_basic.py:54:37: error[invalid-type-form] Bare TypeVarTuple `Shape` is not valid in this context in a parameter annotation +generics_typevartuple_basic.py:57:34: error[invalid-type-form] Bare TypeVarTuple `Shape` is not valid in this context in a return type annotation +generics_typevartuple_basic.py:60:24: error[invalid-type-form] Bare TypeVarTuple `Shape` is not valid in this context in a parameter annotation +generics_typevartuple_basic.py:66:7: error[invalid-legacy-type-variable] `TypeVarTuple` can only have one positional argument +generics_typevartuple_basic.py:67:27: error[invalid-legacy-type-variable] The `bound` parameter of `typing.TypeVarTuple` was added in Python 3.15 +generics_typevartuple_basic.py:91:15: error[invalid-argument-type] Argument to function `func2` is incorrect: Expected `tuple[Literal[0], Literal[0]]`, found `tuple[Literal[0]]` +generics_typevartuple_basic.py:100:14: error[invalid-argument-type] Argument to function `multiply` is incorrect: Expected `Array[Height | Width]`, found `Array[Height]` +generics_typevartuple_basic.py:100:17: error[invalid-argument-type] Argument to function `multiply` is incorrect: Expected `Array[Height | Width]`, found `Array[Width]` +generics_typevartuple_basic.py:101:17: error[invalid-argument-type] Argument to function `multiply` is incorrect: Expected `Array[Height]`, found `Array[Height, Width]` +generics_typevartuple_basic.py:107:14: error[invalid-generic-class] Only one `TypeVarTuple` parameter is allowed in a `Generic` subscription +generics_typevartuple_basic.py:111:20: error[invalid-type-form] Generic class `Array4` cannot have multiple `TypeVarTuple` type parameters: `Ts2` is an additional TypeVarTuple +""" diff --git a/conformance/results/ty/generics_typevartuple_callable.toml b/conformance/results/ty/generics_typevartuple_callable.toml new file mode 100644 index 000000000..f133063e7 --- /dev/null +++ b/conformance/results/ty/generics_typevartuple_callable.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_typevartuple_callable.py:26:9: error[invalid-argument-type] Argument to `Process.__init__` is incorrect: Expected `(int | Literal[""], str | Literal[0], /) -> None`, found `def func1(arg1: int, arg2: str) -> None` +""" diff --git a/conformance/results/ty/generics_typevartuple_concat.toml b/conformance/results/ty/generics_typevartuple_concat.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/ty/generics_typevartuple_concat.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/ty/generics_typevartuple_overloads.toml b/conformance/results/ty/generics_typevartuple_overloads.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/ty/generics_typevartuple_overloads.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/ty/generics_typevartuple_specialization.toml b/conformance/results/ty/generics_typevartuple_specialization.toml new file mode 100644 index 000000000..4da80c277 --- /dev/null +++ b/conformance/results/ty/generics_typevartuple_specialization.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_typevartuple_specialization.py:109:17: error[invalid-type-form] `*` can only unpack a tuple type or `TypeVarTuple` +generics_typevartuple_specialization.py:110:17: error[invalid-type-form] `Unpack` can only be used with a fixed tuple type in this context +generics_typevartuple_specialization.py:121:7: error[invalid-type-form] Multiple unpacked variadic tuples are not allowed in a `tuple` specialization +generics_typevartuple_specialization.py:122:7: error[invalid-type-form] Multiple unpacked variadic tuples are not allowed in a `tuple` specialization +generics_typevartuple_specialization.py:127:5: error[invalid-type-arguments] No type arguments provided for required type variables `T1`, `T2` +generics_typevartuple_specialization.py:163:13: error[invalid-type-form] A TypeVarTuple cannot be split to provide a fixed type argument +""" diff --git a/conformance/results/ty/generics_typevartuple_unpack.toml b/conformance/results/ty/generics_typevartuple_unpack.toml new file mode 100644 index 000000000..d0ac4414c --- /dev/null +++ b/conformance/results/ty/generics_typevartuple_unpack.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_typevartuple_unpack.py:30:28: error[invalid-argument-type] Argument to function `process_batch_channels` is incorrect: Expected `Array[*tuple[Batch, *tuple[Any, ...], Channels]]`, found `Array[Batch]` +""" diff --git a/conformance/results/ty/generics_typevartuple_variance.toml b/conformance/results/ty/generics_typevartuple_variance.toml new file mode 100644 index 000000000..51e215aa0 --- /dev/null +++ b/conformance/results/ty/generics_typevartuple_variance.toml @@ -0,0 +1,31 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_typevartuple_variance.py:14:45: error[invalid-assignment] Object of type `InvariantTypeVarTuple[int]` is not assignable to `InvariantTypeVarTuple[object]` +generics_typevartuple_variance.py:15:42: error[invalid-assignment] Object of type `InvariantTypeVarTuple[object]` is not assignable to `InvariantTypeVarTuple[int]` +generics_typevartuple_variance.py:17:64: error[invalid-assignment] Object of type `InvariantTypeVarTuple[*tuple[object, ...]]` is not assignable to `InvariantTypeVarTuple[*tuple[int, ...]]` +generics_typevartuple_variance.py:18:70: error[invalid-assignment] Object of type `InvariantTypeVarTuple[*tuple[int, ...]]` is not assignable to `InvariantTypeVarTuple[*tuple[object, ...]]` +generics_typevartuple_variance.py:20:58: error[invalid-assignment] Object of type `InvariantTypeVarTuple[*tuple[int, ...]]` is not assignable to `InvariantTypeVarTuple[int]` +generics_typevartuple_variance.py:21:71: error[invalid-assignment] Object of type `InvariantTypeVarTuple[int]` is not assignable to `InvariantTypeVarTuple[*tuple[int, ...]]` +generics_typevartuple_variance.py:28:53: error[invalid-assignment] Object of type `ContravariantTypeVarTuple[object, int]` is not assignable to `ContravariantTypeVarTuple[object, object]` +generics_typevartuple_variance.py:31:70: error[invalid-assignment] Object of type `ContravariantTypeVarTuple[*tuple[int, ...]]` is not assignable to `ContravariantTypeVarTuple[*tuple[object, ...]]` +generics_typevartuple_variance.py:34:71: error[invalid-assignment] Object of type `ContravariantTypeVarTuple[int]` is not assignable to `ContravariantTypeVarTuple[*tuple[int, ...]]` +generics_typevartuple_variance.py:42:39: error[invalid-assignment] Object of type `CovariantTypeVarTuple[object]` is not assignable to `CovariantTypeVarTuple[int]` +generics_typevartuple_variance.py:45:50: error[invalid-assignment] Object of type `CovariantTypeVarTuple[bool, object]` is not assignable to `CovariantTypeVarTuple[int, int]` +generics_typevartuple_variance.py:46:50: error[invalid-assignment] Object of type `CovariantTypeVarTuple[object, bool]` is not assignable to `CovariantTypeVarTuple[int, int]` +generics_typevartuple_variance.py:47:50: error[invalid-assignment] Object of type `CovariantTypeVarTuple[object, object]` is not assignable to `CovariantTypeVarTuple[int, int]` +generics_typevartuple_variance.py:48:61: error[invalid-assignment] Object of type `CovariantTypeVarTuple[*tuple[object, ...]]` is not assignable to `CovariantTypeVarTuple[*tuple[int, ...]]` +generics_typevartuple_variance.py:51:55: error[invalid-assignment] Object of type `CovariantTypeVarTuple[*tuple[int, ...]]` is not assignable to `CovariantTypeVarTuple[int]` +generics_typevartuple_variance.py:56:10: error[invalid-legacy-type-variable] A `TypeVarTuple` cannot be both covariant and contravariant +generics_typevartuple_variance.py:57:10: error[invalid-legacy-type-variable] A `TypeVarTuple` cannot specify variance when `infer_variance=True` +generics_typevartuple_variance.py:58:10: error[invalid-legacy-type-variable] A `TypeVarTuple` cannot specify variance when `infer_variance=True` +generics_typevartuple_variance.py:68:45: error[invalid-assignment] Object of type `InvariantTypeVarTupleOld[int]` is not assignable to `InvariantTypeVarTupleOld[object]` +generics_typevartuple_variance.py:69:42: error[invalid-assignment] Object of type `InvariantTypeVarTupleOld[object]` is not assignable to `InvariantTypeVarTupleOld[int]` +generics_typevartuple_variance.py:79:24: error[invalid-generic-class] Variance of type variable `InTs` is incompatible with method `out_f` +generics_typevartuple_variance.py:83:52: error[invalid-assignment] Object of type `ContravariantTypeVarTupleOld[int]` is not assignable to `ContravariantTypeVarTupleOld[object]` +generics_typevartuple_variance.py:90:27: error[invalid-generic-class] Variance of type variable `OutTs` is incompatible with method `in_f` +generics_typevartuple_variance.py:97:46: error[invalid-assignment] Object of type `CovariantTypeVarTupleOld[object]` is not assignable to `CovariantTypeVarTupleOld[int]` +generics_typevartuple_variance.py:107:66: error[invalid-assignment] Object of type `InferredContravariantTypeVarTupleOld[int]` is not assignable to `InferredContravariantTypeVarTupleOld[object]` +generics_typevartuple_variance.py:116:60: error[invalid-assignment] Object of type `InferredCovariantTypeVarTupleOld[object]` is not assignable to `InferredCovariantTypeVarTupleOld[int]` +""" diff --git a/conformance/results/ty/generics_upper_bound.toml b/conformance/results/ty/generics_upper_bound.toml new file mode 100644 index 000000000..47ea50c59 --- /dev/null +++ b/conformance/results/ty/generics_upper_bound.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_upper_bound.py:24:32: error[invalid-type-variable-bound] TypeVar upper bound cannot be generic +generics_upper_bound.py:44:5: error[type-assertion-failure] Type `list[int] | set[int]` does not match asserted type `Collection[int]` +generics_upper_bound.py:52:8: error[invalid-argument-type] Argument to function `longer` is incorrect: Argument type `Literal[3]` does not satisfy upper bound `Sized` of type variable `ST` +generics_upper_bound.py:52:11: error[invalid-argument-type] Argument to function `longer` is incorrect: Argument type `Literal[3]` does not satisfy upper bound `Sized` of type variable `ST` +generics_upper_bound.py:57:10: error[invalid-legacy-type-variable] A `TypeVar` cannot have both a bound and constraints +""" diff --git a/conformance/results/ty/generics_variance.toml b/conformance/results/ty/generics_variance.toml new file mode 100644 index 000000000..dc88240f5 --- /dev/null +++ b/conformance/results/ty/generics_variance.toml @@ -0,0 +1,18 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_variance.py:14:6: error[invalid-legacy-type-variable] A `TypeVar` cannot be both covariant and contravariant +generics_variance.py:77:14: error[invalid-generic-class] Variance of type variable `T_co` is incompatible with base class `Inv` +generics_variance.py:81:14: error[invalid-generic-class] Variance of type variable `T_contra` is incompatible with base class `Inv` +generics_variance.py:93:17: error[invalid-generic-class] Variance of type variable `T_contra` is incompatible with base class `Co` +generics_variance.py:105:21: error[invalid-generic-class] Variance of type variable `T_co` is incompatible with base class `Contra` +generics_variance.py:113:21: error[invalid-generic-class] Variance of type variable `T_co` is incompatible with base class `Contra` +generics_variance.py:126:5: error[invalid-generic-class] Variance of type variable `T_co` is incompatible with base class `CoContra` +generics_variance.py:132:5: error[invalid-generic-class] Variance of type variable `T_contra` is incompatible with base class `CoContra` +generics_variance.py:142:5: error[invalid-generic-class] Variance of type variable `T_co` is incompatible with base class `CoContra` +generics_variance.py:163:26: error[invalid-generic-class] Variance of type variable `T_contra` is incompatible with base class `Contra` +generics_variance.py:167:30: error[invalid-generic-class] Variance of type variable `T_co` is incompatible with base class `Contra` +generics_variance.py:191:33: error[invalid-generic-class] Variance of type variable `T_contra` is incompatible with base class `Contra` +generics_variance.py:196:5: error[invalid-generic-class] Variance of type variable `T_co` is incompatible with base class `Contra` +""" diff --git a/conformance/results/ty/generics_variance_inference.toml b/conformance/results/ty/generics_variance_inference.toml new file mode 100644 index 000000000..80f2098cd --- /dev/null +++ b/conformance/results/ty/generics_variance_inference.toml @@ -0,0 +1,29 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_variance_inference.py:24:33: error[invalid-assignment] Object of type `ClassA[float, int, int]` is not assignable to `ClassA[int, int, int]` +generics_variance_inference.py:25:37: error[invalid-assignment] Object of type `ClassA[float, int, int]` is not assignable to `ClassA[float, float, int]` +generics_variance_inference.py:28:33: error[invalid-assignment] Object of type `ClassA[int, float, float]` is not assignable to `ClassA[int, int, int]` +generics_variance_inference.py:41:35: error[invalid-assignment] Object of type `ShouldBeCovariant1[float]` is not assignable to `ShouldBeCovariant1[int]` +generics_variance_inference.py:49:35: error[invalid-assignment] Object of type `ShouldBeCovariant2[float]` is not assignable to `ShouldBeCovariant2[int]` +generics_variance_inference.py:58:35: error[invalid-assignment] Object of type `ShouldBeCovariant3[float]` is not assignable to `ShouldBeCovariant3[int]` +generics_variance_inference.py:67:34: error[invalid-assignment] Object of type `ShouldBeCovariant4[float]` is not assignable to `ShouldBeCovariant4[int]` +generics_variance_inference.py:80:34: error[invalid-assignment] Object of type `ShouldBeCovariant5[float]` is not assignable to `ShouldBeCovariant5[int]` +generics_variance_inference.py:96:38: error[invalid-assignment] Object of type `ShouldBeInvariant1[int]` is not assignable to `ShouldBeInvariant1[float]` +generics_variance_inference.py:97:36: error[invalid-assignment] Object of type `ShouldBeInvariant1[float]` is not assignable to `ShouldBeInvariant1[int]` +generics_variance_inference.py:111:38: error[invalid-assignment] Object of type `ShouldBeInvariant2[int]` is not assignable to `ShouldBeInvariant2[float]` +generics_variance_inference.py:112:36: error[invalid-assignment] Object of type `ShouldBeInvariant2[float]` is not assignable to `ShouldBeInvariant2[int]` +generics_variance_inference.py:119:43: error[invalid-assignment] Object of type `ShouldBeInvariant3[int, str]` is not assignable to `ShouldBeInvariant3[float, str]` +generics_variance_inference.py:120:41: error[invalid-assignment] Object of type `ShouldBeInvariant3[float, str]` is not assignable to `ShouldBeInvariant3[int, str]` +generics_variance_inference.py:121:43: error[invalid-assignment] Object of type `ShouldBeInvariant3[str, int]` is not assignable to `ShouldBeInvariant3[str, float]` +generics_variance_inference.py:122:41: error[invalid-assignment] Object of type `ShouldBeInvariant3[str, float]` is not assignable to `ShouldBeInvariant3[str, int]` +generics_variance_inference.py:130:38: error[invalid-assignment] Object of type `ShouldBeInvariant4[int]` is not assignable to `ShouldBeInvariant4[float]` +generics_variance_inference.py:138:38: error[invalid-assignment] Object of type `ShouldBeInvariant5[int]` is not assignable to `ShouldBeInvariant5[float]` +generics_variance_inference.py:149:45: error[invalid-assignment] Object of type `ShouldBeContravariant1[int]` is not assignable to `ShouldBeContravariant1[float]` +generics_variance_inference.py:169:31: error[invalid-assignment] Object of type `ShouldBeInvariant6[float]` is not assignable to `ShouldBeInvariant6[int]` +generics_variance_inference.py:170:33: error[invalid-assignment] Object of type `ShouldBeInvariant6[int]` is not assignable to `ShouldBeInvariant6[float]` +generics_variance_inference.py:181:31: error[invalid-assignment] Object of type `ShouldBeCovariant6[float]` is not assignable to `ShouldBeCovariant6[int]` +generics_variance_inference.py:194:37: error[invalid-assignment] Object of type `ShouldBeContravariant2[int]` is not assignable to `ShouldBeContravariant2[float]` +generics_variance_inference.py:205:31: error[invalid-assignment] Object of type `ShouldBeCovariant7[object]` is not assignable to `ShouldBeCovariant7[int]` +""" diff --git a/conformance/results/ty/historical_positional.toml b/conformance/results/ty/historical_positional.toml new file mode 100644 index 000000000..f435999e0 --- /dev/null +++ b/conformance/results/ty/historical_positional.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +historical_positional.py:18:4: error[positional-only-parameter-as-kwarg] Positional-only parameter 1 (`__x`) passed as keyword argument of function `f1` +historical_positional.py:26:16: error[invalid-legacy-positional-parameter] Invalid use of the legacy convention for positional-only parameters: Parameter name begins with `__` but will not be treated as positional-only +historical_positional.py:45:28: error[invalid-legacy-positional-parameter] Invalid use of the legacy convention for positional-only parameters: Parameter name begins with `__` but will not be treated as positional-only +historical_positional.py:54:26: error[invalid-legacy-positional-parameter] Invalid use of the legacy convention for positional-only parameters: Parameter name begins with `__` but will not be treated as positional-only +historical_positional.py:59:6: error[positional-only-parameter-as-kwarg] Positional-only parameter 2 (`__x`) passed as keyword argument of bound method `A.m1` +""" diff --git a/conformance/results/ty/literals_interactions.toml b/conformance/results/ty/literals_interactions.toml new file mode 100644 index 000000000..080adb007 --- /dev/null +++ b/conformance/results/ty/literals_interactions.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +literals_interactions.py:14:5: error[index-out-of-bounds] Index 5 is out of bounds for tuple `tuple[int, str, list[bool]]` with length 3 +literals_interactions.py:15:5: error[index-out-of-bounds] Index -5 is out of bounds for tuple `tuple[int, str, list[bool]]` with length 3 +literals_interactions.py:16:5: error[index-out-of-bounds] Index 4 is out of bounds for tuple `tuple[int, str, list[bool]]` with length 3 +literals_interactions.py:17:5: error[index-out-of-bounds] Index -4 is out of bounds for tuple `tuple[int, str, list[bool]]` with length 3 +""" diff --git a/conformance/results/ty/literals_literalstring.toml b/conformance/results/ty/literals_literalstring.toml new file mode 100644 index 000000000..b123ed0d0 --- /dev/null +++ b/conformance/results/ty/literals_literalstring.toml @@ -0,0 +1,14 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +literals_literalstring.py:36:29: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member +literals_literalstring.py:37:22: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member +literals_literalstring.py:43:23: error[invalid-assignment] Object of type `Literal["two"]` is not assignable to `Literal[""]` +literals_literalstring.py:65:25: error[invalid-assignment] Object of type `str` is not assignable to `LiteralString` +literals_literalstring.py:73:25: error[invalid-assignment] Object of type `Literal[3]` is not assignable to `LiteralString` +literals_literalstring.py:74:25: error[invalid-assignment] Object of type `Literal[b"test"]` is not assignable to `LiteralString` +literals_literalstring.py:119:22: error[invalid-argument-type] Argument to function `literal_identity` is incorrect: Argument type `str` does not satisfy upper bound `LiteralString` of type variable `TLiteral` +literals_literalstring.py:133:51: error[invalid-argument-type] Argument to `Container.__init__` is incorrect: Argument type `str` does not satisfy upper bound `LiteralString` of type variable `T` +literals_literalstring.py:171:21: error[invalid-assignment] Object of type `list[LiteralString]` is not assignable to `list[str]` +""" diff --git a/conformance/results/ty/literals_parameterizations.toml b/conformance/results/ty/literals_parameterizations.toml new file mode 100644 index 000000000..27f64295d --- /dev/null +++ b/conformance/results/ty/literals_parameterizations.toml @@ -0,0 +1,22 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +literals_parameterizations.py:41:15: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member +literals_parameterizations.py:42:15: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member +literals_parameterizations.py:43:15: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member +literals_parameterizations.py:44:15: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member +literals_parameterizations.py:45:15: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member +literals_parameterizations.py:46:15: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member +literals_parameterizations.py:47:15: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member +literals_parameterizations.py:48:15: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member +literals_parameterizations.py:49:15: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member +literals_parameterizations.py:50:16: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member +literals_parameterizations.py:51:16: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member +literals_parameterizations.py:52:16: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member +literals_parameterizations.py:53:16: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member +literals_parameterizations.py:56:28: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member +literals_parameterizations.py:60:4: error[invalid-type-form] `typing.Literal` requires at least one argument when used in a type expression +literals_parameterizations.py:61:12: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member +literals_parameterizations.py:65:32: error[invalid-assignment] Object of type `Literal[Color.RED]` is not assignable to `Literal["Color.RED"]` +""" diff --git a/conformance/results/ty/literals_semantics.toml b/conformance/results/ty/literals_semantics.toml new file mode 100644 index 000000000..f0a0bb5f6 --- /dev/null +++ b/conformance/results/ty/literals_semantics.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +literals_semantics.py:10:18: error[invalid-assignment] Object of type `Literal[4]` is not assignable to `Literal[3]` +literals_semantics.py:24:26: error[invalid-assignment] Object of type `Literal[0]` is not assignable to `Literal[False]` +literals_semantics.py:25:22: error[invalid-assignment] Object of type `Literal[False]` is not assignable to `Literal[0]` +literals_semantics.py:33:5: error[invalid-assignment] Object of type `Literal[6, 7, 8]` is not assignable to `Literal[3, 4, 5]` +""" diff --git a/conformance/results/ty/namedtuples_define_class.toml b/conformance/results/ty/namedtuples_define_class.toml new file mode 100644 index 000000000..ea5576d1d --- /dev/null +++ b/conformance/results/ty/namedtuples_define_class.toml @@ -0,0 +1,20 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +namedtuples_define_class.py:33:7: error[index-out-of-bounds] Index 3 is out of bounds for tuple `Point` with length 3 +namedtuples_define_class.py:34:7: error[index-out-of-bounds] Index -4 is out of bounds for tuple `Point` with length 3 +namedtuples_define_class.py:45:6: error[missing-argument] No argument provided for required parameter `y` +namedtuples_define_class.py:46:6: error[missing-argument] No argument provided for required parameter `y` +namedtuples_define_class.py:47:15: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `Literal[""]` +namedtuples_define_class.py:48:18: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `Literal[3]` +namedtuples_define_class.py:49:22: error[too-many-positional-arguments] Too many positional arguments: expected 4, got 5 +namedtuples_define_class.py:50:23: error[unknown-argument] Argument `other` does not match any known parameter +namedtuples_define_class.py:70:20: error[too-many-positional-arguments] Too many positional arguments: expected 3, got 4 +namedtuples_define_class.py:77:5: error[invalid-named-tuple] NamedTuple field `_y` cannot start with an underscore +namedtuples_define_class.py:87:5: error[invalid-named-tuple] NamedTuple field without default value cannot follow field(s) with default value(s): Field `latitude` defined here without a default value +namedtuples_define_class.py:107:5: error[invalid-named-tuple-override] Cannot override NamedTuple field `x` inherited from `Point` +namedtuples_define_class.py:121:24: error[too-many-positional-arguments] Too many positional arguments: expected 3, got 4 +namedtuples_define_class.py:140:19: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `float*` +namedtuples_define_class.py:147:24: error[invalid-named-tuple] NamedTuple class `Unit` cannot use multiple inheritance except with `Generic[]` +""" diff --git a/conformance/results/ty/namedtuples_define_functional.toml b/conformance/results/ty/namedtuples_define_functional.toml new file mode 100644 index 000000000..037fdf685 --- /dev/null +++ b/conformance/results/ty/namedtuples_define_functional.toml @@ -0,0 +1,19 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +namedtuples_define_functional.py:16:8: error[missing-argument] No argument provided for required parameter `y` +namedtuples_define_functional.py:21:8: error[missing-argument] No arguments provided for required parameters `x`, `y` +namedtuples_define_functional.py:26:21: error[too-many-positional-arguments] Too many positional arguments: expected 3, got 4 +namedtuples_define_functional.py:31:8: error[missing-argument] No argument provided for required parameter `y` +namedtuples_define_functional.py:31:18: error[unknown-argument] Argument `z` does not match any known parameter +namedtuples_define_functional.py:36:18: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `Literal["1"]` +namedtuples_define_functional.py:37:21: error[too-many-positional-arguments] Too many positional arguments: expected 3, got 4 +namedtuples_define_functional.py:42:18: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `Literal["1"]` +namedtuples_define_functional.py:43:15: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `float*` +namedtuples_define_functional.py:52:25: error[invalid-named-tuple] Duplicate field name `a` in `namedtuple()`: Field `a` already defined; will raise `ValueError` at runtime +namedtuples_define_functional.py:53:25: error[invalid-named-tuple] Field name `def` in `namedtuple()` cannot be a Python keyword: Will raise `ValueError` at runtime +namedtuples_define_functional.py:54:25: error[invalid-named-tuple] Field name `def` in `namedtuple()` cannot be a Python keyword: Will raise `ValueError` at runtime +namedtuples_define_functional.py:55:25: error[invalid-named-tuple] Field name `_d` in `namedtuple()` cannot start with an underscore: Will raise `ValueError` at runtime +namedtuples_define_functional.py:69:1: error[missing-argument] No argument provided for required parameter `a` +""" diff --git a/conformance/results/ty/namedtuples_type_compat.toml b/conformance/results/ty/namedtuples_type_compat.toml new file mode 100644 index 000000000..1003a3256 --- /dev/null +++ b/conformance/results/ty/namedtuples_type_compat.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +namedtuples_type_compat.py:22:23: error[invalid-assignment] Object of type `Point` is not assignable to `tuple[int, int]` +namedtuples_type_compat.py:23:28: error[invalid-assignment] Object of type `Point` is not assignable to `tuple[int, str, str]` +""" diff --git a/conformance/results/ty/namedtuples_usage.toml b/conformance/results/ty/namedtuples_usage.toml new file mode 100644 index 000000000..01cf6f669 --- /dev/null +++ b/conformance/results/ty/namedtuples_usage.toml @@ -0,0 +1,13 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +namedtuples_usage.py:34:7: error[index-out-of-bounds] Index 3 is out of bounds for tuple `Point` with length 3 +namedtuples_usage.py:35:7: error[index-out-of-bounds] Index -4 is out of bounds for tuple `Point` with length 3 +namedtuples_usage.py:40:1: error[invalid-assignment] Cannot assign to read-only property `x` on object of type `Point` +namedtuples_usage.py:41:1: error[invalid-assignment] Cannot assign to a subscript on an object of type `Point` +namedtuples_usage.py:42:5: error[invalid-assignment] Cannot delete read-only property `x` on object of type `Point` +namedtuples_usage.py:43:5: error[not-subscriptable] Cannot delete subscript on object of type `Point` with no `__delitem__` method +namedtuples_usage.py:52:1: error[invalid-assignment] Too many values to unpack: Expected 2 +namedtuples_usage.py:53:1: error[invalid-assignment] Not enough values to unpack: Expected 4 +""" diff --git a/conformance/results/ty/narrowing_typeguard.toml b/conformance/results/ty/narrowing_typeguard.toml new file mode 100644 index 000000000..196a41941 --- /dev/null +++ b/conformance/results/ty/narrowing_typeguard.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +narrowing_typeguard.py:102:23: error[invalid-type-guard-definition] `TypeGuard` function must have a parameter to narrow +narrowing_typeguard.py:107:22: error[invalid-type-guard-definition] `TypeGuard` function must have a parameter to narrow +narrowing_typeguard.py:128:20: error[invalid-argument-type] Argument to function `takes_callable_str` is incorrect: Expected `(object, /) -> str`, found `def simple_typeguard(val: object) -> TypeGuard[int]` +narrowing_typeguard.py:148:26: error[invalid-argument-type] Argument to function `takes_callable_str_proto` is incorrect: Expected `CallableStrProto`, found `def simple_typeguard(val: object) -> TypeGuard[int]` +""" diff --git a/conformance/results/ty/narrowing_typeis.toml b/conformance/results/ty/narrowing_typeis.toml new file mode 100644 index 000000000..d4882af5b --- /dev/null +++ b/conformance/results/ty/narrowing_typeis.toml @@ -0,0 +1,14 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +narrowing_typeis.py:110:23: error[invalid-type-guard-definition] `TypeIs` function must have a parameter to narrow +narrowing_typeis.py:115:22: error[invalid-type-guard-definition] `TypeIs` function must have a parameter to narrow +narrowing_typeis.py:137:20: error[invalid-argument-type] Argument to function `takes_callable_str` is incorrect: Expected `(object, /) -> str`, found `def simple_typeguard(val: object) -> TypeIs[int]` +narrowing_typeis.py:157:26: error[invalid-argument-type] Argument to function `takes_callable_str_proto` is incorrect: Expected `CallableStrProto`, found `def simple_typeguard(val: object) -> TypeIs[int]` +narrowing_typeis.py:174:17: error[invalid-argument-type] Argument to function `takes_typeguard` is incorrect: Expected `(object, /) -> TypeGuard[int]`, found `def is_int_typeis(val: object) -> TypeIs[int]` +narrowing_typeis.py:175:14: error[invalid-argument-type] Argument to function `takes_typeis` is incorrect: Expected `(object, /) -> TypeIs[int]`, found `def is_int_typeguard(val: object) -> TypeGuard[int]` +narrowing_typeis.py:196:18: error[invalid-argument-type] Argument to function `takes_int_typeis` is incorrect: Expected `(object, /) -> TypeIs[int]`, found `def bool_typeis(val: object) -> TypeIs[bool]` +narrowing_typeis.py:200:27: error[invalid-type-guard-definition] Narrowed type `str` is not assignable to the declared parameter type `int` +narrowing_typeis.py:204:45: error[invalid-type-guard-definition] Narrowed type `list[int]` is not assignable to the declared parameter type `list[object]` +""" diff --git a/conformance/results/ty/overloads_basic.toml b/conformance/results/ty/overloads_basic.toml new file mode 100644 index 000000000..eb874c741 --- /dev/null +++ b/conformance/results/ty/overloads_basic.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +overloads_basic.py:39:1: error[invalid-argument-type] Method `__getitem__` of type `Overload[(__i: int, /) -> int, (__s: slice[Any, Any, Any], /) -> bytes]` cannot be called with key of type `Literal[""]` on object of type `Bytes` +""" diff --git a/conformance/results/ty/overloads_consistency.toml b/conformance/results/ty/overloads_consistency.toml new file mode 100644 index 000000000..ba10fac4e --- /dev/null +++ b/conformance/results/ty/overloads_consistency.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +overloads_consistency.py:25:5: error[invalid-overload] Overload return type is not assignable to implementation return type +overloads_consistency.py:41:5: error[invalid-overload] Implementation does not accept all arguments of this overload +""" diff --git a/conformance/results/ty/overloads_definitions.toml b/conformance/results/ty/overloads_definitions.toml new file mode 100644 index 000000000..090f8fdf0 --- /dev/null +++ b/conformance/results/ty/overloads_definitions.toml @@ -0,0 +1,17 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +overloads_definitions.py:16:5: error[invalid-overload] Overloaded function `func1` requires at least two overloads: Only one overload defined here +overloads_definitions.py:28:5: error[invalid-overload] Overloads for function `func2` must be followed by a non-`@overload`-decorated implementation function +overloads_definitions.py:59:9: error[invalid-overload] Overloads for function `not_abstract` must be followed by a non-`@overload`-decorated implementation function +overloads_definitions.py:81:9: error[invalid-overload] Overloaded function `func5` does not use the `@staticmethod` decorator consistently +overloads_definitions.py:94:9: error[invalid-overload] Overloaded function `func6` does not use the `@classmethod` decorator consistently +overloads_definitions.py:124:9: error[invalid-overload] `@final` decorator should be applied only to the overload implementation +overloads_definitions.py:139:9: error[invalid-overload] `@final` decorator should be applied only to the overload implementation +overloads_definitions.py:144:9: error[invalid-overload] `@final` decorator should be applied only to the overload implementation +overloads_definitions.py:186:9: error[override-of-final-method] Cannot override final member `final_method` from superclass `Base` +overloads_definitions.py:203:9: error[invalid-explicit-override] Method `bad_override` is decorated with `@override` but does not override anything +overloads_definitions.py:228:9: error[invalid-overload] `@override` decorator should be applied only to the overload implementation +overloads_definitions.py:232:9: error[invalid-overload] `@override` decorator should be applied only to the overload implementation +""" diff --git a/conformance/results/ty/overloads_definitions_stub.toml b/conformance/results/ty/overloads_definitions_stub.toml new file mode 100644 index 000000000..43ec8feea --- /dev/null +++ b/conformance/results/ty/overloads_definitions_stub.toml @@ -0,0 +1,13 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +overloads_definitions_stub.pyi:14:5: error[invalid-overload] Overloaded function `func1` requires at least two overloads: Only one overload defined here +overloads_definitions_stub.pyi:37:9: error[invalid-overload] Overloaded function `func5` does not use the `@staticmethod` decorator consistently +overloads_definitions_stub.pyi:44:9: error[invalid-overload] Overloaded function `func6` does not use the `@classmethod` decorator consistently +overloads_definitions_stub.pyi:73:9: error[invalid-overload] `@final` decorator should be applied only to the first overload +overloads_definitions_stub.pyi:86:9: error[invalid-overload] `@final` decorator should be applied only to the first overload +overloads_definitions_stub.pyi:111:9: error[override-of-final-method] Cannot override final member `final_method` from superclass `Base` +overloads_definitions_stub.pyi:122:9: error[invalid-explicit-override] Method `bad_override` is decorated with `@override` but does not override anything +overloads_definitions_stub.pyi:147:9: error[invalid-overload] `@override` decorator should be applied only to the first overload +""" diff --git a/conformance/results/ty/overloads_evaluation.toml b/conformance/results/ty/overloads_evaluation.toml new file mode 100644 index 000000000..3a9a963c2 --- /dev/null +++ b/conformance/results/ty/overloads_evaluation.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +overloads_evaluation.py:38:1: error[no-matching-overload] No overload of function `example1_1` matches arguments +overloads_evaluation.py:46:15: error[invalid-argument-type] Argument to function `example1_1` is incorrect: Expected `str`, found `Literal[1]` +overloads_evaluation.py:51:12: error[invalid-argument-type] Argument to function `example1_1` is incorrect: Expected `str`, found `Literal[1]` +overloads_evaluation.py:116:5: error[no-matching-overload] No overload of function `example2` matches arguments +""" diff --git a/conformance/results/ty/protocols_class_objects.toml b/conformance/results/ty/protocols_class_objects.toml new file mode 100644 index 000000000..de396b6e0 --- /dev/null +++ b/conformance/results/ty/protocols_class_objects.toml @@ -0,0 +1,18 @@ +conformance_automated = "Fail" +conformant = "Partial" +notes = """ +Does not reject protocol classes where `type[Proto]` requires a concrete class. +Incorrectly considers instance attributes as satisfying protocol members on class objects. +""" +errors_diff = """ +Line 29: Expected 1 errors +Line 34: Expected 1 errors +Line 107: Expected 1 errors +""" +output = """ +protocols_class_objects.py:58:16: error[invalid-assignment] Object of type `` is not assignable to `ProtoA1` +protocols_class_objects.py:74:16: error[invalid-assignment] Object of type `` is not assignable to `ProtoB1` +protocols_class_objects.py:104:16: error[invalid-assignment] Object of type `` is not assignable to `ProtoC1` +protocols_class_objects.py:106:16: error[invalid-assignment] Object of type `` is not assignable to `ProtoC1` +protocols_class_objects.py:108:16: error[invalid-assignment] Object of type `` is not assignable to `ProtoC1` +""" diff --git a/conformance/results/ty/protocols_definition.toml b/conformance/results/ty/protocols_definition.toml new file mode 100644 index 000000000..09ccdd19e --- /dev/null +++ b/conformance/results/ty/protocols_definition.toml @@ -0,0 +1,28 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +protocols_definition.py:30:11: error[invalid-argument-type] Argument to function `close_all` is incorrect: Expected `Iterable[SupportsClose]`, found `list[int]` +protocols_definition.py:67:9: error[ambiguous-protocol-member] Cannot assign to an undeclared attribute in a protocol method: `temp` is not declared as a protocol member +protocols_definition.py:114:22: error[invalid-assignment] Object of type `Concrete2_Bad1` is not assignable to `Template2` +protocols_definition.py:115:22: error[invalid-assignment] Object of type `Concrete2_Bad2` is not assignable to `Template2` +protocols_definition.py:116:22: error[invalid-assignment] Object of type `Concrete2_Bad3` is not assignable to `Template2` +protocols_definition.py:117:22: error[invalid-assignment] Object of type `Concrete2_Bad4` is not assignable to `Template2` +protocols_definition.py:156:22: error[invalid-assignment] Object of type `Concrete3_Bad1` is not assignable to `Template3` +protocols_definition.py:157:22: error[invalid-assignment] Object of type `Concrete3_Bad2` is not assignable to `Template3` +protocols_definition.py:158:22: error[invalid-assignment] Object of type `Concrete3_Bad3` is not assignable to `Template3` +protocols_definition.py:159:22: error[invalid-assignment] Object of type `Concrete3_Bad4` is not assignable to `Template3` +protocols_definition.py:160:22: error[invalid-assignment] Object of type `Concrete3_Bad5` is not assignable to `Template3` +protocols_definition.py:218:22: error[invalid-assignment] Object of type `Concrete4_Bad1` is not assignable to `Template4` +protocols_definition.py:219:22: error[invalid-assignment] Object of type `Concrete4_Bad2` is not assignable to `Template4` +protocols_definition.py:285:22: error[invalid-assignment] Object of type `Concrete5_Bad1` is not assignable to `Template5` +protocols_definition.py:286:22: error[invalid-assignment] Object of type `Concrete5_Bad2` is not assignable to `Template5` +protocols_definition.py:287:22: error[invalid-assignment] Object of type `Concrete5_Bad3` is not assignable to `Template5` +protocols_definition.py:288:22: error[invalid-assignment] Object of type `Concrete5_Bad4` is not assignable to `Template5` +protocols_definition.py:289:22: error[invalid-assignment] Object of type `Concrete5_Bad5` is not assignable to `Template5` +protocols_definition.py:339:22: error[invalid-assignment] Object of type `Concrete6_Bad1` is not assignable to `Template6` +protocols_definition.py:340:22: error[invalid-assignment] Object of type `Concrete6_Bad2` is not assignable to `Template6` +protocols_definition.py:341:22: error[invalid-assignment] Object of type `Concrete6_Bad3` is not assignable to `Template6` +protocols_definition.py:369:22: error[invalid-assignment] Object of type `Concrete7_Bad1` is not assignable to `Template7` +protocols_definition.py:370:22: error[invalid-assignment] Object of type `Concrete7_Bad2` is not assignable to `Template7` +""" diff --git a/conformance/results/ty/protocols_explicit.toml b/conformance/results/ty/protocols_explicit.toml new file mode 100644 index 000000000..1390ea2cb --- /dev/null +++ b/conformance/results/ty/protocols_explicit.toml @@ -0,0 +1,16 @@ +conformance_automated = "Fail" +conformant = "Partial" +notes = """ +Allows abstract protocol methods with no default implementation to be called via `super()` on a protocol subclass. +Allows instantiation of protocol subclasses with uninitialized `ClassVar` members. +""" +errors_diff = """ +Line 27: Expected 1 errors +Line 89: Expected 1 errors +""" +output = """ +protocols_explicit.py:56:9: error[invalid-assignment] Object of type `tuple[int, int, str]` is not assignable to attribute `rgb` of type `tuple[int, int, int]` +protocols_explicit.py:60:5: error[call-non-callable] Cannot instantiate `Point` with unimplemented abstract methods `intensity` and `transparency` +protocols_explicit.py:134:6: error[call-non-callable] Cannot instantiate `Concrete5` with unimplemented abstract method `method1` +protocols_explicit.py:164:7: error[call-non-callable] Cannot instantiate `Concrete7A` with unimplemented abstract method `method1` +""" diff --git a/conformance/results/ty/protocols_generic.toml b/conformance/results/ty/protocols_generic.toml new file mode 100644 index 000000000..81b16bf33 --- /dev/null +++ b/conformance/results/ty/protocols_generic.toml @@ -0,0 +1,18 @@ +conformance_automated = "Fail" +conformant = "Partial" +notes = """ +Does not reject incompatible non-generic implementations of generic protocol methods. +""" +errors_diff = """ +Line 153: Expected 1 errors +""" +output = """ +protocols_generic.py:40:24: error[invalid-assignment] Object of type `Concrete1` is not assignable to `Proto1[int, str]` +protocols_generic.py:44:14: error[invalid-generic-class] Cannot both inherit from subscripted `Protocol` and subscripted `Generic` +protocols_generic.py:56:20: error[invalid-assignment] Object of type `Box[float]` is not assignable to `Box[int]` +protocols_generic.py:66:25: error[invalid-assignment] Object of type `Sender[int]` is not assignable to `Sender[float]` +protocols_generic.py:74:28: error[invalid-assignment] Object of type `AttrProto[int]` is not assignable to `AttrProto[float]` +protocols_generic.py:75:26: error[invalid-assignment] Object of type `AttrProto[float]` is not assignable to `AttrProto[int]` +protocols_generic.py:133:26: error[invalid-assignment] Object of type `InvalidParentProperty` is not assignable to `HasParentProperty` +protocols_generic.py:185:23: error[invalid-assignment] Object of type `InvalidGreaterThan` is not assignable to `HasGreaterThan` +""" diff --git a/conformance/results/ty/protocols_merging.toml b/conformance/results/ty/protocols_merging.toml new file mode 100644 index 000000000..539c057e8 --- /dev/null +++ b/conformance/results/ty/protocols_merging.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +protocols_merging.py:52:25: error[invalid-assignment] Object of type `SCConcrete2` is not assignable to `SizedAndClosable1` +protocols_merging.py:53:25: error[invalid-assignment] Object of type `SCConcrete2` is not assignable to `SizedAndClosable2` +protocols_merging.py:54:25: error[invalid-assignment] Object of type `SCConcrete2` is not assignable to `SizedAndClosable3` +protocols_merging.py:67:16: error[invalid-protocol] Protocol class `BadProto` cannot inherit from non-protocol class `SizedAndClosable3` +protocols_merging.py:82:5: error[call-non-callable] Cannot instantiate `SizedAndClosable4` with unimplemented abstract method `close` +protocols_merging.py:83:24: error[invalid-assignment] Object of type `SCConcrete1` is not assignable to `SizedAndClosable4` +""" diff --git a/conformance/results/ty/protocols_modules.toml b/conformance/results/ty/protocols_modules.toml new file mode 100644 index 000000000..1b0a41e46 --- /dev/null +++ b/conformance/results/ty/protocols_modules.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +protocols_modules.py:26:17: error[invalid-assignment] Object of type `` is not assignable to `Options2` +protocols_modules.py:48:18: error[invalid-assignment] Object of type `` is not assignable to `Reporter2` +protocols_modules.py:49:18: error[invalid-assignment] Object of type `` is not assignable to `Reporter3` +""" diff --git a/conformance/results/ty/protocols_recursive.toml b/conformance/results/ty/protocols_recursive.toml new file mode 100644 index 000000000..f6bfd7871 --- /dev/null +++ b/conformance/results/ty/protocols_recursive.toml @@ -0,0 +1,11 @@ +conformance_automated = "Fail" +conformant = "Partial" +notes = """ +Fails to solve a type variable involving a recursive generic protocol. +""" +errors_diff = """ +Line 81: Unexpected errors ['protocols_recursive.py:81:1: error[type-assertion-failure] Type `Unknown` does not match asserted type `list[int]`'] +""" +output = """ +protocols_recursive.py:81:1: error[type-assertion-failure] Type `Unknown` does not match asserted type `list[int]` +""" diff --git a/conformance/results/ty/protocols_runtime_checkable.toml b/conformance/results/ty/protocols_runtime_checkable.toml new file mode 100644 index 000000000..8725a7eec --- /dev/null +++ b/conformance/results/ty/protocols_runtime_checkable.toml @@ -0,0 +1,15 @@ +conformance_automated = "Fail" +conformant = "Partial" +notes = """ +Does not reject `isinstance()` or `issubclass()` calls against runtime-checkable protocols where there is an unsafe overlap between the type of the first argument and the protocol. +""" +errors_diff = """ +Line 88: Expected 1 errors +Line 91: Expected 1 errors +Line 94: Expected 1 errors +""" +output = """ +protocols_runtime_checkable.py:23:8: error[isinstance-against-protocol] Class `Proto1` cannot be used as the second argument to `isinstance`: This call will raise `TypeError` at runtime +protocols_runtime_checkable.py:55:8: error[isinstance-against-protocol] `DataProtocol` cannot be used as the second argument to `issubclass` as it is a protocol with non-method members +protocols_runtime_checkable.py:61:8: error[isinstance-against-protocol] `DataProtocol` cannot be used as the second argument to `issubclass` as it is a protocol with non-method members +""" diff --git a/conformance/results/ty/protocols_self.toml b/conformance/results/ty/protocols_self.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/ty/protocols_self.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/ty/protocols_subtyping.toml b/conformance/results/ty/protocols_subtyping.toml new file mode 100644 index 000000000..3e5b0c8dd --- /dev/null +++ b/conformance/results/ty/protocols_subtyping.toml @@ -0,0 +1,12 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +protocols_subtyping.py:16:6: error[call-non-callable] Cannot instantiate class `Proto1`: This call will raise `TypeError` at runtime +protocols_subtyping.py:38:21: error[invalid-assignment] Object of type `Proto2` is not assignable to `Concrete2` +protocols_subtyping.py:55:18: error[invalid-assignment] Object of type `Proto2` is not assignable to `Proto3` +protocols_subtyping.py:79:30: error[invalid-assignment] Object of type `Proto5[int]` is not assignable to `Proto4[int, float]` +protocols_subtyping.py:80:25: error[invalid-assignment] Object of type `Proto4[int, int]` is not assignable to `Proto5[float]` +protocols_subtyping.py:102:30: error[invalid-assignment] Object of type `Proto6[float, float]` is not assignable to `Proto7[int, float]` +protocols_subtyping.py:103:33: error[invalid-assignment] Object of type `Proto6[float, float]` is not assignable to `Proto7[float, object]` +""" diff --git a/conformance/results/ty/protocols_variance.toml b/conformance/results/ty/protocols_variance.toml new file mode 100644 index 000000000..fb6d606cd --- /dev/null +++ b/conformance/results/ty/protocols_variance.toml @@ -0,0 +1,12 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +protocols_variance.py:22:7: error[invalid-protocol] Type variable `T1` in protocol `AnotherBox` should be covariant, but is invariant +protocols_variance.py:41:7: error[invalid-protocol] Type variable `T3` in protocol `Protocol2` should be contravariant, but is invariant +protocols_variance.py:57:7: error[invalid-protocol] Type variable `T1` in protocol `Protocol4` should be contravariant, but is invariant +protocols_variance.py:62:7: error[invalid-protocol] Type variable `T1_co` in protocol `Protocol5` should be contravariant, but is covariant +protocols_variance.py:67:7: error[invalid-protocol] Type variable `T1` in protocol `Protocol6` should be covariant, but is invariant +protocols_variance.py:72:7: error[invalid-protocol] Type variable `T1_contra` in protocol `Protocol7` should be covariant, but is contravariant +protocols_variance.py:105:7: error[invalid-protocol] Type variable `T1` in protocol `Protocol12` should be covariant, but is invariant +""" diff --git a/conformance/results/ty/qualifiers_annotated.toml b/conformance/results/ty/qualifiers_annotated.toml new file mode 100644 index 000000000..cd76ea815 --- /dev/null +++ b/conformance/results/ty/qualifiers_annotated.toml @@ -0,0 +1,25 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +qualifiers_annotated.py:38:17: error[invalid-type-form] List literals are not allowed in this context in a type expression +qualifiers_annotated.py:39:17: error[invalid-type-form] Tuple literals are not allowed in this context in a type expression +qualifiers_annotated.py:40:17: error[invalid-type-form] List comprehensions are not allowed in type expressions +qualifiers_annotated.py:41:17: error[invalid-type-form] Dict literals are not allowed in type expressions +qualifiers_annotated.py:42:17: error[invalid-type-form] Function calls are not allowed in type expressions +qualifiers_annotated.py:43:17: error[invalid-type-form] Only simple names and dotted names can be subscripted in type expressions +qualifiers_annotated.py:44:17: error[invalid-type-form] `if` expressions are not allowed in type expressions +qualifiers_annotated.py:45:17: error[unresolved-reference] Name `var1` used when not defined +qualifiers_annotated.py:46:17: error[invalid-type-form] Boolean literals are not allowed in this context in a type expression: Did you mean `typing.Literal[True]`? +qualifiers_annotated.py:47:18: error[invalid-type-form] Int literals are not allowed in this context in a type expression: Did you mean `typing.Literal[1]`? +qualifiers_annotated.py:48:18: error[invalid-type-form] Boolean operations are not allowed in type expressions +qualifiers_annotated.py:49:18: error[invalid-type-form] F-strings are not allowed in type expressions +qualifiers_annotated.py:59:8: error[invalid-type-form] Special form `typing.Annotated` expected at least 2 arguments (one type and at least one metadata element) +qualifiers_annotated.py:71:24: error[invalid-assignment] Object of type `]'>` is not assignable to `type[Any]` +qualifiers_annotated.py:72:24: error[invalid-assignment] Object of type `]'>` is not assignable to `type[Any]` +qualifiers_annotated.py:79:7: error[invalid-argument-type] Argument to function `func4` is incorrect: Expected `type[Unknown]`, found `]'>` +qualifiers_annotated.py:80:7: error[invalid-argument-type] Argument to function `func4` is incorrect: Expected `type[Unknown]`, found `]'>` +qualifiers_annotated.py:86:1: error[call-non-callable] Object of type `` is not callable +qualifiers_annotated.py:87:1: error[call-non-callable] Object of type `GenericAlias` is not callable +qualifiers_annotated.py:88:1: error[call-non-callable] Object of type `GenericAlias` is not callable +""" diff --git a/conformance/results/ty/qualifiers_final_annotation.toml b/conformance/results/ty/qualifiers_final_annotation.toml new file mode 100644 index 000000000..ba871f898 --- /dev/null +++ b/conformance/results/ty/qualifiers_final_annotation.toml @@ -0,0 +1,35 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +qualifiers_final_annotation.py:16:1: error[final-without-value] `Final` symbol `BAD1` is not assigned a value +qualifiers_final_annotation.py:18:7: error[invalid-type-form] Type qualifier `typing.Final` expected exactly 1 argument, got 2 +qualifiers_final_annotation.py:34:5: error[final-without-value] `Final` symbol `ID2` is not assigned a value +qualifiers_final_annotation.py:38:5: error[final-without-value] `Final` symbol `ID3` is not assigned a value +qualifiers_final_annotation.py:54:9: error[invalid-assignment] Invalid assignment to final attribute: `ID5` already has a value in the class body +qualifiers_final_annotation.py:62:9: error[invalid-assignment] Cannot assign to final attribute `id3` on type `Self@method1`: `Final` attributes can only be assigned in the class body or `__init__` +qualifiers_final_annotation.py:63:9: error[invalid-assignment] Cannot assign to final attribute `id4` on type `Self@method1`: `Final` attributes can only be assigned in the class body or `__init__` +qualifiers_final_annotation.py:65:9: error[invalid-assignment] Cannot assign to final attribute `ID7` on type `Self@method1`: `Final` attributes can only be assigned in the class body or `__init__` +qualifiers_final_annotation.py:67:9: error[invalid-assignment] Cannot assign to final attribute `ID7` on type `Self@method1`: `Final` attributes can only be assigned in the class body or `__init__` +qualifiers_final_annotation.py:71:1: error[invalid-assignment] Reassignment of `Final` symbol `RATE` is not allowed: Symbol later reassigned here +qualifiers_final_annotation.py:81:1: error[invalid-assignment] Cannot assign to final attribute `DEFAULT_ID` on type ``: `Final` attributes can only be assigned in the class body or `__init__` +qualifiers_final_annotation.py:94:5: error[override-of-final-variable] Cannot override final variable `BORDER_WIDTH` from superclass `ClassC` +qualifiers_final_annotation.py:107:13: error[redundant-final-classvar] `Combining `ClassVar` and `Final` is redundant +qualifiers_final_annotation.py:108:13: error[redundant-final-classvar] `Combining `ClassVar` and `Final` is redundant +qualifiers_final_annotation.py:118:9: error[invalid-type-form] Type qualifier `typing.Final` is not allowed in type expressions (only in annotation expressions) +qualifiers_final_annotation.py:121:14: error[invalid-type-form] Type qualifier `typing.Final` is not allowed in parameter annotations +qualifiers_final_annotation.py:131:8: error[invalid-type-form] `Final` is not allowed in TypedDict fields +qualifiers_final_annotation.py:136:5: error[invalid-named-tuple] Type qualifier `Final` is not allowed on NamedTuple field `b` +qualifiers_final_annotation.py:148:1: error[missing-argument] No arguments provided for required parameters `x`, `y` +qualifiers_final_annotation.py:148:3: error[unknown-argument] Argument `a` does not match any known parameter +qualifiers_final_annotation.py:149:3: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `Literal[""]` +qualifiers_final_annotation.py:149:9: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `Literal[""]` +qualifiers_final_annotation.py:155:5: error[invalid-assignment] Reassignment of `Final` symbol `ID1` is not allowed: Reassignment of `Final` symbol +qualifiers_final_annotation.py:159:5: error[invalid-assignment] Reassignment of `Final` symbol `x` is not allowed: Symbol later reassigned here +qualifiers_final_annotation.py:161:10: error[invalid-assignment] Reassignment of `Final` symbol `x` is not allowed: Symbol later reassigned here +qualifiers_final_annotation.py:163:9: error[invalid-assignment] Reassignment of `Final` symbol `x` is not allowed: Symbol later reassigned here +qualifiers_final_annotation.py:166:30: error[invalid-assignment] Reassignment of `Final` symbol `x` is not allowed: Symbol later reassigned here +qualifiers_final_annotation.py:169:9: error[invalid-assignment] Reassignment of `Final` symbol `x` is not allowed: Symbol later reassigned here +qualifiers_final_annotation.py:180:1: error[invalid-assignment] Reassignment of `Final` symbol `TEN` is not allowed: Reassignment of `Final` symbol +qualifiers_final_annotation.py:184:1: error[invalid-assignment] Reassignment of `Final` symbol `PI` is not allowed: Reassignment of `Final` symbol +""" diff --git a/conformance/results/ty/qualifiers_final_decorator.toml b/conformance/results/ty/qualifiers_final_decorator.toml new file mode 100644 index 000000000..7236dc2a4 --- /dev/null +++ b/conformance/results/ty/qualifiers_final_decorator.toml @@ -0,0 +1,16 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +qualifiers_final_decorator.py:21:16: error[subclass-of-final-class] Class `Derived1` cannot inherit from final class `Base1` +qualifiers_final_decorator.py:56:9: error[override-of-final-method] Cannot override final member `method1` from superclass `Base2` +qualifiers_final_decorator.py:60:9: error[override-of-final-method] Cannot override final member `method2` from superclass `Base2` +qualifiers_final_decorator.py:64:9: error[override-of-final-method] Cannot override final member `method3` from superclass `Base2` +qualifiers_final_decorator.py:75:9: error[override-of-final-method] Cannot override final member `method4` from superclass `Base2` +qualifiers_final_decorator.py:86:9: error[invalid-overload] `@final` decorator should be applied only to the overload implementation +qualifiers_final_decorator.py:89:9: error[override-of-final-method] Cannot override final member `method` from superclass `Base3` +qualifiers_final_decorator.py:102:9: error[override-of-final-method] Cannot override final member `method` from superclass `Base4` +qualifiers_final_decorator.py:118:9: error[invalid-method-override] Invalid override of method `method`: Definition is incompatible with `Base5_2.method` +qualifiers_final_decorator.py:118:9: error[override-of-final-method] Cannot override final member `method` from superclass `Base5_2` +qualifiers_final_decorator.py:125:1: error[final-on-non-method] `@final` cannot be applied to non-method function `func1` +""" diff --git a/conformance/results/ty/specialtypes_any.toml b/conformance/results/ty/specialtypes_any.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/ty/specialtypes_any.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/ty/specialtypes_never.toml b/conformance/results/ty/specialtypes_never.toml new file mode 100644 index 000000000..9f528bb43 --- /dev/null +++ b/conformance/results/ty/specialtypes_never.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +specialtypes_never.py:19:22: error[invalid-return-type] Function always implicitly returns `None`, which is not assignable to return type `Never` +specialtypes_never.py:85:21: error[invalid-assignment] Object of type `list[Never]` is not assignable to `list[int]` +specialtypes_never.py:104:12: error[invalid-return-type] Return type does not match returned value: expected `ClassC[U@func10]`, found `ClassC[Never]` +""" diff --git a/conformance/results/ty/specialtypes_none.toml b/conformance/results/ty/specialtypes_none.toml new file mode 100644 index 000000000..9801c5cc7 --- /dev/null +++ b/conformance/results/ty/specialtypes_none.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +specialtypes_none.py:21:7: error[invalid-argument-type] Argument to function `func1` is incorrect: Expected `None`, found `` +specialtypes_none.py:27:19: error[invalid-assignment] Object of type `None` is not assignable to `Iterable[Unknown]` +specialtypes_none.py:41:7: error[invalid-argument-type] Argument to function `func2` is incorrect: Expected ``, found `None` +""" diff --git a/conformance/results/ty/specialtypes_promotions.toml b/conformance/results/ty/specialtypes_promotions.toml new file mode 100644 index 000000000..1e2be6c14 --- /dev/null +++ b/conformance/results/ty/specialtypes_promotions.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +specialtypes_promotions.py:13:5: error[unresolved-attribute] Attribute `numerator` is not defined on `float*` in union `float` +""" diff --git a/conformance/results/ty/specialtypes_sentinels.toml b/conformance/results/ty/specialtypes_sentinels.toml new file mode 100644 index 000000000..0a2125c36 --- /dev/null +++ b/conformance/results/ty/specialtypes_sentinels.toml @@ -0,0 +1,9 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +specialtypes_sentinels.py:14:11: error[invalid-parameter-default] Default value of type `MISSING` is not assignable to annotated parameter type `int` +specialtypes_sentinels.py:36:7: error[invalid-argument-type] Argument to function `func2` is incorrect: Expected `int | MISSING | SPECIAL`, found `IN_CLASS` +specialtypes_sentinels.py:39:7: error[invalid-argument-type] Argument to function `func3` is incorrect: Expected `int | IN_CLASS`, found `MISSING` +""" diff --git a/conformance/results/ty/specialtypes_type.toml b/conformance/results/ty/specialtypes_type.toml new file mode 100644 index 000000000..b059eb5e5 --- /dev/null +++ b/conformance/results/ty/specialtypes_type.toml @@ -0,0 +1,36 @@ +conformance_automated = "Fail" +conformant = "Partial" +notes = """ +Treats `type` equivalently to `type[object]` rather than `type[typing.Any]`. +""" +errors_diff = """ +Line 84: Unexpected errors ['specialtypes_type.py:84:5: error[type-assertion-failure] Type `type` does not match asserted type `type[Any]`'] +Line 99: Unexpected errors ['specialtypes_type.py:99:17: error[unresolved-attribute] Object of type `type` has no attribute `unknown`'] +Line 100: Unexpected errors ['specialtypes_type.py:100:17: error[unresolved-attribute] Object of type `type` has no attribute `unknown`'] +Line 107: Unexpected errors ['specialtypes_type.py:107:17: error[unresolved-attribute] Object of type `type` has no attribute `unknown`'] +Line 108: Unexpected errors ['specialtypes_type.py:108:17: error[unresolved-attribute] Object of type `type` has no attribute `unknown`'] +Line 137: Unexpected errors ['specialtypes_type.py:137:5: error[type-assertion-failure] Type `type` does not match asserted type `type[Any]`'] +Line 139: Unexpected errors ['specialtypes_type.py:139:5: error[type-assertion-failure] Type `type` does not match asserted type `type[Any]`'] +Line 169: Unexpected errors ['specialtypes_type.py:169:21: error[invalid-assignment] Object of type `type` is not assignable to `type[int]`'] +Line 175: Unexpected errors ['specialtypes_type.py:175:16: error[invalid-return-type] Return type does not match returned value: expected `type[T@ClassA]`, found `type`'] +""" +output = """ +specialtypes_type.py:56:7: error[invalid-argument-type] Argument to function `func4` is incorrect: Expected `type[BasicUser | ProUser]`, found `` +specialtypes_type.py:70:7: error[invalid-argument-type] Argument to function `func5` is incorrect: Expected `type[Unknown]`, found `` +specialtypes_type.py:76:17: error[invalid-type-form] type[...] must have exactly one type argument +specialtypes_type.py:84:5: error[type-assertion-failure] Type `type` does not match asserted type `type[Any]` +specialtypes_type.py:99:17: error[unresolved-attribute] Object of type `type` has no attribute `unknown` +specialtypes_type.py:100:17: error[unresolved-attribute] Object of type `type` has no attribute `unknown` +specialtypes_type.py:107:17: error[unresolved-attribute] Object of type `type` has no attribute `unknown` +specialtypes_type.py:108:17: error[unresolved-attribute] Object of type `type` has no attribute `unknown` +specialtypes_type.py:117:5: error[unresolved-attribute] Object of type `type` has no attribute `unknown` +specialtypes_type.py:120:5: error[unresolved-attribute] Object of type `type` has no attribute `unknown` +specialtypes_type.py:137:5: error[type-assertion-failure] Type `type` does not match asserted type `type[Any]` +specialtypes_type.py:139:5: error[type-assertion-failure] Type `type` does not match asserted type `type[Any]` +specialtypes_type.py:143:1: error[unresolved-attribute] Special form `typing.Type` has no attribute `unknown` +specialtypes_type.py:144:1: error[unresolved-attribute] Object of type `` has no attribute `unknown` +specialtypes_type.py:145:1: error[unresolved-attribute] Class `type` has no attribute `unknown` +specialtypes_type.py:146:1: error[unresolved-attribute] Object of type `` has no attribute `unknown` +specialtypes_type.py:169:21: error[invalid-assignment] Object of type `type` is not assignable to `type[int]` +specialtypes_type.py:175:16: error[invalid-return-type] Return type does not match returned value: expected `type[T@ClassA]`, found `type` +""" diff --git a/conformance/results/ty/tuples_type_compat.toml b/conformance/results/ty/tuples_type_compat.toml new file mode 100644 index 000000000..6b7200081 --- /dev/null +++ b/conformance/results/ty/tuples_type_compat.toml @@ -0,0 +1,29 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +tuples_type_compat.py:15:27: error[invalid-assignment] Object of type `tuple[float, complex]` is not assignable to `tuple[int, int]` +tuples_type_compat.py:29:10: error[invalid-assignment] Object of type `tuple[int, ...]` is not assignable to `tuple[int, *tuple[int, ...]]` +tuples_type_compat.py:32:10: error[invalid-assignment] Object of type `tuple[int, *tuple[int, ...]]` is not assignable to `tuple[int]` +tuples_type_compat.py:33:10: error[invalid-assignment] Object of type `tuple[int, ...]` is not assignable to `tuple[int]` +tuples_type_compat.py:43:22: error[invalid-assignment] Object of type `tuple[int, ...]` is not assignable to `tuple[int]` +tuples_type_compat.py:62:26: error[invalid-assignment] Object of type `tuple[int, ...]` is not assignable to `tuple[int, int]` +tuples_type_compat.py:76:9: error[type-assertion-failure] Type `tuple[int]` does not match asserted type `tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]` +tuples_type_compat.py:81:9: error[type-assertion-failure] Type `tuple[str, str] | tuple[int, int]` does not match asserted type `tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]` +tuples_type_compat.py:86:9: error[type-assertion-failure] Type `tuple[int, str, int]` does not match asserted type `tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]` +tuples_type_compat.py:102:13: error[type-assertion-failure] Type `tuple[int]` does not match asserted type `tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]` +tuples_type_compat.py:107:13: error[type-assertion-failure] Type `tuple[str, str] | tuple[int, int]` does not match asserted type `tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]` +tuples_type_compat.py:112:13: error[type-assertion-failure] Type `tuple[int, str, int]` does not match asserted type `tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]` +tuples_type_compat.py:127:13: error[type-assertion-failure] Type `tuple[int | str, str]` does not match asserted type `tuple[int | str, int | str]` +tuples_type_compat.py:130:13: error[type-assertion-failure] Type `tuple[int | str, int]` does not match asserted type `tuple[int | str, int | str]` +tuples_type_compat.py:157:6: error[invalid-assignment] Object of type `tuple[Literal[1], Literal[""], Literal[""]]` is not assignable to `tuple[int, str]` +tuples_type_compat.py:162:6: error[invalid-assignment] Object of type `tuple[Literal[1], Literal[1], Literal[""]]` is not assignable to `tuple[int, *tuple[str, ...]]` +tuples_type_compat.py:163:6: error[invalid-assignment] Object of type `tuple[Literal[1], Literal[""], Literal[1]]` is not assignable to `tuple[int, *tuple[str, ...]]` +tuples_type_compat.py:169:6: error[invalid-assignment] Object of type `tuple[Literal[1], Literal[""], Literal[""]]` is not assignable to `tuple[int, *tuple[str, ...], int]` +tuples_type_compat.py:170:6: error[invalid-assignment] Object of type `tuple[Literal[1], Literal[""], Literal[""], float*]` is not assignable to `tuple[int, *tuple[str, ...], int]` +tuples_type_compat.py:175:6: error[invalid-assignment] Object of type `tuple[Literal[1], Literal[""], Literal[1]]` is not assignable to `tuple[*tuple[str, ...], int]` +tuples_type_compat.py:176:6: error[invalid-assignment] Object of type `tuple[Literal[""], Literal[""], float*]` is not assignable to `tuple[*tuple[str, ...], int]` +tuples_type_compat.py:181:40: error[invalid-assignment] Object of type `tuple[str, str]` is not assignable to `tuple[str, str, int]` +tuples_type_compat.py:184:50: error[invalid-assignment] Object of type `tuple[str, str]` is not assignable to `tuple[str, str, str, *tuple[str, ...]]` +tuples_type_compat.py:188:50: error[invalid-assignment] Object of type `tuple[str, str]` is not assignable to `tuple[*tuple[str, ...], str, str, str]` +""" diff --git a/conformance/results/ty/tuples_type_form.toml b/conformance/results/ty/tuples_type_form.toml new file mode 100644 index 000000000..1130058d6 --- /dev/null +++ b/conformance/results/ty/tuples_type_form.toml @@ -0,0 +1,16 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +tuples_type_form.py:12:6: error[invalid-assignment] Object of type `tuple[Literal[1], Literal[2]]` is not assignable to `tuple[int]` +tuples_type_form.py:14:6: error[invalid-assignment] Object of type `tuple[Literal[1]]` is not assignable to `tuple[int, int]` +tuples_type_form.py:15:6: error[invalid-assignment] Object of type `tuple[Literal[1], Literal[""]]` is not assignable to `tuple[int, int]` +tuples_type_form.py:25:7: error[invalid-assignment] Object of type `tuple[Literal[1]]` is not assignable to `tuple[()]` +tuples_type_form.py:36:7: error[invalid-assignment] Object of type `tuple[Literal[1], Literal[2], Literal[3], Literal[""]]` is not assignable to `tuple[int, ...]` +tuples_type_form.py:40:22: error[invalid-type-form] Invalid `tuple` specialization: `...` can only be used as the second element in a two-element `tuple` specialization +tuples_type_form.py:41:12: error[invalid-type-form] Invalid `tuple` specialization: `...` can only be used as the second element in a two-element `tuple` specialization +tuples_type_form.py:42:12: error[invalid-type-form] Invalid `tuple` specialization: `...` can only be used as the second element in a two-element `tuple` specialization +tuples_type_form.py:43:17: error[invalid-type-form] Invalid `tuple` specialization: `...` can only be used as the second element in a two-element `tuple` specialization +tuples_type_form.py:44:25: error[invalid-type-form] Invalid `tuple` specialization: `...` cannot be used after an unpacked element +tuples_type_form.py:45:30: error[invalid-type-form] Invalid `tuple` specialization: `...` cannot be used after an unpacked element +""" diff --git a/conformance/results/ty/tuples_unpacked.toml b/conformance/results/ty/tuples_unpacked.toml new file mode 100644 index 000000000..b45a4fd3a --- /dev/null +++ b/conformance/results/ty/tuples_unpacked.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +tuples_unpacked.py:40:5: error[invalid-type-form] Multiple unpacked variadic tuples are not allowed in a `tuple` specialization +tuples_unpacked.py:41:5: error[invalid-type-form] Multiple unpacked variadic tuples are not allowed in a `tuple` specialization +tuples_unpacked.py:51:9: error[invalid-type-form] Multiple unpacked variadic tuples are not allowed in a `tuple` specialization +tuples_unpacked.py:59:6: error[invalid-type-form] Multiple unpacked variadic tuples are not allowed in a `tuple` specialization +tuples_unpacked.py:60:6: error[invalid-type-form] Multiple unpacked variadic tuples are not allowed in a `tuple` specialization +""" diff --git a/conformance/results/ty/typeddicts_alt_syntax.toml b/conformance/results/ty/typeddicts_alt_syntax.toml new file mode 100644 index 000000000..4a49527d4 --- /dev/null +++ b/conformance/results/ty/typeddicts_alt_syntax.toml @@ -0,0 +1,12 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_alt_syntax.py:23:44: error[invalid-argument-type] Expected a dict literal for parameter `fields` of `TypedDict()` +typeddicts_alt_syntax.py:27:45: error[invalid-argument-type] Expected a string-literal key in the `fields` dict of `TypedDict()`: Found `Literal[1]` +typeddicts_alt_syntax.py:31:27: error[mismatched-type-name] The name passed to `TypedDict` must match the variable it is assigned to: Expected "BadTypedDict3", got "WrongName" +typeddicts_alt_syntax.py:35:72: error[unknown-argument] Argument `other` does not match any known parameter of function `TypedDict` +typeddicts_alt_syntax.py:41:10: error[missing-argument] No argument provided for required parameter `fields` of function `TypedDict` +typeddicts_alt_syntax.py:41:30: error[unknown-argument] Argument `name` does not match any known parameter of function `TypedDict` +typeddicts_alt_syntax.py:41:40: error[unknown-argument] Argument `year` does not match any known parameter of function `TypedDict` +""" diff --git a/conformance/results/ty/typeddicts_class_syntax.toml b/conformance/results/ty/typeddicts_class_syntax.toml new file mode 100644 index 000000000..86d0c210c --- /dev/null +++ b/conformance/results/ty/typeddicts_class_syntax.toml @@ -0,0 +1,14 @@ +conformant = "Pass" +notes = """ +""" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_class_syntax.py:30:5: error[invalid-typed-dict-statement] TypedDict class cannot have methods +typeddicts_class_syntax.py:34:5: error[invalid-typed-dict-statement] TypedDict class cannot have methods +typeddicts_class_syntax.py:39:5: error[invalid-typed-dict-statement] TypedDict class cannot have methods +typeddicts_class_syntax.py:49:32: error[invalid-typed-dict-header] Custom metaclasses are not supported in `TypedDict` definitions +typeddicts_class_syntax.py:54:32: error[unknown-argument] Unknown keyword argument `other` in `TypedDict` definition +typeddicts_class_syntax.py:69:28: error[invalid-key] Unknown key "z" for TypedDict `ConditionalField` +""" diff --git a/conformance/results/ty/typeddicts_extra_items.toml b/conformance/results/ty/typeddicts_extra_items.toml new file mode 100644 index 000000000..c1f7d049a --- /dev/null +++ b/conformance/results/ty/typeddicts_extra_items.toml @@ -0,0 +1,32 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_extra_items.py:15:45: error[invalid-argument-type] Invalid argument to key "year" with declared type `bool` on TypedDict `Movie`: value of type `Literal[1982]` +typeddicts_extra_items.py:22:55: error[invalid-argument-type] Invalid argument to key "year" with declared type `bool` on TypedDict `MovieFunctional`: value of type `Literal[1982]` +typeddicts_extra_items.py:39:54: error[invalid-argument-type] Invalid argument to key "year" with declared type `int` on TypedDict `InheritedMovie`: value of type `None` +typeddicts_extra_items.py:49:28: error[invalid-argument-type] Invalid argument to parameter `closed` in `TypedDict` definition: Expected either `True` or `False`, got object of type `Literal[True]` +typeddicts_extra_items.py:67:7: error[invalid-typed-dict-header] TypedDict `IllegalChild1` must remain closed because base `ClosedBase` is closed +typeddicts_extra_items.py:73:7: error[invalid-typed-dict-header] TypedDict `IllegalChild2` must preserve mutable extra items from base `ExtraItemsBase` +typeddicts_extra_items.py:91:7: error[invalid-typed-dict-header] Cannot add item `age` to closed TypedDict base `MovieA` +typeddicts_extra_items.py:94:7: error[invalid-typed-dict-header] Cannot add item `age` to closed TypedDict base `MovieB` +typeddicts_extra_items.py:109:7: error[invalid-typed-dict-header] TypedDict `IllegalCloseNonReadOnly` must preserve mutable extra items from base `ExtraItemsBase` +typeddicts_extra_items.py:114:50: error[invalid-type-form] Type qualifier `typing.Required` is not valid in a TypedDict `extra_items` argument +typeddicts_extra_items.py:117:57: error[invalid-type-form] Type qualifier `typing.NotRequired` is not valid in a TypedDict `extra_items` argument +typeddicts_extra_items.py:128:15: error[invalid-argument-type] Cannot delete required key "name" from TypedDict `MovieEI` +typeddicts_extra_items.py:174:7: error[invalid-typed-dict-header] TypedDict `Child` must preserve mutable extra items type `int | None` from base `Parent` +typeddicts_extra_items.py:184:7: error[invalid-typed-dict-header] Item `year` must be mutable, not required, and consistent with extra items type `int | None` from base `MovieBase2` +typeddicts_extra_items.py:187:7: error[invalid-typed-dict-header] Item `year` must be mutable, not required, and consistent with extra items type `int | None` from base `MovieBase2` +typeddicts_extra_items.py:196:7: error[invalid-typed-dict-header] Item `publisher` of type `str` is not assignable to extra items type `int | None` from base `BookBase` +typeddicts_extra_items.py:215:22: error[invalid-assignment] Object of type `MovieDetails` is not assignable to `MovieBase2` +typeddicts_extra_items.py:222:22: error[invalid-assignment] Object of type `MovieWithYear2` is not assignable to `MovieBase2` +typeddicts_extra_items.py:242:19: error[invalid-assignment] Object of type `MovieDetails5` is not assignable to `MovieSI` +typeddicts_extra_items.py:256:13: error[invalid-assignment] Object of type `MovieExtraStr` is not assignable to `MovieExtraInt` +typeddicts_extra_items.py:257:13: error[invalid-assignment] Object of type `MovieExtraInt` is not assignable to `MovieExtraStr` +typeddicts_extra_items.py:268:14: error[invalid-assignment] Object of type `MovieNotClosed` is not assignable to `MovieExtraInt` +typeddicts_extra_items.py:278:47: error[invalid-key] Unknown key "year" for TypedDict `NonClosedMovie` +typeddicts_extra_items.py:285:52: error[invalid-argument-type] Invalid argument to key "language" with declared type `int` on TypedDict `ExtraMovie`: value of type `Literal["English"]` +typeddicts_extra_items.py:293:44: error[invalid-key] Unknown key "year" for TypedDict `ClosedMovie` +typeddicts_extra_items.py:303:34: error[invalid-assignment] Object of type `MovieExtraInt` is not assignable to `Mapping[str, int]` +typeddicts_extra_items.py:352:25: error[invalid-assignment] Object of type `dict[str, int]` is not assignable to `IntDict` +""" diff --git a/conformance/results/ty/typeddicts_final.toml b/conformance/results/ty/typeddicts_final.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/ty/typeddicts_final.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/ty/typeddicts_inheritance.toml b/conformance/results/ty/typeddicts_inheritance.toml new file mode 100644 index 000000000..52361d4b1 --- /dev/null +++ b/conformance/results/ty/typeddicts_inheritance.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_inheritance.py:44:31: error[invalid-typed-dict-header] TypedDict class `BadTypedDict` can only inherit from TypedDict classes: `NonTypedDict` is not a `TypedDict` class +typeddicts_inheritance.py:55:4: error[invalid-typed-dict-field] Cannot overwrite TypedDict field `x`: Inherited mutable field type `str` is incompatible with `int` +typeddicts_inheritance.py:65:7: error[invalid-typed-dict-field] Cannot overwrite TypedDict field `x` while merging base classes: Inherited mutable field type `str` is incompatible with `int` +""" diff --git a/conformance/results/ty/typeddicts_operations.toml b/conformance/results/ty/typeddicts_operations.toml new file mode 100644 index 000000000..7a6929fb0 --- /dev/null +++ b/conformance/results/ty/typeddicts_operations.toml @@ -0,0 +1,16 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_operations.py:22:17: error[invalid-assignment] Invalid assignment to key "name" with declared type `str` on TypedDict `Movie`: value of type `Literal[1982]` +typeddicts_operations.py:23:17: error[invalid-assignment] Invalid assignment to key "year" with declared type `int` on TypedDict `Movie`: value of type `Literal[""]` +typeddicts_operations.py:24:7: error[invalid-key] Unknown key "other" for TypedDict `Movie` +typeddicts_operations.py:26:13: error[invalid-key] Unknown key "other" for TypedDict `Movie` +typeddicts_operations.py:28:9: error[missing-typed-dict-key] Missing required key 'year' in TypedDict `Movie` constructor +typeddicts_operations.py:29:42: error[invalid-argument-type] Invalid argument to key "year" with declared type `int` on TypedDict `Movie`: value of type `float*` +typeddicts_operations.py:32:36: error[invalid-key] Unknown key "other" for TypedDict `Movie` +typeddicts_operations.py:37:20: error[missing-typed-dict-key] Missing required key 'name' in TypedDict `Movie` constructor +typeddicts_operations.py:47:1: error[unresolved-attribute] Object of type `Movie` has no attribute `clear` +typeddicts_operations.py:49:11: error[invalid-argument-type] Cannot delete required key "name" from TypedDict `Movie` +typeddicts_operations.py:62:1: error[unresolved-attribute] Object of type `MovieOptional` has no attribute `clear` +""" diff --git a/conformance/results/ty/typeddicts_readonly.toml b/conformance/results/ty/typeddicts_readonly.toml new file mode 100644 index 000000000..cfb8b6c9b --- /dev/null +++ b/conformance/results/ty/typeddicts_readonly.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_readonly.py:24:4: error[invalid-assignment] Cannot assign to key "members" on TypedDict `Band`: key is marked read-only +typeddicts_readonly.py:36:4: error[invalid-assignment] Cannot assign to key "members" on TypedDict `Band2`: key is marked read-only +typeddicts_readonly.py:50:4: error[invalid-assignment] Cannot assign to key "title" on TypedDict `Movie1`: key is marked read-only +typeddicts_readonly.py:51:4: error[invalid-assignment] Cannot assign to key "year" on TypedDict `Movie1`: key is marked read-only +typeddicts_readonly.py:60:4: error[invalid-assignment] Cannot assign to key "title" on TypedDict `Movie2`: key is marked read-only +typeddicts_readonly.py:61:4: error[invalid-assignment] Cannot assign to key "year" on TypedDict `Movie2`: key is marked read-only +""" diff --git a/conformance/results/ty/typeddicts_readonly_consistency.toml b/conformance/results/ty/typeddicts_readonly_consistency.toml new file mode 100644 index 000000000..b289d22e6 --- /dev/null +++ b/conformance/results/ty/typeddicts_readonly_consistency.toml @@ -0,0 +1,12 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_readonly_consistency.py:37:14: error[invalid-assignment] Object of type `A1` is not assignable to `B1` +typeddicts_readonly_consistency.py:38:14: error[invalid-assignment] Object of type `C1` is not assignable to `B1` +typeddicts_readonly_consistency.py:40:14: error[invalid-assignment] Object of type `A1` is not assignable to `C1` +typeddicts_readonly_consistency.py:81:14: error[invalid-assignment] Object of type `A2` is not assignable to `B2` +typeddicts_readonly_consistency.py:82:14: error[invalid-assignment] Object of type `C2` is not assignable to `B2` +typeddicts_readonly_consistency.py:84:14: error[invalid-assignment] Object of type `A2` is not assignable to `C2` +typeddicts_readonly_consistency.py:85:14: error[invalid-assignment] Object of type `B2` is not assignable to `C2` +""" diff --git a/conformance/results/ty/typeddicts_readonly_inheritance.toml b/conformance/results/ty/typeddicts_readonly_inheritance.toml new file mode 100644 index 000000000..a19eb7560 --- /dev/null +++ b/conformance/results/ty/typeddicts_readonly_inheritance.toml @@ -0,0 +1,16 @@ +conformance_automated = "Pass" +output = """ +typeddicts_readonly_inheritance.py:36:4: error[invalid-assignment] Cannot assign to key "name" on TypedDict `Album2`: key is marked read-only +typeddicts_readonly_inheritance.py:50:5: error[invalid-typed-dict-field] Cannot overwrite TypedDict field `alt`: Inherited read-only field type `list[str | int]` is not assignable from `list[str]` +typeddicts_readonly_inheritance.py:65:19: error[missing-typed-dict-key] Missing required key 'name' in TypedDict `RequiredName` constructor +typeddicts_readonly_inheritance.py:82:14: error[invalid-assignment] Invalid assignment to key "ident" with declared type `str` on TypedDict `User`: value of type `Literal[3]` +typeddicts_readonly_inheritance.py:83:15: error[invalid-argument-type] Invalid argument to key "ident" with declared type `str` on TypedDict `User`: value of type `Literal[3]` +typeddicts_readonly_inheritance.py:84:5: error[missing-typed-dict-key] Missing required key 'ident' in TypedDict `User` constructor +typeddicts_readonly_inheritance.py:94:5: error[invalid-typed-dict-field] Cannot overwrite TypedDict field `a`: Mutable inherited fields cannot be redeclared as read-only +typeddicts_readonly_inheritance.py:98:5: error[invalid-typed-dict-field] Cannot overwrite TypedDict field `a`: Required inherited fields cannot be redeclared as `NotRequired` +typeddicts_readonly_inheritance.py:106:5: error[invalid-typed-dict-field] Cannot overwrite TypedDict field `c`: Required inherited fields cannot be redeclared as `NotRequired` +typeddicts_readonly_inheritance.py:119:7: error[invalid-typed-dict-field] Cannot overwrite TypedDict field `x` while merging base classes: Inherited mutable field type `float` is incompatible with `int` +typeddicts_readonly_inheritance.py:132:7: error[invalid-typed-dict-field] Cannot overwrite TypedDict field `x` while merging base classes: Required inherited fields cannot be redeclared as `NotRequired` +""" +errors_diff = """ +""" diff --git a/conformance/results/ty/typeddicts_readonly_kwargs.toml b/conformance/results/ty/typeddicts_readonly_kwargs.toml new file mode 100644 index 000000000..cbe729539 --- /dev/null +++ b/conformance/results/ty/typeddicts_readonly_kwargs.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_readonly_kwargs.py:33:12: error[invalid-assignment] Cannot assign to key "key1" on TypedDict `ReadOnlyArgs`: key is marked read-only +""" diff --git a/conformance/results/ty/typeddicts_readonly_update.toml b/conformance/results/ty/typeddicts_readonly_update.toml new file mode 100644 index 000000000..4173f61dc --- /dev/null +++ b/conformance/results/ty/typeddicts_readonly_update.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_readonly_update.py:23:11: error[invalid-argument-type] Argument is incorrect: Expected ``, found `A` +""" diff --git a/conformance/results/ty/typeddicts_required.toml b/conformance/results/ty/typeddicts_required.toml new file mode 100644 index 000000000..0abae1d27 --- /dev/null +++ b/conformance/results/ty/typeddicts_required.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_required.py:12:8: error[invalid-type-form] `Required` is only allowed in TypedDict fields +typeddicts_required.py:16:8: error[invalid-type-form] Type qualifier `typing.NotRequired` is not allowed in parameter annotations +typeddicts_required.py:60:8: error[invalid-type-form] `typing.Required` cannot be nested inside `Required` or `NotRequired` +typeddicts_required.py:61:8: error[invalid-type-form] `typing.Required` cannot be nested inside `Required` or `NotRequired` +""" diff --git a/conformance/results/ty/typeddicts_type_consistency.toml b/conformance/results/ty/typeddicts_type_consistency.toml new file mode 100644 index 000000000..030df7b1e --- /dev/null +++ b/conformance/results/ty/typeddicts_type_consistency.toml @@ -0,0 +1,14 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_type_consistency.py:21:10: error[invalid-assignment] Object of type `B1` is not assignable to `A1` +typeddicts_type_consistency.py:38:10: error[invalid-assignment] Object of type `B2` is not assignable to `A2` +typeddicts_type_consistency.py:65:6: error[invalid-assignment] Object of type `A3` is not assignable to `B3` +typeddicts_type_consistency.py:69:21: error[invalid-key] Unknown key "y" for TypedDict `A3` +typeddicts_type_consistency.py:76:22: error[invalid-assignment] Object of type `B3` is not assignable to `dict[str, int]` +typeddicts_type_consistency.py:77:25: error[invalid-assignment] Object of type `B3` is not assignable to `dict[str, object]` +typeddicts_type_consistency.py:78:22: error[invalid-assignment] Object of type `B3` is not assignable to `dict[Any, Any]` +typeddicts_type_consistency.py:82:25: error[invalid-assignment] Object of type `B3` is not assignable to `Mapping[str, int]` +typeddicts_type_consistency.py:126:56: error[invalid-argument-type] Invalid argument to key "inner_key" with declared type `str` on TypedDict `Inner1`: value of type `Literal[1]` +""" diff --git a/conformance/results/ty/typeddicts_usage.toml b/conformance/results/ty/typeddicts_usage.toml new file mode 100644 index 000000000..648b7db1d --- /dev/null +++ b/conformance/results/ty/typeddicts_usage.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_usage.py:23:7: error[invalid-key] Unknown key "director" for TypedDict `Movie` +typeddicts_usage.py:24:17: error[invalid-assignment] Invalid assignment to key "year" with declared type `int` on TypedDict `Movie`: value of type `Literal["1982"]` +typeddicts_usage.py:28:17: error[missing-typed-dict-key] Missing required key 'name' in TypedDict `Movie` constructor +typeddicts_usage.py:28:18: error[invalid-key] Unknown key "title" for TypedDict `Movie` +typeddicts_usage.py:35:4: error[isinstance-against-typed-dict] `TypedDict` class `Movie` cannot be used as the second argument to `isinstance`: This call will raise `TypeError` at runtime +typeddicts_usage.py:40:24: error[invalid-type-form] The special form `typing.TypedDict` is not allowed in type expressions +""" diff --git a/conformance/results/ty/typeforms_typeform.toml b/conformance/results/ty/typeforms_typeform.toml new file mode 100644 index 000000000..129019af8 --- /dev/null +++ b/conformance/results/ty/typeforms_typeform.toml @@ -0,0 +1,21 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeforms_typeform.py:23:30: error[invalid-assignment] Object of type `TypeForm[str | int]` is not assignable to `TypeForm[str | None]` +typeforms_typeform.py:24:30: error[invalid-assignment] Object of type `TypeForm[list[str | None]]` is not assignable to `TypeForm[str | None]` +typeforms_typeform.py:59:14: error[invalid-syntax-in-forward-annotation] Syntax error in forward annotation: Unexpected token at the end of an expression +typeforms_typeform.py:67:18: error[invalid-type-form] Function calls are not allowed in type expressions +typeforms_typeform.py:68:18: error[invalid-type-form] Tuple literals are not allowed in this context in a type expression +typeforms_typeform.py:69:18: error[invalid-type-form] Int literals are not allowed in this context in a type expression: Did you mean `typing.Literal[1]`? +typeforms_typeform.py:70:18: error[invalid-type-form] Variable of type `` is not allowed in a type expression +typeforms_typeform.py:71:18: error[invalid-type-form] Type qualifier `typing.ClassVar` is not allowed in type expressions (only in annotation expressions) +typeforms_typeform.py:72:18: error[invalid-type-form] Type qualifier `typing.Final` is not allowed in type expressions (only in annotation expressions) +typeforms_typeform.py:73:18: error[invalid-type-form] `Unpack` is not allowed in type expressions +typeforms_typeform.py:74:18: error[invalid-type-form] `typing.Optional` requires exactly one argument when used in a type expression +typeforms_typeform.py:75:19: error[invalid-type-form] Invalid binary operator `+` in a type expression +typeforms_typeform.py:86:16: error[invalid-type-form] Function calls are not allowed in type expressions +typeforms_typeform.py:88:15: error[invalid-type-form] Function calls are not allowed in type expressions +typeforms_typeform.py:98:21: error[invalid-assignment] Object of type `TypeForm[int]` is not assignable to `TypeForm[str]` +typeforms_typeform.py:108:21: error[invalid-assignment] Object of type `type[int]` is not assignable to `TypeForm[str]` +""" diff --git a/conformance/results/ty/version.toml b/conformance/results/ty/version.toml new file mode 100644 index 000000000..de28a49c9 --- /dev/null +++ b/conformance/results/ty/version.toml @@ -0,0 +1 @@ +version = "ty 0.0.93" diff --git a/conformance/results/zuban/aliases_explicit.toml b/conformance/results/zuban/aliases_explicit.toml new file mode 100644 index 000000000..0f48394fe --- /dev/null +++ b/conformance/results/zuban/aliases_explicit.toml @@ -0,0 +1,29 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +aliases_explicit.py:67: error: Bad number of arguments for type alias, expected 0, given 1 [misc] +aliases_explicit.py:68: error: Bad number of arguments for type alias, expected 0, given 1 [misc] +aliases_explicit.py:69: error: Bad number of arguments for type alias, expected 1, given 2 [misc] +aliases_explicit.py:70: error: Bad number of arguments for type alias, expected 1, given 2 [misc] +aliases_explicit.py:71: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "int" [misc] +aliases_explicit.py:79: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_explicit.py:80: error: Bracketed expression "[...]" is not valid as a type [valid-type] +aliases_explicit.py:80: note: Did you mean "List[...]"? +aliases_explicit.py:81: error: Syntax error in type annotation [valid-type] +aliases_explicit.py:81: note: Suggestion: Is there a spurious trailing comma? +aliases_explicit.py:82: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_explicit.py:83: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_explicit.py:84: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_explicit.py:85: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_explicit.py:86: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_explicit.py:87: error: Variable "tests.aliases_explicit.var1" is not valid as a type [valid-type] +aliases_explicit.py:87: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +aliases_explicit.py:88: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_explicit.py:89: error: Invalid type: try using Literal[1] instead? [valid-type] +aliases_explicit.py:90: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_explicit.py:91: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_explicit.py:100: error: Bad number of arguments for type alias, expected 0, given 1 [misc] +aliases_explicit.py:101: error: "" not callable [operator] +aliases_explicit.py:102: error: Bad number of arguments for type alias, expected 0, given 1 [misc] +""" diff --git a/conformance/results/zuban/aliases_implicit.toml b/conformance/results/zuban/aliases_implicit.toml new file mode 100644 index 000000000..1ba69a041 --- /dev/null +++ b/conformance/results/zuban/aliases_implicit.toml @@ -0,0 +1,41 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +aliases_implicit.py:76: error: Bad number of arguments for type alias, expected 0, given 1 [misc] +aliases_implicit.py:77: error: Bad number of arguments for type alias, expected 0, given 1 [misc] +aliases_implicit.py:78: error: Bad number of arguments for type alias, expected 1, given 2 [misc] +aliases_implicit.py:79: error: Bad number of arguments for type alias, expected 1, given 2 [misc] +aliases_implicit.py:80: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "int" [misc] +aliases_implicit.py:81: error: Type argument "str" of "GoodTypeAlias12" must be a subtype of "float" [type-var] +aliases_implicit.py:106: error: Variable "tests.aliases_implicit.BadTypeAlias1" is not valid as a type [valid-type] +aliases_implicit.py:106: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +aliases_implicit.py:107: error: Variable "tests.aliases_implicit.BadTypeAlias2" is not valid as a type [valid-type] +aliases_implicit.py:107: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +aliases_implicit.py:108: error: Variable "tests.aliases_implicit.BadTypeAlias3" is not valid as a type [valid-type] +aliases_implicit.py:108: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +aliases_implicit.py:109: error: Variable "tests.aliases_implicit.BadTypeAlias4" is not valid as a type [valid-type] +aliases_implicit.py:109: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +aliases_implicit.py:110: error: Variable "tests.aliases_implicit.BadTypeAlias5" is not valid as a type [valid-type] +aliases_implicit.py:110: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +aliases_implicit.py:111: error: Variable "tests.aliases_implicit.BadTypeAlias6" is not valid as a type [valid-type] +aliases_implicit.py:111: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +aliases_implicit.py:112: error: Variable "tests.aliases_implicit.BadTypeAlias7" is not valid as a type [valid-type] +aliases_implicit.py:112: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +aliases_implicit.py:113: error: Variable "tests.aliases_implicit.BadTypeAlias8" is not valid as a type [valid-type] +aliases_implicit.py:113: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +aliases_implicit.py:114: error: Variable "tests.aliases_implicit.var1" is not valid as a type [valid-type] +aliases_implicit.py:114: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +aliases_implicit.py:115: error: Variable "tests.aliases_implicit.BadTypeAlias10" is not valid as a type [valid-type] +aliases_implicit.py:115: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +aliases_implicit.py:116: error: Variable "tests.aliases_implicit.BadTypeAlias11" is not valid as a type [valid-type] +aliases_implicit.py:116: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +aliases_implicit.py:117: error: Variable "tests.aliases_implicit.BadTypeAlias12" is not valid as a type [valid-type] +aliases_implicit.py:117: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +aliases_implicit.py:118: error: Variable "tests.aliases_implicit.BadTypeAlias13" is not valid as a type [valid-type] +aliases_implicit.py:118: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +aliases_implicit.py:119: error: Variable "tests.aliases_implicit.BadTypeAlias14" is not valid as a type [valid-type] +aliases_implicit.py:119: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +aliases_implicit.py:133: error: "UnionType" not callable [operator] +aliases_implicit.py:135: error: Bad number of arguments for type alias, expected 0, given 1 [misc] +""" diff --git a/conformance/results/zuban/aliases_newtype.toml b/conformance/results/zuban/aliases_newtype.toml new file mode 100644 index 000000000..840d3b002 --- /dev/null +++ b/conformance/results/zuban/aliases_newtype.toml @@ -0,0 +1,21 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +aliases_newtype.py:11: error: Argument 1 to "UserId" has incompatible type "str"; expected "int" [arg-type] +aliases_newtype.py:12: error: Incompatible types in assignment (expression has type "int", variable has type "UserId") [assignment] +aliases_newtype.py:18: error: Incompatible types in assignment (expression has type "type[UserId]", variable has type "type[Any]") [assignment] +aliases_newtype.py:23: error: Cannot use isinstance() with NewType type [misc] +aliases_newtype.py:26: error: Cannot subclass "NewType" [misc] +aliases_newtype.py:35: error: String argument 1 "BadName" to NewType(...) does not match variable name "GoodName" [misc] +aliases_newtype.py:41: error: Bad number of arguments for type alias, expected 0, given 1 [misc] +aliases_newtype.py:47: error: Argument 2 to NewType(...) must be subclassable (got "int | str") [valid-newtype] +aliases_newtype.py:50: error: Type variable "tests.aliases_newtype.T" is unbound [misc] +aliases_newtype.py:50: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) +aliases_newtype.py:50: note: (Hint: Use "T" in function signature to bind "T" inside a function) +aliases_newtype.py:52: error: NewType cannot be used with protocol classes [misc] +aliases_newtype.py:54: error: Argument 2 to NewType(...) must be subclassable (got "Literal[7]") [valid-newtype] +aliases_newtype.py:61: error: Argument 2 to NewType(...) must be subclassable (got "TD1") [valid-newtype] +aliases_newtype.py:63: error: NewType(...) expects exactly two positional arguments [call-arg] +aliases_newtype.py:65: error: Argument 2 to NewType(...) must be subclassable (got "Any") [valid-newtype] +""" diff --git a/conformance/results/zuban/aliases_recursive.toml b/conformance/results/zuban/aliases_recursive.toml new file mode 100644 index 000000000..e58e7affa --- /dev/null +++ b/conformance/results/zuban/aliases_recursive.toml @@ -0,0 +1,16 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +aliases_recursive.py:19: error: Dict entry 1 has incompatible type "str": "complex"; expected "str": "None | int | str | float | list[Json] | dict[str, Json]" [dict-item] +aliases_recursive.py:20: error: List item 1 has incompatible type "complex"; expected "None | int | str | float | list[Json] | dict[str, Json]" [list-item] +aliases_recursive.py:38: error: Incompatible types in assignment (expression has type "tuple[int, tuple[str, int], tuple[int, tuple[int, list[int]]]]", variable has type "str | int | tuple[RecursiveTuple, ...]") [assignment] +aliases_recursive.py:39: error: Incompatible types in assignment (expression has type "tuple[int, list[int]]", variable has type "str | int | tuple[RecursiveTuple, ...]") [assignment] +aliases_recursive.py:50: error: Dict entry 0 has incompatible type "str": "list[int]"; expected "str": "str | int | Mapping[str, str | int | Mapping[str, RecursiveMapping]]" [dict-item] +aliases_recursive.py:51: error: Dict entry 2 has incompatible type "str": "list[int]"; expected "str": "str | int | Mapping[str, str | int | Mapping[str, RecursiveMapping]]" [dict-item] +aliases_recursive.py:52: error: Dict entry 2 has incompatible type "str": "list[int]"; expected "str": "str | int | Mapping[str, str | int | Mapping[str, RecursiveMapping]]" [dict-item] +aliases_recursive.py:63: error: List item 0 has incompatible type "float"; expected "GenericTypeAlias1[str] | str" [list-item] +aliases_recursive.py:69: error: List item 0 has incompatible type "float"; expected "GenericTypeAlias2[str, int] | str | int" [list-item] +aliases_recursive.py:72: error: Invalid recursive alias: a union item of itself [misc] +aliases_recursive.py:75: error: Invalid recursive alias: a union item of itself [misc] +""" diff --git a/conformance/results/zuban/aliases_type_statement.toml b/conformance/results/zuban/aliases_type_statement.toml new file mode 100644 index 000000000..d844880b7 --- /dev/null +++ b/conformance/results/zuban/aliases_type_statement.toml @@ -0,0 +1,33 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +aliases_type_statement.py:17: error: "TypeAliasType" has no attribute "bit_count" [attr-defined] +aliases_type_statement.py:19: error: "TypeAliasType" not callable [operator] +aliases_type_statement.py:23: error: "TypeAliasType" has no attribute "other_attrib" [attr-defined] +aliases_type_statement.py:26: error: Type alias defined using "type" statement not valid as base class [misc] +aliases_type_statement.py:31: error: Argument 2 to "isinstance" has incompatible type "TypeAliasType"; expected "type[Any] | UnionType | tuple[_ClassInfo, ...]" [arg-type] +aliases_type_statement.py:37: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_type_statement.py:38: error: Bracketed expression "[...]" is not valid as a type [valid-type] +aliases_type_statement.py:38: note: Did you mean "List[...]"? +aliases_type_statement.py:39: error: Syntax error in type annotation [valid-type] +aliases_type_statement.py:39: note: Suggestion: Is there a spurious trailing comma? +aliases_type_statement.py:40: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_type_statement.py:41: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_type_statement.py:42: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_type_statement.py:43: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_type_statement.py:44: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_type_statement.py:45: error: Variable "tests.aliases_type_statement.var1" is not valid as a type [valid-type] +aliases_type_statement.py:45: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +aliases_type_statement.py:46: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_type_statement.py:47: error: Invalid type: try using Literal[1] instead? [valid-type] +aliases_type_statement.py:48: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_type_statement.py:49: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_type_statement.py:53: error: All type parameters should be declared ("V" not declared) [misc] +aliases_type_statement.py:58: error: All type parameters should be declared ("T1" not declared) [misc] +aliases_type_statement.py:68: error: Type argument "str" of "RecursiveTypeAlias2" must be a subtype of "int" [type-var] +aliases_type_statement.py:70: error: Type argument "int" of "RecursiveTypeAlias2" must be a subtype of "str" [type-var] +aliases_type_statement.py:73: error: Invalid recursive alias: a union item of itself [misc] +aliases_type_statement.py:75: error: Invalid recursive alias: a union item of itself [misc] +aliases_type_statement.py:79: error: Invalid recursive alias: a union item of itself [misc] +""" diff --git a/conformance/results/zuban/aliases_typealiastype.toml b/conformance/results/zuban/aliases_typealiastype.toml new file mode 100644 index 000000000..5eb157015 --- /dev/null +++ b/conformance/results/zuban/aliases_typealiastype.toml @@ -0,0 +1,30 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +aliases_typealiastype.py:32: error: "TypeAliasType" has no attribute "other_attrib" [attr-defined] +aliases_typealiastype.py:40: error: Type argument "int" of "GoodAlias5" must be a subtype of "str" [type-var] +aliases_typealiastype.py:43: error: All type parameters should be declared ("S" not declared) [misc] +aliases_typealiastype.py:44: error: All type parameters should be declared ("S" not declared) [misc] +aliases_typealiastype.py:45: error: Tuple literal expected as the type_params argument to TypeAliasType [misc] +aliases_typealiastype.py:46: error: Invalid recursive alias: a union item of itself [misc] +aliases_typealiastype.py:47: error: Invalid recursive alias: a union item of itself [misc] +aliases_typealiastype.py:48: error: Invalid recursive alias: a union item of itself [misc] +aliases_typealiastype.py:52: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_typealiastype.py:53: error: Bracketed expression "[...]" is not valid as a type [valid-type] +aliases_typealiastype.py:53: note: Did you mean "List[...]"? +aliases_typealiastype.py:54: error: Syntax error in type annotation [valid-type] +aliases_typealiastype.py:54: note: Suggestion: Is there a spurious trailing comma? +aliases_typealiastype.py:55: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_typealiastype.py:56: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_typealiastype.py:57: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_typealiastype.py:58: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_typealiastype.py:59: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_typealiastype.py:60: error: Variable "tests.aliases_typealiastype.var1" is not valid as a type [valid-type] +aliases_typealiastype.py:60: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +aliases_typealiastype.py:61: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_typealiastype.py:62: error: Invalid type: try using Literal[1] instead? [valid-type] +aliases_typealiastype.py:63: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_typealiastype.py:64: error: Invalid type alias: expression is not a valid type [valid-type] +aliases_typealiastype.py:66: error: Name "BadAlias21" is used before definition [used-before-def] +""" diff --git a/conformance/results/zuban/aliases_variance.toml b/conformance/results/zuban/aliases_variance.toml new file mode 100644 index 000000000..8d4c8f1f1 --- /dev/null +++ b/conformance/results/zuban/aliases_variance.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +aliases_variance.py:24: error: Variance of TypeVar "T_co" incompatible with variance in parent type [type-var] +aliases_variance.py:28: error: Variance of TypeVar "T_co" incompatible with variance in parent type [type-var] +aliases_variance.py:32: error: Variance of TypeVar "T_co" incompatible with variance in parent type [type-var] +aliases_variance.py:44: error: Variance of TypeVar "T_contra" incompatible with variance in parent type [type-var] +""" diff --git a/conformance/results/zuban/annotations_coroutines.toml b/conformance/results/zuban/annotations_coroutines.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/zuban/annotations_coroutines.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/zuban/annotations_forward_refs.toml b/conformance/results/zuban/annotations_forward_refs.toml new file mode 100644 index 000000000..4dec4e92a --- /dev/null +++ b/conformance/results/zuban/annotations_forward_refs.toml @@ -0,0 +1,34 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +annotations_forward_refs.py:24: error: Forward reference unions cause runtime errors, consider wrapping the whole annotation with a string [misc] +annotations_forward_refs.py:25: error: Forward reference unions cause runtime errors, consider wrapping the whole annotation with a string [misc] +annotations_forward_refs.py:41: error: Invalid type comment or annotation [valid-type] +annotations_forward_refs.py:42: error: Bracketed expression "[...]" is not valid as a type [valid-type] +annotations_forward_refs.py:42: note: Did you mean "List[...]"? +annotations_forward_refs.py:43: error: Syntax error in type annotation [valid-type] +annotations_forward_refs.py:43: note: Suggestion: Use Tuple[T1, ..., Tn] instead of (T1, ..., Tn) +annotations_forward_refs.py:44: error: Invalid type comment or annotation [valid-type] +annotations_forward_refs.py:45: error: Invalid type comment or annotation [valid-type] +annotations_forward_refs.py:46: error: Invalid type comment or annotation [valid-type] +annotations_forward_refs.py:47: error: Invalid type comment or annotation [valid-type] +annotations_forward_refs.py:48: error: Invalid type comment or annotation [valid-type] +annotations_forward_refs.py:49: error: Variable "tests.annotations_forward_refs.var1" is not valid as a type [valid-type] +annotations_forward_refs.py:49: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +annotations_forward_refs.py:50: error: Invalid type comment or annotation [valid-type] +annotations_forward_refs.py:51: error: Invalid type: try using Literal[1] instead? [valid-type] +annotations_forward_refs.py:52: error: Invalid type comment or annotation [valid-type] +annotations_forward_refs.py:53: error: Invalid type comment or annotation [valid-type] +annotations_forward_refs.py:54: error: Invalid type comment or annotation [valid-type] +annotations_forward_refs.py:55: error: Module "types" is not valid as a type [valid-type] +annotations_forward_refs.py:55: note: Perhaps you meant to use a protocol matching the module structure? +annotations_forward_refs.py:92: error: Name "ClassF" is not defined [name-defined] +annotations_forward_refs.py:94: error: Cannot resolve name "str" (possible cyclic definition) [misc] +annotations_forward_refs.py:96: error: Function "tests.annotations_forward_refs.ClassD.int" is not valid as a type [valid-type] +annotations_forward_refs.py:96: note: Perhaps you need "Callable[...]" or a callback protocol? +annotations_forward_refs.py:101: error: Function "tests.annotations_forward_refs.ClassD.int" is not valid as a type [valid-type] +annotations_forward_refs.py:101: note: Perhaps you need "Callable[...]" or a callback protocol? +annotations_forward_refs.py:103: error: Function "tests.annotations_forward_refs.ClassD.int" is not valid as a type [valid-type] +annotations_forward_refs.py:103: note: Perhaps you need "Callable[...]" or a callback protocol? +""" diff --git a/conformance/results/zuban/annotations_future_import.toml b/conformance/results/zuban/annotations_future_import.toml new file mode 100644 index 000000000..d35c6ae0d --- /dev/null +++ b/conformance/results/zuban/annotations_future_import.toml @@ -0,0 +1,12 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +annotations_future_import.py:37: error: Cannot resolve name "str" (possible cyclic definition) [misc] +annotations_future_import.py:39: error: Function "tests.annotations_future_import.ClassB.int" is not valid as a type [valid-type] +annotations_future_import.py:39: note: Perhaps you need "Callable[...]" or a callback protocol? +annotations_future_import.py:44: error: Function "tests.annotations_future_import.ClassB.int" is not valid as a type [valid-type] +annotations_future_import.py:44: note: Perhaps you need "Callable[...]" or a callback protocol? +annotations_future_import.py:46: error: Function "tests.annotations_future_import.ClassB.int" is not valid as a type [valid-type] +annotations_future_import.py:46: note: Perhaps you need "Callable[...]" or a callback protocol? +""" diff --git a/conformance/results/zuban/annotations_generators.toml b/conformance/results/zuban/annotations_generators.toml new file mode 100644 index 000000000..8243e130d --- /dev/null +++ b/conformance/results/zuban/annotations_generators.toml @@ -0,0 +1,16 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +annotations_generators.py:51: error: Incompatible return value type (implicitly returns "None", expected "C") [return-value] +annotations_generators.py:54: error: Incompatible return value type (got "bool", expected "C") [return-value] +annotations_generators.py:57: error: Incompatible types in "yield" (actual type "int", expected type "A") [misc] +annotations_generators.py:66: error: Incompatible types in "yield" (actual type "int", expected type "A") [misc] +annotations_generators.py:71: error: No return value expected [return-value] +annotations_generators.py:75: error: Incompatible types in "yield" (actual type "B", expected type "A") [misc] +annotations_generators.py:86: error: The return type of a generator function should be "Generator" or one of its supertypes [misc] +annotations_generators.py:91: error: The return type of an async generator function should be "AsyncGenerator" or one of its supertypes [misc] +annotations_generators.py:118: error: Incompatible types in "yield from" (actual type "A", expected type "B") [misc] +annotations_generators.py:119: error: Incompatible types in "yield from" (actual type "int", expected type "B") [misc] +annotations_generators.py:135: error: Incompatible send types in yield from (actual type "int", expected type "str") [misc] +""" diff --git a/conformance/results/zuban/annotations_methods.toml b/conformance/results/zuban/annotations_methods.toml new file mode 100644 index 000000000..bd2004812 --- /dev/null +++ b/conformance/results/zuban/annotations_methods.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +annotations_methods.py:42: error: Expression is of type "B", not "A" [misc] +""" diff --git a/conformance/results/zuban/annotations_typeexpr.toml b/conformance/results/zuban/annotations_typeexpr.toml new file mode 100644 index 000000000..67edaac2d --- /dev/null +++ b/conformance/results/zuban/annotations_typeexpr.toml @@ -0,0 +1,24 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +annotations_typeexpr.py:88: error: Invalid type comment or annotation [valid-type] +annotations_typeexpr.py:89: error: Bracketed expression "[...]" is not valid as a type [valid-type] +annotations_typeexpr.py:89: note: Did you mean "List[...]"? +annotations_typeexpr.py:90: error: Syntax error in type annotation [valid-type] +annotations_typeexpr.py:90: note: Suggestion: Use Tuple[T1, ..., Tn] instead of (T1, ..., Tn) +annotations_typeexpr.py:91: error: Invalid type comment or annotation [valid-type] +annotations_typeexpr.py:92: error: Invalid type comment or annotation [valid-type] +annotations_typeexpr.py:93: error: Invalid type comment or annotation [valid-type] +annotations_typeexpr.py:94: error: Invalid type comment or annotation [valid-type] +annotations_typeexpr.py:95: error: Invalid type comment or annotation [valid-type] +annotations_typeexpr.py:96: error: Variable "tests.annotations_typeexpr.var1" is not valid as a type [valid-type] +annotations_typeexpr.py:96: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +annotations_typeexpr.py:97: error: Invalid type comment or annotation [valid-type] +annotations_typeexpr.py:98: error: Invalid type: try using Literal[1] instead? [valid-type] +annotations_typeexpr.py:99: error: Invalid type comment or annotation [valid-type] +annotations_typeexpr.py:100: error: Invalid type comment or annotation [valid-type] +annotations_typeexpr.py:101: error: Invalid type comment or annotation [valid-type] +annotations_typeexpr.py:102: error: Module "types" is not valid as a type [valid-type] +annotations_typeexpr.py:102: note: Perhaps you meant to use a protocol matching the module structure? +""" diff --git a/conformance/results/zuban/callables_annotation.toml b/conformance/results/zuban/callables_annotation.toml new file mode 100644 index 000000000..e131dee29 --- /dev/null +++ b/conformance/results/zuban/callables_annotation.toml @@ -0,0 +1,29 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +callables_annotation.py:25: error: Too few arguments [call-arg] +callables_annotation.py:26: error: Argument 2 has incompatible type "int"; expected "str" [arg-type] +callables_annotation.py:27: error: Too many arguments [call-arg] +callables_annotation.py:29: error: Unexpected keyword argument "a" [call-arg] +callables_annotation.py:29: error: Unexpected keyword argument "b" [call-arg] +callables_annotation.py:35: error: Too many arguments [call-arg] +callables_annotation.py:55: error: Please use "Callable[[], ]" or "Callable" [misc] +callables_annotation.py:56: error: The first argument to Callable must be a list of types, parameter specification, or "..." [misc] +callables_annotation.py:56: note: See https://mypy.readthedocs.io/en/stable/kinds_of_types.html#callable-types-and-lambdas +callables_annotation.py:57: error: Bracketed expression "[...]" is not valid as a type [valid-type] +callables_annotation.py:57: note: Did you mean "List[...]"? +callables_annotation.py:58: error: Please use "Callable[[], ]" or "Callable" [misc] +callables_annotation.py:59: error: Unexpected "..." [valid-type] +callables_annotation.py:91: error: Incompatible types in assignment (expression has type "Callable[[], str]", variable has type "def (int, /, *Any, **Any) -> str") [assignment] +callables_annotation.py:93: error: Incompatible types in assignment (expression has type "def test_cb4(*, a: int) -> str", variable has type "def (int, /, *Any, **Any) -> str") [assignment] +callables_annotation.py:159: error: Incompatible types in assignment (expression has type "Proto8", variable has type "Proto5[Any]") [assignment] +callables_annotation.py:159: note: Following member(s) of "Proto8" have conflicts: +callables_annotation.py:159: note: Expected: +callables_annotation.py:159: note: def __call__(self, *args: Any, **kwargs: Any) -> None +callables_annotation.py:159: note: Got: +callables_annotation.py:159: note: def __call__(self) -> None +callables_annotation.py:172: error: Incompatible types in assignment (expression has type "Callable[[], str]", variable has type "def (int, /, *Any, **Any) -> str") [assignment] +callables_annotation.py:187: error: Incompatible types in assignment (expression has type "Callable[[int, str], str]", variable has type "def (str, /, *Any, **Any) -> str") [assignment] +callables_annotation.py:189: error: Incompatible types in assignment (expression has type "Callable[[int, str], str]", variable has type "def (str, /, *Any, **Any) -> str") [assignment] +""" diff --git a/conformance/results/zuban/callables_kwargs.toml b/conformance/results/zuban/callables_kwargs.toml new file mode 100644 index 000000000..678f5d318 --- /dev/null +++ b/conformance/results/zuban/callables_kwargs.toml @@ -0,0 +1,25 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +callables_kwargs.py:46: error: Missing named argument "v1" for "func1" [call-arg] +callables_kwargs.py:46: error: Missing named argument "v3" for "func1" [call-arg] +callables_kwargs.py:51: error: Unexpected keyword argument "v4" for "func1" [call-arg] +callables_kwargs.py:52: error: Too many positional arguments for "func1" [call-arg] +callables_kwargs.py:52: error: Missing named argument "v1" for "func1" [call-arg] +callables_kwargs.py:52: error: Missing named argument "v3" for "func1" [call-arg] +callables_kwargs.py:58: error: Argument 1 to "func1" has incompatible type "**dict[str, str]"; expected "int" [arg-type] +callables_kwargs.py:61: error: Argument 1 to "func1" has incompatible type "**dict[str, int | str]"; expected "int" [arg-type] +callables_kwargs.py:61: error: Argument 1 to "func1" has incompatible type "**dict[str, int | str]"; expected "str" [arg-type] +callables_kwargs.py:61: error: Argument 1 to "func1" has incompatible type "**dict[str, int | str]"; expected "str" [arg-type] +callables_kwargs.py:63: error: "func1" gets multiple values for keyword argument "v1" [call-arg] +callables_kwargs.py:64: error: Argument 1 to "func2" has incompatible type "int"; expected "str" [arg-type] +callables_kwargs.py:64: error: "func2" gets multiple values for keyword argument "v3" [call-arg] +callables_kwargs.py:65: error: "func2" gets multiple values for keyword argument "v1" [call-arg] +callables_kwargs.py:101: error: Incompatible types in assignment (expression has type "def func1(**kwargs: Unpack[TD2]) -> None", variable has type "TDProtocol3") [assignment] +callables_kwargs.py:102: error: Incompatible types in assignment (expression has type "def func1(**kwargs: Unpack[TD2]) -> None", variable has type "TDProtocol4") [assignment] +callables_kwargs.py:103: error: Incompatible types in assignment (expression has type "def func1(**kwargs: Unpack[TD2]) -> None", variable has type "TDProtocol5") [assignment] +callables_kwargs.py:111: error: Overlap between parameter names and ** TypedDict items: "v1" [misc] +callables_kwargs.py:122: error: Unpack item in ** parameter must be a TypedDict [misc] +callables_kwargs.py:134: error: Incompatible types in assignment (expression has type "def func7(*, v1: int, v3: str, v2: str = ...) -> None", variable has type "TDProtocol6") [assignment] +""" diff --git a/conformance/results/zuban/callables_protocol.toml b/conformance/results/zuban/callables_protocol.toml new file mode 100644 index 000000000..675f92555 --- /dev/null +++ b/conformance/results/zuban/callables_protocol.toml @@ -0,0 +1,24 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +callables_protocol.py:35: error: Incompatible types in assignment (expression has type "def cb1_bad1(*vals: bytes, max_items: int | None) -> list[bytes]", variable has type "Proto1") [assignment] +callables_protocol.py:36: error: Incompatible types in assignment (expression has type "def cb1_bad2(*vals: bytes) -> list[bytes]", variable has type "Proto1") [assignment] +callables_protocol.py:37: error: Incompatible types in assignment (expression has type "def cb1_bad3(*vals: bytes, max_len: str | None) -> list[bytes]", variable has type "Proto1") [assignment] +callables_protocol.py:67: error: Incompatible types in assignment (expression has type "def cb2_bad1(*a: bytes) -> None", variable has type "Proto2") [assignment] +callables_protocol.py:68: error: Incompatible types in assignment (expression has type "def cb2_bad2(*a: str, **b: str) -> None", variable has type "Proto2") [assignment] +callables_protocol.py:69: error: Incompatible types in assignment (expression has type "def cb2_bad3(*a: bytes, **b: bytes) -> None", variable has type "Proto2") [assignment] +callables_protocol.py:70: error: Incompatible types in assignment (expression has type "def cb2_bad4(**b: str) -> None", variable has type "Proto2") [assignment] +callables_protocol.py:97: error: Incompatible types in assignment (expression has type "Callable[[int], None]", variable has type "Proto4") [assignment] +callables_protocol.py:97: note: "Callable[[int], None]" is missing following "Proto4" protocol member: +callables_protocol.py:97: note: other_attribute +callables_protocol.py:121: error: Incompatible types in assignment (expression has type "def cb6_bad1(*vals: bytes, max_len: int | None = ...) -> list[bytes]", variable has type "NotProto6") [assignment] +callables_protocol.py:169: error: Incompatible types in assignment (expression has type "Callable[[int], Any]", variable has type "Proto8") [assignment] +callables_protocol.py:186: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] +callables_protocol.py:187: error: "Proto9[P, R]" has no attribute "xxx" [attr-defined] +callables_protocol.py:197: error: "Proto9[[x: int], str]" has no attribute "other_attribute2" [attr-defined] +callables_protocol.py:238: error: Incompatible types in assignment (expression has type "Callable[[int, str], Any]", variable has type "Proto11") [assignment] +callables_protocol.py:260: error: Incompatible types in assignment (expression has type "def cb12_bad1(*args: Any, kwarg0: Any) -> None", variable has type "Proto12") [assignment] +callables_protocol.py:284: error: Incompatible types in assignment (expression has type "Callable[[str], str]", variable has type "Proto13_Default") [assignment] +callables_protocol.py:311: error: Incompatible types in assignment (expression has type "def cb14_no_default(*, path: str) -> str", variable has type "Proto14_Default") [assignment] +""" diff --git a/conformance/results/zuban/callables_subtyping.toml b/conformance/results/zuban/callables_subtyping.toml new file mode 100644 index 000000000..221fac6db --- /dev/null +++ b/conformance/results/zuban/callables_subtyping.toml @@ -0,0 +1,193 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +callables_subtyping.py:26: error: Incompatible types in assignment (expression has type "Callable[[int], int]", variable has type "Callable[[float], float]") [assignment] +callables_subtyping.py:29: error: Incompatible types in assignment (expression has type "Callable[[float], float]", variable has type "Callable[[int], int]") [assignment] +callables_subtyping.py:51: error: Incompatible types in assignment (expression has type "PosOnly2", variable has type "Standard2") [assignment] +callables_subtyping.py:51: note: Following member(s) of "PosOnly2" have conflicts: +callables_subtyping.py:51: note: Expected: +callables_subtyping.py:51: note: def __call__(self, a: int, b: int) -> None +callables_subtyping.py:51: note: Got: +callables_subtyping.py:51: note: def __call__(self, int, int, /) -> None +callables_subtyping.py:52: error: Incompatible types in assignment (expression has type "KwOnly2", variable has type "Standard2") [assignment] +callables_subtyping.py:52: note: Following member(s) of "KwOnly2" have conflicts: +callables_subtyping.py:52: note: Expected: +callables_subtyping.py:52: note: def __call__(self, a: int, b: int) -> None +callables_subtyping.py:52: note: Got: +callables_subtyping.py:52: note: def __call__(self, *, b: int, a: int) -> None +callables_subtyping.py:55: error: Incompatible types in assignment (expression has type "KwOnly2", variable has type "PosOnly2") [assignment] +callables_subtyping.py:55: note: Following member(s) of "KwOnly2" have conflicts: +callables_subtyping.py:55: note: Expected: +callables_subtyping.py:55: note: def __call__(self, int, int, /) -> None +callables_subtyping.py:55: note: Got: +callables_subtyping.py:55: note: def __call__(self, *, b: int, a: int) -> None +callables_subtyping.py:58: error: Incompatible types in assignment (expression has type "PosOnly2", variable has type "KwOnly2") [assignment] +callables_subtyping.py:58: note: Following member(s) of "PosOnly2" have conflicts: +callables_subtyping.py:58: note: Expected: +callables_subtyping.py:58: note: def __call__(self, *, b: int, a: int) -> None +callables_subtyping.py:58: note: Got: +callables_subtyping.py:58: note: def __call__(self, int, int, /) -> None +callables_subtyping.py:82: error: Incompatible types in assignment (expression has type "NoArgs3", variable has type "IntArgs3") [assignment] +callables_subtyping.py:82: note: Following member(s) of "NoArgs3" have conflicts: +callables_subtyping.py:82: note: Expected: +callables_subtyping.py:82: note: def __call__(self, *args: int) -> None +callables_subtyping.py:82: note: Got: +callables_subtyping.py:82: note: def __call__(self) -> None +callables_subtyping.py:85: error: Incompatible types in assignment (expression has type "NoArgs3", variable has type "FloatArgs3") [assignment] +callables_subtyping.py:85: note: Following member(s) of "NoArgs3" have conflicts: +callables_subtyping.py:85: note: Expected: +callables_subtyping.py:85: note: def __call__(self, *args: float) -> None +callables_subtyping.py:85: note: Got: +callables_subtyping.py:85: note: def __call__(self) -> None +callables_subtyping.py:86: error: Incompatible types in assignment (expression has type "IntArgs3", variable has type "FloatArgs3") [assignment] +callables_subtyping.py:86: note: Following member(s) of "IntArgs3" have conflicts: +callables_subtyping.py:86: note: Expected: +callables_subtyping.py:86: note: def __call__(self, *args: float) -> None +callables_subtyping.py:86: note: Got: +callables_subtyping.py:86: note: def __call__(self, *args: int) -> None +callables_subtyping.py:116: error: Incompatible types in assignment (expression has type "IntArgs4", variable has type "PosOnly4") [assignment] +callables_subtyping.py:116: note: Following member(s) of "IntArgs4" have conflicts: +callables_subtyping.py:116: note: Expected: +callables_subtyping.py:116: note: def __call__(self, int, str, /) -> None +callables_subtyping.py:116: note: Got: +callables_subtyping.py:116: note: def __call__(self, *args: int) -> None +callables_subtyping.py:119: error: Incompatible types in assignment (expression has type "StrArgs4", variable has type "IntStrArgs4") [assignment] +callables_subtyping.py:119: note: Following member(s) of "StrArgs4" have conflicts: +callables_subtyping.py:119: note: Expected: +callables_subtyping.py:119: note: def __call__(self, *args: int | str) -> None +callables_subtyping.py:119: note: Got: +callables_subtyping.py:119: note: def __call__(self, int, /, *args: str) -> None +callables_subtyping.py:120: error: Incompatible types in assignment (expression has type "IntArgs4", variable has type "IntStrArgs4") [assignment] +callables_subtyping.py:120: note: Following member(s) of "IntArgs4" have conflicts: +callables_subtyping.py:120: note: Expected: +callables_subtyping.py:120: note: def __call__(self, *args: int | str) -> None +callables_subtyping.py:120: note: Got: +callables_subtyping.py:120: note: def __call__(self, *args: int) -> None +callables_subtyping.py:122: error: Incompatible types in assignment (expression has type "IntArgs4", variable has type "StrArgs4") [assignment] +callables_subtyping.py:122: note: Following member(s) of "IntArgs4" have conflicts: +callables_subtyping.py:122: note: Expected: +callables_subtyping.py:122: note: def __call__(self, int, /, *args: str) -> None +callables_subtyping.py:122: note: Got: +callables_subtyping.py:122: note: def __call__(self, *args: int) -> None +callables_subtyping.py:124: error: Incompatible types in assignment (expression has type "StrArgs4", variable has type "IntArgs4") [assignment] +callables_subtyping.py:124: note: Following member(s) of "StrArgs4" have conflicts: +callables_subtyping.py:124: note: Expected: +callables_subtyping.py:124: note: def __call__(self, *args: int) -> None +callables_subtyping.py:124: note: Got: +callables_subtyping.py:124: note: def __call__(self, int, /, *args: str) -> None +callables_subtyping.py:125: error: Incompatible types in assignment (expression has type "IntStrArgs4", variable has type "Standard4") [assignment] +callables_subtyping.py:125: note: Following member(s) of "IntStrArgs4" have conflicts: +callables_subtyping.py:125: note: Expected: +callables_subtyping.py:125: note: def __call__(self, a: int, b: str) -> None +callables_subtyping.py:125: note: Got: +callables_subtyping.py:125: note: def __call__(self, *args: int | str) -> None +callables_subtyping.py:126: error: Incompatible types in assignment (expression has type "StrArgs4", variable has type "Standard4") [assignment] +callables_subtyping.py:126: note: Following member(s) of "StrArgs4" have conflicts: +callables_subtyping.py:126: note: Expected: +callables_subtyping.py:126: note: def __call__(self, a: int, b: str) -> None +callables_subtyping.py:126: note: Got: +callables_subtyping.py:126: note: def __call__(self, int, /, *args: str) -> None +callables_subtyping.py:151: error: Incompatible types in assignment (expression has type "NoKwargs5", variable has type "IntKwargs5") [assignment] +callables_subtyping.py:151: note: Following member(s) of "NoKwargs5" have conflicts: +callables_subtyping.py:151: note: Expected: +callables_subtyping.py:151: note: def __call__(self, **kwargs: int) -> None +callables_subtyping.py:151: note: Got: +callables_subtyping.py:151: note: def __call__(self) -> None +callables_subtyping.py:154: error: Incompatible types in assignment (expression has type "NoKwargs5", variable has type "FloatKwargs5") [assignment] +callables_subtyping.py:154: note: Following member(s) of "NoKwargs5" have conflicts: +callables_subtyping.py:154: note: Expected: +callables_subtyping.py:154: note: def __call__(self, **kwargs: float) -> None +callables_subtyping.py:154: note: Got: +callables_subtyping.py:154: note: def __call__(self) -> None +callables_subtyping.py:155: error: Incompatible types in assignment (expression has type "IntKwargs5", variable has type "FloatKwargs5") [assignment] +callables_subtyping.py:155: note: Following member(s) of "IntKwargs5" have conflicts: +callables_subtyping.py:155: note: Expected: +callables_subtyping.py:155: note: def __call__(self, **kwargs: float) -> None +callables_subtyping.py:155: note: Got: +callables_subtyping.py:155: note: def __call__(self, **kwargs: int) -> None +callables_subtyping.py:187: error: Incompatible types in assignment (expression has type "IntKwargs6", variable has type "KwOnly6") [assignment] +callables_subtyping.py:187: note: Following member(s) of "IntKwargs6" have conflicts: +callables_subtyping.py:187: note: Expected: +callables_subtyping.py:187: note: def __call__(self, *, a: int, b: str) -> None +callables_subtyping.py:187: note: Got: +callables_subtyping.py:187: note: def __call__(self, **kwargs: int) -> None +callables_subtyping.py:190: error: Incompatible types in assignment (expression has type "StrKwargs6", variable has type "IntStrKwargs6") [assignment] +callables_subtyping.py:190: note: Following member(s) of "StrKwargs6" have conflicts: +callables_subtyping.py:190: note: Expected: +callables_subtyping.py:190: note: def __call__(self, **kwargs: int | str) -> None +callables_subtyping.py:190: note: Got: +callables_subtyping.py:190: note: def __call__(self, *, a: int, **kwargs: str) -> None +callables_subtyping.py:191: error: Incompatible types in assignment (expression has type "IntKwargs6", variable has type "IntStrKwargs6") [assignment] +callables_subtyping.py:191: note: Following member(s) of "IntKwargs6" have conflicts: +callables_subtyping.py:191: note: Expected: +callables_subtyping.py:191: note: def __call__(self, **kwargs: int | str) -> None +callables_subtyping.py:191: note: Got: +callables_subtyping.py:191: note: def __call__(self, **kwargs: int) -> None +callables_subtyping.py:193: error: Incompatible types in assignment (expression has type "IntKwargs6", variable has type "StrKwargs6") [assignment] +callables_subtyping.py:193: note: Following member(s) of "IntKwargs6" have conflicts: +callables_subtyping.py:193: note: Expected: +callables_subtyping.py:193: note: def __call__(self, *, a: int, **kwargs: str) -> None +callables_subtyping.py:193: note: Got: +callables_subtyping.py:193: note: def __call__(self, **kwargs: int) -> None +callables_subtyping.py:195: error: Incompatible types in assignment (expression has type "StrKwargs6", variable has type "IntKwargs6") [assignment] +callables_subtyping.py:195: note: Following member(s) of "StrKwargs6" have conflicts: +callables_subtyping.py:195: note: Expected: +callables_subtyping.py:195: note: def __call__(self, **kwargs: int) -> None +callables_subtyping.py:195: note: Got: +callables_subtyping.py:195: note: def __call__(self, *, a: int, **kwargs: str) -> None +callables_subtyping.py:196: error: Incompatible types in assignment (expression has type "IntStrKwargs6", variable has type "Standard6") [assignment] +callables_subtyping.py:196: note: Following member(s) of "IntStrKwargs6" have conflicts: +callables_subtyping.py:196: note: Expected: +callables_subtyping.py:196: note: def __call__(self, a: int, b: str) -> None +callables_subtyping.py:196: note: Got: +callables_subtyping.py:196: note: def __call__(self, **kwargs: int | str) -> None +callables_subtyping.py:197: error: Incompatible types in assignment (expression has type "StrKwargs6", variable has type "Standard6") [assignment] +callables_subtyping.py:197: note: Following member(s) of "StrKwargs6" have conflicts: +callables_subtyping.py:197: note: Expected: +callables_subtyping.py:197: note: def __call__(self, a: int, b: str) -> None +callables_subtyping.py:197: note: Got: +callables_subtyping.py:197: note: def __call__(self, *, a: int, **kwargs: str) -> None +callables_subtyping.py:236: error: Incompatible types in assignment (expression has type "NoDefaultArg8", variable has type "DefaultArg8") [assignment] +callables_subtyping.py:236: note: Following member(s) of "NoDefaultArg8" have conflicts: +callables_subtyping.py:236: note: Expected: +callables_subtyping.py:236: note: def __call__(self, x: int = ...) -> None +callables_subtyping.py:236: note: Got: +callables_subtyping.py:236: note: def __call__(self, x: int) -> None +callables_subtyping.py:237: error: Incompatible types in assignment (expression has type "NoX8", variable has type "DefaultArg8") [assignment] +callables_subtyping.py:237: note: Following member(s) of "NoX8" have conflicts: +callables_subtyping.py:237: note: Expected: +callables_subtyping.py:237: note: def __call__(self, x: int = ...) -> None +callables_subtyping.py:237: note: Got: +callables_subtyping.py:237: note: def __call__(self) -> None +callables_subtyping.py:240: error: Incompatible types in assignment (expression has type "NoX8", variable has type "NoDefaultArg8") [assignment] +callables_subtyping.py:240: note: Following member(s) of "NoX8" have conflicts: +callables_subtyping.py:240: note: Expected: +callables_subtyping.py:240: note: def __call__(self, x: int) -> None +callables_subtyping.py:240: note: Got: +callables_subtyping.py:240: note: def __call__(self) -> None +callables_subtyping.py:243: error: Incompatible types in assignment (expression has type "NoDefaultArg8", variable has type "NoX8") [assignment] +callables_subtyping.py:243: note: Following member(s) of "NoDefaultArg8" have conflicts: +callables_subtyping.py:243: note: Expected: +callables_subtyping.py:243: note: def __call__(self) -> None +callables_subtyping.py:243: note: Got: +callables_subtyping.py:243: note: def __call__(self, x: int) -> None +callables_subtyping.py:273: error: Incompatible types in assignment (expression has type "Overloaded9", variable has type "FloatArg9") [assignment] +callables_subtyping.py:273: note: Following member(s) of "Overloaded9" have conflicts: +callables_subtyping.py:273: note: Expected: +callables_subtyping.py:273: note: def __call__(self, x: float) -> float +callables_subtyping.py:273: note: Got: +callables_subtyping.py:273: note: @overload +callables_subtyping.py:273: note: def __call__(self, x: int) -> int +callables_subtyping.py:273: note: @overload +callables_subtyping.py:273: note: def __call__(self, x: str) -> str +callables_subtyping.py:297: error: Incompatible types in assignment (expression has type "StrArg10", variable has type "Overloaded10") [assignment] +callables_subtyping.py:297: note: Following member(s) of "StrArg10" have conflicts: +callables_subtyping.py:297: note: Expected: +callables_subtyping.py:297: note: @overload +callables_subtyping.py:297: note: def __call__(self, x: int, y: str) -> float +callables_subtyping.py:297: note: @overload +callables_subtyping.py:297: note: def __call__(self, x: str) -> complex +callables_subtyping.py:297: note: Got: +callables_subtyping.py:297: note: def __call__(self, x: str) -> complex +""" diff --git a/conformance/results/zuban/classes_classvar.toml b/conformance/results/zuban/classes_classvar.toml new file mode 100644 index 000000000..afb724d07 --- /dev/null +++ b/conformance/results/zuban/classes_classvar.toml @@ -0,0 +1,29 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +classes_classvar.py:40: error: ClassVar[...] must have at most one type argument [misc] +classes_classvar.py:41: error: Invalid type: try using Literal[3] instead? [valid-type] +classes_classvar.py:42: error: Name "var" is not defined [name-defined] +classes_classvar.py:47: error: ClassVar cannot contain type variables [misc] +classes_classvar.py:48: error: ClassVar cannot contain type variables [misc] +classes_classvar.py:49: error: ClassVar cannot contain type variables [misc] +classes_classvar.py:54: error: Incompatible types in assignment (expression has type "dict[Any, Any]", variable has type "list[str]") [assignment] +classes_classvar.py:56: error: Variable should not be annotated with both ClassVar and Final [misc] +classes_classvar.py:57: error: Invalid Type: ClassVar nested inside other type [misc] +classes_classvar.py:68: error: Type in ClassVar[...] can only be omitted if there is an initializer [misc] +classes_classvar.py:71: error: ClassVar can only be used for assignments in class body [misc] +classes_classvar.py:72: error: ClassVar can only be used for assignments in class body [misc] +classes_classvar.py:73: error: ClassVar can only be used for assignments in class body [misc] +classes_classvar.py:75: error: ClassVar can only be used for assignments in class body [misc] +classes_classvar.py:79: error: ClassVar can only be used for assignments in class body [misc] +classes_classvar.py:80: error: ClassVar can only be used for assignments in class body [misc] +classes_classvar.py:89: error: Invalid Type: ClassVar nested inside other type [misc] +classes_classvar.py:94: error: ClassVar can only be used for assignments in class body [misc] +classes_classvar.py:127: error: Cannot assign to class variable "stats" via instance [misc] +classes_classvar.py:156: error: Incompatible types in assignment (expression has type "ProtoAImpl", variable has type "ProtoA") [assignment] +classes_classvar.py:156: note: Protocol member ProtoA.x expected class variable, got instance variable +classes_classvar.py:156: note: Protocol member ProtoA.y expected class variable, got instance variable +classes_classvar.py:156: note: "ProtoAImpl" is missing following "ProtoA" protocol member: +classes_classvar.py:156: note: z +""" diff --git a/conformance/results/zuban/classes_override.toml b/conformance/results/zuban/classes_override.toml new file mode 100644 index 000000000..781906c90 --- /dev/null +++ b/conformance/results/zuban/classes_override.toml @@ -0,0 +1,16 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +classes_override.py:53: error: Method "method3" is marked as an override, but no base method was found with this name [misc] +classes_override.py:56: error: Method "method4" is marked as an override, but no base method was found with this name [misc] +classes_override.py:79: error: Method "static_method1" is marked as an override, but no base method was found with this name [misc] +classes_override.py:84: error: Method "class_method1" is marked as an override, but no base method was found with this name [misc] +classes_override.py:89: error: Method "property1" is marked as an override, but no base method was found with this name [misc] +classes_override.py:135: error: Argument 1 of "__init__" is incompatible with supertype "ParentC"; supertype defines the argument type as "int" [override] +classes_override.py:135: note: This violates the Liskov substitution principle +classes_override.py:135: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides +classes_override.py:138: error: Argument 1 of "__new__" is incompatible with supertype "ParentC"; supertype defines the argument type as "int" [override] +classes_override.py:138: note: This violates the Liskov substitution principle +classes_override.py:138: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides +""" diff --git a/conformance/results/zuban/constructors_call_init.toml b/conformance/results/zuban/constructors_call_init.toml new file mode 100644 index 000000000..6192d7a0d --- /dev/null +++ b/conformance/results/zuban/constructors_call_init.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +constructors_call_init.py:21: error: Argument 1 to "Class1" has incompatible type "float"; expected "int" [arg-type] +constructors_call_init.py:42: error: Argument 1 to "Class3" has incompatible type "Class2[int]"; expected "Self | None" [arg-type] +constructors_call_init.py:56: error: Invalid self type in __init__ [call-arg] +constructors_call_init.py:107: error: The type of self "T1" has type vars in non standard positions for class "Class8" [misc] +constructors_call_init.py:107: error: The type of self "T2" has type vars in non standard positions for class "Class8" [misc] +constructors_call_init.py:130: error: Too many arguments for "Class11" [call-arg] +""" diff --git a/conformance/results/zuban/constructors_call_metaclass.toml b/conformance/results/zuban/constructors_call_metaclass.toml new file mode 100644 index 000000000..c9c2218aa --- /dev/null +++ b/conformance/results/zuban/constructors_call_metaclass.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +constructors_call_metaclass.py:54: error: Missing positional argument "x" in call to "Class3" [call-arg] +constructors_call_metaclass.py:68: error: Missing positional argument "x" in call to "Class4" [call-arg] +""" diff --git a/conformance/results/zuban/constructors_call_new.toml b/conformance/results/zuban/constructors_call_new.toml new file mode 100644 index 000000000..c3407c9ad --- /dev/null +++ b/conformance/results/zuban/constructors_call_new.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +constructors_call_new.py:21: error: Argument 1 to "Class1" has incompatible type "float"; expected "int" [arg-type] +constructors_call_new.py:148: error: Invalid self argument "type[Class11[str]]" to attribute function "__new__" with type "type[Class11[int]]" [misc] +""" diff --git a/conformance/results/zuban/constructors_call_type.toml b/conformance/results/zuban/constructors_call_type.toml new file mode 100644 index 000000000..45cc8aeb0 --- /dev/null +++ b/conformance/results/zuban/constructors_call_type.toml @@ -0,0 +1,13 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +constructors_call_type.py:30: error: Missing positional arguments "x", "y" in call to "Class1" [call-arg] +constructors_call_type.py:40: error: Missing positional arguments "x", "y" in call to "Class2" [call-arg] +constructors_call_type.py:50: error: Missing positional arguments "x", "y" in call to "Class3" [call-arg] +constructors_call_type.py:59: error: Too many arguments for "Class4" [call-arg] +constructors_call_type.py:64: error: Too many arguments for "object" [call-arg] +constructors_call_type.py:72: error: Missing positional arguments "x", "y" in call to "Class1" [call-arg] +constructors_call_type.py:81: error: Missing positional argument "y" in call to "Class2" [call-arg] +constructors_call_type.py:82: error: Argument 2 to "Class2" has incompatible type "int"; expected "str" [arg-type] +""" diff --git a/conformance/results/zuban/constructors_callable.toml b/conformance/results/zuban/constructors_callable.toml new file mode 100644 index 000000000..569f40b9a --- /dev/null +++ b/conformance/results/zuban/constructors_callable.toml @@ -0,0 +1,29 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +constructors_callable.py:36: note: Revealed type is "def (x: builtins.int) -> tests.constructors_callable.Class1" +constructors_callable.py:38: error: Missing positional argument "x" in call [call-arg] +constructors_callable.py:39: error: Unexpected keyword argument "y" [call-arg] +constructors_callable.py:49: note: Revealed type is "def () -> tests.constructors_callable.Class2" +constructors_callable.py:51: error: Too many arguments [call-arg] +constructors_callable.py:64: note: Revealed type is "def (x: builtins.int) -> tests.constructors_callable.Class3" +constructors_callable.py:66: error: Missing positional argument "x" in call [call-arg] +constructors_callable.py:67: error: Unexpected keyword argument "y" [call-arg] +constructors_callable.py:68: error: Too many arguments [call-arg] +constructors_callable.py:79: note: Revealed type is "def (x: builtins.int) -> builtins.int" +constructors_callable.py:81: error: Missing positional argument "x" in call [call-arg] +constructors_callable.py:82: error: Unexpected keyword argument "y" [call-arg] +constructors_callable.py:99: note: Revealed type is "def (*args: Any, **kwargs: Any) -> Never" +constructors_callable.py:127: note: Revealed type is "def () -> tests.constructors_callable.Class6Proxy" +constructors_callable.py:129: error: Too many arguments [call-arg] +constructors_callable.py:144: note: Revealed type is "def () -> Any" +constructors_callable.py:146: error: Too many arguments [call-arg] +constructors_callable.py:164: note: Revealed type is "Overload(def (x: builtins.int) -> tests.constructors_callable.Class7[builtins.int], def (x: builtins.str) -> tests.constructors_callable.Class7[builtins.str])" +constructors_callable.py:184: note: Revealed type is "def [T] (x: builtins.list[T], y: builtins.list[T]) -> tests.constructors_callable.Class8[T]" +constructors_callable.py:185: error: Argument 2 has incompatible type "str"; expected "list[str]" [arg-type] +constructors_callable.py:187: error: List item 0 has incompatible type "str"; expected "int" [list-item] +constructors_callable.py:196: note: Revealed type is "def [T] (x: builtins.list[T], y: builtins.list[T]) -> tests.constructors_callable.Class9" +constructors_callable.py:197: error: Argument 2 has incompatible type "str"; expected "list[str]" [arg-type] +constructors_callable.py:199: error: List item 0 has incompatible type "str"; expected "int" [list-item] +""" diff --git a/conformance/results/zuban/constructors_consistency.toml b/conformance/results/zuban/constructors_consistency.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/zuban/constructors_consistency.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/zuban/dataclasses_descriptors.toml b/conformance/results/zuban/dataclasses_descriptors.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/zuban/dataclasses_descriptors.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/zuban/dataclasses_final.toml b/conformance/results/zuban/dataclasses_final.toml new file mode 100644 index 000000000..b59d3cac0 --- /dev/null +++ b/conformance/results/zuban/dataclasses_final.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_final.py:27: error: Cannot assign to final attribute "final_classvar" [misc] +dataclasses_final.py:35: error: Cannot assign to final attribute "final_no_default" [misc] +dataclasses_final.py:36: error: Cannot assign to final attribute "final_with_default" [misc] +dataclasses_final.py:37: error: Cannot assign to final attribute "final_no_default" [misc] +dataclasses_final.py:38: error: Cannot assign to final attribute "final_with_default" [misc] +""" diff --git a/conformance/results/zuban/dataclasses_frozen.toml b/conformance/results/zuban/dataclasses_frozen.toml new file mode 100644 index 000000000..81262e632 --- /dev/null +++ b/conformance/results/zuban/dataclasses_frozen.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_frozen.py:16: error: Property "a" defined in "DC1" is read-only [misc] +dataclasses_frozen.py:17: error: Property "b" defined in "DC1" is read-only [misc] +dataclasses_frozen.py:23: error: Non-frozen dataclass cannot inherit from a frozen dataclass [misc] +dataclasses_frozen.py:33: error: Frozen dataclass cannot inherit from a non-frozen dataclass [misc] +""" diff --git a/conformance/results/zuban/dataclasses_hash.toml b/conformance/results/zuban/dataclasses_hash.toml new file mode 100644 index 000000000..a041362c2 --- /dev/null +++ b/conformance/results/zuban/dataclasses_hash.toml @@ -0,0 +1,14 @@ +conformance_automated = "Pass" +conformant = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_hash.py:17: error: "None" not callable [operator] +dataclasses_hash.py:18: error: Incompatible types in assignment (expression has type "DC1", variable has type "Hashable") [assignment] +dataclasses_hash.py:18: note: Following member(s) of "DC1" have conflicts: +dataclasses_hash.py:18: note: __hash__: expected "Callable[[], int]", got "None" +dataclasses_hash.py:39: error: "None" not callable [operator] +dataclasses_hash.py:40: error: Incompatible types in assignment (expression has type "DC3", variable has type "Hashable") [assignment] +dataclasses_hash.py:40: note: Following member(s) of "DC3" have conflicts: +dataclasses_hash.py:40: note: __hash__: expected "Callable[[], int]", got "None" +""" diff --git a/conformance/results/zuban/dataclasses_inheritance.toml b/conformance/results/zuban/dataclasses_inheritance.toml new file mode 100644 index 000000000..3baad3e38 --- /dev/null +++ b/conformance/results/zuban/dataclasses_inheritance.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_inheritance.py:62: error: Cannot override instance variable (previously declared on base class "DC6") with class variable [misc] +dataclasses_inheritance.py:66: error: Cannot override class variable (previously declared on base class "DC6") with instance variable [misc] +""" diff --git a/conformance/results/zuban/dataclasses_kwonly.toml b/conformance/results/zuban/dataclasses_kwonly.toml new file mode 100644 index 000000000..88c32379f --- /dev/null +++ b/conformance/results/zuban/dataclasses_kwonly.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_kwonly.py:23: error: Too many positional arguments for "DC1" [call-arg] +dataclasses_kwonly.py:38: error: Too many positional arguments for "DC2" [call-arg] +dataclasses_kwonly.py:53: error: Too many positional arguments for "DC3" [call-arg] +""" diff --git a/conformance/results/zuban/dataclasses_match_args.toml b/conformance/results/zuban/dataclasses_match_args.toml new file mode 100644 index 000000000..9b83abf57 --- /dev/null +++ b/conformance/results/zuban/dataclasses_match_args.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_match_args.py:42: error: "type[DC4]" has no attribute "__match_args__" [attr-defined] +""" diff --git a/conformance/results/zuban/dataclasses_order.toml b/conformance/results/zuban/dataclasses_order.toml new file mode 100644 index 000000000..712ba3e1e --- /dev/null +++ b/conformance/results/zuban/dataclasses_order.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_order.py:50: error: Unsupported operand types for < ("DC1" and "DC2") [operator] +""" diff --git a/conformance/results/zuban/dataclasses_postinit.toml b/conformance/results/zuban/dataclasses_postinit.toml new file mode 100644 index 000000000..cd08f520c --- /dev/null +++ b/conformance/results/zuban/dataclasses_postinit.toml @@ -0,0 +1,13 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_postinit.py:19: error: Argument 2 of "__post_init__" is incompatible with supertype "dataclass"; supertype defines the argument type as "str" [override] +dataclasses_postinit.py:28: error: "DC1" has no attribute "x" [attr-defined] +dataclasses_postinit.py:29: error: "DC1" has no attribute "y" [attr-defined] +dataclasses_postinit.py:36: error: Signature of "__post_init__" incompatible with supertype "dataclass" [override] +dataclasses_postinit.py:36: note: Superclass: +dataclasses_postinit.py:36: note: def __post_init__(self, x: int, y: str) -> None +dataclasses_postinit.py:36: note: Subclass: +dataclasses_postinit.py:36: note: def __post_init__(self, x: int) -> None +""" diff --git a/conformance/results/zuban/dataclasses_slots.toml b/conformance/results/zuban/dataclasses_slots.toml new file mode 100644 index 000000000..3bd82f443 --- /dev/null +++ b/conformance/results/zuban/dataclasses_slots.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_slots.py:11: error: "DC1" both defines "__slots__" and is used with "slots=True" [misc] +dataclasses_slots.py:25: error: Trying to assign name "y" that is not in "__slots__" of type "tests.dataclasses_slots.DC2" [misc] +dataclasses_slots.py:38: error: Trying to assign name "y" that is not in "__slots__" of type "tests.dataclasses_slots.DC3" [misc] +dataclasses_slots.py:66: error: "type[DC6]" has no attribute "__slots__" [attr-defined] +dataclasses_slots.py:69: error: "DC6" has no attribute "__slots__" [attr-defined] +""" diff --git a/conformance/results/zuban/dataclasses_transform_class.toml b/conformance/results/zuban/dataclasses_transform_class.toml new file mode 100644 index 000000000..e007f5906 --- /dev/null +++ b/conformance/results/zuban/dataclasses_transform_class.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_transform_class.py:51: error: Non-frozen dataclass cannot inherit from a frozen dataclass [misc] +dataclasses_transform_class.py:63: error: Property "id" defined in "Customer1" is read-only [misc] +dataclasses_transform_class.py:66: error: Too many positional arguments for "Customer1" [call-arg] +dataclasses_transform_class.py:72: error: Unsupported left operand type for < ("Customer1") [operator] +dataclasses_transform_class.py:82: error: Too many positional arguments for "Customer2" [call-arg] +dataclasses_transform_class.py:122: error: Property "id" defined in "Customer3" is read-only [misc] +""" diff --git a/conformance/results/zuban/dataclasses_transform_converter.toml b/conformance/results/zuban/dataclasses_transform_converter.toml new file mode 100644 index 000000000..5191e0a9b --- /dev/null +++ b/conformance/results/zuban/dataclasses_transform_converter.toml @@ -0,0 +1,14 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_transform_converter.py:48: error: Argument "converter" to "model_field" has incompatible type "Callable[[], int]"; expected "Callable[[Never], int]" [arg-type] +dataclasses_transform_converter.py:49: error: Argument "converter" to "model_field" has incompatible type "def bad_converter2(*, x: int) -> int"; expected "Callable[[Never], int]" [arg-type] +dataclasses_transform_converter.py:107: error: Argument 1 to "DC2" has incompatible type "int"; expected "str" [arg-type] +dataclasses_transform_converter.py:108: error: Argument 4 to "DC2" has incompatible type "int"; expected "str | bytes" [arg-type] +dataclasses_transform_converter.py:109: error: Argument 5 to "DC2" has incompatible type "complex"; expected "str | list[str]" [arg-type] +dataclasses_transform_converter.py:118: error: Incompatible types in assignment of a dataclass converter (expression has type "int", expected type "str") [assignment] +dataclasses_transform_converter.py:119: error: Incompatible types in assignment of a dataclass converter (expression has type "int", expected type "str | bytes") [assignment] +dataclasses_transform_converter.py:130: error: Argument "default" to "model_field" has incompatible type "int"; expected "str | None" [arg-type] +dataclasses_transform_converter.py:133: error: Argument "default_factory" to "model_field" has incompatible type "type[int]"; expected "Callable[[], str] | None" [arg-type] +""" diff --git a/conformance/results/zuban/dataclasses_transform_field.toml b/conformance/results/zuban/dataclasses_transform_field.toml new file mode 100644 index 000000000..90f98c551 --- /dev/null +++ b/conformance/results/zuban/dataclasses_transform_field.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_transform_field.py:64: error: Unexpected keyword argument "id" for "CustomerModel1" [call-arg] +dataclasses_transform_field.py:75: error: Too many positional arguments for "CustomerModel2" [call-arg] +""" diff --git a/conformance/results/zuban/dataclasses_transform_func.toml b/conformance/results/zuban/dataclasses_transform_func.toml new file mode 100644 index 000000000..4ebe35382 --- /dev/null +++ b/conformance/results/zuban/dataclasses_transform_func.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_transform_func.py:56: error: Incompatible types in assignment (expression has type "int", variable has type "str") [assignment] +dataclasses_transform_func.py:60: error: Unsupported left operand type for < ("Customer1") [operator] +dataclasses_transform_func.py:64: error: Unexpected keyword argument "salary" for "Customer1" [call-arg] +dataclasses_transform_func.py:70: error: Too many positional arguments for "Customer2" [call-arg] +dataclasses_transform_func.py:89: error: Non-frozen dataclass cannot inherit from a frozen dataclass [misc] +dataclasses_transform_func.py:96: error: Property "id" defined in "Customer3" is read-only [misc] +""" diff --git a/conformance/results/zuban/dataclasses_transform_meta.toml b/conformance/results/zuban/dataclasses_transform_meta.toml new file mode 100644 index 000000000..f19fbfd87 --- /dev/null +++ b/conformance/results/zuban/dataclasses_transform_meta.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_transform_meta.py:51: error: Non-frozen dataclass cannot inherit from a frozen dataclass [misc] +dataclasses_transform_meta.py:63: error: Property "id" defined in "Customer1" is read-only [misc] +dataclasses_transform_meta.py:66: error: Too many positional arguments for "Customer1" [call-arg] +dataclasses_transform_meta.py:73: error: Unsupported left operand type for < ("Customer1") [operator] +dataclasses_transform_meta.py:83: error: Too many positional arguments for "Customer2" [call-arg] +dataclasses_transform_meta.py:103: error: Property "id" defined in "Customer3" is read-only [misc] +""" diff --git a/conformance/results/zuban/dataclasses_usage.toml b/conformance/results/zuban/dataclasses_usage.toml new file mode 100644 index 000000000..8e2a7cccd --- /dev/null +++ b/conformance/results/zuban/dataclasses_usage.toml @@ -0,0 +1,17 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +dataclasses_usage.py:51: error: Missing positional argument "unit_price" in call to "InventoryItem" [call-arg] +dataclasses_usage.py:52: error: Argument 2 to "InventoryItem" has incompatible type "str"; expected "float" [arg-type] +dataclasses_usage.py:53: error: Too many arguments for "InventoryItem" [call-arg] +dataclasses_usage.py:62: error: Attributes without a default cannot follow attributes with one [misc] +dataclasses_usage.py:68: error: Attributes without a default cannot follow attributes with one [misc] +dataclasses_usage.py:74: error: Attributes without a default cannot follow attributes with one [misc] +dataclasses_usage.py:84: error: Too many arguments for "DC4" [call-arg] +dataclasses_usage.py:89: error: Argument "default_factory" to "field" has incompatible type "type[str]"; expected "Callable[[], int]" [arg-type] +dataclasses_usage.py:128: error: Too many arguments for "DC7" [call-arg] +dataclasses_usage.py:131: error: Missing positional argument "y" in call to "DC8" [call-arg] +dataclasses_usage.py:180: error: Too many arguments for "DC13" [call-arg] +dataclasses_usage.py:246: error: Too many arguments for "DC19" [call-arg] +""" diff --git a/conformance/results/zuban/directives_assert_type.toml b/conformance/results/zuban/directives_assert_type.toml new file mode 100644 index 000000000..154dfdeda --- /dev/null +++ b/conformance/results/zuban/directives_assert_type.toml @@ -0,0 +1,13 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +directives_assert_type.py:27: error: Expression is of type "int | str", not "int" [misc] +directives_assert_type.py:28: error: Expression is of type "int | str", not "Any" [misc] +directives_assert_type.py:29: error: Expression is of type "Any", not "int" [misc] +directives_assert_type.py:30: error: Expression is of type "Literal[4]", not "int" [misc] +directives_assert_type.py:32: error: "assert_type" expects 2 arguments [call-arg] +directives_assert_type.py:33: error: Expression is of type "Literal['']", not "int" [misc] +directives_assert_type.py:34: error: "assert_type" expects 2 arguments [call-arg] +directives_assert_type.py:41: error: Expression is of type "str", not "str | Literal['spam']" [misc] +""" diff --git a/conformance/results/zuban/directives_cast.toml b/conformance/results/zuban/directives_cast.toml new file mode 100644 index 000000000..5f0624563 --- /dev/null +++ b/conformance/results/zuban/directives_cast.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +directives_cast.py:15: error: "cast" expects 2 arguments [call-arg] +directives_cast.py:16: error: Invalid type: try using Literal[1] instead? [valid-type] +directives_cast.py:17: error: "cast" expects 2 arguments [call-arg] +""" diff --git a/conformance/results/zuban/directives_deprecated.toml b/conformance/results/zuban/directives_deprecated.toml new file mode 100644 index 000000000..a980f030f --- /dev/null +++ b/conformance/results/zuban/directives_deprecated.toml @@ -0,0 +1,17 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +directives_deprecated.py:18: error: class tests._directives_deprecated_library.Ham is deprecated: Use Spam instead [deprecated] +directives_deprecated.py:24: error: function tests._directives_deprecated_library.norwegian_blue is deprecated: It is pining for the fjords [deprecated] +directives_deprecated.py:25: error: function tests._directives_deprecated_library.norwegian_blue is deprecated: It is pining for the fjords [deprecated] +directives_deprecated.py:30: error: overload def (x: builtins.int) -> builtins.str of function tests._directives_deprecated_library.foo is deprecated: Only str will be allowed [deprecated] +directives_deprecated.py:41: error: function tests._directives_deprecated_library.Spam.__add__ is deprecated: There is enough spam in the world [deprecated] +directives_deprecated.py:42: error: function tests._directives_deprecated_library.Spam.__add__ is deprecated: There is enough spam in the world [deprecated] +directives_deprecated.py:44: error: function tests._directives_deprecated_library.Spam.greasy is deprecated: All spam will be equally greasy [deprecated] +directives_deprecated.py:47: error: function tests._directives_deprecated_library.Spam.shape is deprecated: Shapes are becoming immutable [deprecated] +directives_deprecated.py:48: error: function tests._directives_deprecated_library.Spam.shape is deprecated: Shapes are becoming immutable [deprecated] +directives_deprecated.py:58: error: function tests.directives_deprecated.Invocable.__call__ is deprecated: Deprecated [deprecated] +directives_deprecated.py:69: error: function tests.directives_deprecated.lorem is deprecated: Deprecated [deprecated] +directives_deprecated.py:98: error: function tests.directives_deprecated.SupportsFoo1.foo is deprecated: Deprecated [deprecated] +""" diff --git a/conformance/results/zuban/directives_disjoint_base.toml b/conformance/results/zuban/directives_disjoint_base.toml new file mode 100644 index 000000000..8746451e5 --- /dev/null +++ b/conformance/results/zuban/directives_disjoint_base.toml @@ -0,0 +1,14 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +directives_disjoint_base.py:69: error: Class "LeftAndRight" has incompatible disjoint bases [misc] +directives_disjoint_base.py:73: error: Class "LeftChildAndRight" has incompatible disjoint bases [misc] +directives_disjoint_base.py:77: error: Class "LeftAndRightViaChild" has incompatible disjoint bases [misc] +directives_disjoint_base.py:81: error: Class "LeftRecord" has incompatible disjoint bases [misc] +directives_disjoint_base.py:105: error: Class "IncompatibleSlots" has incompatible disjoint bases [misc] +directives_disjoint_base.py:113: error: Value of type variable "_TC" of "disjoint_base" cannot be "Callable[[], None]" [type-var] +directives_disjoint_base.py:118: error: @disjoint_base cannot be used with TypedDict [misc] +directives_disjoint_base.py:123: error: @disjoint_base cannot be used with protocol class [misc] +directives_disjoint_base.py:134: error: Subclass of "Left" and "Right" cannot exist: have distinct disjoint bases [unreachable] +""" diff --git a/conformance/results/zuban/directives_no_type_check.toml b/conformance/results/zuban/directives_no_type_check.toml new file mode 100644 index 000000000..722db58b0 --- /dev/null +++ b/conformance/results/zuban/directives_no_type_check.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +directives_no_type_check.py:15: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] +directives_no_type_check.py:32: error: Missing positional arguments "a", "b" in call to "func1" [call-arg] +""" diff --git a/conformance/results/zuban/directives_reveal_type.toml b/conformance/results/zuban/directives_reveal_type.toml new file mode 100644 index 000000000..76a0ed461 --- /dev/null +++ b/conformance/results/zuban/directives_reveal_type.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +directives_reveal_type.py:14: note: Revealed type is "builtins.int | builtins.str" +directives_reveal_type.py:15: note: Revealed type is "builtins.list[builtins.int]" +directives_reveal_type.py:16: note: Revealed type is "Any" +directives_reveal_type.py:17: note: Revealed type is "tests.directives_reveal_type.ForwardReference" +directives_reveal_type.py:19: error: Too few arguments for "reveal_type" [call-arg] +directives_reveal_type.py:20: error: Too many arguments for "reveal_type" [call-arg] +""" diff --git a/conformance/results/zuban/directives_type_checking.toml b/conformance/results/zuban/directives_type_checking.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/zuban/directives_type_checking.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/zuban/directives_type_ignore.toml b/conformance/results/zuban/directives_type_ignore.toml new file mode 100644 index 000000000..1f6e8b4c6 --- /dev/null +++ b/conformance/results/zuban/directives_type_ignore.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +directives_type_ignore.py:16: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] +directives_type_ignore.py:16: note: Error code "assignment" not covered by "type: ignore[an-empty-str-is-not-an-int]" comment +""" diff --git a/conformance/results/zuban/directives_type_ignore_file1.toml b/conformance/results/zuban/directives_type_ignore_file1.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/zuban/directives_type_ignore_file1.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/zuban/directives_type_ignore_file2.toml b/conformance/results/zuban/directives_type_ignore_file2.toml new file mode 100644 index 000000000..afe027f9b --- /dev/null +++ b/conformance/results/zuban/directives_type_ignore_file2.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +directives_type_ignore_file2.py:14: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] +""" diff --git a/conformance/results/zuban/directives_version_platform.toml b/conformance/results/zuban/directives_version_platform.toml new file mode 100644 index 000000000..75af449a0 --- /dev/null +++ b/conformance/results/zuban/directives_version_platform.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +directives_version_platform.py:26: error: Expression is of type "int | str", not "int" [misc] +directives_version_platform.py:33: error: Name "val3" is not defined [name-defined] +directives_version_platform.py:42: error: Expression is of type "int | str", not "int" [misc] +directives_version_platform.py:50: error: Name "val6" is not defined [name-defined] +directives_version_platform.py:59: error: Name "val9" is not defined [name-defined] +""" diff --git a/conformance/results/zuban/enums_behaviors.toml b/conformance/results/zuban/enums_behaviors.toml new file mode 100644 index 000000000..cf90125a2 --- /dev/null +++ b/conformance/results/zuban/enums_behaviors.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +enums_behaviors.py:28: error: Expression is of type "Color", not "Literal[Color.RED]" [misc] +enums_behaviors.py:32: error: Expression is of type "Color", not "Literal[Color.BLUE]" [misc] +enums_behaviors.py:44: error: Cannot extend enum with existing members: "Shape" [misc] +""" diff --git a/conformance/results/zuban/enums_definition.toml b/conformance/results/zuban/enums_definition.toml new file mode 100644 index 000000000..300aa75aa --- /dev/null +++ b/conformance/results/zuban/enums_definition.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +enums_definition.py:25: error: Too many arguments for Enum() [call-arg] +enums_definition.py:92: error: "type[Color12]" has no attribute "BLUE" [attr-defined] +""" diff --git a/conformance/results/zuban/enums_expansion.toml b/conformance/results/zuban/enums_expansion.toml new file mode 100644 index 000000000..5e05ae77b --- /dev/null +++ b/conformance/results/zuban/enums_expansion.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +enums_expansion.py:38: error: Statement is unreachable [unreachable] +enums_expansion.py:56: error: Expression is of type "CustomFlags", not "Literal[CustomFlags.FLAG3]" [misc] +""" diff --git a/conformance/results/zuban/enums_member_names.toml b/conformance/results/zuban/enums_member_names.toml new file mode 100644 index 000000000..f22302d47 --- /dev/null +++ b/conformance/results/zuban/enums_member_names.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +enums_member_names.py:30: error: Expression is of type "str", not "Literal['RED', 'BLUE', 'GREEN']" [misc] +""" diff --git a/conformance/results/zuban/enums_member_values.toml b/conformance/results/zuban/enums_member_values.toml new file mode 100644 index 000000000..0e71e68fa --- /dev/null +++ b/conformance/results/zuban/enums_member_values.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +enums_member_values.py:54: error: Expression is of type "tuple[Literal[1], float, float]", not "Literal[1]" [misc] +enums_member_values.py:68: error: Expression is of type "int", not "Literal[1]" [misc] +enums_member_values.py:78: error: Enum value type "str" does not match the type "int" of "_value_" [misc] +enums_member_values.py:85: error: Incompatible types in assignment (expression has type "int", variable has type "str") [assignment] +enums_member_values.py:96: error: Expression is of type "EllipsisType", not "int" [misc] +""" diff --git a/conformance/results/zuban/enums_members.toml b/conformance/results/zuban/enums_members.toml new file mode 100644 index 000000000..532bcb874 --- /dev/null +++ b/conformance/results/zuban/enums_members.toml @@ -0,0 +1,16 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +enums_members.py:54: error: Enum members must be left unannotated [misc] +enums_members.py:54: note: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members +enums_members.py:86: error: Parameter 1 of Literal[...] is invalid [valid-type] +enums_members.py:87: error: Parameter 1 of Literal[...] is invalid [valid-type] +enums_members.py:88: error: Parameter 1 of Literal[...] is invalid [valid-type] +enums_members.py:89: error: Parameter 1 of Literal[...] is invalid [valid-type] +enums_members.py:120: error: Parameter 1 of Literal[...] is invalid [valid-type] +enums_members.py:132: note: Revealed type is "builtins.int" +enums_members.py:133: error: Parameter 1 of Literal[...] is invalid [valid-type] +enums_members.py:150: error: Expression is of type "Literal[Pet5.DOG]", not "int" [misc] +enums_members.py:151: error: Expression is of type "Literal[Pet5.FISH]", not "int" [misc] +""" diff --git a/conformance/results/zuban/exceptions_context_managers.toml b/conformance/results/zuban/exceptions_context_managers.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/zuban/exceptions_context_managers.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/zuban/generics_base_class.toml b/conformance/results/zuban/generics_base_class.toml new file mode 100644 index 000000000..c6f007321 --- /dev/null +++ b/conformance/results/zuban/generics_base_class.toml @@ -0,0 +1,12 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_base_class.py:26: error: Argument 1 to "takes_dict_incorrect" has incompatible type "SymbolTable"; expected "dict[str, list[object]]" [arg-type] +generics_base_class.py:29: error: Invalid type [valid-type] +generics_base_class.py:30: error: Invalid type [valid-type] +generics_base_class.py:49: error: "LinkedList" expects 1 type argument, but 2 given [type-arg] +generics_base_class.py:61: error: "MyDict" expects 1 type argument, but 2 given [type-arg] +generics_base_class.py:68: error: Duplicate type variables in Generic[...] or Protocol[...] [misc] +generics_base_class.py:98: error: Cannot determine consistent method resolution order (MRO) for "BadChild" [misc] +""" diff --git a/conformance/results/zuban/generics_basic.toml b/conformance/results/zuban/generics_basic.toml new file mode 100644 index 000000000..8a98fe6f7 --- /dev/null +++ b/conformance/results/zuban/generics_basic.toml @@ -0,0 +1,26 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_basic.py:40: error: Argument 2 to "concat" has incompatible type "bytes"; expected "str" [arg-type] +generics_basic.py:41: error: Argument 2 to "concat" has incompatible type "str"; expected "bytes" [arg-type] +generics_basic.py:49: error: Type variable must have at least two constrained types [misc] +generics_basic.py:55: error: TypeVar constraint type cannot be parametrized by type variables [misc] +generics_basic.py:69: error: Argument 2 to "concat" has incompatible type "bytes"; expected "str" [arg-type] +generics_basic.py:121: error: Duplicate type variables in Generic[...] or Protocol[...] [misc] +generics_basic.py:157: error: Invalid index type "int" for "MyMap1[str, int]"; expected type "str" [index] +generics_basic.py:158: error: Invalid index type "int" for "MyMap2[int, str]"; expected type "str" [index] +generics_basic.py:162: error: Free type variable expected in Generic[...] [misc] +generics_basic.py:163: error: Free type variable expected in Protocol[...] [misc] +generics_basic.py:171: error: If Generic[...] or Protocol[...] is present it should list all type variables [misc] +generics_basic.py:172: error: If Generic[...] or Protocol[...] is present it should list all type variables [misc] +generics_basic.py:208: error: Invalid metaclass "GenericMeta[T]" [metaclass] +generics_basic.py:223: error: Argument 2 to "takes_two_lists" has incompatible type "str"; expected "list[int]" [arg-type] +generics_basic.py:225: error: List item 0 has incompatible type "str"; expected "int" [list-item] +generics_basic.py:232: error: Argument 2 to "takes_two_lists" has incompatible type "list[str]"; expected "list[int]" [arg-type] +generics_basic.py:240: error: Argument 2 to "takes_two_int_lists" has incompatible type "str"; expected "list[int]" [arg-type] +generics_basic.py:241: error: List item 0 has incompatible type "str"; expected "int" [list-item] +generics_basic.py:251: error: Argument 2 to "takes_two_int_lists" has incompatible type "list[bool]"; expected "list[int]" [arg-type] +generics_basic.py:251: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance +generics_basic.py:251: note: Consider using "Sequence" instead, which is covariant +""" diff --git a/conformance/results/zuban/generics_defaults.toml b/conformance/results/zuban/generics_defaults.toml new file mode 100644 index 000000000..fd34b3631 --- /dev/null +++ b/conformance/results/zuban/generics_defaults.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_defaults.py:24: error: "T" cannot appear after "DefaultStrT" in type parameter list because it has no default type [misc] +generics_defaults.py:66: error: "AllTheDefaults" expects between 2 and 5 type arguments, but 1 given [type-arg] +generics_defaults.py:152: error: TypeVar default must be a subtype of the bound type [misc] +generics_defaults.py:159: error: TypeVar default must be one of the constraint types [misc] +generics_defaults.py:177: error: Expression is of type "int", not "Any" [misc] +generics_defaults.py:188: error: TypeVar defaults are ambiguous after a TypeVarTuple [misc] +""" diff --git a/conformance/results/zuban/generics_defaults_referential.toml b/conformance/results/zuban/generics_defaults_referential.toml new file mode 100644 index 000000000..874e32116 --- /dev/null +++ b/conformance/results/zuban/generics_defaults_referential.toml @@ -0,0 +1,12 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_defaults_referential.py:36: error: Argument 2 to "Foo" has incompatible type "str"; expected "int" [arg-type] +generics_defaults_referential.py:37: error: Argument 1 to "Foo" has incompatible type "str"; expected "int" [arg-type] +generics_defaults_referential.py:53: error: Type parameter "Start2T" has a default type that refers to one or more type variables that are out of scope [misc] +generics_defaults_referential.py:60: error: Type parameter "S2" has a default type that refers to one or more type variables that are out of scope [misc] +generics_defaults_referential.py:68: error: TypeVar default must be a subtype of the bound type [misc] +generics_defaults_referential.py:74: error: TypeVar default must be one of the constraint types [misc] +generics_defaults_referential.py:78: error: TypeVar default must be one of the constraint types [misc] +""" diff --git a/conformance/results/zuban/generics_defaults_specialization.toml b/conformance/results/zuban/generics_defaults_specialization.toml new file mode 100644 index 000000000..a485b047c --- /dev/null +++ b/conformance/results/zuban/generics_defaults_specialization.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_defaults_specialization.py:30: error: Bad number of arguments for type alias, expected between 0 and 1, given 2 [misc] +generics_defaults_specialization.py:48: error: Incompatible types in assignment (expression has type "type[Bar]", variable has type "type[Bar[int]]") [assignment] +generics_defaults_specialization.py:58: error: "Foo" expects no type arguments, but 1 given [type-arg] +""" diff --git a/conformance/results/zuban/generics_mixed_variance_inference.toml b/conformance/results/zuban/generics_mixed_variance_inference.toml new file mode 100644 index 000000000..bd9c4a3d8 --- /dev/null +++ b/conformance/results/zuban/generics_mixed_variance_inference.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_mixed_variance_inference.py:13: error: Incompatible types in assignment (expression has type "Mixed[bool, []]", variable has type "Mixed[int, []]") [assignment] +generics_mixed_variance_inference.py:16: error: Incompatible types in assignment (expression has type "Mixed[int, object, []]", variable has type "Mixed[int, int, []]") [assignment] +generics_mixed_variance_inference.py:21: error: Incompatible types in assignment (expression has type "Mixed[int, [bool]]", variable has type "Mixed[int, [int]]") [assignment] +""" diff --git a/conformance/results/zuban/generics_paramspec_basic.toml b/conformance/results/zuban/generics_paramspec_basic.toml new file mode 100644 index 000000000..4d3ada23c --- /dev/null +++ b/conformance/results/zuban/generics_paramspec_basic.toml @@ -0,0 +1,22 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_paramspec_basic.py:10: error: String argument 1 "NotIt" to ParamSpec(...) does not match variable name "WrongName" [misc] +generics_paramspec_basic.py:15: error: Invalid location for ParamSpec "P" [valid-type] +generics_paramspec_basic.py:15: note: You can use ParamSpec as the first argument to Callable, e.g., "Callable[P, int]" +generics_paramspec_basic.py:23: error: Invalid location for ParamSpec "P" [valid-type] +generics_paramspec_basic.py:23: note: You can use ParamSpec as the first argument to Callable, e.g., "Callable[P, int]" +generics_paramspec_basic.py:23: error: Invalid location for ParamSpec "P" [valid-type] +generics_paramspec_basic.py:23: note: You can use ParamSpec as the first argument to Callable, e.g., "Callable[P, int]" +generics_paramspec_basic.py:27: error: Invalid location for Concatenate [valid-type] +generics_paramspec_basic.py:27: note: You can use Concatenate as the first argument to Callable +generics_paramspec_basic.py:31: error: Invalid location for ParamSpec "P" [valid-type] +generics_paramspec_basic.py:31: note: You can use ParamSpec as the first argument to Callable, e.g., "Callable[P, int]" +generics_paramspec_basic.py:35: error: Invalid location for ParamSpec "P" [valid-type] +generics_paramspec_basic.py:35: note: You can use ParamSpec as the first argument to Callable, e.g., "Callable[P, int]" +generics_paramspec_basic.py:39: error: Invalid location for ParamSpec "P" [valid-type] +generics_paramspec_basic.py:39: note: You can use ParamSpec as the first argument to Callable, e.g., "Callable[P, int]" +generics_paramspec_basic.py:39: error: Invalid location for ParamSpec "P" [valid-type] +generics_paramspec_basic.py:39: note: You can use ParamSpec as the first argument to Callable, e.g., "Callable[P, int]" +""" diff --git a/conformance/results/zuban/generics_paramspec_components.toml b/conformance/results/zuban/generics_paramspec_components.toml new file mode 100644 index 000000000..0e1fa0041 --- /dev/null +++ b/conformance/results/zuban/generics_paramspec_components.toml @@ -0,0 +1,27 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_paramspec_components.py:17: error: Use "P.args" for variadic "*" parameter [misc] +generics_paramspec_components.py:17: error: Use "P.kwargs" for variadic "**" parameter [misc] +generics_paramspec_components.py:20: error: ParamSpec components are not allowed here [misc] +generics_paramspec_components.py:23: error: Use "P.kwargs" for variadic "**" parameter [misc] +generics_paramspec_components.py:26: error: ParamSpec must have "*args" typed as "P.args" and "**kwargs" typed as "P.kwargs" [misc] +generics_paramspec_components.py:30: error: ParamSpec "P" is unbound [misc] +generics_paramspec_components.py:35: error: ParamSpec components are not allowed here [misc] +generics_paramspec_components.py:36: error: ParamSpec components are not allowed here [misc] +generics_paramspec_components.py:38: error: ParamSpec must have "*args" typed as "P.args" and "**kwargs" typed as "P.kwargs" [misc] +generics_paramspec_components.py:41: error: ParamSpec must have "*args" typed as "P.args" and "**kwargs" typed as "P.kwargs" [misc] +generics_paramspec_components.py:49: error: Argument 1 has incompatible type "*P.kwargs"; expected "P.args" [arg-type] +generics_paramspec_components.py:49: error: Argument after ** must be a mapping, not "P.args" [arg-type] +generics_paramspec_components.py:51: error: Argument 1 has incompatible type "int"; expected "P.args" [arg-type] +generics_paramspec_components.py:60: error: Arguments not allowed after ParamSpec.args [misc] +generics_paramspec_components.py:70: error: Too few arguments [call-arg] +generics_paramspec_components.py:70: error: ParamSpec arguments must be of types "*P.args, **P.kwargs" [misc] +generics_paramspec_components.py:70: error: Argument 3 has incompatible type "**P.kwargs"; expected "P.kwargs" [arg-type] +generics_paramspec_components.py:72: error: Too few arguments [call-arg] +generics_paramspec_components.py:83: error: Argument "x" to "foo" has incompatible type "int"; expected "P.args" [arg-type] +generics_paramspec_components.py:83: error: Argument 2 to "foo" has incompatible type "*P.args"; expected "int" [arg-type] +generics_paramspec_components.py:98: error: Argument 2 to "twice" has incompatible type "str"; expected "int" [arg-type] +generics_paramspec_components.py:98: error: Argument 3 to "twice" has incompatible type "int"; expected "str" [arg-type] +""" diff --git a/conformance/results/zuban/generics_paramspec_semantics.toml b/conformance/results/zuban/generics_paramspec_semantics.toml new file mode 100644 index 000000000..7aec788a2 --- /dev/null +++ b/conformance/results/zuban/generics_paramspec_semantics.toml @@ -0,0 +1,15 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_paramspec_semantics.py:26: error: Unexpected keyword argument "a" [call-arg] +generics_paramspec_semantics.py:26: error: Unexpected keyword argument "b" [call-arg] +generics_paramspec_semantics.py:27: error: Argument 2 has incompatible type "str"; expected "bool" [arg-type] +generics_paramspec_semantics.py:61: error: Argument 2 to "func1" has incompatible type "def keyword_only_y(*, y: int) -> int"; expected "Callable[[NamedArg(int, 'x')], int]" [arg-type] +generics_paramspec_semantics.py:98: error: Argument 1 has incompatible type "int"; expected "str" [arg-type] +generics_paramspec_semantics.py:108: error: Argument 1 has incompatible type "int"; expected "bool" [arg-type] +generics_paramspec_semantics.py:120: error: Argument 1 has incompatible type "int"; expected "str" [arg-type] +generics_paramspec_semantics.py:127: error: Argument 1 to "expects_int_first" has incompatible type "Callable[[str], int]"; expected "Callable[[int], int]" [arg-type] +generics_paramspec_semantics.py:132: error: Argument 1 to "expects_int_first" has incompatible type "def two(*, x: int) -> int"; expected "Callable[[int, Never], int]" [arg-type] +generics_paramspec_semantics.py:137: error: Argument 1 to "expects_int_first" has incompatible type "def three(**kwargs: int) -> int"; expected "Callable[[int, Never], int]" [arg-type] +""" diff --git a/conformance/results/zuban/generics_paramspec_specialization.toml b/conformance/results/zuban/generics_paramspec_specialization.toml new file mode 100644 index 000000000..70ea88ccc --- /dev/null +++ b/conformance/results/zuban/generics_paramspec_specialization.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_paramspec_specialization.py:44: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "int" [misc] +generics_paramspec_specialization.py:54: error: Argument 1 has incompatible type "str"; expected "int" [arg-type] +generics_paramspec_specialization.py:55: error: Argument 3 has incompatible type "str"; expected "bool" [arg-type] +generics_paramspec_specialization.py:60: error: Argument 1 has incompatible type "str"; expected "int" [arg-type] +generics_paramspec_specialization.py:61: error: Argument 3 has incompatible type "str"; expected "bool" [arg-type] +""" diff --git a/conformance/results/zuban/generics_paramspec_variance.toml b/conformance/results/zuban/generics_paramspec_variance.toml new file mode 100644 index 000000000..0b4029a1c --- /dev/null +++ b/conformance/results/zuban/generics_paramspec_variance.toml @@ -0,0 +1,27 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_paramspec_variance.py:14: error: Incompatible types in assignment (expression has type "InvariantParamSpec[[int]]", variable has type "InvariantParamSpec[[object]]") [assignment] +generics_paramspec_variance.py:15: error: Incompatible types in assignment (expression has type "InvariantParamSpec[[object]]", variable has type "InvariantParamSpec[[int]]") [assignment] +generics_paramspec_variance.py:21: error: Incompatible types in assignment (expression has type "ContravariantParamSpec[[int]]", variable has type "ContravariantParamSpec[[object]]") [assignment] +generics_paramspec_variance.py:30: error: Incompatible types in assignment (expression has type "CovariantParamSpec[[object]]", variable has type "CovariantParamSpec[[int]]") [assignment] +generics_paramspec_variance.py:61: error: Incompatible types in assignment (expression has type "InitP[[*, a: int]]", variable has type "InitP[[a: int]]") [assignment] +generics_paramspec_variance.py:63: error: Incompatible types in assignment (expression has type "InitP[[int]]", variable has type "InitP[[a: int]]") [assignment] +generics_paramspec_variance.py:65: error: Incompatible types in assignment (expression has type "InitP[[b: int]]", variable has type "InitP[[a: int]]") [assignment] +generics_paramspec_variance.py:69: error: Incompatible types in assignment (expression has type "InitP[[a: int, b: str]]", variable has type "InitP[[a: int]]") [assignment] +generics_paramspec_variance.py:88: error: Incompatible types in assignment (expression has type "OutitP[[b: int]]", variable has type "OutitP[[a: int]]") [assignment] +generics_paramspec_variance.py:90: error: Incompatible types in assignment (expression has type "OutitP[[a: int =]]", variable has type "OutitP[[a: int]]") [assignment] +generics_paramspec_variance.py:92: error: Incompatible types in assignment (expression has type "OutitP[[a: int, b: str]]", variable has type "OutitP[[a: int]]") [assignment] +generics_paramspec_variance.py:100: error: ParamSpec cannot be both covariant and contravariant [misc] +generics_paramspec_variance.py:101: error: Cannot use covariant with infer_variance [misc] +generics_paramspec_variance.py:102: error: Cannot use contravariant with infer_variance [misc] +generics_paramspec_variance.py:110: error: Incompatible types in assignment (expression has type "InvariantParamSpecOld[[bool]]", variable has type "InvariantParamSpecOld[[int]]") [assignment] +generics_paramspec_variance.py:111: error: Incompatible types in assignment (expression has type "InvariantParamSpecOld[[object]]", variable has type "InvariantParamSpecOld[[int]]") [assignment] +generics_paramspec_variance.py:117: error: Cannot use a contravariant param spec as a parameter [type-var] +generics_paramspec_variance.py:121: error: Incompatible types in assignment (expression has type "ContravariantParamSpecOld[[int]]", variable has type "ContravariantParamSpecOld[[object]]") [assignment] +generics_paramspec_variance.py:126: error: Cannot use a covariant param spec as return type [type-var] +generics_paramspec_variance.py:132: error: Incompatible types in assignment (expression has type "CovariantParamSpecOld[[object]]", variable has type "CovariantParamSpecOld[[int]]") [assignment] +generics_paramspec_variance.py:142: error: Incompatible types in assignment (expression has type "InferredContravariantParamSpecOld[[int]]", variable has type "InferredContravariantParamSpecOld[[object]]") [assignment] +generics_paramspec_variance.py:151: error: Incompatible types in assignment (expression has type "InferredCovariantParamSpecOld[[object]]", variable has type "InferredCovariantParamSpecOld[[int]]") [assignment] +""" diff --git a/conformance/results/zuban/generics_scoping.toml b/conformance/results/zuban/generics_scoping.toml new file mode 100644 index 000000000..000fd4f34 --- /dev/null +++ b/conformance/results/zuban/generics_scoping.toml @@ -0,0 +1,30 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_scoping.py:15: error: Expression is of type "Literal[1]", not "int" [misc] +generics_scoping.py:19: error: Expression is of type "Literal['a']", not "str" [misc] +generics_scoping.py:34: error: Argument 1 to "meth_2" of "MyClass" has incompatible type "str"; expected "int" [arg-type] +generics_scoping.py:49: error: Expression is of type "Literal['abc']", not "str" [misc] +generics_scoping.py:53: error: Expression is of type "Literal[b'abc']", not "bytes" [misc] +generics_scoping.py:61: error: Type variable "tests.generics_scoping.S" is unbound [misc] +generics_scoping.py:61: note: (Hint: Use "Generic[S]" or "Protocol[S]" base class to bind "S" inside a class) +generics_scoping.py:61: note: (Hint: Use "S" in function signature to bind "S" inside a function) +generics_scoping.py:65: error: Type variable "tests.generics_scoping.S" is unbound [misc] +generics_scoping.py:65: note: (Hint: Use "Generic[S]" or "Protocol[S]" base class to bind "S" inside a class) +generics_scoping.py:65: note: (Hint: Use "S" in function signature to bind "S" inside a function) +generics_scoping.py:76: error: Free type variable expected in Generic[...] [misc] +generics_scoping.py:86: error: Type variable "T" is bound by an outer class [misc] +generics_scoping.py:89: error: Type variable "T" is bound by an outer class [misc] +generics_scoping.py:91: error: Type variable "T" is bound by an outer class [misc] +generics_scoping.py:98: error: Can't use bound type variable "T" to define generic alias [misc] +generics_scoping.py:105: error: Type variable "tests.generics_scoping.T" is unbound [misc] +generics_scoping.py:105: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) +generics_scoping.py:105: note: (Hint: Use "T" in function signature to bind "T" inside a function) +generics_scoping.py:106: error: Type variable "tests.generics_scoping.T" is unbound [misc] +generics_scoping.py:106: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) +generics_scoping.py:106: note: (Hint: Use "T" in function signature to bind "T" inside a function) +generics_scoping.py:107: error: Type variable "tests.generics_scoping.T" is unbound [misc] +generics_scoping.py:107: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) +generics_scoping.py:107: note: (Hint: Use "T" in function signature to bind "T" inside a function) +""" diff --git a/conformance/results/zuban/generics_self_advanced.toml b/conformance/results/zuban/generics_self_advanced.toml new file mode 100644 index 000000000..ff36318bb --- /dev/null +++ b/conformance/results/zuban/generics_self_advanced.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_self_advanced.py:48: error: Access to generic instance variables via class is ambiguous [misc] +""" diff --git a/conformance/results/zuban/generics_self_attributes.toml b/conformance/results/zuban/generics_self_attributes.toml new file mode 100644 index 000000000..449b88a32 --- /dev/null +++ b/conformance/results/zuban/generics_self_attributes.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_self_attributes.py:26: error: Argument "next" to "OrdinalLinkedList" has incompatible type "LinkedList[int]"; expected "OrdinalLinkedList | None" [arg-type] +generics_self_attributes.py:32: error: Incompatible types in assignment (expression has type "LinkedList[int]", variable has type "OrdinalLinkedList | None") [assignment] +""" diff --git a/conformance/results/zuban/generics_self_basic.toml b/conformance/results/zuban/generics_self_basic.toml new file mode 100644 index 000000000..428c5a58a --- /dev/null +++ b/conformance/results/zuban/generics_self_basic.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_self_basic.py:20: error: Incompatible return value type (got "Shape", expected "Self") [return-value] +generics_self_basic.py:33: error: Incompatible return value type (got "Shape", expected "Self") [return-value] +generics_self_basic.py:68: error: Self type cannot have type arguments [valid-type] +""" diff --git a/conformance/results/zuban/generics_self_protocols.toml b/conformance/results/zuban/generics_self_protocols.toml new file mode 100644 index 000000000..7d25923b6 --- /dev/null +++ b/conformance/results/zuban/generics_self_protocols.toml @@ -0,0 +1,17 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_self_protocols.py:61: error: Argument 1 to "accepts_shape" has incompatible type "BadReturnType"; expected "ShapeProtocol" [arg-type] +generics_self_protocols.py:61: note: Following member(s) of "BadReturnType" have conflicts: +generics_self_protocols.py:61: note: Expected: +generics_self_protocols.py:61: note: def [Self: BadReturnType] set_scale(self, scale: float) -> Self +generics_self_protocols.py:61: note: Got: +generics_self_protocols.py:61: note: def set_scale(self, scale: float) -> int +generics_self_protocols.py:64: error: Argument 1 to "accepts_shape" has incompatible type "ReturnDifferentClass"; expected "ShapeProtocol" [arg-type] +generics_self_protocols.py:64: note: Following member(s) of "ReturnDifferentClass" have conflicts: +generics_self_protocols.py:64: note: Expected: +generics_self_protocols.py:64: note: def [Self: ReturnDifferentClass] set_scale(self, scale: float) -> Self +generics_self_protocols.py:64: note: Got: +generics_self_protocols.py:64: note: def set_scale(self, scale: float) -> ReturnConcreteShape +""" diff --git a/conformance/results/zuban/generics_self_usage.toml b/conformance/results/zuban/generics_self_usage.toml new file mode 100644 index 000000000..f2ff29fdf --- /dev/null +++ b/conformance/results/zuban/generics_self_usage.toml @@ -0,0 +1,18 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_self_usage.py:73: error: Self type is only allowed in annotations within class definition [misc] +generics_self_usage.py:73: error: Self type is only allowed in annotations within class definition [misc] +generics_self_usage.py:76: error: Self type is only allowed in annotations within class definition [misc] +generics_self_usage.py:82: error: "self" parameter missing for a non-static method (or an invalid type for self) [misc] +generics_self_usage.py:87: error: Incompatible return value type (got "Foo3", expected "Self") [return-value] +generics_self_usage.py:103: error: Self type is only allowed in annotations within class definition [misc] +generics_self_usage.py:105: error: Self type is only allowed in annotations within class definition [misc] +generics_self_usage.py:108: error: Self type cannot be used in type alias target [misc] +generics_self_usage.py:113: error: Static methods cannot use Self type [misc] +generics_self_usage.py:118: error: Static methods cannot use Self type [misc] +generics_self_usage.py:118: error: Static methods cannot use Self type [misc] +generics_self_usage.py:123: error: Self type cannot be used in a metaclass [misc] +generics_self_usage.py:127: error: Self type cannot be used in a metaclass [misc] +""" diff --git a/conformance/results/zuban/generics_syntax_compatibility.toml b/conformance/results/zuban/generics_syntax_compatibility.toml new file mode 100644 index 000000000..9eb19efc3 --- /dev/null +++ b/conformance/results/zuban/generics_syntax_compatibility.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_syntax_compatibility.py:14: error: All type parameters should be declared ("K" not declared) [misc] +generics_syntax_compatibility.py:26: error: All type parameters should be declared ("K" not declared) [misc] +""" diff --git a/conformance/results/zuban/generics_syntax_declarations.toml b/conformance/results/zuban/generics_syntax_declarations.toml new file mode 100644 index 000000000..6da51b54f --- /dev/null +++ b/conformance/results/zuban/generics_syntax_declarations.toml @@ -0,0 +1,17 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_syntax_declarations.py:17: error: Generic[...] base class is redundant [misc] +generics_syntax_declarations.py:25: error: No arguments expected for "Protocol" base class [misc] +generics_syntax_declarations.py:32: error: "T" has no attribute "is_integer" [attr-defined] +generics_syntax_declarations.py:44: error: TypeVar bound must not contain type variables [misc] +generics_syntax_declarations.py:48: error: Bracketed expression "[...]" is not valid as a type [valid-type] +generics_syntax_declarations.py:48: note: Did you mean "List[...]"? +generics_syntax_declarations.py:60: error: Type variable must have at least two constrained types [misc] +generics_syntax_declarations.py:64: error: Type variable must have at least two constrained types [misc] +generics_syntax_declarations.py:71: error: Variable "tests.generics_syntax_declarations.t1" is not valid as a type [valid-type] +generics_syntax_declarations.py:71: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_declarations.py:75: error: Invalid type: try using Literal[3] instead? [valid-type] +generics_syntax_declarations.py:79: error: Name "S" is not defined [name-defined] +""" diff --git a/conformance/results/zuban/generics_syntax_infer_variance.toml b/conformance/results/zuban/generics_syntax_infer_variance.toml new file mode 100644 index 000000000..36d8e5ac7 --- /dev/null +++ b/conformance/results/zuban/generics_syntax_infer_variance.toml @@ -0,0 +1,23 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_syntax_infer_variance.py:15: error: Cannot use covariant with infer_variance [misc] +generics_syntax_infer_variance.py:17: error: Cannot use contravariant with infer_variance [misc] +generics_syntax_infer_variance.py:29: error: Incompatible types in assignment (expression has type "ShouldBeCovariant1[float]", variable has type "ShouldBeCovariant1[int]") [assignment] +generics_syntax_infer_variance.py:47: error: Incompatible types in assignment (expression has type "ShouldBeCovariant2[float]", variable has type "ShouldBeCovariant2[int]") [assignment] +generics_syntax_infer_variance.py:56: error: Incompatible types in assignment (expression has type "ShouldBeCovariant3[float]", variable has type "ShouldBeCovariant3[int]") [assignment] +generics_syntax_infer_variance.py:85: error: Incompatible types in assignment (expression has type "ShouldBeCovariant5[float]", variable has type "ShouldBeCovariant5[int]") [assignment] +generics_syntax_infer_variance.py:96: error: Incompatible types in assignment (expression has type "ShouldBeCovariant6[float]", variable has type "ShouldBeCovariant6[int]") [assignment] +generics_syntax_infer_variance.py:112: error: Incompatible types in assignment (expression has type "ShouldBeInvariant1[int]", variable has type "ShouldBeInvariant1[float]") [assignment] +generics_syntax_infer_variance.py:113: error: Incompatible types in assignment (expression has type "ShouldBeInvariant1[float]", variable has type "ShouldBeInvariant1[int]") [assignment] +generics_syntax_infer_variance.py:127: error: Incompatible types in assignment (expression has type "ShouldBeInvariant2[int]", variable has type "ShouldBeInvariant2[float]") [assignment] +generics_syntax_infer_variance.py:128: error: Incompatible types in assignment (expression has type "ShouldBeInvariant2[float]", variable has type "ShouldBeInvariant2[int]") [assignment] +generics_syntax_infer_variance.py:135: error: Incompatible types in assignment (expression has type "ShouldBeInvariant3[int, str]", variable has type "ShouldBeInvariant3[float, str]") [assignment] +generics_syntax_infer_variance.py:136: error: Incompatible types in assignment (expression has type "ShouldBeInvariant3[float, str]", variable has type "ShouldBeInvariant3[int, str]") [assignment] +generics_syntax_infer_variance.py:137: error: Incompatible types in assignment (expression has type "ShouldBeInvariant3[str, int]", variable has type "ShouldBeInvariant3[str, float]") [assignment] +generics_syntax_infer_variance.py:138: error: Incompatible types in assignment (expression has type "ShouldBeInvariant3[str, float]", variable has type "ShouldBeInvariant3[str, int]") [assignment] +generics_syntax_infer_variance.py:146: error: Incompatible types in assignment (expression has type "ShouldBeInvariant4[int]", variable has type "ShouldBeInvariant4[float]") [assignment] +generics_syntax_infer_variance.py:154: error: Incompatible types in assignment (expression has type "ShouldBeInvariant5[int]", variable has type "ShouldBeInvariant5[float]") [assignment] +generics_syntax_infer_variance.py:165: error: Incompatible types in assignment (expression has type "ShouldBeContravariant1[int]", variable has type "ShouldBeContravariant1[float]") [assignment] +""" diff --git a/conformance/results/zuban/generics_syntax_scoping.toml b/conformance/results/zuban/generics_syntax_scoping.toml new file mode 100644 index 000000000..c72eeb1b0 --- /dev/null +++ b/conformance/results/zuban/generics_syntax_scoping.toml @@ -0,0 +1,16 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_syntax_scoping.py:14: error: Variable "tests.generics_syntax_scoping.S" is not valid as a type [valid-type] +generics_syntax_scoping.py:14: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_scoping.py:18: error: Variable "tests.generics_syntax_scoping.T" is not valid as a type [valid-type] +generics_syntax_scoping.py:18: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_scoping.py:26: error: Name "T" is used before definition [used-before-def] +generics_syntax_scoping.py:35: error: Name "T" is used before definition [used-before-def] +generics_syntax_scoping.py:35: error: Variable "tests.generics_syntax_scoping.T" is not valid as a type [valid-type] +generics_syntax_scoping.py:35: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_scoping.py:83: error: "T" already defined as a type parameter [misc] +generics_syntax_scoping.py:86: error: "T" already defined as a type parameter [misc] +generics_syntax_scoping.py:89: error: "T" already defined as a type parameter [misc] +""" diff --git a/conformance/results/zuban/generics_type_erasure.toml b/conformance/results/zuban/generics_type_erasure.toml new file mode 100644 index 000000000..051f94d22 --- /dev/null +++ b/conformance/results/zuban/generics_type_erasure.toml @@ -0,0 +1,13 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_type_erasure.py:38: error: Argument 1 to "Node" has incompatible type "str"; expected "int | None" [arg-type] +generics_type_erasure.py:40: error: Argument 1 to "Node" has incompatible type "int"; expected "str | None" [arg-type] +generics_type_erasure.py:42: error: Access to generic instance variables via class is ambiguous [misc] +generics_type_erasure.py:43: error: Access to generic instance variables via class is ambiguous [misc] +generics_type_erasure.py:44: error: Access to generic instance variables via class is ambiguous [misc] +generics_type_erasure.py:45: error: Access to generic instance variables via class is ambiguous [misc] +generics_type_erasure.py:46: error: Access to generic instance variables via class is ambiguous [misc] +""" diff --git a/conformance/results/zuban/generics_typevartuple_args.toml b/conformance/results/zuban/generics_typevartuple_args.toml new file mode 100644 index 000000000..29b6e9434 --- /dev/null +++ b/conformance/results/zuban/generics_typevartuple_args.toml @@ -0,0 +1,14 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_typevartuple_args.py:33: error: Argument 3 to "exec_le" has incompatible type "str"; expected "Env" [arg-type] +generics_typevartuple_args.py:34: error: Argument 3 to "exec_le" has incompatible type "str"; expected "Env" [arg-type] +generics_typevartuple_args.py:48: error: Argument 2 to "func1" has incompatible type "str"; expected "int" [arg-type] +generics_typevartuple_args.py:57: error: Argument 2 to "func2" has incompatible type "int"; expected "str" [arg-type] +generics_typevartuple_args.py:58: error: Too few arguments for "func2" [call-arg] +generics_typevartuple_args.py:59: error: Too few arguments for "func2" [call-arg] +generics_typevartuple_args.py:59: error: Argument 1 to "func2" has incompatible type "str"; expected "int" [arg-type] +generics_typevartuple_args.py:67: error: Too few arguments for "func3" [call-arg] +generics_typevartuple_args.py:75: error: Argument 2 to "func4" has incompatible type "tuple[int, int]"; expected "tuple[int]" [arg-type] +""" diff --git a/conformance/results/zuban/generics_typevartuple_basic.toml b/conformance/results/zuban/generics_typevartuple_basic.toml new file mode 100644 index 000000000..b9ffa1e5a --- /dev/null +++ b/conformance/results/zuban/generics_typevartuple_basic.toml @@ -0,0 +1,19 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_typevartuple_basic.py:43: error: Argument 1 to "Array" has incompatible type "Height"; expected "tuple[Height, Width]" [arg-type] +generics_typevartuple_basic.py:44: error: Argument 1 to "Array" has incompatible type "tuple[Batch, Width]"; expected "tuple[Batch, Height, Width]" [arg-type] +generics_typevartuple_basic.py:46: error: Argument 1 to "Array" has incompatible type "tuple[Time, Batch, Width, Height]"; expected "tuple[Time, Batch, Height, Width]" [arg-type] +generics_typevartuple_basic.py:53: error: Free type variable expected in Generic[...] [misc] +generics_typevartuple_basic.py:54: error: TypeVarTuple "Shape" is only valid with an unpack [valid-type] +generics_typevartuple_basic.py:57: error: TypeVarTuple "Shape" is only valid with an unpack [valid-type] +generics_typevartuple_basic.py:60: error: TypeVarTuple "Shape" is only valid with an unpack [valid-type] +generics_typevartuple_basic.py:66: error: Too many positional arguments for "TypeVarTuple" [call-arg] +generics_typevartuple_basic.py:67: error: Unexpected keyword argument "bound" for "TypeVarTuple" [call-arg] +generics_typevartuple_basic.py:91: error: Argument 2 to "func2" has incompatible type "tuple[int]"; expected "tuple[int, int]" [arg-type] +generics_typevartuple_basic.py:100: error: Argument 2 to "multiply" has incompatible type "Array[Width]"; expected "Array[Height]" [arg-type] +generics_typevartuple_basic.py:101: error: Argument 2 to "multiply" has incompatible type "Array[Height, Width]"; expected "Array[Height]" [arg-type] +generics_typevartuple_basic.py:107: error: Can only use one type var tuple in a class def [misc] +generics_typevartuple_basic.py:111: error: Can only use one TypeVarTuple in type params [misc] +""" diff --git a/conformance/results/zuban/generics_typevartuple_callable.toml b/conformance/results/zuban/generics_typevartuple_callable.toml new file mode 100644 index 000000000..d18ba3c57 --- /dev/null +++ b/conformance/results/zuban/generics_typevartuple_callable.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_typevartuple_callable.py:26: error: Argument "args" to "Process" has incompatible type "tuple[str, int]"; expected "tuple[int, str]" [arg-type] +""" diff --git a/conformance/results/zuban/generics_typevartuple_concat.toml b/conformance/results/zuban/generics_typevartuple_concat.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/zuban/generics_typevartuple_concat.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/zuban/generics_typevartuple_overloads.toml b/conformance/results/zuban/generics_typevartuple_overloads.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/zuban/generics_typevartuple_overloads.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/zuban/generics_typevartuple_specialization.toml b/conformance/results/zuban/generics_typevartuple_specialization.toml new file mode 100644 index 000000000..b7b6182df --- /dev/null +++ b/conformance/results/zuban/generics_typevartuple_specialization.toml @@ -0,0 +1,12 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_typevartuple_specialization.py:109: error: Unpack is only valid in a variadic position [misc] +generics_typevartuple_specialization.py:109: error: TypeVarTuple "Ts" is unbound [misc] +generics_typevartuple_specialization.py:110: error: Unpack is only valid in a variadic position [misc] +generics_typevartuple_specialization.py:121: error: More than one variadic Unpack in a type is not allowed [misc] +generics_typevartuple_specialization.py:122: error: More than one variadic Unpack in a type is not allowed [misc] +generics_typevartuple_specialization.py:127: error: Bad number of arguments for type alias, expected at least 2, given 2 [misc] +generics_typevartuple_specialization.py:163: error: TypeVarTuple cannot be split [misc] +""" diff --git a/conformance/results/zuban/generics_typevartuple_unpack.toml b/conformance/results/zuban/generics_typevartuple_unpack.toml new file mode 100644 index 000000000..5f2652dd0 --- /dev/null +++ b/conformance/results/zuban/generics_typevartuple_unpack.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_typevartuple_unpack.py:30: error: Argument 1 to "process_batch_channels" has incompatible type "Array[Batch]"; expected "Array[Batch, Unpack[Tuple[Any, ...]], Channels]" [arg-type] +""" diff --git a/conformance/results/zuban/generics_typevartuple_variance.toml b/conformance/results/zuban/generics_typevartuple_variance.toml new file mode 100644 index 000000000..5c9e528d5 --- /dev/null +++ b/conformance/results/zuban/generics_typevartuple_variance.toml @@ -0,0 +1,31 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_typevartuple_variance.py:14: error: Incompatible types in assignment (expression has type "InvariantTypeVarTuple[int]", variable has type "InvariantTypeVarTuple[object]") [assignment] +generics_typevartuple_variance.py:15: error: Incompatible types in assignment (expression has type "InvariantTypeVarTuple[object]", variable has type "InvariantTypeVarTuple[int]") [assignment] +generics_typevartuple_variance.py:17: error: Incompatible types in assignment (expression has type "InvariantTypeVarTuple[Unpack[Tuple[object, ...]]]", variable has type "InvariantTypeVarTuple[Unpack[Tuple[int, ...]]]") [assignment] +generics_typevartuple_variance.py:18: error: Incompatible types in assignment (expression has type "InvariantTypeVarTuple[Unpack[Tuple[int, ...]]]", variable has type "InvariantTypeVarTuple[Unpack[Tuple[object, ...]]]") [assignment] +generics_typevartuple_variance.py:20: error: Incompatible types in assignment (expression has type "InvariantTypeVarTuple[Unpack[Tuple[int, ...]]]", variable has type "InvariantTypeVarTuple[int]") [assignment] +generics_typevartuple_variance.py:21: error: Incompatible types in assignment (expression has type "InvariantTypeVarTuple[int]", variable has type "InvariantTypeVarTuple[Unpack[Tuple[int, ...]]]") [assignment] +generics_typevartuple_variance.py:28: error: Incompatible types in assignment (expression has type "ContravariantTypeVarTuple[object, int]", variable has type "ContravariantTypeVarTuple[object, object]") [assignment] +generics_typevartuple_variance.py:31: error: Incompatible types in assignment (expression has type "ContravariantTypeVarTuple[Unpack[Tuple[int, ...]]]", variable has type "ContravariantTypeVarTuple[Unpack[Tuple[object, ...]]]") [assignment] +generics_typevartuple_variance.py:34: error: Incompatible types in assignment (expression has type "ContravariantTypeVarTuple[int]", variable has type "ContravariantTypeVarTuple[Unpack[Tuple[int, ...]]]") [assignment] +generics_typevartuple_variance.py:42: error: Incompatible types in assignment (expression has type "CovariantTypeVarTuple[object]", variable has type "CovariantTypeVarTuple[int]") [assignment] +generics_typevartuple_variance.py:45: error: Incompatible types in assignment (expression has type "CovariantTypeVarTuple[bool, object]", variable has type "CovariantTypeVarTuple[int, int]") [assignment] +generics_typevartuple_variance.py:46: error: Incompatible types in assignment (expression has type "CovariantTypeVarTuple[object, bool]", variable has type "CovariantTypeVarTuple[int, int]") [assignment] +generics_typevartuple_variance.py:47: error: Incompatible types in assignment (expression has type "CovariantTypeVarTuple[object, object]", variable has type "CovariantTypeVarTuple[int, int]") [assignment] +generics_typevartuple_variance.py:48: error: Incompatible types in assignment (expression has type "CovariantTypeVarTuple[Unpack[Tuple[object, ...]]]", variable has type "CovariantTypeVarTuple[Unpack[Tuple[int, ...]]]") [assignment] +generics_typevartuple_variance.py:51: error: Incompatible types in assignment (expression has type "CovariantTypeVarTuple[Unpack[Tuple[int, ...]]]", variable has type "CovariantTypeVarTuple[int]") [assignment] +generics_typevartuple_variance.py:56: error: TypeVarTuple cannot be both covariant and contravariant [misc] +generics_typevartuple_variance.py:57: error: Cannot use covariant with infer_variance [misc] +generics_typevartuple_variance.py:58: error: Cannot use contravariant with infer_variance [misc] +generics_typevartuple_variance.py:68: error: Incompatible types in assignment (expression has type "InvariantTypeVarTupleOld[int]", variable has type "InvariantTypeVarTupleOld[object]") [assignment] +generics_typevartuple_variance.py:69: error: Incompatible types in assignment (expression has type "InvariantTypeVarTupleOld[object]", variable has type "InvariantTypeVarTupleOld[int]") [assignment] +generics_typevartuple_variance.py:79: error: Cannot use a contravariant type var tuples as return type [type-var] +generics_typevartuple_variance.py:83: error: Incompatible types in assignment (expression has type "ContravariantTypeVarTupleOld[int]", variable has type "ContravariantTypeVarTupleOld[object]") [assignment] +generics_typevartuple_variance.py:90: error: Cannot use a covariant type var tuples as a parameter [type-var] +generics_typevartuple_variance.py:97: error: Incompatible types in assignment (expression has type "CovariantTypeVarTupleOld[object]", variable has type "CovariantTypeVarTupleOld[int]") [assignment] +generics_typevartuple_variance.py:107: error: Incompatible types in assignment (expression has type "InferredContravariantTypeVarTupleOld[int]", variable has type "InferredContravariantTypeVarTupleOld[object]") [assignment] +generics_typevartuple_variance.py:116: error: Incompatible types in assignment (expression has type "InferredCovariantTypeVarTupleOld[object]", variable has type "InferredCovariantTypeVarTupleOld[int]") [assignment] +""" diff --git a/conformance/results/zuban/generics_upper_bound.toml b/conformance/results/zuban/generics_upper_bound.toml new file mode 100644 index 000000000..766c0373a --- /dev/null +++ b/conformance/results/zuban/generics_upper_bound.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_upper_bound.py:24: error: TypeVar bound must not contain type variables [misc] +generics_upper_bound.py:44: error: Expression is of type "list[int] | set[int]", not "Collection[int]" [misc] +generics_upper_bound.py:52: error: Value of type variable "ST" of "longer" cannot be "int" [type-var] +generics_upper_bound.py:52: error: Value of type variable "ST" of "longer" cannot be "int" [type-var] +generics_upper_bound.py:57: error: TypeVar cannot have both values and an upper bound [misc] +""" diff --git a/conformance/results/zuban/generics_variance.toml b/conformance/results/zuban/generics_variance.toml new file mode 100644 index 000000000..f104685a4 --- /dev/null +++ b/conformance/results/zuban/generics_variance.toml @@ -0,0 +1,18 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_variance.py:14: error: TypeVar cannot be both covariant and contravariant [misc] +generics_variance.py:77: error: Variance of TypeVar "T_co" incompatible with variance in parent type [type-var] +generics_variance.py:81: error: Variance of TypeVar "T_contra" incompatible with variance in parent type [type-var] +generics_variance.py:93: error: Variance of TypeVar "T_contra" incompatible with variance in parent type [type-var] +generics_variance.py:105: error: Variance of TypeVar "T_co" incompatible with variance in parent type [type-var] +generics_variance.py:113: error: Variance of TypeVar "T_co" incompatible with variance in parent type [type-var] +generics_variance.py:125: error: Variance of TypeVar "T_co" incompatible with variance in parent type [type-var] +generics_variance.py:131: error: Variance of TypeVar "T_contra" incompatible with variance in parent type [type-var] +generics_variance.py:141: error: Variance of TypeVar "T_co" incompatible with variance in parent type [type-var] +generics_variance.py:163: error: Variance of TypeVar "T_contra" incompatible with variance in parent type [type-var] +generics_variance.py:167: error: Variance of TypeVar "T_co" incompatible with variance in parent type [type-var] +generics_variance.py:191: error: Variance of TypeVar "T_contra" incompatible with variance in parent type [type-var] +generics_variance.py:195: error: Variance of TypeVar "T_co" incompatible with variance in parent type [type-var] +""" diff --git a/conformance/results/zuban/generics_variance_inference.toml b/conformance/results/zuban/generics_variance_inference.toml new file mode 100644 index 000000000..600ad7145 --- /dev/null +++ b/conformance/results/zuban/generics_variance_inference.toml @@ -0,0 +1,29 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +generics_variance_inference.py:24: error: Incompatible types in assignment (expression has type "ClassA[float, int, int]", variable has type "ClassA[int, int, int]") [assignment] +generics_variance_inference.py:25: error: Incompatible types in assignment (expression has type "ClassA[float, int, int]", variable has type "ClassA[float, float, int]") [assignment] +generics_variance_inference.py:28: error: Incompatible types in assignment (expression has type "ClassA[int, float, float]", variable has type "ClassA[int, int, int]") [assignment] +generics_variance_inference.py:41: error: Incompatible types in assignment (expression has type "ShouldBeCovariant1[float]", variable has type "ShouldBeCovariant1[int]") [assignment] +generics_variance_inference.py:49: error: Incompatible types in assignment (expression has type "ShouldBeCovariant2[float]", variable has type "ShouldBeCovariant2[int]") [assignment] +generics_variance_inference.py:58: error: Incompatible types in assignment (expression has type "ShouldBeCovariant3[float]", variable has type "ShouldBeCovariant3[int]") [assignment] +generics_variance_inference.py:67: error: Incompatible types in assignment (expression has type "ShouldBeCovariant4[float]", variable has type "ShouldBeCovariant4[int]") [assignment] +generics_variance_inference.py:80: error: Incompatible types in assignment (expression has type "ShouldBeCovariant5[float]", variable has type "ShouldBeCovariant5[int]") [assignment] +generics_variance_inference.py:96: error: Incompatible types in assignment (expression has type "ShouldBeInvariant1[int]", variable has type "ShouldBeInvariant1[float]") [assignment] +generics_variance_inference.py:97: error: Incompatible types in assignment (expression has type "ShouldBeInvariant1[float]", variable has type "ShouldBeInvariant1[int]") [assignment] +generics_variance_inference.py:111: error: Incompatible types in assignment (expression has type "ShouldBeInvariant2[int]", variable has type "ShouldBeInvariant2[float]") [assignment] +generics_variance_inference.py:112: error: Incompatible types in assignment (expression has type "ShouldBeInvariant2[float]", variable has type "ShouldBeInvariant2[int]") [assignment] +generics_variance_inference.py:119: error: Incompatible types in assignment (expression has type "ShouldBeInvariant3[int, str]", variable has type "ShouldBeInvariant3[float, str]") [assignment] +generics_variance_inference.py:120: error: Incompatible types in assignment (expression has type "ShouldBeInvariant3[float, str]", variable has type "ShouldBeInvariant3[int, str]") [assignment] +generics_variance_inference.py:121: error: Incompatible types in assignment (expression has type "ShouldBeInvariant3[str, int]", variable has type "ShouldBeInvariant3[str, float]") [assignment] +generics_variance_inference.py:122: error: Incompatible types in assignment (expression has type "ShouldBeInvariant3[str, float]", variable has type "ShouldBeInvariant3[str, int]") [assignment] +generics_variance_inference.py:130: error: Incompatible types in assignment (expression has type "ShouldBeInvariant4[int]", variable has type "ShouldBeInvariant4[float]") [assignment] +generics_variance_inference.py:138: error: Incompatible types in assignment (expression has type "ShouldBeInvariant5[int]", variable has type "ShouldBeInvariant5[float]") [assignment] +generics_variance_inference.py:149: error: Incompatible types in assignment (expression has type "ShouldBeContravariant1[int]", variable has type "ShouldBeContravariant1[float]") [assignment] +generics_variance_inference.py:169: error: Incompatible types in assignment (expression has type "ShouldBeInvariant6[float]", variable has type "ShouldBeInvariant6[int]") [assignment] +generics_variance_inference.py:170: error: Incompatible types in assignment (expression has type "ShouldBeInvariant6[int]", variable has type "ShouldBeInvariant6[float]") [assignment] +generics_variance_inference.py:181: error: Incompatible types in assignment (expression has type "ShouldBeCovariant6[float]", variable has type "ShouldBeCovariant6[int]") [assignment] +generics_variance_inference.py:194: error: Incompatible types in assignment (expression has type "ShouldBeContravariant2[int]", variable has type "ShouldBeContravariant2[float]") [assignment] +generics_variance_inference.py:205: error: Incompatible types in assignment (expression has type "ShouldBeCovariant7[object]", variable has type "ShouldBeCovariant7[int]") [assignment] +""" diff --git a/conformance/results/zuban/historical_positional.toml b/conformance/results/zuban/historical_positional.toml new file mode 100644 index 000000000..787972c69 --- /dev/null +++ b/conformance/results/zuban/historical_positional.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +historical_positional.py:18: error: Unexpected keyword argument "__x" for "f1" [call-arg] +historical_positional.py:26: error: A positional only param starting with two underscores is not allowed after a positional or keyword param [misc] +historical_positional.py:54: error: A positional only param starting with two underscores is not allowed after a positional or keyword param [misc] +historical_positional.py:59: error: Unexpected keyword argument "__x" for "m1" of "A" [call-arg] +""" diff --git a/conformance/results/zuban/literals_interactions.toml b/conformance/results/zuban/literals_interactions.toml new file mode 100644 index 000000000..166336175 --- /dev/null +++ b/conformance/results/zuban/literals_interactions.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +literals_interactions.py:14: error: Tuple index out of range [misc] +literals_interactions.py:15: error: Tuple index out of range [misc] +literals_interactions.py:16: error: Tuple index out of range [misc] +literals_interactions.py:17: error: Tuple index out of range [misc] +""" diff --git a/conformance/results/zuban/literals_literalstring.toml b/conformance/results/zuban/literals_literalstring.toml new file mode 100644 index 000000000..6db478d33 --- /dev/null +++ b/conformance/results/zuban/literals_literalstring.toml @@ -0,0 +1,16 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +literals_literalstring.py:36: error: Parameter 2 of Literal[...] is invalid [valid-type] +literals_literalstring.py:37: error: Parameter 1 of Literal[...] is invalid [valid-type] +literals_literalstring.py:43: error: Incompatible types in assignment (expression has type "Literal['two']", variable has type "Literal['']") [assignment] +literals_literalstring.py:65: error: Incompatible types in assignment (expression has type "str", variable has type "LiteralString") [assignment] +literals_literalstring.py:73: error: Incompatible types in assignment (expression has type "Literal[3]", variable has type "LiteralString") [assignment] +literals_literalstring.py:74: error: Incompatible types in assignment (expression has type "Literal[b'test']", variable has type "LiteralString") [assignment] +literals_literalstring.py:119: error: Value of type variable "TLiteral" of "literal_identity" cannot be "str" [type-var] +literals_literalstring.py:133: error: Value of type variable "T" of "Container" cannot be "str" [type-var] +literals_literalstring.py:171: error: Incompatible types in assignment (expression has type "list[LiteralString]", variable has type "list[str]") [assignment] +literals_literalstring.py:171: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance +literals_literalstring.py:171: note: Consider using "Sequence" instead, which is covariant +""" diff --git a/conformance/results/zuban/literals_parameterizations.toml b/conformance/results/zuban/literals_parameterizations.toml new file mode 100644 index 000000000..0a1ba71fa --- /dev/null +++ b/conformance/results/zuban/literals_parameterizations.toml @@ -0,0 +1,24 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +literals_parameterizations.py:41: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type] +literals_parameterizations.py:42: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type] +literals_parameterizations.py:43: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type] +literals_parameterizations.py:44: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type] +literals_parameterizations.py:45: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type] +literals_parameterizations.py:46: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type] +literals_parameterizations.py:47: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type] +literals_parameterizations.py:48: error: Parameter 1 of Literal[...] is invalid [valid-type] +literals_parameterizations.py:49: error: Parameter 1 of Literal[...] is invalid [valid-type] +literals_parameterizations.py:50: error: Type variable "tests.literals_parameterizations.T" is unbound [misc] +literals_parameterizations.py:50: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) +literals_parameterizations.py:50: note: (Hint: Use "T" in function signature to bind "T" inside a function) +literals_parameterizations.py:51: error: Parameter 1 of Literal[...] cannot be of type "float" [valid-type] +literals_parameterizations.py:52: error: Parameter 1 of Literal[...] cannot be of type "Any" [valid-type] +literals_parameterizations.py:53: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type] +literals_parameterizations.py:56: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type] +literals_parameterizations.py:60: error: Literal[...] must have at least one parameter [valid-type] +literals_parameterizations.py:61: error: Parameter 1 of Literal[...] is invalid [valid-type] +literals_parameterizations.py:65: error: Incompatible types in assignment (expression has type "Literal[Color.RED]", variable has type "Literal['Color.RED']") [assignment] +""" diff --git a/conformance/results/zuban/literals_semantics.toml b/conformance/results/zuban/literals_semantics.toml new file mode 100644 index 000000000..57c26e052 --- /dev/null +++ b/conformance/results/zuban/literals_semantics.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +literals_semantics.py:10: error: Incompatible types in assignment (expression has type "Literal[4]", variable has type "Literal[3]") [assignment] +literals_semantics.py:24: error: Incompatible types in assignment (expression has type "Literal[0]", variable has type "Literal[False]") [assignment] +literals_semantics.py:25: error: Incompatible types in assignment (expression has type "Literal[False]", variable has type "Literal[0]") [assignment] +literals_semantics.py:33: error: Incompatible types in assignment (expression has type "Literal[6, 7, 8]", variable has type "Literal[3, 4, 5]") [assignment] +""" diff --git a/conformance/results/zuban/namedtuples_define_class.toml b/conformance/results/zuban/namedtuples_define_class.toml new file mode 100644 index 000000000..d5c42ff3f --- /dev/null +++ b/conformance/results/zuban/namedtuples_define_class.toml @@ -0,0 +1,20 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +namedtuples_define_class.py:33: error: Tuple index out of range [misc] +namedtuples_define_class.py:34: error: Tuple index out of range [misc] +namedtuples_define_class.py:45: error: Missing positional argument "y" in call to "Point" [call-arg] +namedtuples_define_class.py:46: error: Missing positional argument "y" in call to "Point" [call-arg] +namedtuples_define_class.py:47: error: Argument 2 to "Point" has incompatible type "str"; expected "int" [arg-type] +namedtuples_define_class.py:48: error: Argument "units" to "Point" has incompatible type "int"; expected "str" [arg-type] +namedtuples_define_class.py:49: error: Too many arguments for "Point" [call-arg] +namedtuples_define_class.py:50: error: Unexpected keyword argument "other" for "Point" [call-arg] +namedtuples_define_class.py:70: error: Too many arguments for "Point2" [call-arg] +namedtuples_define_class.py:77: error: NamedTuple field name cannot start with an underscore: _y [misc] +namedtuples_define_class.py:87: error: Non-default NamedTuple fields cannot follow default fields [misc] +namedtuples_define_class.py:107: error: NamedTuple attributes cannot be overridden in subclasses [misc] +namedtuples_define_class.py:121: error: Too many arguments for "ConditionalField" [call-arg] +namedtuples_define_class.py:140: error: Argument 2 to "Property" has incompatible type "float"; expected "str" [arg-type] +namedtuples_define_class.py:147: error: NamedTuple should be a single base [misc] +""" diff --git a/conformance/results/zuban/namedtuples_define_functional.toml b/conformance/results/zuban/namedtuples_define_functional.toml new file mode 100644 index 000000000..98ee2d2fd --- /dev/null +++ b/conformance/results/zuban/namedtuples_define_functional.toml @@ -0,0 +1,18 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +namedtuples_define_functional.py:16: error: Missing positional argument "y" in call to "Point1" [call-arg] +namedtuples_define_functional.py:21: error: Missing positional arguments "x", "y" in call to "Point2" [call-arg] +namedtuples_define_functional.py:26: error: Too many arguments for "Point3" [call-arg] +namedtuples_define_functional.py:31: error: Unexpected keyword argument "z" for "Point4" [call-arg] +namedtuples_define_functional.py:36: error: Argument 2 to "Point5" has incompatible type "str"; expected "int" [arg-type] +namedtuples_define_functional.py:37: error: Too many arguments for "Point5" [call-arg] +namedtuples_define_functional.py:42: error: Argument 2 to "Point6" has incompatible type "str"; expected "int" [arg-type] +namedtuples_define_functional.py:43: error: Argument "x" to "Point6" has incompatible type "float"; expected "int" [arg-type] +namedtuples_define_functional.py:52: error: "namedtuple()" has duplicate field name "a" [misc] +namedtuples_define_functional.py:53: error: "namedtuple()" field name "def" is a keyword [misc] +namedtuples_define_functional.py:54: error: "namedtuple()" field name "def" is a keyword [misc] +namedtuples_define_functional.py:55: error: "namedtuple()" field name "_d" starts with an underscore [misc] +namedtuples_define_functional.py:69: error: Missing positional argument "a" in call to "NT7" [call-arg] +""" diff --git a/conformance/results/zuban/namedtuples_type_compat.toml b/conformance/results/zuban/namedtuples_type_compat.toml new file mode 100644 index 000000000..bddb6fd78 --- /dev/null +++ b/conformance/results/zuban/namedtuples_type_compat.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +namedtuples_type_compat.py:22: error: Incompatible types in assignment (expression has type "Point", variable has type "tuple[int, int]") [assignment] +namedtuples_type_compat.py:23: error: Incompatible types in assignment (expression has type "Point", variable has type "tuple[int, str, str]") [assignment] +""" diff --git a/conformance/results/zuban/namedtuples_usage.toml b/conformance/results/zuban/namedtuples_usage.toml new file mode 100644 index 000000000..75ebf0e03 --- /dev/null +++ b/conformance/results/zuban/namedtuples_usage.toml @@ -0,0 +1,13 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +namedtuples_usage.py:34: error: Tuple index out of range [misc] +namedtuples_usage.py:35: error: Tuple index out of range [misc] +namedtuples_usage.py:40: error: Property "x" defined in "Point" is read-only [misc] +namedtuples_usage.py:41: error: Unsupported target for indexed assignment ("Point") [index] +namedtuples_usage.py:42: error: NamedTuple attributes cannot be deleted [misc] +namedtuples_usage.py:43: error: "Point" has no attribute "__delitem__" [attr-defined] +namedtuples_usage.py:52: error: Too many values to unpack (2 expected, 3 provided) [misc] +namedtuples_usage.py:53: error: Need more than 3 values to unpack (4 expected) [misc] +""" diff --git a/conformance/results/zuban/narrowing_typeguard.toml b/conformance/results/zuban/narrowing_typeguard.toml new file mode 100644 index 000000000..b8892b074 --- /dev/null +++ b/conformance/results/zuban/narrowing_typeguard.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +narrowing_typeguard.py:102: error: TypeGuard functions must have a positional argument [misc] +narrowing_typeguard.py:107: error: TypeGuard functions must have a positional argument [misc] +narrowing_typeguard.py:128: error: Argument 1 to "takes_callable_str" has incompatible type "Callable[[object], TypeGuard[int]]"; expected "Callable[[object], str]" [arg-type] +narrowing_typeguard.py:148: error: Argument 1 to "takes_callable_str_proto" has incompatible type "Callable[[object], TypeGuard[int]]"; expected "CallableStrProto" [arg-type] +""" diff --git a/conformance/results/zuban/narrowing_typeis.toml b/conformance/results/zuban/narrowing_typeis.toml new file mode 100644 index 000000000..8e3c790bf --- /dev/null +++ b/conformance/results/zuban/narrowing_typeis.toml @@ -0,0 +1,14 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +narrowing_typeis.py:110: error: "TypeIs" functions must have a positional argument [misc] +narrowing_typeis.py:115: error: "TypeIs" functions must have a positional argument [misc] +narrowing_typeis.py:137: error: Argument 1 to "takes_callable_str" has incompatible type "Callable[[object], TypeIs[int]]"; expected "Callable[[object], str]" [arg-type] +narrowing_typeis.py:157: error: Argument 1 to "takes_callable_str_proto" has incompatible type "Callable[[object], TypeIs[int]]"; expected "CallableStrProto" [arg-type] +narrowing_typeis.py:174: error: Argument 1 to "takes_typeguard" has incompatible type "Callable[[object], TypeIs[int]]"; expected "Callable[[object], TypeGuard[int]]" [arg-type] +narrowing_typeis.py:175: error: Argument 1 to "takes_typeis" has incompatible type "Callable[[object], TypeGuard[int]]"; expected "Callable[[object], TypeIs[int]]" [arg-type] +narrowing_typeis.py:196: error: Argument 1 to "takes_int_typeis" has incompatible type "Callable[[object], TypeIs[bool]]"; expected "Callable[[object], TypeIs[int]]" [arg-type] +narrowing_typeis.py:200: error: Narrowed type "str" is not a subtype of input type "int" [narrowed-type-not-subtype] +narrowing_typeis.py:204: error: Narrowed type "list[int]" is not a subtype of input type "list[object]" [narrowed-type-not-subtype] +""" diff --git a/conformance/results/zuban/overloads_basic.toml b/conformance/results/zuban/overloads_basic.toml new file mode 100644 index 000000000..6c3455642 --- /dev/null +++ b/conformance/results/zuban/overloads_basic.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +overloads_basic.py:39: error: No overload variant of "__getitem__" of "Bytes" matches argument type "str" [call-overload] +overloads_basic.py:39: note: Possible overload variants: +overloads_basic.py:39: note: def __getitem__(self, int, /) -> int +overloads_basic.py:39: note: def __getitem__(self, slice[Any, Any, Any], /) -> bytes +""" diff --git a/conformance/results/zuban/overloads_consistency.toml b/conformance/results/zuban/overloads_consistency.toml new file mode 100644 index 000000000..146fdfb76 --- /dev/null +++ b/conformance/results/zuban/overloads_consistency.toml @@ -0,0 +1,7 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +overloads_consistency.py:28: error: Overloaded function implementation cannot produce return type of signature 2 [misc] +overloads_consistency.py:44: error: Overloaded function implementation does not accept all possible parameters of signature 2 [misc] +""" diff --git a/conformance/results/zuban/overloads_definitions.toml b/conformance/results/zuban/overloads_definitions.toml new file mode 100644 index 000000000..b9cab56f9 --- /dev/null +++ b/conformance/results/zuban/overloads_definitions.toml @@ -0,0 +1,18 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +overloads_definitions.py:15: error: Single overload definition, multiple required [misc] +overloads_definitions.py:28: error: An overloaded function outside a stub file must have an implementation [no-overload-impl] +overloads_definitions.py:59: error: An overloaded function outside a stub file must have an implementation [no-overload-impl] +overloads_definitions.py:71: error: Overload does not consistently use the "@staticmethod" decorator on all function signatures. [misc] +overloads_definitions.py:84: error: Overload does not consistently use the "@classmethod" decorator on all function signatures. [misc] +overloads_definitions.py:93: error: Overloaded function implementation does not accept all possible parameters of signature 2 [misc] +overloads_definitions.py:123: error: @final should be applied only to overload implementation [misc] +overloads_definitions.py:138: error: @final should be applied only to overload implementation [misc] +overloads_definitions.py:143: error: @final should be applied only to overload implementation [misc] +overloads_definitions.py:180: error: Cannot override final attribute "final_method" (previously declared in base class "Base") [misc] +overloads_definitions.py:195: error: Method "bad_override" is marked as an override, but no base method was found with this name [misc] +overloads_definitions.py:227: error: @override should be applied only to overload implementation [misc] +overloads_definitions.py:231: error: @override should be applied only to overload implementation [misc] +""" diff --git a/conformance/results/zuban/overloads_definitions_stub.toml b/conformance/results/zuban/overloads_definitions_stub.toml new file mode 100644 index 000000000..0dbbf6319 --- /dev/null +++ b/conformance/results/zuban/overloads_definitions_stub.toml @@ -0,0 +1,13 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +overloads_definitions_stub.pyi:13: error: Single overload definition, multiple required [misc] +overloads_definitions_stub.pyi:32: error: Overload does not consistently use the "@staticmethod" decorator on all function signatures. [misc] +overloads_definitions_stub.pyi:39: error: Overload does not consistently use the "@classmethod" decorator on all function signatures. [misc] +overloads_definitions_stub.pyi:72: error: In a stub file @final must be applied only to the first overload [misc] +overloads_definitions_stub.pyi:85: error: In a stub file @final must be applied only to the first overload [misc] +overloads_definitions_stub.pyi:107: error: Cannot override final attribute "final_method" (previously declared in base class "Base") [misc] +overloads_definitions_stub.pyi:120: error: Method "bad_override" is marked as an override, but no base method was found with this name [misc] +overloads_definitions_stub.pyi:146: error: In a stub file @override must be applied only to the first overload [misc] +""" diff --git a/conformance/results/zuban/overloads_evaluation.toml b/conformance/results/zuban/overloads_evaluation.toml new file mode 100644 index 000000000..0e3b48cf8 --- /dev/null +++ b/conformance/results/zuban/overloads_evaluation.toml @@ -0,0 +1,19 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +overloads_evaluation.py:38: error: All overload variants of "example1_1" require at least one argument [call-overload] +overloads_evaluation.py:38: note: Possible overload variants: +overloads_evaluation.py:38: note: def example1_1(x: int, y: str) -> int +overloads_evaluation.py:38: note: def example1_1(x: str) -> str +overloads_evaluation.py:46: error: No overload variant of "example1_1" matches argument types "int", "int" [call-overload] +overloads_evaluation.py:46: note: Possible overload variants: +overloads_evaluation.py:46: note: def example1_1(x: int, y: str) -> int +overloads_evaluation.py:46: note: def example1_1(x: str) -> str +overloads_evaluation.py:51: error: No overload variant of "example1_1" matches argument type "int" [call-overload] +overloads_evaluation.py:51: note: Possible overload variants: +overloads_evaluation.py:51: note: def example1_1(x: int, y: str) -> int +overloads_evaluation.py:51: note: def example1_1(x: str) -> str +overloads_evaluation.py:116: error: Argument 1 to "example2" has incompatible type "int | str"; expected "int" [arg-type] +overloads_evaluation.py:116: error: Argument 2 to "example2" has incompatible type "int | str"; expected "str" [arg-type] +""" diff --git a/conformance/results/zuban/protocols_class_objects.toml b/conformance/results/zuban/protocols_class_objects.toml new file mode 100644 index 000000000..04681647c --- /dev/null +++ b/conformance/results/zuban/protocols_class_objects.toml @@ -0,0 +1,25 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +protocols_class_objects.py:29: error: Only concrete class can be given where "type[Proto]" is expected [misc] +protocols_class_objects.py:34: error: Can only assign concrete classes to a variable of type "type[Proto]" [misc] +protocols_class_objects.py:58: error: Incompatible types in assignment (expression has type "type[ConcreteA]", variable has type "ProtoA1") [assignment] +protocols_class_objects.py:58: note: Following member(s) of "ConcreteA" have conflicts: +protocols_class_objects.py:58: note: Expected: +protocols_class_objects.py:58: note: def method1(x: int) -> int +protocols_class_objects.py:58: note: Got: +protocols_class_objects.py:58: note: def method1(self: ConcreteA, x: int) -> int +protocols_class_objects.py:74: error: Incompatible types in assignment (expression has type "type[ConcreteB]", variable has type "ProtoB1") [assignment] +protocols_class_objects.py:74: note: Following member(s) of "ConcreteB" have conflicts: +protocols_class_objects.py:74: note: prop1: expected "int", got "property" +protocols_class_objects.py:104: error: Incompatible types in assignment (expression has type "type[ConcreteC1]", variable has type "ProtoC1") [assignment] +protocols_class_objects.py:104: note: ClassVar protocol member ProtoC1.attr1 can never be matched by a class object +protocols_class_objects.py:106: error: Incompatible types in assignment (expression has type "type[ConcreteC2]", variable has type "ProtoC1") [assignment] +protocols_class_objects.py:106: note: Protocol member ProtoC1.attr1 expected class variable, got instance variable +protocols_class_objects.py:106: note: Only class variables allowed for class object access on protocols, attr1 is an instance variable of "ConcreteC2" +protocols_class_objects.py:107: error: Incompatible types in assignment (expression has type "type[ConcreteC2]", variable has type "ProtoC2") [assignment] +protocols_class_objects.py:107: note: Only class variables allowed for class object access on protocols, attr1 is an instance variable of "ConcreteC2" +protocols_class_objects.py:108: error: Incompatible types in assignment (expression has type "type[ConcreteC3]", variable has type "ProtoC1") [assignment] +protocols_class_objects.py:108: note: ClassVar protocol member ProtoC1.attr1 can never be matched by a class object +""" diff --git a/conformance/results/zuban/protocols_definition.toml b/conformance/results/zuban/protocols_definition.toml new file mode 100644 index 000000000..26d390b47 --- /dev/null +++ b/conformance/results/zuban/protocols_definition.toml @@ -0,0 +1,73 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +protocols_definition.py:30: error: List item 0 has incompatible type "int"; expected "SupportsClose" [list-item] +protocols_definition.py:67: error: Protocol members cannot be defined via assignment to self [misc] +protocols_definition.py:67: error: "Template" has no attribute "temp" [attr-defined] +protocols_definition.py:114: error: Incompatible types in assignment (expression has type "Concrete2_Bad1", variable has type "Template2") [assignment] +protocols_definition.py:115: error: Incompatible types in assignment (expression has type "Concrete2_Bad2", variable has type "Template2") [assignment] +protocols_definition.py:115: note: Following member(s) of "Concrete2_Bad2" have conflicts: +protocols_definition.py:115: note: val1: expected "Sequence[int]", got "Sequence[float]" +protocols_definition.py:115: note: Protocol member Template2.val1 expected class variable, got instance variable +protocols_definition.py:116: error: Incompatible types in assignment (expression has type "Concrete2_Bad3", variable has type "Template2") [assignment] +protocols_definition.py:116: note: Following member(s) of "Concrete2_Bad3" have conflicts: +protocols_definition.py:116: note: val1: expected "Sequence[int]", got "list[int]" +protocols_definition.py:116: note: Protocol member Template2.val1 expected class variable, got instance variable +protocols_definition.py:117: error: Incompatible types in assignment (expression has type "Concrete2_Bad4", variable has type "Template2") [assignment] +protocols_definition.py:117: note: Protocol member Template2.val1 expected class variable, got instance variable +protocols_definition.py:156: error: Incompatible types in assignment (expression has type "Concrete3_Bad1", variable has type "Template3") [assignment] +protocols_definition.py:157: error: Incompatible types in assignment (expression has type "Concrete3_Bad2", variable has type "Template3") [assignment] +protocols_definition.py:157: note: Protocol member Template3.val1 expected instance variable, got class variable +protocols_definition.py:158: error: Incompatible types in assignment (expression has type "Concrete3_Bad3", variable has type "Template3") [assignment] +protocols_definition.py:158: note: Protocol member Template3.val1 expected settable variable, got read-only attribute +protocols_definition.py:159: error: Incompatible types in assignment (expression has type "Concrete3_Bad4", variable has type "Template3") [assignment] +protocols_definition.py:159: note: Following member(s) of "Concrete3_Bad4" have conflicts: +protocols_definition.py:159: note: val1: expected "Sequence[int]", got "Sequence[float]" +protocols_definition.py:160: error: Incompatible types in assignment (expression has type "Concrete3_Bad5", variable has type "Template3") [assignment] +protocols_definition.py:160: note: Following member(s) of "Concrete3_Bad5" have conflicts: +protocols_definition.py:160: note: val1: expected "Sequence[int]", got "list[int]" +protocols_definition.py:218: error: Incompatible types in assignment (expression has type "Concrete4_Bad1", variable has type "Template4") [assignment] +protocols_definition.py:218: note: Following member(s) of "Concrete4_Bad1" have conflicts: +protocols_definition.py:218: note: val1: expected "Sequence[float]", got "Callable[[], Sequence[int]]" +protocols_definition.py:219: error: Incompatible types in assignment (expression has type "Concrete4_Bad2", variable has type "Template4") [assignment] +protocols_definition.py:285: error: Incompatible types in assignment (expression has type "Concrete5_Bad1", variable has type "Template5") [assignment] +protocols_definition.py:285: note: Following member(s) of "Concrete5_Bad1" have conflicts: +protocols_definition.py:285: note: Expected: +protocols_definition.py:285: note: def method1(self, a: int, b: int) -> float +protocols_definition.py:285: note: Got: +protocols_definition.py:285: note: def method1(self, a: Any, c: Any) -> int +protocols_definition.py:286: error: Incompatible types in assignment (expression has type "Concrete5_Bad2", variable has type "Template5") [assignment] +protocols_definition.py:286: note: Following member(s) of "Concrete5_Bad2" have conflicts: +protocols_definition.py:286: note: Expected: +protocols_definition.py:286: note: def method1(self, a: int, b: int) -> float +protocols_definition.py:286: note: Got: +protocols_definition.py:286: note: def method1(self, a: int, c: int) -> int +protocols_definition.py:287: error: Incompatible types in assignment (expression has type "Concrete5_Bad3", variable has type "Template5") [assignment] +protocols_definition.py:287: note: Following member(s) of "Concrete5_Bad3" have conflicts: +protocols_definition.py:287: note: Expected: +protocols_definition.py:287: note: def method1(self, a: int, b: int) -> float +protocols_definition.py:287: note: Got: +protocols_definition.py:287: note: def method1(self, *, a: int, b: int) -> float +protocols_definition.py:288: error: Incompatible types in assignment (expression has type "Concrete5_Bad4", variable has type "Template5") [assignment] +protocols_definition.py:288: note: Following member(s) of "Concrete5_Bad4" have conflicts: +protocols_definition.py:288: note: Expected: +protocols_definition.py:288: note: def method1(self, a: int, b: int) -> float +protocols_definition.py:288: note: Got: +protocols_definition.py:288: note: def method1(self, int, int, /) -> float +protocols_definition.py:289: error: Incompatible types in assignment (expression has type "Concrete5_Bad5", variable has type "Template5") [assignment] +protocols_definition.py:289: note: Following member(s) of "Concrete5_Bad5" have conflicts: +protocols_definition.py:289: note: Expected: +protocols_definition.py:289: note: def method1(self: Template5, a: int, b: int) -> float +protocols_definition.py:289: note: Got: +protocols_definition.py:289: note: def method1(self: Any, a: int, b: int) -> float +protocols_definition.py:339: error: Incompatible types in assignment (expression has type "Concrete6_Bad1", variable has type "Template6") [assignment] +protocols_definition.py:339: note: Protocol member Template6.val1 expected settable variable, got read-only attribute +protocols_definition.py:340: error: Incompatible types in assignment (expression has type "Concrete6_Bad2", variable has type "Template6") [assignment] +protocols_definition.py:340: note: Protocol member Template6.val1 expected settable variable, got read-only attribute +protocols_definition.py:341: error: Incompatible types in assignment (expression has type "Concrete6_Bad3", variable has type "Template6") [assignment] +protocols_definition.py:341: note: Protocol member Template6.val1 expected settable variable, got read-only attribute +protocols_definition.py:369: error: Incompatible types in assignment (expression has type "Concrete7_Bad1", variable has type "Template7") [assignment] +protocols_definition.py:369: note: Protocol member Template7.val1 expected class variable, got instance variable +protocols_definition.py:370: error: Incompatible types in assignment (expression has type "Concrete7_Bad2", variable has type "Template7") [assignment] +""" diff --git a/conformance/results/zuban/protocols_explicit.toml b/conformance/results/zuban/protocols_explicit.toml new file mode 100644 index 000000000..259623c10 --- /dev/null +++ b/conformance/results/zuban/protocols_explicit.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +protocols_explicit.py:27: error: Call to abstract method "draw" of "PColor" with trivial body via super() is unsafe [safe-super] +protocols_explicit.py:56: error: Incompatible types in assignment (expression has type "tuple[int, int, str]", variable has type "tuple[int, int, int]") [assignment] +protocols_explicit.py:60: error: Cannot instantiate abstract class "Point" with abstract attributes "intensity" and "transparency" [abstract] +protocols_explicit.py:89: error: Cannot instantiate abstract class "Concrete1" with abstract attribute "cm1" [abstract] +protocols_explicit.py:134: error: Cannot instantiate abstract class "Concrete5" with abstract attribute "method1" [abstract] +protocols_explicit.py:164: error: Cannot instantiate abstract class "Concrete7A" with abstract attribute "method1" [abstract] +""" diff --git a/conformance/results/zuban/protocols_generic.toml b/conformance/results/zuban/protocols_generic.toml new file mode 100644 index 000000000..570482769 --- /dev/null +++ b/conformance/results/zuban/protocols_generic.toml @@ -0,0 +1,35 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +protocols_generic.py:40: error: Incompatible types in assignment (expression has type "Concrete1", variable has type "Proto1[int, str]") [assignment] +protocols_generic.py:40: note: Following member(s) of "Concrete1" have conflicts: +protocols_generic.py:40: note: Expected: +protocols_generic.py:40: note: def method1(self, x: int) -> int +protocols_generic.py:40: note: Got: +protocols_generic.py:40: note: def method1(self, x: str) -> str +protocols_generic.py:40: note: Expected: +protocols_generic.py:40: note: def __iter__(self) -> Iterator[str] +protocols_generic.py:40: note: Got: +protocols_generic.py:40: note: def __iter__(self) -> Iterator[int] +protocols_generic.py:44: error: Only single Generic[...] or Protocol[...] can be in bases [misc] +protocols_generic.py:56: error: Incompatible types in assignment (expression has type "Box[float]", variable has type "Box[int]") [assignment] +protocols_generic.py:66: error: Incompatible types in assignment (expression has type "Sender[int]", variable has type "Sender[float]") [assignment] +protocols_generic.py:74: error: Incompatible types in assignment (expression has type "AttrProto[int]", variable has type "AttrProto[float]") [assignment] +protocols_generic.py:75: error: Incompatible types in assignment (expression has type "AttrProto[float]", variable has type "AttrProto[int]") [assignment] +protocols_generic.py:133: error: Incompatible types in assignment (expression has type "InvalidParentProperty", variable has type "HasParentProperty") [assignment] +protocols_generic.py:133: note: Following member(s) of "InvalidParentProperty" have conflicts: +protocols_generic.py:133: note: parent: expected "InvalidParentProperty", got "HasParentProperty" +protocols_generic.py:153: error: Incompatible types in assignment (expression has type "InvalidHasMethod", variable has type "HasMethod") [assignment] +protocols_generic.py:153: note: Following member(s) of "InvalidHasMethod" have conflicts: +protocols_generic.py:153: note: Expected: +protocols_generic.py:153: note: def [T] m(self, item: T, callback: Callable[[T], str]) -> str +protocols_generic.py:153: note: Got: +protocols_generic.py:153: note: def m(self, item: int, callback: Callable[[int], str]) -> str +protocols_generic.py:185: error: Incompatible types in assignment (expression has type "InvalidGreaterThan", variable has type "HasGreaterThan") [assignment] +protocols_generic.py:185: note: Following member(s) of "InvalidGreaterThan" have conflicts: +protocols_generic.py:185: note: Expected: +protocols_generic.py:185: note: def [Self: InvalidGreaterThan] __gt__(self, other: Self) -> bool +protocols_generic.py:185: note: Got: +protocols_generic.py:185: note: def __gt__(self, other: int) -> bool +""" diff --git a/conformance/results/zuban/protocols_merging.toml b/conformance/results/zuban/protocols_merging.toml new file mode 100644 index 000000000..96fe626e1 --- /dev/null +++ b/conformance/results/zuban/protocols_merging.toml @@ -0,0 +1,15 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +protocols_merging.py:52: error: Incompatible types in assignment (expression has type "SCConcrete2", variable has type "SizedAndClosable1") [assignment] +protocols_merging.py:52: note: "SCConcrete2" is missing following "SizedAndClosable1" protocol member: +protocols_merging.py:52: note: __len__ +protocols_merging.py:53: error: Incompatible types in assignment (expression has type "SCConcrete2", variable has type "SizedAndClosable2") [assignment] +protocols_merging.py:53: note: "SCConcrete2" is missing following "SizedAndClosable2" protocol member: +protocols_merging.py:53: note: __len__ +protocols_merging.py:54: error: Incompatible types in assignment (expression has type "SCConcrete2", variable has type "SizedAndClosable3") [assignment] +protocols_merging.py:67: error: All bases of a protocol must be protocols [misc] +protocols_merging.py:82: error: Cannot instantiate abstract class "SizedAndClosable4" with abstract attribute "close" [abstract] +protocols_merging.py:83: error: Incompatible types in assignment (expression has type "SCConcrete1", variable has type "SizedAndClosable4") [assignment] +""" diff --git a/conformance/results/zuban/protocols_modules.toml b/conformance/results/zuban/protocols_modules.toml new file mode 100644 index 000000000..c478b180b --- /dev/null +++ b/conformance/results/zuban/protocols_modules.toml @@ -0,0 +1,15 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +protocols_modules.py:26: error: Incompatible types in assignment (expression has type "ModuleType", variable has type "Options2") [assignment] +protocols_modules.py:26: note: Following member(s) of Module "tests._protocols_modules1" have conflicts: +protocols_modules.py:26: note: timeout: expected "str", got "int" +protocols_modules.py:48: error: Incompatible types in assignment (expression has type "ModuleType", variable has type "Reporter2") [assignment] +protocols_modules.py:48: note: Following member(s) of Module "tests._protocols_modules2" have conflicts: +protocols_modules.py:48: note: Expected: +protocols_modules.py:48: note: def on_error(x: int) -> int +protocols_modules.py:48: note: Got: +protocols_modules.py:48: note: def on_error(x: int) -> None +protocols_modules.py:49: error: Incompatible types in assignment (expression has type "ModuleType", variable has type "Reporter3") [assignment] +""" diff --git a/conformance/results/zuban/protocols_recursive.toml b/conformance/results/zuban/protocols_recursive.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/zuban/protocols_recursive.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/zuban/protocols_runtime_checkable.toml b/conformance/results/zuban/protocols_runtime_checkable.toml new file mode 100644 index 000000000..e1daddfe8 --- /dev/null +++ b/conformance/results/zuban/protocols_runtime_checkable.toml @@ -0,0 +1,15 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +protocols_runtime_checkable.py:23: error: Only @runtime_checkable protocols can be used with instance and class checks [misc] +protocols_runtime_checkable.py:55: error: Only protocols that don't have non-method members can be used with issubclass() [misc] +protocols_runtime_checkable.py:55: note: Protocol "DataProtocol" has non-method member(s): name +protocols_runtime_checkable.py:61: error: Only protocols that don't have non-method members can be used with issubclass() [misc] +protocols_runtime_checkable.py:61: note: Protocol "DataProtocol" has non-method member(s): name +protocols_runtime_checkable.py:88: error: Subclass of "Concrete3A" and "Proto3" cannot exist: would have incompatible method signatures [unreachable] +protocols_runtime_checkable.py:91: error: Subclass of "Concrete3B" and "Proto3" cannot exist: would have incompatible method signatures [unreachable] +protocols_runtime_checkable.py:91: error: Subclass of "Concrete3B" and "NonDataProtocol" cannot exist: would have incompatible method signatures [unreachable] +protocols_runtime_checkable.py:94: error: Subclass of "Concrete3A" and "Proto3" cannot exist: would have incompatible method signatures [unreachable] +protocols_runtime_checkable.py:94: error: Subclass of "Concrete3A" and "NonDataProtocol" cannot exist: would have incompatible method signatures [unreachable] +""" diff --git a/conformance/results/zuban/protocols_self.toml b/conformance/results/zuban/protocols_self.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/zuban/protocols_self.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/zuban/protocols_subtyping.toml b/conformance/results/zuban/protocols_subtyping.toml new file mode 100644 index 000000000..159857a45 --- /dev/null +++ b/conformance/results/zuban/protocols_subtyping.toml @@ -0,0 +1,34 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +protocols_subtyping.py:16: error: Cannot instantiate protocol class "Proto1" [misc] +protocols_subtyping.py:38: error: Incompatible types in assignment (expression has type "Proto2", variable has type "Concrete2") [assignment] +protocols_subtyping.py:55: error: Incompatible types in assignment (expression has type "Proto2", variable has type "Proto3") [assignment] +protocols_subtyping.py:55: note: "Proto2" is missing following "Proto3" protocol member: +protocols_subtyping.py:55: note: method2 +protocols_subtyping.py:79: error: Incompatible types in assignment (expression has type "Proto5[int]", variable has type "Proto4[int, float]") [assignment] +protocols_subtyping.py:79: note: Following member(s) of "Proto5[int]" have conflicts: +protocols_subtyping.py:79: note: Expected: +protocols_subtyping.py:79: note: def method1(self, a: int, b: float) -> tuple[int, float] +protocols_subtyping.py:79: note: Got: +protocols_subtyping.py:79: note: def method1(self, a: int, b: int) -> tuple[int, int] +protocols_subtyping.py:80: error: Incompatible types in assignment (expression has type "Proto4[int, int]", variable has type "Proto5[float]") [assignment] +protocols_subtyping.py:80: note: Following member(s) of "Proto4[int, int]" have conflicts: +protocols_subtyping.py:80: note: Expected: +protocols_subtyping.py:80: note: def method1(self, a: float, b: float) -> tuple[float, float] +protocols_subtyping.py:80: note: Got: +protocols_subtyping.py:80: note: def method1(self, a: int, b: int) -> tuple[int, int] +protocols_subtyping.py:102: error: Incompatible types in assignment (expression has type "Proto6[float, float]", variable has type "Proto7[int, float]") [assignment] +protocols_subtyping.py:102: note: Following member(s) of "Proto6[float, float]" have conflicts: +protocols_subtyping.py:102: note: Expected: +protocols_subtyping.py:102: note: def method1(self, a: float) -> Sequence[int] +protocols_subtyping.py:102: note: Got: +protocols_subtyping.py:102: note: def method1(self, a: float) -> Sequence[float] +protocols_subtyping.py:103: error: Incompatible types in assignment (expression has type "Proto6[float, float]", variable has type "Proto7[float, object]") [assignment] +protocols_subtyping.py:103: note: Following member(s) of "Proto6[float, float]" have conflicts: +protocols_subtyping.py:103: note: Expected: +protocols_subtyping.py:103: note: def method1(self, a: object) -> Sequence[float] +protocols_subtyping.py:103: note: Got: +protocols_subtyping.py:103: note: def method1(self, a: float) -> Sequence[float] +""" diff --git a/conformance/results/zuban/protocols_variance.toml b/conformance/results/zuban/protocols_variance.toml new file mode 100644 index 000000000..187f0d716 --- /dev/null +++ b/conformance/results/zuban/protocols_variance.toml @@ -0,0 +1,14 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +protocols_variance.py:22: error: Invariant type variable "T1" used in protocol where Covariant one is expected [misc] +protocols_variance.py:41: error: Invariant type variable "T3" used in protocol where Contravariant one is expected [misc] +protocols_variance.py:57: error: Invariant type variable "T1" used in protocol where Contravariant one is expected [misc] +protocols_variance.py:62: error: Covariant type variable "T1_co" used in protocol where Contravariant one is expected [misc] +protocols_variance.py:63: error: Cannot use a covariant type variable as a parameter [type-var] +protocols_variance.py:67: error: Invariant type variable "T1" used in protocol where Covariant one is expected [misc] +protocols_variance.py:72: error: Contravariant type variable "T1_contra" used in protocol where Covariant one is expected [misc] +protocols_variance.py:73: error: Cannot use a contravariant type variable as return type [type-var] +protocols_variance.py:105: error: Invariant type variable "T1" used in protocol where Covariant one is expected [misc] +""" diff --git a/conformance/results/zuban/qualifiers_annotated.toml b/conformance/results/zuban/qualifiers_annotated.toml new file mode 100644 index 000000000..03e563a7a --- /dev/null +++ b/conformance/results/zuban/qualifiers_annotated.toml @@ -0,0 +1,27 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +qualifiers_annotated.py:38: error: Bracketed expression "[...]" is not valid as a type [valid-type] +qualifiers_annotated.py:38: note: Did you mean "List[...]"? +qualifiers_annotated.py:39: error: Syntax error in type annotation [valid-type] +qualifiers_annotated.py:39: note: Suggestion: Is there a spurious trailing comma? +qualifiers_annotated.py:40: error: Invalid type comment or annotation [valid-type] +qualifiers_annotated.py:41: error: Invalid type comment or annotation [valid-type] +qualifiers_annotated.py:42: error: Invalid type comment or annotation [valid-type] +qualifiers_annotated.py:43: error: Invalid type comment or annotation [valid-type] +qualifiers_annotated.py:44: error: Invalid type comment or annotation [valid-type] +qualifiers_annotated.py:45: error: Name "var1" is not defined [name-defined] +qualifiers_annotated.py:46: error: Invalid type comment or annotation [valid-type] +qualifiers_annotated.py:47: error: Invalid type: try using Literal[1] instead? [valid-type] +qualifiers_annotated.py:48: error: Invalid type comment or annotation [valid-type] +qualifiers_annotated.py:49: error: Invalid type comment or annotation [valid-type] +qualifiers_annotated.py:59: error: Annotated[...] must have exactly one type argument and at least one annotation [valid-type] +qualifiers_annotated.py:71: error: Incompatible types in assignment (expression has type "_SpecialForm", variable has type "type[Any]") [assignment] +qualifiers_annotated.py:72: error: Incompatible types in assignment (expression has type "_SpecialForm", variable has type "type[Any]") [assignment] +qualifiers_annotated.py:79: error: Argument 1 to "func4" has incompatible type "_SpecialForm"; expected "type[Never]" [arg-type] +qualifiers_annotated.py:80: error: Argument 1 to "func4" has incompatible type "_SpecialForm"; expected "type[Never]" [arg-type] +qualifiers_annotated.py:86: error: "_SpecialForm" not callable [operator] +qualifiers_annotated.py:87: error: "_SpecialForm" not callable [operator] +qualifiers_annotated.py:88: error: "" not callable [operator] +""" diff --git a/conformance/results/zuban/qualifiers_final_annotation.toml b/conformance/results/zuban/qualifiers_final_annotation.toml new file mode 100644 index 000000000..1101ba386 --- /dev/null +++ b/conformance/results/zuban/qualifiers_final_annotation.toml @@ -0,0 +1,35 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +qualifiers_final_annotation.py:16: error: Type in Final[...] can only be omitted if there is an initializer [misc] +qualifiers_final_annotation.py:18: error: Final[...] takes at most one type argument [misc] +qualifiers_final_annotation.py:34: error: Type in Final[...] can only be omitted if there is an initializer [misc] +qualifiers_final_annotation.py:38: error: Final name must be initialized with a value [misc] +qualifiers_final_annotation.py:54: error: Cannot assign to final attribute "ID5" [misc] +qualifiers_final_annotation.py:62: error: Can only declare a final attribute in class body or __init__ [misc] +qualifiers_final_annotation.py:63: error: Can only declare a final attribute in class body or __init__ [misc] +qualifiers_final_annotation.py:65: error: Cannot assign to final attribute "ID7" [misc] +qualifiers_final_annotation.py:67: error: Cannot assign to final attribute "ID7" [misc] +qualifiers_final_annotation.py:71: error: Cannot assign to final name "RATE" [misc] +qualifiers_final_annotation.py:81: error: Cannot assign to final attribute "DEFAULT_ID" [misc] +qualifiers_final_annotation.py:94: error: Cannot assign to final name "BORDER_WIDTH" [misc] +qualifiers_final_annotation.py:107: error: Final can be only used as an outermost qualifier in a variable annotation [misc] +qualifiers_final_annotation.py:108: error: Invalid Type: ClassVar nested inside other type [misc] +qualifiers_final_annotation.py:118: error: Final can be only used as an outermost qualifier in a variable annotation [misc] +qualifiers_final_annotation.py:121: error: Final can be only used as an outermost qualifier in a variable annotation [misc] +qualifiers_final_annotation.py:131: error: Final can be only used as an outermost qualifier in a variable annotation [misc] +qualifiers_final_annotation.py:136: error: Final can be only used as an outermost qualifier in a variable annotation [misc] +qualifiers_final_annotation.py:148: error: Unexpected keyword argument "a" for "N" [call-arg] +qualifiers_final_annotation.py:149: error: Argument "x" to "N" has incompatible type "str"; expected "int" [arg-type] +qualifiers_final_annotation.py:149: error: Argument "y" to "N" has incompatible type "str"; expected "int" [arg-type] +qualifiers_final_annotation.py:155: error: Cannot assign to final name "ID1" [misc] +qualifiers_final_annotation.py:159: error: Cannot assign to final name "x" [misc] +qualifiers_final_annotation.py:161: error: Cannot assign to final name "x" [misc] +qualifiers_final_annotation.py:163: error: Cannot assign to final name "x" [misc] +qualifiers_final_annotation.py:166: error: Cannot assign to final name "x" [misc] +qualifiers_final_annotation.py:166: error: Incompatible types in assignment (expression has type "TextIOWrapper[_WrappedBuffer]", variable has type "int") [assignment] +qualifiers_final_annotation.py:169: error: Cannot assign to final name "x" [misc] +qualifiers_final_annotation.py:180: error: Cannot assign to final name "TEN" [misc] +qualifiers_final_annotation.py:184: error: Cannot assign to final name "PI" [misc] +""" diff --git a/conformance/results/zuban/qualifiers_final_decorator.toml b/conformance/results/zuban/qualifiers_final_decorator.toml new file mode 100644 index 000000000..bbedc5e60 --- /dev/null +++ b/conformance/results/zuban/qualifiers_final_decorator.toml @@ -0,0 +1,20 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +qualifiers_final_decorator.py:21: error: Cannot inherit from final class "Base1" [misc] +qualifiers_final_decorator.py:56: error: Cannot override final attribute "method1" (previously declared in base class "Base2") [misc] +qualifiers_final_decorator.py:59: error: Cannot override final attribute "method2" (previously declared in base class "Base2") [misc] +qualifiers_final_decorator.py:63: error: Cannot override final attribute "method3" (previously declared in base class "Base2") [misc] +qualifiers_final_decorator.py:67: error: Cannot override final attribute "method4" (previously declared in base class "Base2") [misc] +qualifiers_final_decorator.py:80: error: Cannot override final attribute "method" (previously declared in base class "Base3") [misc] +qualifiers_final_decorator.py:85: error: @final should be applied only to overload implementation [misc] +qualifiers_final_decorator.py:94: error: Cannot override final attribute "method" (previously declared in base class "Base4") [misc] +qualifiers_final_decorator.py:118: error: Cannot override final attribute "method" (previously declared in base class "Base5_2") [misc] +qualifiers_final_decorator.py:118: error: Signature of "method" incompatible with supertype "Base5_2" [override] +qualifiers_final_decorator.py:118: note: Superclass: +qualifiers_final_decorator.py:118: note: def method(self, v: int) -> None +qualifiers_final_decorator.py:118: note: Subclass: +qualifiers_final_decorator.py:118: note: def method(self) -> None +qualifiers_final_decorator.py:125: error: @final cannot be used with non-method functions [misc] +""" diff --git a/conformance/results/zuban/specialtypes_any.toml b/conformance/results/zuban/specialtypes_any.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/zuban/specialtypes_any.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/zuban/specialtypes_never.toml b/conformance/results/zuban/specialtypes_never.toml new file mode 100644 index 000000000..d65bc2c97 --- /dev/null +++ b/conformance/results/zuban/specialtypes_never.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +specialtypes_never.py:19: error: Implicit return in function which does not return [misc] +specialtypes_never.py:85: error: Incompatible types in assignment (expression has type "list[Never]", variable has type "list[int]") [assignment] +specialtypes_never.py:85: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance +specialtypes_never.py:85: note: Consider using "Sequence" instead, which is covariant +specialtypes_never.py:104: error: Incompatible return value type (got "ClassC[Never]", expected "ClassC[U]") [return-value] +""" diff --git a/conformance/results/zuban/specialtypes_none.toml b/conformance/results/zuban/specialtypes_none.toml new file mode 100644 index 000000000..c7f0e4b42 --- /dev/null +++ b/conformance/results/zuban/specialtypes_none.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +specialtypes_none.py:21: error: Argument 1 to "func1" has incompatible type "type[None]"; expected "None" [arg-type] +specialtypes_none.py:27: error: Incompatible types in assignment (expression has type "None", variable has type "Iterable[Any]") [assignment] +specialtypes_none.py:41: error: Argument 1 to "func2" has incompatible type "None"; expected "type[None]" [arg-type] +""" diff --git a/conformance/results/zuban/specialtypes_promotions.toml b/conformance/results/zuban/specialtypes_promotions.toml new file mode 100644 index 000000000..a261c18d2 --- /dev/null +++ b/conformance/results/zuban/specialtypes_promotions.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +specialtypes_promotions.py:13: error: "float" has no attribute "numerator" [attr-defined] +""" diff --git a/conformance/results/zuban/specialtypes_sentinels.toml b/conformance/results/zuban/specialtypes_sentinels.toml new file mode 100644 index 000000000..fc3d0bca4 --- /dev/null +++ b/conformance/results/zuban/specialtypes_sentinels.toml @@ -0,0 +1,9 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +specialtypes_sentinels.py:14: error: Incompatible default for parameter "x" (default has type "Sentinel('')", parameter has type "int") [assignment] +specialtypes_sentinels.py:36: error: Argument 1 to "func2" has incompatible type "Sentinel('Cls.IN_CLASS')"; expected "int | Sentinel('') | Sentinel('SPECIAL')" [arg-type] +specialtypes_sentinels.py:39: error: Argument 1 to "func3" has incompatible type "Sentinel('')"; expected "int | Sentinel('Cls.IN_CLASS')" [arg-type] +""" diff --git a/conformance/results/zuban/specialtypes_type.toml b/conformance/results/zuban/specialtypes_type.toml new file mode 100644 index 000000000..838e866ac --- /dev/null +++ b/conformance/results/zuban/specialtypes_type.toml @@ -0,0 +1,14 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +specialtypes_type.py:56: error: Argument 1 to "func4" has incompatible type "type[TeamUser]"; expected "type[BasicUser | ProUser]" [arg-type] +specialtypes_type.py:70: error: Argument 1 to "func5" has incompatible type "_SpecialForm"; expected "type[Never]" [arg-type] +specialtypes_type.py:76: error: Invalid type comment or annotation [valid-type] +specialtypes_type.py:117: error: "type[object]" has no attribute "unknown" [attr-defined] +specialtypes_type.py:120: error: "type[object]" has no attribute "unknown" [attr-defined] +specialtypes_type.py:143: error: "_SpecialForm" has no attribute "unknown" [attr-defined] +specialtypes_type.py:144: error: "_SpecialForm" has no attribute "unknown" [attr-defined] +specialtypes_type.py:145: error: "_SpecialForm" has no attribute "unknown" [attr-defined] +specialtypes_type.py:146: error: "_SpecialForm" has no attribute "unknown" [attr-defined] +""" diff --git a/conformance/results/zuban/tuples_type_compat.toml b/conformance/results/zuban/tuples_type_compat.toml new file mode 100644 index 000000000..a32b872d5 --- /dev/null +++ b/conformance/results/zuban/tuples_type_compat.toml @@ -0,0 +1,29 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +tuples_type_compat.py:15: error: Incompatible types in assignment (expression has type "tuple[float, complex]", variable has type "tuple[int, int]") [assignment] +tuples_type_compat.py:29: error: Incompatible types in assignment (expression has type "tuple[int, ...]", variable has type "tuple[int, Unpack[Tuple[int, ...]]]") [assignment] +tuples_type_compat.py:32: error: Incompatible types in assignment (expression has type "tuple[int, Unpack[Tuple[int, ...]]]", variable has type "tuple[int]") [assignment] +tuples_type_compat.py:33: error: Incompatible types in assignment (expression has type "tuple[int, ...]", variable has type "tuple[int]") [assignment] +tuples_type_compat.py:43: error: Incompatible types in assignment (expression has type "tuple[int, ...]", variable has type "tuple[int]") [assignment] +tuples_type_compat.py:62: error: Incompatible types in assignment (expression has type "tuple[int, ...]", variable has type "tuple[int, int]") [assignment] +tuples_type_compat.py:76: error: Expression is of type "tuple[int]", not "tuple[int] | tuple[str, str] | tuple[int, Unpack[Tuple[str, ...]], int]" [misc] +tuples_type_compat.py:81: error: Expression is of type "tuple[str, str] | tuple[int, int]", not "tuple[int] | tuple[str, str] | tuple[int, Unpack[Tuple[str, ...]], int]" [misc] +tuples_type_compat.py:86: error: Expression is of type "tuple[int, str, int]", not "tuple[int] | tuple[str, str] | tuple[int, Unpack[Tuple[str, ...]], int]" [misc] +tuples_type_compat.py:102: error: Expression is of type "tuple[int]", not "tuple[int] | tuple[str, str] | tuple[int, Unpack[Tuple[str, ...]], int]" [misc] +tuples_type_compat.py:107: error: Expression is of type "tuple[str, str] | tuple[int, int]", not "tuple[int] | tuple[str, str] | tuple[int, Unpack[Tuple[str, ...]], int]" [misc] +tuples_type_compat.py:112: error: Expression is of type "tuple[int, str, int]", not "tuple[int] | tuple[str, str] | tuple[int, Unpack[Tuple[str, ...]], int]" [misc] +tuples_type_compat.py:127: error: Expression is of type "tuple[int | str, str]", not "tuple[int | str, int | str]" [misc] +tuples_type_compat.py:129: error: Expression is of type "tuple[int | str, int | str]", not "tuple[int | str, int]" [misc] +tuples_type_compat.py:157: error: Incompatible types in assignment (expression has type "tuple[int, str, str]", variable has type "tuple[int, str]") [assignment] +tuples_type_compat.py:162: error: Incompatible types in assignment (expression has type "tuple[int, int, str]", variable has type "tuple[int, Unpack[Tuple[str, ...]]]") [assignment] +tuples_type_compat.py:163: error: Incompatible types in assignment (expression has type "tuple[int, str, int]", variable has type "tuple[int, Unpack[Tuple[str, ...]]]") [assignment] +tuples_type_compat.py:169: error: Incompatible types in assignment (expression has type "tuple[int, str, str]", variable has type "tuple[int, Unpack[Tuple[str, ...]], int]") [assignment] +tuples_type_compat.py:170: error: Incompatible types in assignment (expression has type "tuple[int, str, str, float]", variable has type "tuple[int, Unpack[Tuple[str, ...]], int]") [assignment] +tuples_type_compat.py:175: error: Incompatible types in assignment (expression has type "tuple[int, str, int]", variable has type "tuple[Unpack[Tuple[str, ...]], int]") [assignment] +tuples_type_compat.py:176: error: Incompatible types in assignment (expression has type "tuple[str, str, float]", variable has type "tuple[Unpack[Tuple[str, ...]], int]") [assignment] +tuples_type_compat.py:181: error: Incompatible types in assignment (expression has type "tuple[str, str]", variable has type "tuple[str, str, int]") [assignment] +tuples_type_compat.py:184: error: Incompatible types in assignment (expression has type "tuple[str, str]", variable has type "tuple[str, str, str, Unpack[Tuple[str, ...]]]") [assignment] +tuples_type_compat.py:188: error: Incompatible types in assignment (expression has type "tuple[str, str]", variable has type "tuple[Unpack[Tuple[str, ...]], str, str, str]") [assignment] +""" diff --git a/conformance/results/zuban/tuples_type_form.toml b/conformance/results/zuban/tuples_type_form.toml new file mode 100644 index 000000000..c363b015b --- /dev/null +++ b/conformance/results/zuban/tuples_type_form.toml @@ -0,0 +1,16 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +tuples_type_form.py:12: error: Incompatible types in assignment (expression has type "tuple[int, int]", variable has type "tuple[int]") [assignment] +tuples_type_form.py:14: error: Incompatible types in assignment (expression has type "tuple[int]", variable has type "tuple[int, int]") [assignment] +tuples_type_form.py:15: error: Incompatible types in assignment (expression has type "tuple[int, str]", variable has type "tuple[int, int]") [assignment] +tuples_type_form.py:25: error: Incompatible types in assignment (expression has type "tuple[int]", variable has type "tuple[()]") [assignment] +tuples_type_form.py:36: error: Incompatible types in assignment (expression has type "tuple[int, int, int, str]", variable has type "tuple[int, ...]") [assignment] +tuples_type_form.py:40: error: Unexpected "..." [valid-type] +tuples_type_form.py:41: error: Unexpected "..." [valid-type] +tuples_type_form.py:42: error: Unexpected "..." [valid-type] +tuples_type_form.py:43: error: Unexpected "..." [valid-type] +tuples_type_form.py:44: error: Unpack is only valid in a variadic position [misc] +tuples_type_form.py:45: error: Unpack is only valid in a variadic position [misc] +""" diff --git a/conformance/results/zuban/tuples_unpacked.toml b/conformance/results/zuban/tuples_unpacked.toml new file mode 100644 index 000000000..f550fe371 --- /dev/null +++ b/conformance/results/zuban/tuples_unpacked.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +tuples_unpacked.py:40: error: More than one variadic Unpack in a type is not allowed [misc] +tuples_unpacked.py:41: error: More than one variadic Unpack in a type is not allowed [misc] +tuples_unpacked.py:51: error: More than one variadic Unpack in a type is not allowed [misc] +tuples_unpacked.py:59: error: More than one variadic Unpack in a type is not allowed [misc] +tuples_unpacked.py:61: error: More than one variadic Unpack in a type is not allowed [misc] +""" diff --git a/conformance/results/zuban/typeddicts_alt_syntax.toml b/conformance/results/zuban/typeddicts_alt_syntax.toml new file mode 100644 index 000000000..a9440e734 --- /dev/null +++ b/conformance/results/zuban/typeddicts_alt_syntax.toml @@ -0,0 +1,10 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_alt_syntax.py:23: error: TypedDict() expects a dictionary literal as the second argument [misc] +typeddicts_alt_syntax.py:27: error: Invalid TypedDict() field name [misc] +typeddicts_alt_syntax.py:31: error: First argument "WrongName" to TypedDict() does not match variable name "BadTypedDict3" [name-match] +typeddicts_alt_syntax.py:35: error: Unexpected keyword argument "other" for "TypedDict" [call-arg] +typeddicts_alt_syntax.py:41: error: TypedDict() expects a dictionary literal as the second argument [misc] +""" diff --git a/conformance/results/zuban/typeddicts_class_syntax.toml b/conformance/results/zuban/typeddicts_class_syntax.toml new file mode 100644 index 000000000..ff31335d0 --- /dev/null +++ b/conformance/results/zuban/typeddicts_class_syntax.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_class_syntax.py:30: error: Invalid statement in TypedDict definition; expected "field_name: field_type" [misc] +typeddicts_class_syntax.py:34: error: Invalid statement in TypedDict definition; expected "field_name: field_type" [misc] +typeddicts_class_syntax.py:39: error: Invalid statement in TypedDict definition; expected "field_name: field_type" [misc] +typeddicts_class_syntax.py:49: error: Unexpected keyword argument "metaclass" for "TypedDict" [call-arg] +typeddicts_class_syntax.py:54: error: Unexpected keyword argument "other" for "TypedDict" [call-arg] +typeddicts_class_syntax.py:69: error: Extra key "z" for TypedDict "ConditionalField" [typeddict-unknown-key] +""" diff --git a/conformance/results/zuban/typeddicts_extra_items.toml b/conformance/results/zuban/typeddicts_extra_items.toml new file mode 100644 index 000000000..82d257007 --- /dev/null +++ b/conformance/results/zuban/typeddicts_extra_items.toml @@ -0,0 +1,33 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_extra_items.py:15: error: Incompatible types (expression has type "int", TypedDict item "year" has type "bool") [typeddict-item] +typeddicts_extra_items.py:22: error: Incompatible types (expression has type "int", TypedDict item "year" has type "bool") [typeddict-item] +typeddicts_extra_items.py:39: error: Incompatible types (expression has type "None", TypedDict item "year" has type "int") [typeddict-item] +typeddicts_extra_items.py:49: error: "closed" argument must be a True or False literal [misc] +typeddicts_extra_items.py:67: error: Cannot set "closed=False" when superclass is "closed=True" [misc] +typeddicts_extra_items.py:73: error: Cannot set "closed=False" when superclass has "extra_items" [misc] +typeddicts_extra_items.py:92: error: TypedDict member "age" is required, but the extra_items of the super class are not [misc] +typeddicts_extra_items.py:95: error: TypedDict member "age" is required, but the extra_items of the super class are not [misc] +typeddicts_extra_items.py:109: error: Cannot set "closed=True" when superclass has non-read-only "extra_items" [misc] +typeddicts_extra_items.py:114: error: "extra_items" value cannot be "Required[...]" [misc] +typeddicts_extra_items.py:117: error: "extra_items" value cannot be "NotRequired[...]" [misc] +typeddicts_extra_items.py:128: error: Key "name" of TypedDict "MovieEI" cannot be deleted [misc] +typeddicts_extra_items.py:143: error: Unexpected keyword argument "year" for "unpack_no_extra" [call-arg] +typeddicts_extra_items.py:174: error: Cannot change "extra_items" type unless it is "ReadOnly" in the superclass [misc] +typeddicts_extra_items.py:185: error: TypedDict member "year" is required, but the extra_items of the super class are not [misc] +typeddicts_extra_items.py:188: error: TypedDict member "year" type "int" is not assignable, but the extra_items of the super class are of type "int | None" [misc] +typeddicts_extra_items.py:197: error: TypedDict member "publisher" type "str" is not assignable, but the extra_items of the super class are of type "int | None" [misc] +typeddicts_extra_items.py:215: error: Incompatible types in assignment (expression has type "MovieDetails", variable has type "MovieBase2") [assignment] +typeddicts_extra_items.py:222: error: Incompatible types in assignment (expression has type "MovieWithYear2", variable has type "MovieBase2") [assignment] +typeddicts_extra_items.py:242: error: Incompatible types in assignment (expression has type "MovieDetails5", variable has type "MovieSI") [assignment] +typeddicts_extra_items.py:256: error: Incompatible types in assignment (expression has type "MovieExtraStr", variable has type "MovieExtraInt") [assignment] +typeddicts_extra_items.py:257: error: Incompatible types in assignment (expression has type "MovieExtraInt", variable has type "MovieExtraStr") [assignment] +typeddicts_extra_items.py:268: error: Incompatible types in assignment (expression has type "MovieNotClosed", variable has type "MovieExtraInt") [assignment] +typeddicts_extra_items.py:278: error: Extra key "year" for TypedDict "NonClosedMovie" [typeddict-unknown-key] +typeddicts_extra_items.py:285: error: Incompatible types (expression has type "str", TypedDict item "language" has type "int") [typeddict-item] +typeddicts_extra_items.py:293: error: Extra key "year" for TypedDict "ClosedMovie" [typeddict-unknown-key] +typeddicts_extra_items.py:303: error: Incompatible types in assignment (expression has type "MovieExtraInt", variable has type "Mapping[str, int]") [assignment] +typeddicts_extra_items.py:352: error: Incompatible types in assignment (expression has type "dict[str, int]", variable has type "IntDict") [assignment] +""" diff --git a/conformance/results/zuban/typeddicts_final.toml b/conformance/results/zuban/typeddicts_final.toml new file mode 100644 index 000000000..cdd4d0cd9 --- /dev/null +++ b/conformance/results/zuban/typeddicts_final.toml @@ -0,0 +1,5 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +""" diff --git a/conformance/results/zuban/typeddicts_inheritance.toml b/conformance/results/zuban/typeddicts_inheritance.toml new file mode 100644 index 000000000..51cd4730d --- /dev/null +++ b/conformance/results/zuban/typeddicts_inheritance.toml @@ -0,0 +1,8 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_inheritance.py:44: error: All bases of a new TypedDict must be TypedDict types [misc] +typeddicts_inheritance.py:55: error: Overwriting TypedDict field "x" while extending [misc] +typeddicts_inheritance.py:65: error: Overwriting TypedDict field "x" while merging [misc] +""" diff --git a/conformance/results/zuban/typeddicts_operations.toml b/conformance/results/zuban/typeddicts_operations.toml new file mode 100644 index 000000000..7a38bd857 --- /dev/null +++ b/conformance/results/zuban/typeddicts_operations.toml @@ -0,0 +1,16 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_operations.py:22: error: Value of "name" has incompatible type "int"; expected "str" [typeddict-item] +typeddicts_operations.py:23: error: Value of "year" has incompatible type "str"; expected "int" [typeddict-item] +typeddicts_operations.py:24: error: TypedDict "Movie" has no key "other" [typeddict-unknown-key] +typeddicts_operations.py:26: error: TypedDict "Movie" has no key "other" [typeddict-item] +typeddicts_operations.py:28: error: Missing key "year" for TypedDict "Movie" [typeddict-item] +typeddicts_operations.py:29: error: Incompatible types (expression has type "float", TypedDict item "year" has type "int") [typeddict-item] +typeddicts_operations.py:32: error: Extra key "other" for TypedDict "Movie" [typeddict-unknown-key] +typeddicts_operations.py:37: error: Expected TypedDict key to be string literal [literal-required] +typeddicts_operations.py:47: error: "Movie" has no attribute "clear" [attr-defined] +typeddicts_operations.py:49: error: Key "name" of TypedDict "Movie" cannot be deleted [misc] +typeddicts_operations.py:62: error: "MovieOptional" has no attribute "clear" [attr-defined] +""" diff --git a/conformance/results/zuban/typeddicts_readonly.toml b/conformance/results/zuban/typeddicts_readonly.toml new file mode 100644 index 000000000..a9a626030 --- /dev/null +++ b/conformance/results/zuban/typeddicts_readonly.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_readonly.py:24: error: ReadOnly TypedDict key "members" TypedDict is mutated [typeddict-readonly-mutated] +typeddicts_readonly.py:36: error: ReadOnly TypedDict key "members" TypedDict is mutated [typeddict-readonly-mutated] +typeddicts_readonly.py:50: error: ReadOnly TypedDict key "title" TypedDict is mutated [typeddict-readonly-mutated] +typeddicts_readonly.py:51: error: ReadOnly TypedDict key "year" TypedDict is mutated [typeddict-readonly-mutated] +typeddicts_readonly.py:60: error: ReadOnly TypedDict key "title" TypedDict is mutated [typeddict-readonly-mutated] +typeddicts_readonly.py:61: error: ReadOnly TypedDict key "year" TypedDict is mutated [typeddict-readonly-mutated] +""" diff --git a/conformance/results/zuban/typeddicts_readonly_consistency.toml b/conformance/results/zuban/typeddicts_readonly_consistency.toml new file mode 100644 index 000000000..183704fe6 --- /dev/null +++ b/conformance/results/zuban/typeddicts_readonly_consistency.toml @@ -0,0 +1,12 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_readonly_consistency.py:37: error: Incompatible types in assignment (expression has type "A1", variable has type "B1") [assignment] +typeddicts_readonly_consistency.py:38: error: Incompatible types in assignment (expression has type "C1", variable has type "B1") [assignment] +typeddicts_readonly_consistency.py:40: error: Incompatible types in assignment (expression has type "A1", variable has type "C1") [assignment] +typeddicts_readonly_consistency.py:81: error: Incompatible types in assignment (expression has type "A2", variable has type "B2") [assignment] +typeddicts_readonly_consistency.py:82: error: Incompatible types in assignment (expression has type "C2", variable has type "B2") [assignment] +typeddicts_readonly_consistency.py:84: error: Incompatible types in assignment (expression has type "A2", variable has type "C2") [assignment] +typeddicts_readonly_consistency.py:85: error: Incompatible types in assignment (expression has type "B2", variable has type "C2") [assignment] +""" diff --git a/conformance/results/zuban/typeddicts_readonly_inheritance.toml b/conformance/results/zuban/typeddicts_readonly_inheritance.toml new file mode 100644 index 000000000..d40209993 --- /dev/null +++ b/conformance/results/zuban/typeddicts_readonly_inheritance.toml @@ -0,0 +1,18 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_readonly_inheritance.py:36: error: ReadOnly TypedDict key "name" TypedDict is mutated [typeddict-readonly-mutated] +typeddicts_readonly_inheritance.py:50: error: Overwriting TypedDict field "alt" while extending [misc] +typeddicts_readonly_inheritance.py:65: error: Missing key "name" for TypedDict "RequiredName" [typeddict-item] +typeddicts_readonly_inheritance.py:82: error: Value of "ident" has incompatible type "int"; expected "str" [typeddict-item] +typeddicts_readonly_inheritance.py:83: error: Incompatible types (expression has type "int", TypedDict item "ident" has type "str") [typeddict-item] +typeddicts_readonly_inheritance.py:84: error: Missing key "ident" for TypedDict "User" [typeddict-item] +typeddicts_readonly_inheritance.py:94: error: Overwriting TypedDict field "a" while extending [misc] +typeddicts_readonly_inheritance.py:98: error: Overwriting TypedDict field "a" while extending [misc] +typeddicts_readonly_inheritance.py:106: error: Overwriting TypedDict field "c" while extending [misc] +typeddicts_readonly_inheritance.py:119: error: Overwriting TypedDict field "x" while merging [misc] +typeddicts_readonly_inheritance.py:119: error: Overwriting TypedDict field "y" while merging [misc] +typeddicts_readonly_inheritance.py:132: error: Overwriting TypedDict field "x" while merging [misc] +typeddicts_readonly_inheritance.py:132: error: Overwriting TypedDict field "y" while merging [misc] +""" diff --git a/conformance/results/zuban/typeddicts_readonly_kwargs.toml b/conformance/results/zuban/typeddicts_readonly_kwargs.toml new file mode 100644 index 000000000..48f979f9b --- /dev/null +++ b/conformance/results/zuban/typeddicts_readonly_kwargs.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_readonly_kwargs.py:33: error: ReadOnly TypedDict key "key1" TypedDict is mutated [typeddict-readonly-mutated] +""" diff --git a/conformance/results/zuban/typeddicts_readonly_update.toml b/conformance/results/zuban/typeddicts_readonly_update.toml new file mode 100644 index 000000000..c5069c3d5 --- /dev/null +++ b/conformance/results/zuban/typeddicts_readonly_update.toml @@ -0,0 +1,6 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_readonly_update.py:23: error: TypedDict member "x" is read-only [misc] +""" diff --git a/conformance/results/zuban/typeddicts_required.toml b/conformance/results/zuban/typeddicts_required.toml new file mode 100644 index 000000000..9d0cc227a --- /dev/null +++ b/conformance/results/zuban/typeddicts_required.toml @@ -0,0 +1,9 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_required.py:12: error: Required[] can be only used in a TypedDict definition [valid-type] +typeddicts_required.py:16: error: NotRequired[] can be only used in a TypedDict definition [valid-type] +typeddicts_required.py:60: error: "Required[]" type cannot be nested [misc] +typeddicts_required.py:61: error: "NotRequired[]" type cannot be nested [misc] +""" diff --git a/conformance/results/zuban/typeddicts_type_consistency.toml b/conformance/results/zuban/typeddicts_type_consistency.toml new file mode 100644 index 000000000..6f058b674 --- /dev/null +++ b/conformance/results/zuban/typeddicts_type_consistency.toml @@ -0,0 +1,17 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_type_consistency.py:21: error: Incompatible types in assignment (expression has type "B1", variable has type "A1") [assignment] +typeddicts_type_consistency.py:38: error: Incompatible types in assignment (expression has type "B2", variable has type "A2") [assignment] +typeddicts_type_consistency.py:65: error: Incompatible types in assignment (expression has type "A3", variable has type "B3") [assignment] +typeddicts_type_consistency.py:69: error: Extra key "y" for TypedDict "A3" [typeddict-unknown-key] +typeddicts_type_consistency.py:76: error: Incompatible types in assignment (expression has type "B3", variable has type "dict[str, int]") [assignment] +typeddicts_type_consistency.py:76: note: TypedDicts cannot be assigned to dict, callers could delete or change keys to violate their type contract. Use Mapping[...] for read-only access or make all TypedDict keys NotRequired, with identical types, combined with a compatible `extra_items` class parameter. +typeddicts_type_consistency.py:77: error: Incompatible types in assignment (expression has type "B3", variable has type "dict[str, object]") [assignment] +typeddicts_type_consistency.py:77: note: TypedDicts cannot be assigned to dict, callers could delete or change keys to violate their type contract. Use Mapping[...] for read-only access or make all TypedDict keys NotRequired, with identical types, combined with a compatible `extra_items` class parameter. +typeddicts_type_consistency.py:78: error: Incompatible types in assignment (expression has type "B3", variable has type "dict[Any, Any]") [assignment] +typeddicts_type_consistency.py:78: note: TypedDicts cannot be assigned to dict, callers could delete or change keys to violate their type contract. Use Mapping[...] for read-only access or make all TypedDict keys NotRequired, with identical types, combined with a compatible `extra_items` class parameter. +typeddicts_type_consistency.py:82: error: Incompatible types in assignment (expression has type "B3", variable has type "Mapping[str, int]") [assignment] +typeddicts_type_consistency.py:126: error: Incompatible types (expression has type "int", TypedDict item "inner_key" has type "str") [typeddict-item] +""" diff --git a/conformance/results/zuban/typeddicts_usage.toml b/conformance/results/zuban/typeddicts_usage.toml new file mode 100644 index 000000000..b77f80f23 --- /dev/null +++ b/conformance/results/zuban/typeddicts_usage.toml @@ -0,0 +1,11 @@ +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeddicts_usage.py:23: error: TypedDict "Movie" has no key "director" [typeddict-unknown-key] +typeddicts_usage.py:24: error: Value of "year" has incompatible type "str"; expected "int" [typeddict-item] +typeddicts_usage.py:28: error: Extra key "title" for TypedDict "Movie" [typeddict-unknown-key] +typeddicts_usage.py:28: error: Missing key "name" for TypedDict "Movie" [typeddict-item] +typeddicts_usage.py:35: error: Cannot use isinstance() with TypedDict type [misc] +typeddicts_usage.py:40: error: Invalid type [valid-type] +""" diff --git a/conformance/results/zuban/typeforms_typeform.toml b/conformance/results/zuban/typeforms_typeform.toml new file mode 100644 index 000000000..f2ef075dd --- /dev/null +++ b/conformance/results/zuban/typeforms_typeform.toml @@ -0,0 +1,23 @@ +conformant = "Pass" +conformance_automated = "Pass" +errors_diff = """ +""" +output = """ +typeforms_typeform.py:23: error: Incompatible types in assignment (expression has type "TypeForm[str | int]", variable has type "TypeForm[str | None]") [assignment] +typeforms_typeform.py:24: error: Incompatible types in assignment (expression has type "type[list[str | None]]", variable has type "TypeForm[str | None]") [assignment] +typeforms_typeform.py:59: error: Invalid syntax [syntax] +typeforms_typeform.py:67: error: Invalid type comment or annotation [valid-type] +typeforms_typeform.py:68: error: Syntax error in type annotation [valid-type] +typeforms_typeform.py:68: note: Suggestion: Use Tuple[T1, ..., Tn] instead of (T1, ..., Tn) +typeforms_typeform.py:69: error: Invalid type: try using Literal[1] instead? [valid-type] +typeforms_typeform.py:70: error: Self type is only allowed in annotations within class definition [misc] +typeforms_typeform.py:71: error: ClassVar can only be used for assignments in class body [misc] +typeforms_typeform.py:72: error: Final can be only used as an outermost qualifier in a variable annotation [misc] +typeforms_typeform.py:73: error: TypeVarTuple "Ts" is unbound [misc] +typeforms_typeform.py:74: error: Optional[...] must have exactly one type argument [misc] +typeforms_typeform.py:75: error: Invalid type comment or annotation [valid-type] +typeforms_typeform.py:86: error: Invalid type comment or annotation [valid-type] +typeforms_typeform.py:88: error: Invalid type comment or annotation [valid-type] +typeforms_typeform.py:98: error: Incompatible types in assignment (expression has type "TypeForm[int]", variable has type "TypeForm[str]") [assignment] +typeforms_typeform.py:108: error: Incompatible types in assignment (expression has type "type[int]", variable has type "TypeForm[str]") [assignment] +""" diff --git a/conformance/results/zuban/version.toml b/conformance/results/zuban/version.toml new file mode 100644 index 000000000..66bb20900 --- /dev/null +++ b/conformance/results/zuban/version.toml @@ -0,0 +1 @@ +version = "zuban 0.10.2" diff --git a/conformance/scripts/bump_type_checkers.py b/conformance/scripts/bump_type_checkers.py new file mode 100755 index 000000000..195b19663 --- /dev/null +++ b/conformance/scripts/bump_type_checkers.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +""" +Update the conformance checker versions in uv.lock to the latest releases. +""" + +from pathlib import Path +from subprocess import CalledProcessError, run + + +TYPE_CHECKERS = ("mypy", "pyright", "zuban", "pyrefly", "ty", "pycroscope") + + +def main() -> int: + root_dir = Path(__file__).resolve().parents[1] + lock_command = ["uv", "lock", "--python", "3.12"] + for checker in TYPE_CHECKERS: + lock_command.extend(["--upgrade-package", checker]) + + try: + print("+", " ".join(lock_command)) + run(lock_command, cwd=root_dir, check=True) + except CalledProcessError as exc: + print(f"Failed with exit code {exc.returncode}") + return exc.returncode + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/conformance/src/main.py b/conformance/src/main.py index c1c8d76fa..54c47cb77 100644 --- a/conformance/src/main.py +++ b/conformance/src/main.py @@ -2,14 +2,15 @@ Type system conformance test for static type checkers. """ -import os -from pathlib import Path +import contextlib import re import sys +import tomllib +from collections.abc import Container, Sequence +from enum import Enum +from pathlib import Path from time import time -from typing import Sequence -import tomli import tomlkit from options import parse_options @@ -17,12 +18,15 @@ from test_groups import get_test_cases, get_test_groups from type_checker import TYPE_CHECKERS, TypeChecker +FULL_OUTPUT_KEY = "__full_output__" + def run_tests( root_dir: Path, type_checker: TypeChecker, test_cases: Sequence[Path], - skip_timing: bool = False, + *, + verbose: bool = False, ): print(f"Running tests for {type_checker.name}") @@ -30,7 +34,24 @@ def run_tests( tests_output = type_checker.run_tests([file.name for file in test_cases]) test_duration = time() - test_start_time - for _, output in tests_output.items(): + print(f"Completed tests for {type_checker.name} in {test_duration:.2f} seconds") + if verbose: + print(f"Verbose output for {type_checker.name}:") + full_output = tests_output.get(FULL_OUTPUT_KEY) + if full_output: + print("===== raw =====") + print(full_output, end="" if full_output.endswith("\n") else "\n") + else: + for test_name in sorted(tests_output): + print(f"===== {test_name} =====") + output = tests_output[test_name] + if output: + print(output, end="" if output.endswith("\n") else "\n") + print("") + + for test_name, output in tests_output.items(): + if test_name.startswith("__"): + continue type_checker.parse_errors(output.splitlines()) results_dir = root_dir / "results" / type_checker.name @@ -40,18 +61,27 @@ def run_tests( type_checker, results_dir, test_case, tests_output.get(test_case.name, "") ) - update_type_checker_info(type_checker, root_dir, test_duration, skip_timing=skip_timing) + update_type_checker_info(type_checker, root_dir) + + +class ErrorMultiplicity(Enum): + """How many lines with the same tag can have an error.""" + + SINGLE = 1 # exactly one line must have an error + MULTI = 2 # at least one line must have an error + REQUIRE_SUCCESS = 3 # at least one line must not have an error def get_expected_errors(test_case: Path) -> tuple[ dict[int, tuple[int, int]], - dict[str, list[int]], + dict[str, tuple[list[int], ErrorMultiplicity]], ]: """Return the line numbers where type checkers are expected to produce an error. The return value is a tuple of two dictionaries: - The format of the first is {line number: (number of required errors, number of optional errors)}. - - The format of the second is {error tag: [lines where the error may appear]}. + - The format of the second is {error tag: ([lines where the error may appear], error multiplicity)}. + See the ErrorMultiplicy enum for the second argument. For example, the following test case: @@ -64,13 +94,13 @@ def f(): pass # E[final] ( {1: (1, 0), 2: (0, 1)}, - {"final": [3, 4]} + {"final": ([3, 4], ErrorMultiplicity.SINGLE)} ) """ - with open(test_case, "r") as f: + with open(test_case, "r", encoding="utf-8") as f: lines = f.readlines() output: dict[int, tuple[int, int]] = {} - groups: dict[str, list[int]] = {} + groups: dict[str, tuple[list[int], ErrorMultiplicity]] = {} for i, line in enumerate(lines, start=1): line_without_comment, *_ = line.split("#") # Ignore lines with no non-comment content. This allows commenting out test cases. @@ -86,8 +116,22 @@ def f(): pass # E[final] if required or optional: output[i] = (required, optional) for match in re.finditer(r"# E\[([^\]]+)\]", line): - groups.setdefault(match.group(1), []).append(i) - for group, linenos in groups.items(): + tag = match.group(1) + if tag.endswith("+"): + multiplicity = ErrorMultiplicity.MULTI + tag = tag[:-1] + elif tag.endswith("!"): + multiplicity = ErrorMultiplicity.REQUIRE_SUCCESS + tag = tag[:-1] + else: + multiplicity = ErrorMultiplicity.SINGLE + if tag not in groups: + groups[tag] = ([i], multiplicity) + else: + if groups[tag][1] != multiplicity: + raise ValueError(f"Error group {tag} has inconsistent multiplicity value in {test_case}") + groups[tag][0].append(i) + for group, (linenos, _) in groups.items(): if len(linenos) == 1: raise ValueError(f"Error group {group} only appears on a single line in {test_case}") return output, groups @@ -118,18 +162,47 @@ def diff_expected_errors( differences.append(f"Line {expected_lineno}: Expected {expected_count} errors") # We don't report an issue if the count differs, because type checkers may produce # multiple error messages for a single line. - linenos_used_by_groups: set[int] = set() - for group, linenos in error_groups.items(): - if not any(lineno in errors for lineno in linenos): - differences.append(f"Lines {', '.join(map(str, linenos))}: Expected error (tag {group!r})") - else: - linenos_used_by_groups.update(linenos) + + for group, (linenos, multiplicity) in error_groups.items(): + error = determine_group_error(group, linenos, multiplicity, errors) + if error is not None: + differences.append(error) + + linenos_used_by_groups = {ln for linenos, _ in error_groups.values() for ln in linenos} for actual_lineno, actual_errors in errors.items(): - if actual_lineno not in expected_errors and actual_lineno not in linenos_used_by_groups: - differences.append(f"Line {actual_lineno}: Unexpected errors {actual_errors}") + if ( + actual_lineno not in expected_errors + and actual_lineno not in linenos_used_by_groups + ): + differences.append( + f"Line {actual_lineno}: Unexpected errors {actual_errors}" + ) return "".join(f"{diff}\n" for diff in differences) +def determine_group_error( + group: str, + group_linenos: Sequence[int], + multiplicity: ErrorMultiplicity, + error_linenos: Container[int], +) -> str | None: + """Return the error message for the given group or None.""" + num_errors = sum(1 for lineno in group_linenos if lineno in error_linenos) + match multiplicity: + case ErrorMultiplicity.SINGLE: + if num_errors == 0: + return f"Lines {', '.join(map(str, group_linenos))}: Expected error (tag {group!r})" + elif num_errors > 1: + return f"Lines {', '.join(map(str, group_linenos))}: Expected exactly one error (tag {group!r})" + case ErrorMultiplicity.MULTI: + if num_errors == 0: + return f"Lines {', '.join(map(str, group_linenos))}: Expected error (tag {group!r})" + case ErrorMultiplicity.REQUIRE_SUCCESS: + if num_errors == len(group_linenos): + return f"Lines {', '.join(map(str, group_linenos))}: Expected at least one success (tag {group!r})" + return None + + def update_output_for_test( type_checker: TypeChecker, results_dir: Path, @@ -141,19 +214,19 @@ def update_output_for_test( results_file = results_dir / f"{test_name}.toml" results_file.parent.mkdir(parents=True, exist_ok=True) + should_write = False # Read the existing results file if present. try: with open(results_file, "rb") as f: - existing_results = tomli.load(f) + existing_results = tomllib.load(f) except FileNotFoundError: should_write = True existing_results = {} - except tomli.TOMLDecodeError: + except tomllib.TOMLDecodeError: print(f"Error decoding {results_file}") existing_results = {} - should_write = False ignored_errors = existing_results.get("ignore_errors", []) errors_diff = "\n" + diff_expected_errors(type_checker, test_case, output, ignored_errors) old_errors_diff = "\n" + existing_results.get("errors_diff", "") @@ -165,8 +238,10 @@ def update_output_for_test( print(f"New output: {errors_diff}") print("") - existing_results["conformance_automated"] = "Fail" if errors_diff.strip() else "Pass" - + conformance_automated = "Fail" if errors_diff.strip() else "Pass" + if existing_results.get("conformance_automated") != conformance_automated: + should_write = True + existing_results["conformance_automated"] = conformance_automated old_output = existing_results.get("output", "") old_output = f"\n{old_output}" @@ -195,29 +270,25 @@ def update_output_for_test( notes = "\n" + notes existing_results["notes"] = tomlkit.string(notes, multiline=True) results_file.parent.mkdir(parents=True, exist_ok=True) - with open(results_file, "w") as f: + with open(results_file, "w", encoding="utf-8") as f: tomlkit.dump(existing_results, f) -def update_type_checker_info( - type_checker: TypeChecker, root_dir: Path, test_duration: float, skip_timing: bool = False -): +def update_type_checker_info(type_checker: TypeChecker, root_dir: Path): # Record the version of the type checker used for the latest run. version_file = root_dir / "results" / type_checker.name / "version.toml" # Read the existing version file if present. try: with open(version_file, "rb") as f: - existing_info = tomli.load(f) + existing_info = tomllib.load(f) except FileNotFoundError: existing_info = {} - except tomli.TOMLDecodeError: + except tomllib.TOMLDecodeError: print(f"Error decoding {version_file}") existing_info = {} existing_info["version"] = type_checker.get_version() - if not skip_timing: - existing_info["test_duration"] = round(test_duration, 1) version_file.parent.mkdir(parents=True, exist_ok=True) with open(version_file, "w") as f: @@ -241,14 +312,16 @@ def main(): test_cases = get_test_cases(test_groups, tests_dir) # Switch to the tests directory. - os.chdir(tests_dir) - - # Run each test case with each type checker. - for type_checker in TYPE_CHECKERS: - if not type_checker.install(): - print(f"Skipping tests for {type_checker.name}") - else: - run_tests(root_dir, type_checker, test_cases, skip_timing=options.skip_timing) + with contextlib.chdir(tests_dir): + + # Run each test case with each type checker. + for type_checker in TYPE_CHECKERS: + if options.only_run and options.only_run != type_checker.name: + continue + if not type_checker.install(): + print(f"Skipping tests for {type_checker.name}") + else: + run_tests(root_dir, type_checker, test_cases, verbose=options.verbose) # Generate a summary report. generate_summary(root_dir) diff --git a/conformance/src/options.py b/conformance/src/options.py index 93caef022..854672776 100644 --- a/conformance/src/options.py +++ b/conformance/src/options.py @@ -5,11 +5,13 @@ import argparse from dataclasses import dataclass +from type_checker import TYPE_CHECKERS @dataclass class _Options: - report_only: bool | None - skip_timing: bool + report_only: bool + only_run: str | None + verbose: bool def parse_options(argv: list[str]) -> _Options: @@ -21,9 +23,14 @@ def parse_options(argv: list[str]) -> _Options: help="regenerates the test suite report from past results", ) reporting_group.add_argument( - "--skip-timing", + "--only-run", + help="Only runs the type checker", + choices=[tc.name for tc in TYPE_CHECKERS], + ) + parser.add_argument( + "--verbose", action="store_true", - help="do not update timing information in the output files", + help="print full output from the type checker", ) ret = _Options(**vars(parser.parse_args(argv))) return ret diff --git a/conformance/src/reporting.py b/conformance/src/reporting.py index 1c4243709..41b5949e5 100644 --- a/conformance/src/reporting.py +++ b/conformance/src/reporting.py @@ -2,118 +2,227 @@ Generates a summary of the type checker conformant tests. """ +import itertools +import operator +import tomllib +from collections.abc import Sequence +from dataclasses import dataclass, field +from decimal import Decimal from pathlib import Path -import tomli +import jinja2 +import markdown +import markupsafe from test_groups import get_test_cases, get_test_groups -from type_checker import TYPE_CHECKERS +from type_checker import TYPE_CHECKERS, TypeChecker + + +@dataclass(frozen=True, kw_only=True, slots=True) +class TestResult: + type_checker: str + conformance: str + notes: list[markupsafe.Markup] = field(default_factory=list) + + +@dataclass(frozen=True, kw_only=True, slots=True) +class TestCase: + name: str + results: list[TestResult] = field(default_factory=list) + + +@dataclass(frozen=True, kw_only=True, slots=True) +class TestStat: + type_checker: str + total: int + passed: Decimal + + @property + def percentage(self) -> str: + return f"{self.passed / self.total:.1%}" + + +@dataclass(frozen=True, kw_only=True, slots=True) +class TestGroup: + slug: str + name: str + href: str + paths: list[Path] = field(default_factory=list) + cases: list[TestCase] = field(default_factory=list) + stats: list[TestStat] = field(default_factory=list) def generate_summary(root_dir: Path): print("Generating summary report") - template_file = root_dir / "src" / "results_template.html" - with open(template_file, "r") as f: - template = f.read() - summary = template.replace("{{summary}}", generate_summary_html(root_dir)) + env = jinja2.Environment( + loader=jinja2.FileSystemLoader(root_dir.joinpath("src/templates")), + autoescape=jinja2.select_autoescape(), + keep_trailing_newline=True, + ) + env.filters["conformance_class"] = _conformance_class + + template = env.get_template("base.html") + + type_checkers = sorted(TYPE_CHECKERS, key=operator.attrgetter("name")) + + groups = _get_groups(root_dir, type_checkers) + totals = _get_totals(groups) + versions = _get_versions(root_dir, type_checkers) + + results = template.render(groups=groups, totals=totals, versions=versions) + + root_dir.joinpath("results", "results.html").write_text(results) - results_file = root_dir / "results" / "results.html" - with open(results_file, "w") as f: - f.write(summary) +def _conformance_class(value: str) -> str: + if value == "Pass": + return "conformant" + if value == "Partial": + return "partially-conformant" + return "not-conformant" -def generate_summary_html(root_dir: Path) -> str: - column_count = len(TYPE_CHECKERS) + 1 +def _get_groups( + root_dir: Path, + type_checkers: Sequence[TypeChecker], +) -> list[TestGroup]: test_groups = get_test_groups(root_dir) test_cases = get_test_cases(test_groups, root_dir / "tests") - summary_html = ['
'] - summary_html.append('') + groups = [] + + for test_group_slug, test_group in test_groups.items(): + paths = sorted( + [ + case + for case in test_cases + if case.name.startswith(f"{test_group_slug}_") + ], + key=operator.attrgetter("name"), + ) + + # Skip if there are no test cases in the group. + if not paths: + continue + + group = TestGroup( + slug=test_group_slug, + name=test_group.name, + href=test_group.href, + paths=paths, + ) + groups.append(group) + + for path in group.paths: + case = TestCase(name=path.stem) + group.cases.append(case) + + for type_checker in type_checkers: + result_path = ( + root_dir / "results" / type_checker.name / f"{case.name}.toml" + ) + try: + with result_path.open("rb") as f: + data = tomllib.load(f) + except FileNotFoundError: + data = {} + + conformance = data.get("conformant") + if not conformance: + # Try to look up the automated test results and use that if the test passes. + automated = data.get("conformance_automated") + conformance = "Pass" if automated == "Pass" else "Unknown" + + notes = [ + markupsafe.Markup( + markdown.markdown(note, output_format="html") + .removeprefix("

") + .removesuffix("

") + ) + for note in data.get("notes", "").strip().splitlines() + ] + + result = TestResult( + type_checker=type_checker.name, + conformance=conformance, + notes=notes, + ) + case.results.append(result) + + for n, type_checker in enumerate(type_checkers): + passed = Decimal("0.0") + + for case in group.cases: + match case.results[n].conformance: + case "Pass": + passed += Decimal("1.0") + case "Partial": + # For partial support, give half a mark :) + passed += Decimal("0.5") + + stat = TestStat( + type_checker=type_checker.name, + total=len(group.paths), + passed=_remove_exponent(passed), + ) + group.stats.append(stat) - for type_checker in TYPE_CHECKERS: - # Load the version file for the type checker. - version_file = root_dir / "results" / type_checker.name / "version.toml" + return groups - try: - with open(version_file, "rb") as f: - existing_info = tomli.load(f) - except FileNotFoundError: - existing_info = {} - except tomli.TOMLDecodeError: - print(f"Error decoding {version_file}") - existing_info = {} - - version = existing_info["version"] or "Unknown version" - test_duration = existing_info.get("test_duration") - - summary_html.append(f"") - - summary_html.append("") - - for test_group_name, test_group in test_groups.items(): - tests_in_group = [ - case for case in test_cases if case.name.startswith(f"{test_group_name}_") - ] - - tests_in_group.sort(key=lambda x: x.name) - - # Are there any test cases in this group? - if len(tests_in_group) > 0: - summary_html.append(f'") - - for test_case in tests_in_group: - test_case_name = test_case.stem - - summary_html.append(f'') - - for type_checker in TYPE_CHECKERS: - try: - results_file = ( - root_dir - / "results" - / type_checker.name - / f"{test_case_name}.toml" - ) - with open(results_file, "rb") as f: - results = tomli.load(f) - except FileNotFoundError: - results = {} - - raw_notes = results.get("notes", "").strip() - conformance = results.get("conformant", "Unknown") - notes = "".join( - [f"

{note}

" for note in raw_notes.split("\n")] - ) - conformance_class = ( - "conformant" - if conformance == "Pass" - else "partially-conformant" - if conformance == "Partial" - else "not-conformant" - ) +def _get_totals(groups: list[TestGroup]) -> list[TestStat]: + totals = [] + + # As we already sort by type checker above, we can sort and group by here and maintain the + # correct order for the totals output. + ordered = sorted( + [stat for group in groups for stat in group.stats], + key=operator.attrgetter("type_checker"), + ) - # Add an asterisk if there are notes to display for a "Pass". - if raw_notes != "" and conformance == "Pass": - conformance = "Pass*" + for type_checker, stats_it in itertools.groupby( + ordered, operator.attrgetter("type_checker") + ): + stats = list(stats_it) + total = TestStat( + type_checker=type_checker, + total=sum([stat.total for stat in stats]), + passed=_remove_exponent( + sum([stat.passed for stat in stats], start=Decimal("0")) + ), + ) + totals.append(total) + + return totals + + +def _get_versions( + root_dir: Path, + type_checkers: Sequence[TypeChecker], +) -> list[str]: + versions = [] + + for type_checker in type_checkers: + name = type_checker.name + + try: + with root_dir.joinpath("results", name, "version.toml").open("rb") as f: + data = tomllib.load(f) + except (FileNotFoundError, tomllib.TOMLDecodeError): + version = None + else: + version = data.get("version") or None - conformance_cell = f"{conformance}" - if raw_notes != "": - conformance_cell = f'
{conformance_cell}{notes}
' + # If version file cannot be found or has missing/invalid content, fall back to name. + if version is None: + version = f"{type_checker.name} ?.?.?" - summary_html.append(f'') + versions.append(version) - summary_html.append("") + return versions - summary_html.append("
 
{version}
") - if test_duration is not None: - summary_html.append(f"
{test_duration:.1f}sec
") - summary_html.append("
') - summary_html.append( - f'{test_group.name}' - ) - summary_html.append("
     {test_case_name}{conformance_cell}
\n") - return "\n".join(summary_html) +def _remove_exponent(d: Decimal) -> Decimal: + # See https://docs.python.org/3/library/decimal.html#decimal-faq + return d.quantize(Decimal(1)) if d == d.to_integral() else d.normalize() diff --git a/conformance/src/results_template.html b/conformance/src/results_template.html deleted file mode 100644 index 2e9b95f35..000000000 --- a/conformance/src/results_template.html +++ /dev/null @@ -1,176 +0,0 @@ - - - - - - - Type System Test Results - - - - -
-
-

Python Type System Conformance Test Results

-
- {{summary}} - -
- - - diff --git a/conformance/src/templates/base.html b/conformance/src/templates/base.html new file mode 100644 index 000000000..d1f5a3f27 --- /dev/null +++ b/conformance/src/templates/base.html @@ -0,0 +1,102 @@ +{%- set columns = versions|length -%} + + + + + + + + Python Type System Conformance Test Results + + + + +
+

Python Type System Conformance Test Results

+

+ While specification conformance is important for the ecosystem, we don't recommend + using it as the primary basis for choosing a type checker. It is not representative + of many of the things users typically care about. +

+
+ + +
+
+
+ + + + + + + + + {%- for version in versions %} + + {%- endfor %} + + + {%- for group in groups %} + + + + + {%- for case in group.cases %} + + + {%- for result in case.results %} + {%- if result.notes %} + + {%- else %} + + {%- endif %} + {%- endfor %} + + {%- endfor %} + + + {%- for stats in group.stats %} + + {%- endfor %} + + + {%- endfor %} + + + + {%- for stats in totals %} + + {%- endfor %} + + +
{{ version }}
+ {{ group.name }} +
{{ case.name }} + {{ result.conformance }} +
    + {%- for note in result.notes %} +
  • {{ note }}
  • + {%- endfor %} +
+
{{ result.conformance }}
{{ stats.passed }} / {{ stats.total }} • {{ stats.percentage }}
{{ stats.passed }} / {{ stats.total }} • {{ stats.percentage }}
+
+ + + diff --git a/conformance/src/templates/style.css b/conformance/src/templates/style.css new file mode 100644 index 000000000..e72684ace --- /dev/null +++ b/conformance/src/templates/style.css @@ -0,0 +1,227 @@ +:root { + --dark-main-bg: #333; + --dark-main-fg: #fff; + --dark-muted-fg: #ddd; + --dark-selection-bg: #ec6e4a; + --dark-shadow: #999; + --light-main-bg: #fff; + --light-main-fg: #000; + --light-muted-fg: #666; + --light-selection-bg: #ec6e4a; + --light-shadow: #ccc; + + --conformant: rgb(203, 255, 203); + --partially-conformant: rgb(251, 244, 166); + --not-conformant: rgb(242, 171, 171); + + color-scheme: light dark; + &:has(#color-scheme option[value="light"]:checked) { + color-scheme: light; + } + &:has(#color-scheme option[value="dark"]:checked) { + color-scheme: dark; + } +} + +* { + box-sizing: border-box; +} + +::selection { + background: light-dark(var(--light-selection-bg), var(--dark-selection-bg)); + color: light-dark(var(--dark-main-fg), var(--light-main-fg)); +} + +html { + background: light-dark(var(--light-main-bg), var(--dark-main-bg)); + color: light-dark(var(--light-main-fg), var(--dark-main-fg)); + font-family: "system-ui", "Segoe UI", Helvetica, Arial, sans-serif; + font-size: 0.85rem; +} + +body { + margin: 0; + padding: 0; +} + +header { + background-color: #2b5b84; + box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.03), inset 0 0 20px rgba(0, 0, 0, 0.03); + color: #fff; + padding: 1em; + text-align: center; +} + +main { + padding: 2em; +} + +a { + text-underline-offset: 2px; +} + +code { + background: light-dark(#eee, #666); + border: 1px solid light-dark(#ddd, #888); + border-radius: 3px; + padding: 0 2px; +} + +table { + border-collapse: collapse; + inline-size: 100%; + margin: 0; + padding: 0; +} + +th, +td { + border-color: transparent; + border-style: solid; + border-width: 0 10px; + margin: 0; + padding: 3px; + position: relative; + text-align: start; + + &:not(:first-child) { + text-align: center; + } +} + +thead { + background: light-dark(var(--light-main-bg), var(--dark-main-bg)); + inset-block-start: 0; + position: sticky; + z-index: 3; + & > tr > th { + padding-block: 1em; + } +} + +tbody > tr > th:not([colspan]) { + font-weight: normal; + padding-inline-start: 2em; +} + +tbody > tr.summary { + color: light-dark(var(--light-muted-fg), var(--dark-muted-fg)); +} + +tfoot td { + font-weight: bold; + padding-block-start: 1em; +} + +.col1 { + inline-size: 30%; +} + +.col2 { + inline-size: calc(70% / {{ columns }}); +} + +.conformant { + background-color: var(--conformant); + color: var(--light-main-fg); +} + +.partially-conformant { + background-color: var(--partially-conformant); + color: var(--light-main-fg); +} + +.not-conformant { + background-color: var(--not-conformant); + color: var(--light-main-fg); +} + +tbody > tr:hover { + th:not([colspan]) { + background-color: light-dark(#eee, #444); + border-color: light-dark(#eee, #444); + } + th:not([colspan]) ~ td { + border-color: light-dark(#eee, #444); + } + .conformant { + background-color: hsl(from var(--conformant) h s calc(l - 5)); + } + .partially-conformant { + background-color: hsl(from var(--partially-conformant) h s calc(l - 5)); + } + .not-conformant { + background-color: hsl(from var(--not-conformant) h s calc(l - 5)); + } +} + +.tooltip { + cursor: help; + + /* Add an asterisk if there are notes to display for a "Pass". */ + &.conformant::after { + content: "*"; + position: absolute; + } + + .notes { + background-color: light-dark(var(--light-main-bg), var(--dark-main-bg)); + border-radius: 5px; + box-shadow: 0 0 3px light-dark(var(--light-shadow), var(--dark-shadow)); + color: light-dark(var(--light-main-fg), var(--dark-main-fg)); + cursor: default; + font-size: .8em; + inset-block-start: calc(50% - 5px); + inset-inline-end: 50%; + line-height: 1.6; + list-style-position: inside; + min-inline-size: 500px; + padding: 10px 15px; + position: absolute; + text-align: start; + visibility: hidden; + z-index: 2; + & > li { + padding: 3px 0; + text-indent: 1.3em hanging; + } + } + + &:hover .notes { + visibility: visible; + } +} + +.disclaimer { + color: var(--dark-muted-fg); + font-size: 0.9rem; + font-weight: normal; + line-height: 1.4; + margin: 1rem auto; + max-inline-size: 720px; +} + +form:has(#color-scheme) { + background: inherit; + inset-block-start: 1rem; + inset-inline-end: 1rem; + position: absolute; +} + +#color-scheme { + appearance: none; + background: inherit; + border-color: var(--dark-muted-fg); + border-radius: 5px; + border-style: solid; + border-width: 1px; + color: inherit; + padding: 0.5rem; + &:focus { + border-color: inherit; + outline: none; + } + &:hover { + border-color: inherit; + } +} diff --git a/conformance/src/test_groups.py b/conformance/src/test_groups.py index f0145ff11..ae8ab4bfa 100644 --- a/conformance/src/test_groups.py +++ b/conformance/src/test_groups.py @@ -3,12 +3,13 @@ conformance test suite. """ +import tomllib + from dataclasses import dataclass +from itertools import chain from pathlib import Path from typing import Mapping, Sequence -import tomli - @dataclass class TestGroup: @@ -21,7 +22,7 @@ def get_test_groups(root_dir: Path) -> Mapping[str, TestGroup]: # group has a name that associated test cases must start with. test_group_file = root_dir / "src" / "test_groups.toml" with open(test_group_file, "rb") as f: - test_groups = tomli.load(f) + test_groups = tomllib.load(f) return { k: TestGroup(v.get("name", "unknown"), v.get("href", "")) @@ -39,7 +40,7 @@ def get_test_cases( # files that support one or more tests. test_cases = [ p - for p in Path(tests_dir).glob("*.py") + for p in chain(tests_dir.glob("*.py"), tests_dir.glob("*.pyi")) if p.name.split("_")[0] in test_group_names ] diff --git a/conformance/src/test_groups.toml b/conformance/src/test_groups.toml index 155287f48..adf2b355c 100644 --- a/conformance/src/test_groups.toml +++ b/conformance/src/test_groups.toml @@ -7,6 +7,10 @@ href = "https://typing.readthedocs.io/en/latest/spec/concepts.html" name = "Type annotations" href = "https://typing.readthedocs.io/en/latest/spec/annotations.html" +[typeforms] +name = "Type forms" +href = "https://typing.readthedocs.io/en/latest/spec/type-forms.html" + [specialtypes] name = "Special types in annotations" href = "https://typing.readthedocs.io/en/latest/spec/special-types.html" @@ -67,6 +71,10 @@ href = "https://typing.readthedocs.io/en/latest/spec/tuples.html" name = "Named tuples" href = "https://typing.readthedocs.io/en/latest/spec/namedtuples.html" +[enums] +name = "Enumerations" +href = "https://typing.readthedocs.io/en/latest/spec/enums.html" + [narrowing] name = "Type narrowing" href = "https://typing.readthedocs.io/en/latest/spec/narrowing.html" diff --git a/conformance/src/type_checker.py b/conformance/src/type_checker.py index 6ea9d743f..d72ff9dbf 100644 --- a/conformance/src/type_checker.py +++ b/conformance/src/type_checker.py @@ -2,23 +2,19 @@ Classes that abstract differences between type checkers. """ -from abc import ABC, abstractmethod -from curses.ascii import isspace import json -from pathlib import Path import os +from pathlib import Path import re -from pytype import config as pytype_config -from pytype import io as pytype_io -from pytype import analyze as pytype_analyze -from pytype.errors import errors as pytype_errors -from pytype import load_pytd as pytype_loader import shutil -from subprocess import PIPE, CalledProcessError, run import sys -from tqdm import tqdm +import sysconfig +from abc import ABC, abstractmethod +from subprocess import PIPE, CalledProcessError, run from typing import Sequence +CONFORMANCE_ROOT = Path(__file__).resolve().parent.parent + class TypeChecker(ABC): @property @@ -32,8 +28,8 @@ def name(self) -> str: @abstractmethod def install(self) -> bool: """ - Ensures that the latest version of the type checker is installed. - Returns False if installation fails. + Ensures that the type checker is available in the current environment. + Returns False if it cannot be executed. """ raise NotImplementedError @@ -74,18 +70,23 @@ def install(self) -> bool: pass try: - run( - [sys.executable, "-m", "pip", "install", "mypy", "--upgrade"], - check=True, - ) + # Run "mypy --version" to ensure that it's available and to work + # around timing issues caused by malware scanners on some systems. + self.get_version() return True - except CalledProcessError: - print("Unable to install mypy") + except (CalledProcessError, FileNotFoundError): + print( + "Unable to run mypy. Install conformance dependencies with " + "'uv sync --frozen' from the conformance directory." + ) return False def get_version(self) -> str: proc = run( - [sys.executable, "-m", "mypy", "--version"], stdout=PIPE, text=True + [sys.executable, "-m", "mypy", "--version"], + check=True, + stdout=PIPE, + text=True, ) version = proc.stdout.strip() @@ -99,15 +100,11 @@ def run_tests(self, test_files: Sequence[str]) -> dict[str, str]: "-m", "mypy", ".", - # Mypy currently crashes when run on the "generics_defaults.py" test case, - # so we need to exclude it for now. Remove this once mypy adds support for - # this functionality. - "--exclude", - r"generics_defaults\.py", - "--disable-error-code", - "empty-body", + "--enable-error-code", + "deprecated", + "--enable-incomplete-feature=TypeForm", ] - proc = run(command, stdout=PIPE, text=True) + proc = run(command, stdout=PIPE, text=True, encoding="utf-8") lines = proc.stdout.split("\n") # Add results to a dictionary keyed by the file name. @@ -139,29 +136,38 @@ def name(self) -> str: def install(self) -> bool: try: - # Install the Python wrapper if it's not installed. - run( - [sys.executable, "-m", "pip", "install", "pyright", "--upgrade"], - check=True, - ) - # Force the Python wrapper to install node if needed - # and download the latest version of pyright. + # and use the locked version of pyright. self.get_version() return True - except CalledProcessError: - print("Unable to install pyright") + except (CalledProcessError, FileNotFoundError): + print( + "Unable to run pyright. Install conformance dependencies with " + "'uv sync --frozen' from the conformance directory." + ) return False def get_version(self) -> str: proc = run( - [sys.executable, "-m", "pyright", "--version"], stdout=PIPE, text=True + [sys.executable, "-m", "pyright", "--version"], + check=True, + stdout=PIPE, + text=True, ) - return proc.stdout.strip() + return self._parse_version(proc.stdout) + + @staticmethod + def _parse_version(output: str) -> str: + # pyright --version can print an update message ("there is a new pyright version available"), + # make sure we extract only the actual version + for line in output.splitlines(): + if line.startswith("pyright "): + return line + return output.strip() def run_tests(self, test_files: Sequence[str]) -> dict[str, str]: command = [sys.executable, "-m", "pyright", ".", "--outputjson"] - proc = run(command, stdout=PIPE, text=True) + proc = run(command, stdout=PIPE, text=True, encoding="utf-8") output_json = json.loads(proc.stdout) diagnostics = output_json["generalDiagnostics"] @@ -197,43 +203,95 @@ def parse_errors(self, output: Sequence[str]) -> dict[int, list[str]]: return line_to_errors -class PyreTypeChecker(TypeChecker): +class TyTypeChecker(TypeChecker): @property def name(self) -> str: - return "pyre" + return "ty" def install(self) -> bool: try: - # Delete the cache for consistent timings. - shutil.rmtree(".pyre") - except (shutil.Error, OSError): - # Ignore any errors here. - pass - - try: - run( - [sys.executable, "-m", "pip", "install", "pyre-check", "--upgrade"], - check=True, + self.get_version() + return True + except (CalledProcessError, FileNotFoundError): + print( + "Unable to run ty. Install conformance dependencies with " + "'uv sync --frozen' from the conformance directory." ) + return False - # Generate a default config file. - pyre_config = '{"site_package_search_strategy": "pep561", "source_directories": ["."]}\n' - with open(".pyre_configuration", "w") as f: - f.write(pyre_config) + def get_version(self) -> str: + proc = run([sys.executable, "-m", "ty", "--version"], stdout=PIPE, text=True) + return proc.stdout.split("(")[0].strip() + def run_tests(self, test_files: Sequence[str]) -> dict[str, str]: + command = [ + sys.executable, + "-m", + "ty", + "check", + ".", + "--output-format=concise", + "--color=never", + "--config-file=./ty.toml", + ] + proc = run(command, stdout=PIPE, text=True, encoding="utf-8") + results_dict: dict[str, str] = {} + for line in proc.stdout.splitlines(): + if not line.strip(): + continue + file_name = line.split(":")[0].strip() + results_dict[file_name] = results_dict.get(file_name, "") + line + "\n" + return results_dict + + def parse_errors(self, output: Sequence[str]) -> dict[int, list[str]]: + # narrowing_typeguard.py:102:23: error[invalid-type-guard-definition] `TypeGuard` function must have a parameter to narrow + line_to_errors: dict[int, list[str]] = {} + for line in output: + line = line.strip() + if ( + not line + or line == "All checks passed!" + or re.fullmatch(r"Found \d+ diagnostics?", line) + ): + continue + assert line.count(":") >= 3, f"Failed to parse line: {line!r}" + _, lineno, _, rest = line.split(":", maxsplit=3) + kind = rest.split("[")[0].strip() + if kind != "error": + continue + line_to_errors.setdefault(int(lineno), []).append(line) + return line_to_errors + + +class ZubanLSTypeChecker(MypyTypeChecker): + @property + def name(self) -> str: + return "zuban" + + def install(self) -> bool: + try: + self.get_version() return True - except CalledProcessError: - print("Unable to install pyre") + except (CalledProcessError, FileNotFoundError): + print( + "Unable to run zuban. Install conformance dependencies with " + "'uv sync --frozen' from the conformance directory." + ) return False def get_version(self) -> str: - proc = run(["pyre", "--version"], stdout=PIPE, text=True) - version = proc.stdout.strip() - version = version.replace("Client version:", "pyre") - return version + proc = run(["zuban", "--version"], check=True, stdout=PIPE, text=True) + return proc.stdout.strip() def run_tests(self, test_files: Sequence[str]) -> dict[str, str]: - proc = run(["pyre", "check"], stdout=PIPE, text=True) + command = [ + "zuban", + "check", + ".", + "--enable-error-code", + "deprecated", + ] + proc = run(command, stdout=PIPE, text=True, encoding="utf-8") lines = proc.stdout.split("\n") # Add results to a dictionary keyed by the file name. @@ -245,121 +303,210 @@ def run_tests(self, test_files: Sequence[str]) -> dict[str, str]: return results_dict def parse_errors(self, output: Sequence[str]) -> dict[int, list[str]]: - # narrowing_typeguard.py:17:33 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[str], Type[str]]`. + # narrowing_typeguard.py:102: error: TypeGuard functions must have a positional argument [valid-type] line_to_errors: dict[int, list[str]] = {} for line in output: - # Ignore multi-line errors - if ".py:" not in line: + if line.count(":") < 3: + continue + _, lineno, kind, _ = line.split(":", maxsplit=3) + kind = kind.strip() + if kind != "error": continue - assert line.count(":") >= 2, f"Failed to parse line: {line!r}" - _, lineno, _ = line.split(":", maxsplit=2) line_to_errors.setdefault(int(lineno), []).append(line) return line_to_errors -class PytypeTypeChecker(TypeChecker): +class PyreflyTypeChecker(TypeChecker): @property def name(self) -> str: - return "pytype" + return "pyrefly" def install(self) -> bool: try: - run( - [sys.executable, "-m", "pip", "install", "pytype", "--upgrade"], - check=True, - ) + self.get_version() return True - except CalledProcessError: - print("Unable to install pytype on this platform") + except (CalledProcessError, FileNotFoundError): + print( + "Unable to run pyrefly. Install conformance dependencies with " + "'uv sync --frozen' from the conformance directory." + ) return False def get_version(self) -> str: - proc = run( - [sys.executable, "-m", "pytype", "--version"], stdout=PIPE, text=True - ) + proc = run(["pyrefly", "--version"], check=True, stdout=PIPE, text=True) version = proc.stdout.strip() - return f"pytype {version}" + return version def run_tests(self, test_files: Sequence[str]) -> dict[str, str]: - # Specify 3.11 for now to work around the fact that pytype - # currently doesn't support 3.12 and emits an error when - # running on 3.12. - options = pytype_config.Options.create(python_version=(3, 11), quick=True) - loader = pytype_loader.create_loader(options) + proc = run( + [ + "pyrefly", + "check", + "--output-format", + "min-text", + "--summary=none", + "--min-severity=warn", + ], + stdout=PIPE, + text=True, + encoding="utf-8", + ) + lines = proc.stdout.split("\n") # Add results to a dictionary keyed by the file name. results_dict: dict[str, str] = {} - - for fi in tqdm(os.listdir(".")): - if not fi.endswith(".py"): + for line in lines: + if not line.strip(): continue - options.tweak(input=fi) - with open(fi, "r") as test_file: - src = test_file.read() + if line.startswith(" INFO "): + continue + # Extract the absolute path reported by pyrefly and convert it to a + # stable relative path (filename only) so results are consistent. + # Example input line: + # "ERROR /abs/.../conformance/tests/foo.py:12:3-5: message [code]" + # We replace the absolute path with just "foo.py". try: - analysis: pytype_analyze.Analysis = pytype_io.check_py( - src, options=options, loader=loader - ) - except Exception as e: - results_dict[fi] = f"{e.__class__.__name__}: {e}\n" - else: - results_dict[fi] = self.enforce_consistent_order( - analysis.context.errorlog - ) + abs_path = line.split(":", 1)[0].strip().split(" ", 1)[1].strip() + except IndexError: + # If parsing fails, fall back to original line and grouping. + abs_path = "" + file_name = Path(abs_path).name if abs_path else line.split(":")[0] + + # Replace only the first occurrence to avoid touching the message text. + display_line = line.replace(abs_path, file_name, 1) if abs_path else line + results_dict[file_name] = ( + results_dict.get(file_name, "") + display_line + "\n" + ) return results_dict - def enforce_consistent_order(self, log: pytype_errors.ErrorLog) -> str: - """Pytype does not guarantee deterministic output across runs. - It does order diagnostics by line number, but if multiple errors - occur on the same line, the ordering appears to change from one - run to the next. We require deterministic and consistent output, - so this method sorts the pytype output by line number and then - alphabetically within a line. - """ + def parse_errors(self, output: Sequence[str]) -> dict[int, list[str]]: + line_to_errors: dict[int, list[str]] = {} + for line in output: + # Ignore multi-line errors + if ".py:" not in line and ".pyi:" not in line: + continue + # Ignore reveal_type errors + if "revealed type: " in line: + continue + assert line.count(":") >= 3, f"Failed to parse line: {line!r}" + _, lineno, _, error_msg = line.split(":", maxsplit=3) + line_to_errors.setdefault(int(lineno), []).append(error_msg.strip()) + return line_to_errors + - class ErrorSorter: - def __init__(self, err: pytype_errors.Error) -> None: - # Overwrite the details in the error because these can be - # nondeterministic (differ from run to run) in some cases. - err._details = "" - self._err = err - - def __lt__(self, other: "ErrorSorter", /) -> bool: - lineno_diff = self._err.lineno - other._err.lineno - if lineno_diff != 0: - return lineno_diff < 0 - return other._err.message < self._err.message - - def __eq__(self, other: object, /) -> bool: - return ( - isinstance(other, ErrorSorter) - and self._err.lineno == other._err.lineno - and other._err.message == self._err.message - ) - - errors: list[pytype_errors.Error] = [ - error for error in log.unique_sorted_errors() +class PycroscopeTypeChecker(TypeChecker): + @property + def name(self) -> str: + return "pycroscope" + + def install(self) -> bool: + try: + self.get_version() + return True + except (CalledProcessError, FileNotFoundError): + print( + "Unable to run pycroscope. Install conformance dependencies with " + "'uv sync --frozen' from the conformance directory." + ) + return False + + def get_version(self) -> str: + proc = run([self._command(), "--version"], stdout=PIPE, text=True, check=True) + return proc.stdout.strip() + + @staticmethod + def _command() -> str: + executable = "pycroscope.exe" if sys.platform == "win32" else "pycroscope" + return str(Path(sysconfig.get_path("scripts")) / executable) + + @staticmethod + def _normalize_output_line(line: str) -> str: + line = line.replace(str(CONFORMANCE_ROOT), "...") + line = re.sub(r"", r"", line) + # Pycroscope can include object reprs with process-specific addresses + # (e.g. "... at 0x10abc1234>"). Normalize these for stable snapshots. + return re.sub(r"0x[0-9a-fA-F]+", "0x...", line) + + def run_tests(self, test_files: Sequence[str]) -> dict[str, str]: + command = [ + self._command(), + ".", + "--output-format", + "concise", + "--disable", + "import_failed", + "--disable", + "unused_variable", + "--disable", + "unused_assignment", + "--disable", + "must_use", + "--enable", + "invalid_literal", + "--enable", + "incompatible_override", + "--enable", + "classvar_type_parameters", ] - errors.sort(key=ErrorSorter) - return "\n".join(map(str, errors)) + "\n" + proc = run( + command, + stdout=PIPE, + stderr=PIPE, + text=True, + encoding="utf-8", + env={**os.environ, "PYTHONPATH": "."}, + ) + lines = proc.stderr.splitlines() + full_output_lines: list[str] = [] + + # Collect results per file and sort for deterministic output. + sortable_results: dict[str, list[tuple[int, str, str]]] = {} + for line in lines: + if not line.strip(): + continue + line = self._normalize_output_line(line) + full_output_lines.append(line) + # Concise output line format: + # file.py:12:3: Message text [error_code] + match = re.match(r"^(.+?):(\d+)(?::\d+)?:\s(.*)$", line) + if not match: + continue + file_name = Path(match.group(1)).name + lineno = int(match.group(2)) + message = match.group(3) + sortable_results.setdefault(file_name, []).append((lineno, message, line)) + + results_dict: dict[str, str] = {} + for file_name, entries in sortable_results.items(): + entries.sort(key=lambda item: (item[0], item[1])) + results_dict[file_name] = "".join(f"{line}\n" for _, _, line in entries) + if full_output_lines: + results_dict["__full_output__"] = "".join( + f"{line}\n" for line in full_output_lines + ) + return results_dict def parse_errors(self, output: Sequence[str]) -> dict[int, list[str]]: - # File "narrowing_typeguard.py", line 128, in : Function takes_callable_str was called with the wrong arguments [wrong-arg-types] - # File "directives_type_ignore.py", line 11: Stray type comment: ignore - additional stuff [ignored-type-comment]' line_to_errors: dict[int, list[str]] = {} for line in output: - if '.py", line ' not in line: + if not line.strip(): continue - match = re.search(r"^File \"[^\"]+?\", line (\d+)", line) - assert match is not None, f"Failed to parse line number from: {line!r}" - lineno = int(match.group(1)) - line_to_errors.setdefault(int(lineno), []).append(line) + line = self._normalize_output_line(line) + # reveal_type diagnostics are informational for conformance purposes. + if "[reveal_type]" in line or "Revealed type is " in line: + continue + match = re.match(r"^.+?:(\d+)(?::\d+)?:\s", line) + if not match: + continue + line_to_errors.setdefault(int(match.group(1)), []).append(line) return line_to_errors TYPE_CHECKERS: Sequence[TypeChecker] = ( MypyTypeChecker(), PyrightTypeChecker(), - PyreTypeChecker(), - PytypeTypeChecker(), + ZubanLSTypeChecker(), + PyreflyTypeChecker(), + PycroscopeTypeChecker(), + TyTypeChecker(), ) diff --git a/conformance/src/unexpected_fails.py b/conformance/src/unexpected_fails.py index 96ccf3770..0e8453b19 100644 --- a/conformance/src/unexpected_fails.py +++ b/conformance/src/unexpected_fails.py @@ -21,8 +21,11 @@ except Exception as e: raise Exception(f"Error decoding {file}") from e try: - previous_pass = info["conformant"] == "Pass" new_pass = info["conformance_automated"] == "Pass" + if new_pass and "conformant" not in info: + previous_pass = True + else: + previous_pass = info["conformant"] == "Pass" except KeyError as e: raise Exception(f"Missing key in {file}") from e if previous_pass != new_pass: diff --git a/conformance/src/validate_results.py b/conformance/src/validate_results.py new file mode 100644 index 000000000..5db7bff27 --- /dev/null +++ b/conformance/src/validate_results.py @@ -0,0 +1,105 @@ +""" +Validate invariants for conformance result files. +""" + +from pathlib import Path +import sys +import tomllib +from typing import Any + +ALLOWED_RESULT_KEYS = frozenset( + { + "conformance_automated", + "conformant", + "errors_diff", + "ignore_errors", + "notes", + "output", + } +) + + +def main() -> int: + results_dir = Path(__file__).resolve().parent.parent / "results" + issues: list[str] = [] + checked = 0 + + for type_checker_dir in sorted(results_dir.iterdir()): + if not type_checker_dir.is_dir(): + continue + for file in sorted(type_checker_dir.iterdir()): + if file.name == "version.toml": + continue + checked += 1 + try: + with file.open("rb") as f: + info = tomllib.load(f) + except Exception as e: + issues.append(f"{file.relative_to(results_dir)}: failed to parse TOML ({e})") + continue + + issues.extend(_validate_result(file, results_dir, info)) + + if issues: + print(f"Found {len(issues)} invariant violation(s) across {checked} file(s):") + for issue in issues: + print(f"- {issue}") + return 1 + + print(f"Validated {checked} conformance result file(s); no invariant violations found.") + return 0 + + +def _validate_result(file: Path, results_dir: Path, info: dict[str, Any]) -> list[str]: + issues: list[str] = [] + rel_path = file.relative_to(results_dir) + + unknown_keys = sorted(set(info) - ALLOWED_RESULT_KEYS) + if unknown_keys: + issues.append( + f"{rel_path}: unrecognized key(s): {', '.join(repr(key) for key in unknown_keys)}" + ) + + automated = info.get("conformance_automated") + if automated not in {"Pass", "Fail"}: + issues.append( + f"{rel_path}: conformance_automated must be 'Pass' or 'Fail' (got {automated!r})" + ) + return issues + automated_is_pass = automated == "Pass" + + conformant = info.get("conformant") + if conformant is None: + if automated_is_pass: + conformant_is_pass = True + else: + issues.append( + f"{rel_path}: conformant is required when conformance_automated is 'Fail'" + ) + return issues + elif isinstance(conformant, str): + if conformant not in ("Pass", "Partial", "Unsupported"): + issues.append(f"{rel_path}: invalid conformance status {conformant!r}") + conformant_is_pass = conformant == "Pass" + else: + issues.append(f"{rel_path}: conformant must be a string when present") + return issues + + if conformant_is_pass != automated_is_pass: + issues.append( + f"{rel_path}: conformant={conformant!r} does not match " + f"conformance_automated={automated!r}" + ) + + if conformant == "Partial": + notes = info.get("notes", "") + if not isinstance(notes, str) or not notes.strip(): + issues.append( + f"{rel_path}: notes must be present when checker is not fully conformant" + ) + + return issues + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/conformance/tests/_directives_deprecated_library.py b/conformance/tests/_directives_deprecated_library.py new file mode 100644 index 000000000..454f5d69e --- /dev/null +++ b/conformance/tests/_directives_deprecated_library.py @@ -0,0 +1,51 @@ +""" +Support module for directive_deprecated. +""" + +from typing import Self, overload +from typing_extensions import deprecated + + +@deprecated("Use Spam instead") +class Ham: + ... + + +@deprecated("It is pining for the fjords") +def norwegian_blue(x: int) -> int: + ... + + +@overload +@deprecated("Only str will be allowed") +def foo(x: int) -> str: + ... + + +@overload +def foo(x: str) -> str: + ... + + +def foo(x: int | str) -> str: + ... + + +class Spam: + @deprecated("There is enough spam in the world") + def __add__(self, other: object) -> Self: + ... + + @property + @deprecated("All spam will be equally greasy") + def greasy(self) -> float: + ... + + @property + def shape(self) -> str: + ... + + @shape.setter + @deprecated("Shapes are becoming immutable") + def shape(self, value: str) -> None: + ... diff --git a/conformance/tests/_enums_member_values.py b/conformance/tests/_enums_member_values.py new file mode 100644 index 000000000..c51259fe9 --- /dev/null +++ b/conformance/tests/_enums_member_values.py @@ -0,0 +1,3 @@ +""" +Dummy implementation _enums_member_values stub. +""" diff --git a/conformance/tests/_enums_member_values.pyi b/conformance/tests/_enums_member_values.pyi new file mode 100644 index 000000000..4778f266f --- /dev/null +++ b/conformance/tests/_enums_member_values.pyi @@ -0,0 +1,15 @@ +""" +Support stub file for enums_member_values test. +""" + +from enum import Enum + +# > If the literal values for enum members are not supplied, as they sometimes +# > are not within a type stub file, a type checker can use the type of the +# > _value_ attribute. + +class ColumnType(Enum): + _value_: int + DORIC = ... + IONIC = ... + CORINTHIAN = ... diff --git a/conformance/tests/_enums_members.py b/conformance/tests/_enums_members.py new file mode 100644 index 000000000..3a6d43227 --- /dev/null +++ b/conformance/tests/_enums_members.py @@ -0,0 +1,3 @@ +""" +Dummy implementation for stub file for enums_members test. +""" diff --git a/conformance/tests/_enums_members.pyi b/conformance/tests/_enums_members.pyi new file mode 100644 index 000000000..73f3cdc56 --- /dev/null +++ b/conformance/tests/_enums_members.pyi @@ -0,0 +1,15 @@ +""" +Support stub file for enums_members test. +""" + +from enum import Enum + +# > Within a type stub, members can be defined using the actual runtime values, +# > or a placeholder of ... can be used + +class Pet2(Enum): + genus: str # Non-member attribute + species: str # Non-member attribute + + CAT = ... # Member attribute + DOG = ... # Member attribute diff --git a/conformance/tests/_protocols_modules1.py b/conformance/tests/_protocols_modules1.py index 14e4bdd57..ed8a55ed2 100644 --- a/conformance/tests/_protocols_modules1.py +++ b/conformance/tests/_protocols_modules1.py @@ -2,6 +2,6 @@ Support file for protocols_modules.py test. """ -timeout = 100 -one_flag = True -other_flag = False +timeout: int = 100 +one_flag: bool = True +other_flag: bool = False diff --git a/conformance/tests/_qualifiers_final_annotation_1.py b/conformance/tests/_qualifiers_final_annotation_1.py new file mode 100644 index 000000000..b2521b19c --- /dev/null +++ b/conformance/tests/_qualifiers_final_annotation_1.py @@ -0,0 +1,7 @@ +""" +Used as part of the test for the typing.Final special form. +""" + +from typing import Final + +TEN: Final[int] = 10 diff --git a/conformance/tests/_qualifiers_final_annotation_2.py b/conformance/tests/_qualifiers_final_annotation_2.py new file mode 100644 index 000000000..603d8bcb6 --- /dev/null +++ b/conformance/tests/_qualifiers_final_annotation_2.py @@ -0,0 +1,7 @@ +""" +Used as part of the test for the typing.Final special form. +""" + +from typing import Final + +PI: Final = 3.14 diff --git a/conformance/tests/aliases_newtype.py b/conformance/tests/aliases_newtype.py index 00add697e..58baeb8af 100644 --- a/conformance/tests/aliases_newtype.py +++ b/conformance/tests/aliases_newtype.py @@ -1,5 +1,5 @@ """ -Tests the `typing.NewType` function. +Tests the `typing.NewType` type constructor. """ # Specification: https://typing.readthedocs.io/en/latest/spec/aliases.html#newtype @@ -14,9 +14,12 @@ assert_type(UserId(5) + 1, int) -# > Both isinstance and issubclass, as well as subclassing will fail for -# > NewType('Derived', Base) since function objects don’t support these -# > operations. +# > NewType('Derived', Base) returns a dummy object +_: type = UserId # E: `NewType()` does not return an instance of `type` + +# > Both ``isinstance`` and ``issubclass``, as well as subclassing will fail +# > for ``NewType('Derived', Base)``, since the object returned by a call to +# > ``NewType`` is not a class. isinstance(u2, UserId) # E: not allowed in isinstance call diff --git a/conformance/tests/aliases_recursive.py b/conformance/tests/aliases_recursive.py index a5ff7ca92..b36eedf5e 100644 --- a/conformance/tests/aliases_recursive.py +++ b/conformance/tests/aliases_recursive.py @@ -36,7 +36,7 @@ def func1(j1: Json) -> Json2: t4: RecursiveTuple = (1, ("1", 1), "2") # OK t5: RecursiveTuple = (1, ("1", 1), (1, (1, 2))) # OK t6: RecursiveTuple = (1, ("1", 1), (1, (1, [2]))) # E -t6: RecursiveTuple = (1, [1]) # E +t7: RecursiveTuple = (1, [1]) # E RecursiveMapping = str | int | Mapping[str, "RecursiveMapping"] diff --git a/conformance/tests/aliases_type_statement.py b/conformance/tests/aliases_type_statement.py index 23fe137cb..2cca5bfce 100644 --- a/conformance/tests/aliases_type_statement.py +++ b/conformance/tests/aliases_type_statement.py @@ -48,17 +48,6 @@ def func2(x: object): type BadTypeAlias12 = list or set # E type BadTypeAlias13 = f"{'int'}" # E -if 1 < 2: - type BadTypeAlias14 = int # E: redeclared -else: - type BadTypeAlias14 = int - - -def func3(): - type BadTypeAlias15 = int # E: alias not allowed in function - - - V = TypeVar("V") type TA1[K] = dict[K, V] # E: combines old and new TypeVars @@ -87,5 +76,5 @@ def func3(): type RecursiveTypeAlias5[T] = T | list[RecursiveTypeAlias5[T]] -type RecursiveTypeAlias6 = RecursiveTypeAlias7 # E: circular definition -type RecursiveTypeAlias7 = RecursiveTypeAlias6 +type RecursiveTypeAlias6 = RecursiveTypeAlias7 # E[RTA6+]: circular definition +type RecursiveTypeAlias7 = RecursiveTypeAlias6 # E[RTA6+]: circular definition diff --git a/conformance/tests/aliases_typealiastype.py b/conformance/tests/aliases_typealiastype.py index 644809d1f..d696bfdec 100644 --- a/conformance/tests/aliases_typealiastype.py +++ b/conformance/tests/aliases_typealiastype.py @@ -16,10 +16,10 @@ GoodAlias1 = TypeAliasType("GoodAlias1", int) GoodAlias2 = TypeAliasType("GoodAlias2", list[T], type_params=(T,)) GoodAlias3 = TypeAliasType("GoodAlias3", list[T] | list[S], type_params=(S, T)) -GoodAlias4 = TypeAliasType("GoodAlias4", T | list[GoodAlias4[T]], type_params=(T,)) +GoodAlias4 = TypeAliasType("GoodAlias4", T | "list[GoodAlias4[T]]", type_params=(T,)) GoodAlias5 = TypeAliasType( "GoodAlias5", - Callable[P, TStr] | list[S] | list[GoodAlias5[S, TStr, P]] | tuple[*Ts], + Callable[P, TStr] | list[S] | list["GoodAlias5[S, TStr, P]"] | tuple[*Ts], type_params=(S, TStr, P, Ts), ) @@ -43,9 +43,9 @@ class ClassA(Generic[T]): BadAlias1 = TypeAliasType("BadAlias1", list[S], type_params=(T,)) # E: S not in scope BadAlias2 = TypeAliasType("BadAlias2", list[S]) # E: S not in scope BadAlias3 = TypeAliasType("BadAlias3", int, type_params=my_tuple) # E: not literal tuple -BadAlias4 = TypeAliasType("BadAlias4", BadAlias4) # E: circular dependency -BadAlias5 = TypeAliasType("BadAlias5", T | BadAlias5[str], type_params=(T,)) # E: circular dependency -BadAlias6 = TypeAliasType("BadAlias6", BadAlias7) # E: circular dependency +BadAlias4 = TypeAliasType("BadAlias4", "BadAlias4") # E: circular dependency +BadAlias5 = TypeAliasType("BadAlias5", T | "BadAlias5[str]", type_params=(T,)) # E: circular dependency +BadAlias6 = TypeAliasType("BadAlias6", "BadAlias7") # E: circular dependency BadAlias7 = TypeAliasType("BadAlias7", BadAlias6) # E?: circular dependency # The following are invalid type expressions for a type alias. @@ -62,3 +62,5 @@ class ClassA(Generic[T]): BadAlias18 = TypeAliasType("BadAlias18", 1) # E BadAlias19 = TypeAliasType("BadAlias19", list or set) # E BadAlias20 = TypeAliasType("BadAlias20", f"{'int'}") # E + +BadAlias21 = TypeAliasType("BadAlias21", list[BadAlias21]) # E diff --git a/conformance/tests/annotations_coroutines.py b/conformance/tests/annotations_coroutines.py index b2200f6fe..d5b145f45 100644 --- a/conformance/tests/annotations_coroutines.py +++ b/conformance/tests/annotations_coroutines.py @@ -16,7 +16,10 @@ async def func1(ignored: int, /) -> str: return "spam" -assert_type(func1, Callable[[int], Coroutine[Any, Any, str]]) +# Don't use assert_type here because some type checkers infer +# the narrower type types.CoroutineType rather than typing.Coroutine +# in this case. +v1: Callable[[int], Coroutine[Any, Any, str]] = func1 async def func2() -> None: diff --git a/conformance/tests/annotations_forward_refs.py b/conformance/tests/annotations_forward_refs.py index b64a8e936..a3f69b9d3 100644 --- a/conformance/tests/annotations_forward_refs.py +++ b/conformance/tests/annotations_forward_refs.py @@ -19,8 +19,8 @@ def func1( assert_type(p4, list[ClassA | int]) -bad1: ClassA # E: Runtime error: requires quotes -bad2: list[ClassA] # E: Runtime error: requires quotes +bad1: ClassA # E?: Runtime error prior to 3.14: requires quotes +bad2: list[ClassA] # E?: Runtime error prior to 3.14: requires quotes bad3: "ClassA" | int # E: Runtime error bad4: int | "ClassA" # E: Runtime error @@ -38,7 +38,7 @@ class ClassA: # The following should all generate errors because they are not legal type # expressions, despite being enclosed in quotes. def invalid_annotations( - p1: "eval(" ".join(map(chr, [105, 110, 116])))", # E + p1: "eval(''.join(map(chr, [105, 110, 116])))", # E p2: "[int, str]", # E p3: "(int, str)", # E p4: "[int for i in range(1)]", # E @@ -57,13 +57,12 @@ def invalid_annotations( pass -# > It should evaluate without errors once the module has been fully loaded. -# > The local and global namespace in which it is evaluated should be the same -# > namespaces in which default arguments to the same function would be evaluated. - +# > Names within the expression are looked up in the same way as they would be +# > looked up at runtime in Python 3.14 and higher if the annotation was not +# > enclosed in a string literal. class ClassB: - def method1(self) -> ClassB: # E: Runtime error + def method1(self) -> ClassB: # E?: Runtime error prior to 3.14 return ClassB() def method2(self) -> "ClassB": # OK @@ -75,22 +74,60 @@ class ClassC: class ClassD: - ClassC: "ClassC" # OK + # OK + simple_attr: ClassA + ClassB: ClassB + ClassC: "ClassC" + bytes_direct: bytes + bytes: "bytes" + inner1: ClassInner # E?: Runtime error prior to 3.14: requires quotes + inner2: "ClassInner" + + class ClassInner: + ... + + inner_after1: ClassInner + inner_after2: "ClassInner" ClassF: "ClassF" # E: circular reference - str: "str" = "" # OK + str: "str" = "" # E: circular reference + + z: "int" = 0 # E: Refers to the local int function, which isn't a valid type def int(self) -> None: # OK ... - x: "int" = 0 # OK + y: int = 0 # E: Refers to the local int function, which isn't a valid type + + x: "int" = 0 # E: Refers to the local int function, which isn't a valid type + + def __init__(self) -> None: + self.ClassC = ClassC() + + +def check_valid_attributes(d: ClassD) -> None: + assert_type(d.bytes, bytes) + assert_type(d.inner1, ClassD.ClassInner) # E?: Runtime error prior to 3.14: requires quotes + assert_type(d.inner2, ClassD.ClassInner) + assert_type(d.inner_after1, ClassD.ClassInner) + assert_type(d.inner_after2, ClassD.ClassInner) + + +class T: + ... + + +class ClassE[T]: + def identity1(self, value: T) -> T: + return value - y: int = 0 # E: Refers to local int, which isn't a legal type expression + def identity2(self, value: "T") -> "T": + return value -assert_type(ClassD.str, str) -assert_type(ClassD.x, int) +assert_type(ClassE[int]().identity1(1), int) +assert_type(ClassE[int]().identity2(1), int) # > If a triple quote is used, the string should be parsed as though it is implicitly diff --git a/conformance/tests/annotations_future_import.py b/conformance/tests/annotations_future_import.py new file mode 100644 index 000000000..778a46925 --- /dev/null +++ b/conformance/tests/annotations_future_import.py @@ -0,0 +1,58 @@ +""" +Tests the handling name-resolution in annotations while from __future__ import +annotations is present. +""" + +from __future__ import annotations + +from typing import assert_type + +# > For purposes of type checking, annotations in a file containing from +# > __future__ import annotations must use the same name-resolution rules as +# > explicitly stringified annotations, regardless of the target Python version. + +forward1: ClassA +forward2: list[ClassA] +forward3: "ClassA" + + +class ClassA: + ... + + +class ClassB: + ClassA: ClassA + ClassC: ClassC + inner1: ClassInner + inner2: "ClassInner" + bytes_direct: bytes + bytes: bytes + + class ClassInner: + ... + + inner_after1: ClassInner + inner_after2: "ClassInner" + + str: str = "" # E: circular reference + + z: int = 0 # E: Refers to the local int function, which isn't a valid type + + def int(self) -> None: # OK + ... + + y: int = 0 # E: Refers to the local int function, which isn't a valid type + + x: "int" = 0 # E: Refers to the local int function, which isn't a valid type + + +class ClassC: + ... + + +def check_valid_attributes(b: ClassB) -> None: + assert_type(b.ClassC, ClassC) + assert_type(b.inner1, ClassB.ClassInner) + assert_type(b.inner2, ClassB.ClassInner) + assert_type(b.inner_after1, ClassB.ClassInner) + assert_type(b.inner_after2, ClassB.ClassInner) diff --git a/conformance/tests/annotations_generators.py b/conformance/tests/annotations_generators.py index 43d53c0e5..396b51978 100644 --- a/conformance/tests/annotations_generators.py +++ b/conformance/tests/annotations_generators.py @@ -84,12 +84,12 @@ def generator7() -> Iterator[dict[str, int]]: def generator8() -> int: # E: incompatible return type - yield None # E + yield None # E? return 0 async def generator9() -> int: # E: incompatible return type - yield None # E + yield None # E? class IntIterator(Protocol): @@ -179,12 +179,17 @@ async def generator29() -> AsyncIterator[int]: raise NotImplementedError -assert_type(generator29, Callable[[], Coroutine[Any, Any, AsyncIterator[int]]]) +# Don't use assert_type here because some type checkers infer +# the narrower type types.CoroutineType rather than typing.Coroutine +# in this case. +v1: Callable[[], Coroutine[Any, Any, AsyncIterator[int]]] = generator29 async def generator30() -> AsyncIterator[int]: raise NotImplementedError - yield + yield 1 -assert_type(generator30, Callable[[], AsyncIterator[int]]) +async def uses_generator30() -> None: + async for x in generator30(): + assert_type(x, int) diff --git a/conformance/tests/callables_annotation.py b/conformance/tests/callables_annotation.py index 35b98f5ee..8cf25c6ab 100644 --- a/conformance/tests/callables_annotation.py +++ b/conformance/tests/callables_annotation.py @@ -111,7 +111,7 @@ class Proto3(Protocol): def __call__(self, a: int, *args: Any, **kwargs: Any) -> None: ... -class Proto4(Protocol[P]): +class Proto4[**P](Protocol): def __call__(self, a: int, *args: P.args, **kwargs: P.kwargs) -> None: ... diff --git a/conformance/tests/callables_kwargs.py b/conformance/tests/callables_kwargs.py index d8138efed..a4c431dbd 100644 --- a/conformance/tests/callables_kwargs.py +++ b/conformance/tests/callables_kwargs.py @@ -48,7 +48,7 @@ def func3() -> None: td2 = TD2(v1=2, v3="4") func1(**td2) # OK - func1(v1=1, v2="", v3="5", v4=5) # E: v4 is not in TD2 + func1(v1=1, v2="", v3="5", v4=5) # E?: v4 is not in TD2, but could be in a subtype func1(1, "", "5") # E: args not passed by position # > Passing a dictionary of type dict[str, object] as a **kwargs argument @@ -121,3 +121,14 @@ def func5(v1: int, **kwargs: Unpack[TD2]) -> None: # E: parameter v1 overlaps w def func6(**kwargs: Unpack[T]) -> None: # E: unpacked value must be a TypedDict, not a TypeVar bound to TypedDict. ... + +# > The situation where the destination callable contains **kwargs: Unpack[TypedDict] and +# > the source callable doesn’t contain **kwargs should be disallowed. This is because, +# > we cannot be sure that additional keyword arguments are not being passed in when an instance of a subclass +# > had been assigned to a variable with a base class type and then unpacked in the destination callable invocation + +def func7(*, v1: int, v3: str, v2: str = "") -> None: + ... + + +v7: TDProtocol6 = func7 # E: source does not have kwargs diff --git a/conformance/tests/callables_protocol.py b/conformance/tests/callables_protocol.py index c9c8cdf05..3b05d10ca 100644 --- a/conformance/tests/callables_protocol.py +++ b/conformance/tests/callables_protocol.py @@ -173,7 +173,7 @@ def cb8_bad1(x: int) -> Any: R = TypeVar("R", covariant=True) -class Proto9(Protocol[P, R]): +class Proto9[**P, R](Protocol): other_attribute: int def __call__(self, *args: P.args, **kwargs: P.kwargs) -> R: @@ -222,15 +222,15 @@ def __call__(self, x: int, /, y: str) -> Any: def cb11_good1(x: int, /, y: str, z: None = None) -> Any: - pass + raise NotImplementedError def cb11_good2(x: int, y: str, z: None = None) -> Any: - pass + raise NotImplementedError def cb11_bad1(x: int, y: str, /) -> Any: - pass + raise NotImplementedError cb11: Proto11 = cb11_good1 # OK diff --git a/conformance/tests/callables_subtyping.py b/conformance/tests/callables_subtyping.py index 0451d6289..9cecc843e 100644 --- a/conformance/tests/callables_subtyping.py +++ b/conformance/tests/callables_subtyping.py @@ -201,7 +201,7 @@ def func6( # > to a Callable parameterized by P. -class ProtocolWithP(Protocol[P]): +class ProtocolWithP[**P](Protocol): def __call__(self, *args: P.args, **kwargs: P.kwargs) -> None: ... diff --git a/conformance/tests/classes_classvar.py b/conformance/tests/classes_classvar.py index 234a3d5a5..5f0ca9241 100644 --- a/conformance/tests/classes_classvar.py +++ b/conformance/tests/classes_classvar.py @@ -11,12 +11,15 @@ ClassVar, Final, Generic, + NamedTuple, ParamSpec, Protocol, TypeAlias, TypeVar, TypeVarTuple, + TypedDict, assert_type, + cast, ) from typing import ClassVar as CV @@ -34,16 +37,16 @@ class ClassA(Generic[T, P]): # > ClassVar accepts only a single argument that should be a valid type - bad1: ClassVar[int, str] # E: too many arguments - bad2: CV[3] # E: invalid type - bad3: CV[var] # E: invalid type + bad1: ClassVar[int, str] = cast(Any, 0) # E: too many arguments + bad2: CV[3] = cast(Any, 0) # E: invalid type + bad3: CV[var] = cast(Any, 0) # E: invalid type # > Note that a ClassVar parameter cannot include any type variables, # > regardless of the level of nesting. - bad4: ClassVar[T] # E: cannot use TypeVar - bad5: ClassVar[list[T]] # E: cannot use TypeVar - bad6: ClassVar[Callable[P, Any]] # E: cannot use ParamSpec + bad4: ClassVar[T] = cast(Any, 0) # E: cannot use TypeVar + bad5: ClassVar[list[T]] = cast(Any, 0) # E: cannot use TypeVar + bad6: ClassVar[Callable[P, Any]] = cast(Any, 0) # E: cannot use ParamSpec # This is currently commented out because it causes mypy to crash. # bad7: ClassVar[tuple[*Ts]] # E: cannot use TypeVarTuple @@ -56,8 +59,14 @@ class ClassA(Generic[T, P]): good1: CV[int] = 1 good2: ClassVar[list[str]] = [] good3: ClassVar[Any] = 1 + # > If an assigned value is available, the type should be inferred as some type + # > to which this value is assignable. + # Here, type checkers could infer good4 as `float` or `Any`, for example. good4: ClassVar = 3.1 - good5: Annotated[ClassVar[list[int]], ""] = [] + # > If the `ClassVar` qualifier is used without any assigned value, the type + # > should be inferred as `Any`: + good5: ClassVar # E?: Type checkers may error on uninitialized ClassVar + good6: Annotated[ClassVar[list[int]], ""] = [] def method1(self, a: ClassVar[int]): # E: ClassVar not allowed here x: ClassVar[str] = "" # E: ClassVar not allowed here @@ -71,10 +80,24 @@ def method2(self) -> ClassVar[int]: # E: ClassVar not allowed here bad12: TypeAlias = ClassVar[str] # E: ClassVar not allowed here +# > ``ClassVar`` cannot be used as a qualifier for a TypedDict item or a +# > NamedTuple field. Such usage also generates an error at runtime. + + +class TDWithClassVar(TypedDict): + a: int + b: ClassVar[int] # E: ClassVar not allowed in a TypedDict + + +class NTWithClassVar(NamedTuple): + a: int + b: ClassVar[int] # E: ClassVar not allowed in a NamedTuple + + assert_type(ClassA.good1, int) assert_type(ClassA.good2, list[str]) assert_type(ClassA.good3, Any) -assert_type(ClassA.good4, float) +assert_type(ClassA.good5, Any) class BasicStarship: @@ -82,6 +105,9 @@ class BasicStarship: damage: int # Instance variable without default stats: ClassVar[dict[str, int]] = {} # Class variable + def __init__(self, damage: int) -> None: + self.damage = damage + class Starship: captain: str = "Picard" diff --git a/conformance/tests/classes_override.py b/conformance/tests/classes_override.py index 8565ad738..0bbf5eacd 100644 --- a/conformance/tests/classes_override.py +++ b/conformance/tests/classes_override.py @@ -49,19 +49,19 @@ def method2(self, x: str) -> str: def method2(self, x: int | str) -> int | str: # OK return 0 - @override - def method3(self) -> int: # E: no matching signature in ancestor + @override # E[method3] + def method3(self) -> int: # E[method3]: no matching signature in ancestor return 1 @overload # E[method4] - def method4(self, x: int) -> int: + def method4(self, x: int) -> int: # E[method4] ... @overload def method4(self, x: str) -> str: ... - @override + @override # E[method4] def method4(self, x: int | str) -> int | str: # E[method4]: no matching signature in ancestor return 0 @@ -75,18 +75,18 @@ def method5(self): # OK # > only normal methods but also @property, @staticmethod, and @classmethod. @staticmethod - @override - def static_method1() -> int: # E: no matching signature in ancestor + @override # E[static_method1] + def static_method1() -> int: # E[static_method1]: no matching signature in ancestor return 1 @classmethod - @override - def class_method1(cls) -> int: # E: no matching signature in ancestor + @override # E[class_method1] + def class_method1(cls) -> int: # E[class_method1]: no matching signature in ancestor return 1 @property - @override - def property1(self) -> int: # E: no matching signature in ancestor + @override # E[property1] + def property1(self) -> int: # E[property1]: no matching signature in ancestor return 1 @@ -100,3 +100,51 @@ class ChildB(ParentB): @override def method1(self) -> None: # OK pass + + +# > When type checkers encounter a method decorated with @typing.override they +# > should treat it as a type error unless that method is overriding a method or +# > attribute in some ancestor class, and the type of the overriding method is +# > assignable to the type of the overridden method. + +# ``__init__`` and ``__new__`` are normally exempt from override compatibility +# checks, since constructors are not subject to the Liskov substitution +# principle. However, when they are explicitly decorated with ``@override`` the +# decorator's assignability check should still be honored. +# See https://github.com/python/typing/issues/2222 + + +class ParentC: + def __init__(self, x: int) -> None: ... + + def __new__(cls, x: int) -> "ParentC": + raise NotImplementedError + + +class ChildC1(ParentC): + @override + def __init__(self, x: int) -> None: ... # OK + + @override + def __new__(cls, x: int) -> "ChildC1": # OK + raise NotImplementedError + + +class ChildC2(ParentC): + @override # E[init] + def __init__(self, x: str) -> None: ... # E[init]: not assignable to "ParentC.__init__" + + @override # E[new] + def __new__(cls, x: str) -> "ChildC2": # E[new]: not assignable to "ParentC.__new__" + raise NotImplementedError + + +# Without ``@override`` an incompatible constructor signature is allowed, since +# ``__init__`` and ``__new__`` are exempt from the usual override checks. + + +class ChildC3(ParentC): + def __init__(self, x: str) -> None: ... # OK + + def __new__(cls, x: str) -> "ChildC3": # OK + raise NotImplementedError diff --git a/conformance/tests/constructors_call_metaclass.py b/conformance/tests/constructors_call_metaclass.py index fa35bdf18..0a3a9df7a 100644 --- a/conformance/tests/constructors_call_metaclass.py +++ b/conformance/tests/constructors_call_metaclass.py @@ -20,7 +20,10 @@ def __new__(cls, x: int) -> Self: return super().__new__(cls) -assert_type(Class1(), NoReturn) +# This needs to be in a separate scope, because some type checkers might mark +# the statements after it as unreachable. +if bool(): + assert_type(Class1(), NoReturn) class Meta2(type): @@ -40,7 +43,7 @@ def __new__(cls, x: int) -> Self: class Meta3(type): def __call__(cls: type[T], *args, **kwargs) -> T: - return super().__call__(cls, *args, **kwargs) + return type.__call__(cls, *args, **kwargs) class Class3(metaclass=Meta3): @@ -54,7 +57,7 @@ def __new__(cls, x: int) -> Self: class Meta4(type): def __call__(cls, *args, **kwargs): - return super().__call__(cls, *args, **kwargs) + return type.__call__(cls, *args, **kwargs) class Class4(metaclass=Meta4): diff --git a/conformance/tests/constructors_call_new.py b/conformance/tests/constructors_call_new.py index 889fcec41..48275c331 100644 --- a/conformance/tests/constructors_call_new.py +++ b/conformance/tests/constructors_call_new.py @@ -110,7 +110,8 @@ def __init__(self, x: int): class Class8(Generic[T]): - def __new__(cls, *args, **kwargs) -> "Class8[list[T]]": ... + def __new__(cls, *args, **kwargs) -> "Class8[list[T]]": + raise NotImplementedError assert_type(Class8[int](), Class8[list[int]]) @@ -122,7 +123,8 @@ def __new__(cls, *args, **kwargs) -> "Class8[list[T]]": ... class Class9(Generic[T]): - def __new__(cls, *args, **kwargs) -> Self: ... + def __new__(cls, *args, **kwargs) -> Self: + raise NotImplementedError class Class10(Class9[int]): @@ -137,7 +139,8 @@ class Class10(Class9[int]): class Class11(Generic[T]): - def __new__(cls: "type[Class11[int]]") -> "Class11[int]": ... + def __new__(cls: "type[Class11[int]]") -> "Class11[int]": + raise NotImplementedError Class11() # OK diff --git a/conformance/tests/constructors_callable.py b/conformance/tests/constructors_callable.py index d50f93c3b..0ec091e2d 100644 --- a/conformance/tests/constructors_callable.py +++ b/conformance/tests/constructors_callable.py @@ -54,7 +54,8 @@ class Class2: class Class3: """__new__ and __init__""" - def __new__(cls, *args, **kwargs) -> Self: ... + def __new__(cls, *args, **kwargs) -> Self: + raise NotImplementedError def __init__(self, x: int) -> None: ... @@ -70,7 +71,8 @@ def __init__(self, x: int) -> None: ... class Class4: """__new__ but no __init__""" - def __new__(cls, x: int) -> int: ... + def __new__(cls, x: int) -> int: + raise NotImplementedError r4 = accepts_callable(Class4) @@ -114,7 +116,7 @@ class Class6: """__new__ that causes __init__ to be ignored""" def __new__(cls) -> Class6Proxy: - return Class6Proxy.__new__(cls) + return Class6Proxy() def __init__(self, x: int) -> None: """This __init__ is ignored for purposes of conversion""" @@ -179,9 +181,10 @@ def __new__(cls, x: list[T], y: list[T]) -> Self: r8 = accepts_callable(Class8) -reveal_type(r8) # `def [T] (x: T, y: list[T]) -> Class8[T]` +reveal_type(r8) # `def [T] (x: list[T], y: list[T]) -> Class8[T]` +r8([""], "not a list") # E: no assignment of T makes the second argument valid assert_type(r8([""], [""]), Class8[str]) -r8([1], [""]) # E +r8([1], [""]) # E?: T = int | str is a potential solution class Class9: @@ -191,5 +194,6 @@ def __init__(self, x: list[T], y: list[T]) -> None: r9 = accepts_callable(Class9) reveal_type(r9) # `def [T] (x: list[T], y: list[T]) -> Class9` +r9([""], "not a list") # E: no assignment of T makes the second argument valid assert_type(r9([""], [""]), Class9) -r9([1], [""]) # E +r9([1], [""]) # E?: T = int | str is a potential solution diff --git a/conformance/tests/dataclasses_descriptors.py b/conformance/tests/dataclasses_descriptors.py index 37dd1b36a..f2f30a623 100644 --- a/conformance/tests/dataclasses_descriptors.py +++ b/conformance/tests/dataclasses_descriptors.py @@ -21,7 +21,7 @@ def __get__(self, __obj: object, __owner: Any) -> int: ... def __get__(self, __obj: object | None, __owner: Any) -> "int | Desc1": - ... + raise NotImplementedError def __set__(self, __obj: object, __value: int) -> None: ... @@ -48,7 +48,7 @@ def __get__(self, instance: object, owner: Any) -> T: ... def __get__(self, instance: object | None, owner: Any) -> list[T] | T: - ... + raise NotImplementedError @dataclass diff --git a/conformance/tests/dataclasses_hash.py b/conformance/tests/dataclasses_hash.py index 7a5e68842..f2d441d68 100644 --- a/conformance/tests/dataclasses_hash.py +++ b/conformance/tests/dataclasses_hash.py @@ -3,7 +3,7 @@ """ from dataclasses import dataclass -from typing import Hashable +from typing import Callable, Hashable, assert_type @dataclass @@ -11,7 +11,10 @@ class DC1: a: int -# This should generate an error because DC1 isn't hashable. +assert_type(DC1.__hash__, None) + +# These should generate errors because DC1 isn't hashable. +DC1(0).__hash__() # E v1: Hashable = DC1(0) # E @@ -20,7 +23,9 @@ class DC2: a: int -v2: Hashable = DC2(0) +dc2_hash: Callable[..., int] = DC2.__hash__ # OK +DC2(0).__hash__() # OK +v2: Hashable = DC2(0) # OK @dataclass(eq=True) @@ -28,7 +33,10 @@ class DC3: a: int -# This should generate an error because DC3 isn't hashable. +assert_type(DC3.__hash__, None) + +# These should generate errors because DC3 isn't hashable. +DC3(0).__hash__() # E v3: Hashable = DC3(0) # E @@ -37,7 +45,9 @@ class DC4: a: int -v4: Hashable = DC4(0) +dc4_hash: Callable[..., int] = DC4.__hash__ # OK +DC4(0).__hash__() # OK +v4: Hashable = DC4(0) # OK @dataclass(eq=True, unsafe_hash=True) @@ -45,7 +55,9 @@ class DC5: a: int -v5: Hashable = DC5(0) +dc5_hash: Callable[..., int] = DC5.__hash__ # OK +DC5(0).__hash__() # OK +v5: Hashable = DC5(0) # OK @dataclass(eq=True) @@ -56,7 +68,9 @@ def __hash__(self) -> int: return 0 -v6: Hashable = DC6(0) +dc6_hash: Callable[..., int] = DC6.__hash__ # OK +DC6(0).__hash__() # OK +v6: Hashable = DC6(0) # OK @dataclass(frozen=True) @@ -67,4 +81,6 @@ def __eq__(self, other) -> bool: return self.a == other.a -v7: Hashable = DC7(0) +dc7_hash: Callable[..., int] = DC7.__hash__ # OK +DC7(0).__hash__() # OK +v7: Hashable = DC7(0) # OK diff --git a/conformance/tests/dataclasses_inheritance.py b/conformance/tests/dataclasses_inheritance.py index 7468e379c..3ed0b88db 100644 --- a/conformance/tests/dataclasses_inheritance.py +++ b/conformance/tests/dataclasses_inheritance.py @@ -42,9 +42,11 @@ class DC4(DC3): @dataclass class DC5: - # This should generate an error because a default value of - # type list, dict, or set generate a runtime error. - x: list[int] = [] + # While this generates an error at runtime for the stdlib dataclass, + # other libraries that use dataclass_transform don't have similar + # restrictions. It is therefore not required that a type checker + # report an error here. + x: list[int] = [] # E? @dataclass diff --git a/conformance/tests/dataclasses_match_args.py b/conformance/tests/dataclasses_match_args.py new file mode 100644 index 000000000..6593fa205 --- /dev/null +++ b/conformance/tests/dataclasses_match_args.py @@ -0,0 +1,49 @@ +""" +Tests the match_args feature of dataclass added in Python 3.10. +""" + +# Specification: https://docs.python.org/3/library/dataclasses.html#module-contents + +from dataclasses import dataclass, KW_ONLY +from typing import assert_type, Literal + +# If true, the __match_args__ tuple will be created from the list of non keyword-only parameters to the generated __init__() method + +@dataclass(match_args=True) +class DC1: + x: int + _: KW_ONLY + y: str + +assert_type(DC1.__match_args__, tuple[Literal['x']]) + +# The match_args default is True + +@dataclass +class DC2: + x: int + +assert_type(DC2.__match_args__, tuple[Literal['x']]) + +# __match_args__ is created even if __init__() is not generated + +@dataclass(match_args=True, init=False) +class DC3: + x: int = 0 + +assert_type(DC3.__match_args__, tuple[Literal['x']]) + +# If false, or if __match_args__ is already defined in the class, then __match_args__ will not be generated. + +@dataclass(match_args=False) +class DC4: + x: int + +DC4.__match_args__ # E + +@dataclass(match_args=True) +class DC5: + __match_args__ = () + x: int + +assert_type(DC5.__match_args__, tuple[()]) diff --git a/conformance/tests/dataclasses_transform_class.py b/conformance/tests/dataclasses_transform_class.py index bb33fbd0c..da7ab82d4 100644 --- a/conformance/tests/dataclasses_transform_class.py +++ b/conformance/tests/dataclasses_transform_class.py @@ -17,7 +17,7 @@ def __init__(self, *, init: bool = True, default: Any | None = None) -> None: def model_field( *, init: bool = True, default: Any | None = None, alias: str | None = None ) -> Any: - ... + raise NotImplementedError @dataclass_transform( @@ -36,6 +36,9 @@ def __init_subclass__( ) -> None: ... + def __init__(self, not_a_field: str) -> None: + self.not_a_field = not_a_field + class Customer1(ModelBase, frozen=True): id: int = model_field() diff --git a/conformance/tests/dataclasses_transform_converter.py b/conformance/tests/dataclasses_transform_converter.py new file mode 100644 index 000000000..0a54584ea --- /dev/null +++ b/conformance/tests/dataclasses_transform_converter.py @@ -0,0 +1,133 @@ +""" +Tests the dataclass_transform mechanism supports the "converter" parameter +in a field specifier class. +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/dataclasses.html#converters + +from typing import ( + Any, + Callable, + TypeVar, + dataclass_transform, + overload, +) + +T = TypeVar("T") +S = TypeVar("S") + + +def model_field( + *, + converter: Callable[[S], T], + default: S | None = None, + default_factory: Callable[[], S] | None = None, +) -> T: + raise NotImplementedError + + +@dataclass_transform(field_specifiers=(model_field,)) +class ModelBase: + ... + + +# > The converter must be a callable that must accept a single positional +# > argument (but may accept other optional arguments, which are ignored for +# > typing purposes). + + +def bad_converter1() -> int: + return 0 + + +def bad_converter2(*, x: int) -> int: + return 0 + + +class DC1(ModelBase): + field1: int = model_field(converter=bad_converter1) # E + field2: int = model_field(converter=bad_converter2) # E + + +# > The type of the first positional parameter provides the type of the +# > synthesized __init__ parameter for the field. + +# > The return type of the callable must be assignable to the field’s +# > declared type. + + +def converter_simple(s: str) -> int: + return int(s) + + +def converter_with_param_before_args(s: str, *args: int, **kwargs: int) -> int: + return int(s) + + +def converter_with_args(*args: str) -> int: + return int(args[0]) + + +@overload +def overloaded_converter(s: str) -> int: + ... + + +@overload +def overloaded_converter(s: list[str]) -> int: + ... + + +def overloaded_converter(s: str | list[str], *args: str) -> int | str: + return 0 + + +class ConverterClass: + @overload + def __init__(self, val: str) -> None: + ... + + @overload + def __init__(self, val: bytes) -> None: + ... + + def __init__(self, val: str | bytes) -> None: + pass + + +class DC2(ModelBase): + field0: int = model_field(converter=converter_simple) + field1: int = model_field(converter=converter_with_param_before_args) + field2: int = model_field(converter=converter_with_args) + field3: ConverterClass = model_field(converter=ConverterClass) + field4: int = model_field(converter=overloaded_converter) + field5: dict[str, str] = model_field(converter=dict, default=()) + + +DC2(1, "f1", "f2", b"f3", []) # E +DC2("f0", "f1", "f2", 1, []) # E +DC2("f0", "f1", "f2", "f3", 3j) # E + + +dc1 = DC2("f0", "f1", "f2", b"f6", []) + +dc1.field0 = "f1" +dc1.field3 = "f6" +dc1.field3 = b"f6" + +dc1.field0 = 1 # E +dc1.field3 = 1 # E + +dc2 = DC2("f0", "f1", "f2", "f6", "1", (("a", "1"), ("b", "2"))) + + +# > If default or default_factory are provided, the type of the default value +# > should be assignable to the first positional parameter of the converter. + + +class DC3(ModelBase): + field0: int = model_field(converter=converter_simple, default="") + field1: int = model_field(converter=converter_simple, default=1) # E + + field2: int = model_field(converter=converter_simple, default_factory=str) + field3: int = model_field(converter=converter_simple, default_factory=int) # E diff --git a/conformance/tests/dataclasses_transform_field.py b/conformance/tests/dataclasses_transform_field.py index d66bdf9e0..14df5677e 100644 --- a/conformance/tests/dataclasses_transform_field.py +++ b/conformance/tests/dataclasses_transform_field.py @@ -42,12 +42,12 @@ def field1( def field2(*, init: bool = False, kw_only: bool = True) -> Any: - ... + raise NotImplementedError @dataclass_transform(kw_only_default=True, field_specifiers=(field1, field2)) def create_model(*, init: bool = True) -> Callable[[type[T]], type[T]]: - ... + raise NotImplementedError @create_model() diff --git a/conformance/tests/dataclasses_transform_func.py b/conformance/tests/dataclasses_transform_func.py index c93cf4c00..bdff17c82 100644 --- a/conformance/tests/dataclasses_transform_func.py +++ b/conformance/tests/dataclasses_transform_func.py @@ -16,7 +16,6 @@ def create_model(cls: T) -> T: @overload -@dataclass_transform(kw_only_default=True, order_default=True) def create_model( *, frozen: bool = False, @@ -27,7 +26,7 @@ def create_model( def create_model(*args: Any, **kwargs: Any) -> Any: - ... + raise NotImplementedError @create_model(kw_only=False, order=False) @@ -75,7 +74,7 @@ class Customer2Subclass(Customer2): @dataclass_transform(kw_only_default=True, order_default=True, frozen_default=True) def create_model_frozen(cls: T) -> T: - ... + raise NotImplementedError @create_model_frozen diff --git a/conformance/tests/dataclasses_transform_meta.py b/conformance/tests/dataclasses_transform_meta.py index 4414ce725..cf33df87d 100644 --- a/conformance/tests/dataclasses_transform_meta.py +++ b/conformance/tests/dataclasses_transform_meta.py @@ -15,7 +15,7 @@ def __init__(self, *, init: bool = True, default: Any | None = None) -> None: def model_field( *, init: bool = True, default: Any | None = None, alias: str | None = None ) -> Any: - ... + raise NotImplementedError @dataclass_transform( @@ -25,6 +25,9 @@ def model_field( class ModelMeta(type): not_a_field: str + def __init__(self, *args, **kwargs) -> None: + self.not_a_field: str = "not a field" + class ModelBase(metaclass=ModelMeta): def __init_subclass__( diff --git a/conformance/tests/dataclasses_usage.py b/conformance/tests/dataclasses_usage.py index 4338cfa02..6e9c0e6bd 100644 --- a/conformance/tests/dataclasses_usage.py +++ b/conformance/tests/dataclasses_usage.py @@ -7,6 +7,7 @@ from dataclasses import InitVar, dataclass, field from typing import Any, Callable, ClassVar, Generic, Protocol, TypeVar, assert_type +import sys T = TypeVar("T") @@ -57,19 +58,19 @@ def __call__( # > single class, or as a result of class inheritance. @dataclass # E[DC1] class DC1: - a: int = 0 + a: int = 0 # E[DC1]: field with default should follow a field with no default. b: int # E[DC1]: field with no default cannot follow field with default. @dataclass # E[DC2] class DC2: - a: int = field(default=1) + a: int = field(default=1) # E[DC2]: field with default should follow a field with no default. b: int # E[DC2]: field with no default cannot follow field with default. @dataclass # E[DC3] class DC3: - a: InitVar[int] = 0 + a: InitVar[int] = 0 # E[DC3]: field with default should follow a field with no default. b: int # E[DC3]: field with no default cannot follow field with default. @@ -117,6 +118,7 @@ class DC8(DC7): def __init__(self, a: DC7, y: int): self.__dict__ = a.__dict__ + self.y = y a = DC7(3) @@ -173,7 +175,7 @@ class DC13: x_squared: int -# This should generate an error because there is no +# This should generate an error because there is no matching # override __init__ method and no synthesized __init__. DC13(3) # E @@ -225,3 +227,20 @@ class DC18: # This may generate a type checker error because an unannotated field # will result in a runtime exception. y = field() # E? + + +# > Dataclass fields may be conditional, via checks of the same +# > statically-known conditions that a type-checker understands elsewhere, +# > such as Python version: + +@dataclass +class DC19: + x: int + if sys.version_info >= (3, 12): + y: int + if sys.version_info >= (4, 0): + z: int + +# The conformance suite runs type checkers configured to Python 3.12 or later: +DC19(1, 2) +DC19(1, 2, 3) # E diff --git a/conformance/tests/directives_assert_type.py b/conformance/tests/directives_assert_type.py index b5a337378..900529b12 100644 --- a/conformance/tests/directives_assert_type.py +++ b/conformance/tests/directives_assert_type.py @@ -25,6 +25,7 @@ def func1( assert_type(e, Literal[4]) # OK assert_type(a, int) # E: Type mismatch + assert_type(a, Any) # E: Type mismatch assert_type(c, int) # E: Type mismatch assert_type(e, int) # E: Type mismatch @@ -33,5 +34,12 @@ def func1( assert_type(a, int | str, a) # E: too many arguments +# > If the two types are :term:`equivalent` but syntactically different, +# > the type checker may reject the ``assert_type()`` call:: + +def func2(name: str): + assert_type(name, str | Literal["spam"]) # E?: Equivalent but not identical + + class ForwardReference: pass diff --git a/conformance/tests/directives_deprecated.py b/conformance/tests/directives_deprecated.py new file mode 100644 index 000000000..e56b470c4 --- /dev/null +++ b/conformance/tests/directives_deprecated.py @@ -0,0 +1,120 @@ +""" +Tests the warnings.deprecated function. +""" + +# pyright: reportDeprecated=true + +# Specification: https://typing.readthedocs.io/en/latest/spec/directives.html#deprecated +# See also https://peps.python.org/pep-0702/ + +from typing import Protocol, override +from typing_extensions import deprecated + +# > Type checkers should produce a diagnostic whenever they encounter a usage of an object +# > marked as deprecated. [...] For deprecated classes and functions, this includes: + +# > * `from` imports + +from _directives_deprecated_library import Ham # E: Use of deprecated class Ham +import _directives_deprecated_library as library + + +# > * References through module, class, or instance attributes + +library.norwegian_blue(1) # E: Use of deprecated function norwegian_blue +map(library.norwegian_blue, [1, 2, 3]) # E: Use of deprecated function norwegian_blue + + +# > For deprecated overloads, this includes all calls that resolve to the deprecated overload. + +library.foo(1) # E: Use of deprecated overload for foo +library.foo("x") # OK + + +ham = Ham() # E?: OK (already reported above) + + +# > * Any syntax that indirectly triggers a call to the function. + +spam = library.Spam() + +_ = spam + 1 # E: Use of deprecated method Spam.__add__ +spam += 1 # E: Use of deprecated method Spam.__add__ + +spam.greasy # E: Use of deprecated property Spam.greasy +spam.shape # OK + +spam.shape = "cube" # E: Use of deprecated property setter Spam.shape +spam.shape += "cube" # E: Use of deprecated property setter Spam.shape + + +class Invocable: + @deprecated("Deprecated") + def __call__(self) -> None: + ... + + +invocable = Invocable() +invocable() # E: Use of deprecated method __call__ + + +# > * Any usage of deprecated objects in their defining module + + +@deprecated("Deprecated") +def lorem() -> None: + ... + + +lorem() # E: Use of deprecated function lorem + + +# > There are additional scenarios where deprecations could come into play. +# > For example, an object may implement a `typing.Protocol`, +# > but one of the methods required for protocol compliance is deprecated. +# > As scenarios such as this one appear complex and relatively unlikely to come up in practice, +# > this PEP does not mandate that type checkers detect them. + + +class SupportsFoo1(Protocol): + @deprecated("Deprecated") + def foo(self) -> None: + ... + + def bar(self) -> None: + ... + + +class FooConcrete1(SupportsFoo1): + @override + def foo(self) -> None: # E?: Implementation of deprecated method foo + ... + + def bar(self) -> None: + ... + + +def foo_it(f: SupportsFoo1) -> None: + f.foo() # E: Use of deprecated method foo + f.bar() + + +class SupportsFoo2(Protocol): + def foo(self) -> None: + ... + + +class FooConcrete2: + @deprecated("Deprecated") + def foo(self) -> None: + ... + + +def takes_foo(f: SupportsFoo2) -> None: + ... + + +def caller(c: FooConcrete2) -> None: + takes_foo( + c + ) # E?: FooConcrete2 is a SupportsFoo2, but only because of a deprecated method diff --git a/conformance/tests/directives_disjoint_base.py b/conformance/tests/directives_disjoint_base.py new file mode 100644 index 000000000..49ce5d218 --- /dev/null +++ b/conformance/tests/directives_disjoint_base.py @@ -0,0 +1,135 @@ +""" +Tests the typing.disjoint_base decorator introduced in PEP 800. +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/directives.html#disjoint-base +# See also https://peps.python.org/pep-0800/ + +from typing import NamedTuple, Protocol, TypedDict, assert_never +from typing_extensions import disjoint_base + + +# > It may only be used on nominal classes, including ``NamedTuple`` +# > definitions + + +@disjoint_base +class Left: + pass + + +@disjoint_base +class Right: + pass + + +@disjoint_base +class LeftChild(Left): + pass + + +@disjoint_base +class Record(NamedTuple): + value: int + + +class Plain: + pass + + +# > If the candidate set contains a single disjoint base, that is the +# > class's disjoint base. + + +class OtherLeftChild(Left): + pass + + +# > If there are multiple candidates, but one of them is a subclass of +# > all other candidates, that class is the disjoint base. + + +class LeftAndPlain(Left, Plain): + pass + + +class LeftChildAndLeft(LeftChild, Left): + pass + + +class PlainRecord(Plain, Record): + pass + + +# > Type checkers must check for a valid disjoint base when checking class definitions, +# > and emit a diagnostic if they encounter a class +# > definition that lacks a valid disjoint base. + + +class LeftAndRight(Left, Right): # E: incompatible disjoint bases + pass + + +class LeftChildAndRight(LeftChild, Right): # E: incompatible disjoint bases + pass + + +class LeftAndRightViaChild(LeftAndPlain, Right): # E: incompatible disjoint bases + pass + + +class LeftRecord(Left, Record): # E: incompatible disjoint bases + pass + + +# > A nominal class is a disjoint base if it [...] contains a non-empty +# > `__slots__` definition. + + +class SlotBase1: + __slots__ = ("x",) + + +class SlotBase2: + __slots__ = ("y",) + + +class EmptySlots: + __slots__ = () + + +class SlotAndEmptySlots(SlotBase1, EmptySlots): + pass + + +class IncompatibleSlots(SlotBase1, SlotBase2): # E: incompatible disjoint bases + pass + + +# > it is a type checker error to use the decorator on a function, +# > ``TypedDict`` definition, or ``Protocol`` definition. + + +@disjoint_base # E: disjoint_base cannot be applied to a function +def func() -> None: + pass + + +@disjoint_base # E: disjoint_base cannot be applied to a TypedDict +class Movie(TypedDict): + name: str + + +@disjoint_base # E: disjoint_base cannot be applied to a Protocol +class SupportsClose(Protocol): + def close(self) -> None: + ... + + +# > Type checkers may use disjoint bases to determine that two classes cannot +# > have a common subclass. + + +def narrow(obj: Left) -> None: + if isinstance(obj, Right): # E?: may be treated as unreachable + assert_never(obj) # E?: may not be narrowed to Never diff --git a/conformance/tests/directives_type_ignore.py b/conformance/tests/directives_type_ignore.py index b96d23aea..126f3e54d 100644 --- a/conformance/tests/directives_type_ignore.py +++ b/conformance/tests/directives_type_ignore.py @@ -10,8 +10,10 @@ # The following type violation should be suppressed. y: int = "" # type: ignore - additional stuff -# The following type violation should be suppressed. -z: int = "" # type: ignore[additional_stuff] +# The following type violation may be suppressed, if the type checker +# actually uses the code `an-empty-str-is-not-an-int` (unlikely!), or if +# it treats unknown codes as blanket ignores. +z: int = "" # type: ignore[an-empty-str-is-not-an-int] # E? # > In some cases, linting tools or other comments may be needed on the same # > line as a type comment. In these cases, the type comment should be before diff --git a/conformance/tests/directives_version_platform.py b/conformance/tests/directives_version_platform.py index 2ffc85cda..463c0e4d6 100644 --- a/conformance/tests/directives_version_platform.py +++ b/conformance/tests/directives_version_platform.py @@ -6,40 +6,70 @@ import os import sys +from typing import assert_type +def test(a: int, b: str): + val1: int | str + if sys.version_info >= (3, 8): + val1 = a + else: + val1 = b -if sys.version_info >= (3, 8): - pass -else: - val1: int = "" # Should not generate an error + assert_type(val1, int) -if sys.version_info >= (3, 8, 0): - pass -else: - val2: int = "" # E?: May not generate an error (support for three-element sys.version is optional) + val2: int | str + if sys.version_info >= (3, 8, 0): + val2 = a + else: + val2 = b -if sys.version_info < (3, 8): - val3: int = "" # Should not generate an error + assert_type(val2, int) # E?: May not generate an error (support for three-element sys.version is optional) -if sys.version_info < (3, 100, 0): - pass -else: - val3: int = "" # E?: May not generate an error (support for three-element sys.version is optional) + if sys.version_info < (3, 8): + val3 = "" + else: + val4 = "" + this_raises = val3 # E: `val3` is undefined + does_not_raise = val4 # should not error -if sys.platform == "bogus_platform": - val5: int = "" # Should not generate an error + val5: int | str + if sys.version_info < (3, 100, 0): + val5 = a + else: + val5 = b -if sys.platform != "bogus_platform": - pass -else: - val6: int = "" # Should not generate an error + assert_type(val5, int) # E?: May not generate an error (support for three-element sys.version is optional) -if os.name == "bogus_os": - val7: int = "" # E?: May not generate an error (support for os.name is optional) + if sys.platform == "bogus_platform": + val6 = "" + else: + val7 = "" -if os.name != "bogus_platform": - pass -else: - val8: int = "" # E?: May not generate an error (support for os.name is optional) + this_raises = val6 # E: `val6` is undefined + does_not_raise = val7 # should not error + + if sys.platform != "bogus_platform": + val8 = "" + else: + val9 = "" + + does_not_raise = val8 # should not error + this_raises = val9 # E: `val9` is undefined + + if os.name == "bogus_os": + val10 = "" + else: + val11 = "" + + this_raises = val10 # E?: `val10` is undefined, but support for `os.name` is optional + does_not_raise = val11 # E? should not error if `os.name` control flow is supported, but might be flagged as possibly undefined otherwise + + if os.name != "bogus_os": + val12 = "" + else: + val13 = "" + + does_not_raise = val12 # E?: should not error if `os.name` control flow is supported, but might be flagged as possibly undefined otherwise + this_raises = val13 # E?: `val13` is undefined, but support for `os.name` is optional diff --git a/conformance/tests/enums_behaviors.py b/conformance/tests/enums_behaviors.py new file mode 100644 index 000000000..eeb74ddfd --- /dev/null +++ b/conformance/tests/enums_behaviors.py @@ -0,0 +1,45 @@ +""" +Tests basic behaviors of of Enum classes. +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/enums.html#enum-definition + +from enum import Enum +from typing import assert_type, Literal + +# > Enum classes are iterable and indexable, and they can be called with a +# > value to look up the enum member with that value. Type checkers should +# > support these behaviors + +class Color(Enum): + RED = 1 + GREEN = 2 + BLUE = 3 + +for color in Color: + assert_type(color, Color) + +# > Unlike most Python classes, Calling an enum class does not invoke its +# > constructor. Instead, the call performs a value-based lookup of an +# > enum member. + +# 'Literal[Color.RED]' and 'Color' are both acceptable +assert_type(Color["RED"], Color) # E[red] +assert_type(Color["RED"], Literal[Color.RED]) # E[red] + +# 'Literal[Color.BLUE]' and 'Color' are both acceptable +assert_type(Color(3), Color) # E[blue] +assert_type(Color(3), Literal[Color.BLUE]) # E[blue] + + +# > An Enum class with one or more defined members cannot be subclassed. + +class EnumWithNoMembers(Enum): + pass + +class Shape(EnumWithNoMembers): # OK (because no members are defined) + SQUARE = 1 + CIRCLE = 2 + +class ExtendedShape(Shape): # E: Shape is implicitly final + TRIANGLE = 3 diff --git a/conformance/tests/enums_definition.py b/conformance/tests/enums_definition.py new file mode 100644 index 000000000..955618ddf --- /dev/null +++ b/conformance/tests/enums_definition.py @@ -0,0 +1,92 @@ +""" +Tests handling of Enum class definitions using the class syntax. +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/enums.html#enum-definition + +from enum import Enum, EnumType +from typing import Literal, assert_type +import sys + +# > Type checkers should support the class syntax + + +class Color1(Enum): + RED = 1 + GREEN = 2 + BLUE = 3 + + +assert_type(Color1.RED, Literal[Color1.RED]) + + +# > The function syntax (in its various forms) is optional + +Color2 = Enum("Color2", "RED", "GREEN", "BLUE") # E? +Color3 = Enum("Color3", ["RED", "GREEN", "BLUE"]) # E? +Color4 = Enum("Color4", ("RED", "GREEN", "BLUE")) # E? +Color5 = Enum("Color5", "RED, GREEN, BLUE") # E? +Color6 = Enum("Color6", "RED GREEN BLUE") # E? +Color7 = Enum("Color7", [("RED", 1), ("GREEN", 2), ("BLUE", 3)]) # E? +Color8 = Enum("Color8", (("RED", 1), ("GREEN", 2), ("BLUE", 3))) # E? +Color9 = Enum("Color9", {"RED": 1, "GREEN": 2, "BLUE": 3}) # E? + +assert_type(Color2.RED, Literal[Color2.RED]) # E? +assert_type(Color3.RED, Literal[Color3.RED]) # E? +assert_type(Color4.RED, Literal[Color4.RED]) # E? +assert_type(Color5.RED, Literal[Color5.RED]) # E? +assert_type(Color6.RED, Literal[Color6.RED]) # E? +assert_type(Color7.RED, Literal[Color7.RED]) # E? +assert_type(Color8.RED, Literal[Color8.RED]) # E? +assert_type(Color9.RED, Literal[Color9.RED]) # E? + + +# > Enum classes can also be defined using a subclass of enum.Enum or any class +# > that uses enum.EnumType (or a subclass thereof) as a metaclass. +# > Type checkers should treat such classes as enums + + +class CustomEnum1(Enum): + pass + + +class Color10(CustomEnum1): + RED = 1 + GREEN = 2 + BLUE = 3 + + +assert_type(Color10.RED, Literal[Color10.RED]) + + +class CustomEnumType(EnumType): + pass + + +class CustomEnum2(metaclass=CustomEnumType): + pass + + +class Color11(CustomEnum2): + RED = 1 + GREEN = 2 + BLUE = 3 + + +assert_type(Color11.RED, Literal[Color11.RED]) + +# > Enum members may be conditional, via checks of the same +# > statically-known conditions that a type-checker understands elsewhere, +# > such as Python version: + +class Color12(Enum): + RED = 1 + if sys.version_info >= (3, 12): + GREEN = 2 + if sys.version_info >= (4, 0): + BLUE = 3 + +# The conformance suite runs type checkers configured to Python 3.12 or later: +assert_type(Color12.RED, Literal[Color12.RED]) +assert_type(Color12.GREEN, Literal[Color12.GREEN]) +Color12.BLUE # E diff --git a/conformance/tests/enums_expansion.py b/conformance/tests/enums_expansion.py new file mode 100644 index 000000000..ae77565dc --- /dev/null +++ b/conformance/tests/enums_expansion.py @@ -0,0 +1,86 @@ +""" +Tests that the type checker handles literal expansion of enum classes. +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/enums.html#enum-literal-expansion + +from enum import Enum, Flag +from typing import Literal, Never, assert_type + +# > From the perspective of the type system, most enum classes are equivalent +# > to the union of the literal members within that enum. [...] Because of the +# > equivalency between an enum class and the union of literal members within +# > that enum, the two types may be used interchangeably. Type checkers may +# > therefore expand an enum type (that does not derive from enum.Flag) into a +# > union of literal values during type narrowing and exhaustion detection + + +class Color(Enum): + RED = 1 + GREEN = 2 + BLUE = 3 + + +def print_color1(c: Color): + if c is Color.RED or c is Color.BLUE: + print("red or blue") + else: + assert_type(c, Literal[Color.GREEN]) # E? + + +def print_color2(c: Color): + match c: + case Color.RED | Color.BLUE: + print("red or blue") + case Color.GREEN: + print("green") + case _: + assert_type(c, Never) # E? + + +# > (This rule does not apply to classes that derive from enum.Flag because +# > these enums allow flags to be combined in arbitrary ways.) + + +class CustomFlags(Flag): + FLAG1 = 1 + FLAG2 = 2 + FLAG3 = 4 + + +def test1(f: CustomFlags): + if f is CustomFlags.FLAG1 or f is CustomFlags.FLAG2: + print("flag1 and flag2") + else: + assert_type(f, CustomFlags) + assert_type(f, Literal[CustomFlags.FLAG3]) # E + + +def test2(f: CustomFlags): + match f: + case CustomFlags.FLAG1 | CustomFlags.FLAG2: + pass + case CustomFlags.FLAG3: + pass + case _: + assert_type(f, CustomFlags) + + +# > A type checker should treat a complete union of all literal members as +# > equivalent to the enum type. + + +class Answer(Enum): + Yes = 1 + No = 2 + + +def test3(val: object) -> list[Answer]: + assert val is Answer.Yes or val is Answer.No + x = [val] + return x + + +def test4(a: Answer) -> None: + x: Literal[Answer.Yes, Answer.No] = a + assert_type(a, Literal[Answer.Yes, Answer.No]) diff --git a/conformance/tests/enums_member_names.py b/conformance/tests/enums_member_names.py new file mode 100644 index 000000000..dc9ee0aae --- /dev/null +++ b/conformance/tests/enums_member_names.py @@ -0,0 +1,30 @@ +""" +Tests that the type checker handles the `_name_` and `name` attributes correctly. +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/enums.html#member-names + +from enum import Enum +from typing import Literal, assert_type + +# > All enum member objects have an attribute _name_ that contains the member’s +# > name. They also have a property name that returns the same name. Type +# > checkers may infer a literal type for the name of a member + + +class Color(Enum): + RED = 1 + GREEN = 2 + BLUE = 3 + + +assert_type(Color.RED._name_, Literal["RED"]) # E? +assert_type(Color.RED.name, Literal["RED"]) # E? + + +def func1(red_or_blue: Literal[Color.RED, Color.BLUE]): + assert_type(red_or_blue.name, Literal["RED", "BLUE"]) # E? + + +def func2(any_color: Color): + assert_type(any_color.name, Literal["RED", "BLUE", "GREEN"]) # E? diff --git a/conformance/tests/enums_member_values.py b/conformance/tests/enums_member_values.py new file mode 100644 index 000000000..741099596 --- /dev/null +++ b/conformance/tests/enums_member_values.py @@ -0,0 +1,96 @@ +""" +Tests that the type checker handles the `_value_` and `value` attributes correctly. +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/enums.html#member-values + +# > All enum member objects have an attribute _value_ that contains the +# > member’s value. They also have a property value that returns the same value. +# > Type checkers may infer the type of a member’s value. + +from enum import Enum, auto +from typing import Literal, assert_type + + +class Color(Enum): + RED = 1 + GREEN = 2 + BLUE = 3 + + +assert_type(Color.RED._value_, Literal[1]) # E? +assert_type(Color.RED.value, Literal[1]) # E? + + +def func1(red_or_blue: Literal[Color.RED, Color.BLUE]): + assert_type(red_or_blue.value, Literal[1, 3]) # E? + + +def func2(any_color: Color): + assert_type(any_color.value, Literal[1, 2, 3]) # E? + + +# > The value of _value_ can be assigned in a constructor method. This +# > technique is sometimes used to initialize both the member value and +# > non-member attributes. If the value assigned in the class body is a tuple, +# > the unpacked tuple value is passed to the constructor. Type checkers may +# > validate consistency between assigned tuple values and the constructor +# > signature. + + +class Planet(Enum): + def __init__(self, value: int, mass: float, radius: float): + self._value_ = value + self.mass = mass + self.radius = radius + + MERCURY = (1, 3.303e23, 2.4397e6) + VENUS = (2, 4.869e24, 6.0518e6) + EARTH = (3, 5.976e24, 6.37814e6) + MARS = (6.421e23, 3.3972e6) # E?: Type checker error (optional) + JUPITER = 5 # E?: Type checker error (optional) + + +assert_type(Planet.MERCURY.value, Literal[1]) # E? + + +# > The class enum.auto and method _generate_next_value_ can be used within +# > an enum class to automatically generate values for enum members. +# > Type checkers may support these to infer literal types for member values. + + +class Color2(Enum): + RED = auto() + GREEN = auto() + BLUE = auto() + + +assert_type(Color2.RED.value, Literal[1]) # E? + +# > If an enum class provides an explicit type annotation for _value_, type +# > checkers should enforce this declared type when values are assigned to +# > _value_. + + +class Color3(Enum): + _value_: int + RED = 1 # OK + GREEN = "green" # E + + +class Planet2(Enum): + _value_: str + + def __init__(self, value: int, mass: float, radius: float): + self._value_ = value # E + + MERCURY = (1, 3.303e23, 2.4397e6) + + +from _enums_member_values import ColumnType + +# > If the literal values for enum members are not supplied, as they sometimes +# > are not within a type stub file, a type checker can use the type of the +# > _value_ attribute. + +assert_type(ColumnType.DORIC.value, int) # E? diff --git a/conformance/tests/enums_members.py b/conformance/tests/enums_members.py new file mode 100644 index 000000000..a746334d0 --- /dev/null +++ b/conformance/tests/enums_members.py @@ -0,0 +1,151 @@ +""" +Tests that the type checker can distinguish enum members from non-members. +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members + +from enum import Enum, member, nonmember +from typing import Literal, assert_type, reveal_type + +# > If an attribute is defined in the class body with a type annotation but +# > with no assigned value, a type checker should assume this is a non-member +# > attribute + + +class Pet(Enum): + genus: str # Non-member attribute + species: str # Non-member attribute + + CAT = "felis", "catus" # Member attribute + DOG = "canis", "lupus" # Member attribute + + def __init__(self, genus: str, species: str) -> None: + self.genus = genus + self.species = species + + +def func1(pet: Pet) -> None: + assert_type(pet.genus, str) + assert_type(pet.species, str) + +assert_type(Pet.CAT, Literal[Pet.CAT]) +assert_type(Pet.DOG, Literal[Pet.DOG]) + + +from _enums_members import Pet2 + +def func2(pet: Pet2) -> None: + assert_type(pet.genus, str) + assert_type(pet.species, str) + +assert_type(Pet2.CAT, Literal[Pet2.CAT]) +assert_type(Pet2.DOG, Literal[Pet2.DOG]) + + +# > Members defined within an enum class should not include explicit type +# > annotations. Type checkers should infer a literal type for all members. +# > A type checker should report an error if a type annotation is used for +# > an enum member because this type will be incorrect and misleading to +# > readers of the code + + +class Pet3(Enum): + CAT = 1 + DOG: int = 2 # E + + +# > Methods, callables, descriptors (including properties), and nested classes +# > that are defined in the class are not treated as enum members by the +# > EnumType metaclass and should likewise not be treated as enum members by a +# > type checker + + +def identity(x: int) -> int: + return x + + +class Pet4(Enum): + CAT = 1 # Member attribute + DOG = 2 # Member attribute + + converter = lambda x: str(x) # Non-member attribute + transform = staticmethod(identity) # Non-member attribute + + @property + def species(self) -> str: # Non-member property + return "mammal" + + def speak(self) -> None: # Non-member method + print("meow" if self is Pet4.CAT else "woof") + + class Nested: ... # Non-member nested class + + +assert_type(Pet4.CAT, Literal[Pet4.CAT]) +assert_type(Pet4.DOG, Literal[Pet4.DOG]) +converter: Literal[Pet4.converter] # E +transform: Literal[Pet4.transform] # E +species: Literal[Pet4.species] # E +speak: Literal[Pet4.speak] # E + + +# > An attribute that is assigned the value of another member of the same +# > enum is not a member itself. Instead, it is an alias for the first member + + +class TrafficLight(Enum): + RED = 1 + GREEN = 2 + YELLOW = 3 + + AMBER = YELLOW # Alias for YELLOW + + +assert_type(TrafficLight.AMBER, Literal[TrafficLight.YELLOW]) + +# > If using Python 3.11 or newer, the enum.member and enum.nonmember classes +# > can be used to unambiguously distinguish members from non-members. + + +class Example(Enum): + a = member(1) # Member attribute + b = nonmember(2) # Non-member attribute + + @member + def c(self) -> None: # Member method + pass + + +assert_type(Example.a, Literal[Example.a]) +assert_type(Example.b, Literal[Example.b]) # E +assert_type(Example.c, Literal[Example.c]) + + +# > An attribute with a private name (beginning with, but not ending in, +# > a double underscore) is treated as a non-member. + + +class Example2(Enum): + __B = 2 # Non-member attribute + + def method(self): + reveal_type(Example2.__B) + assert_type(Example2.__B, Literal[Example2.__B]) # E + + +# > An enum class can define a class symbol named _ignore_. This can be +# > a list of names or a string containing a space-delimited list of names +# > that are deleted from the enum class at runtime. Type checkers may +# > support this mechanism + + +class Pet5(Enum): + _ignore_ = "DOG FISH" + CAT = 1 # Member attribute + DOG = 2 # temporary variable, will be removed from the final enum class + FISH = 3 # temporary variable, will be removed from the final enum class + + +assert_type(Pet5.CAT, Literal[Pet5.CAT]) +assert_type(Pet5.DOG, int) # E?: Literal[2] is also acceptable +assert_type(Pet5.FISH, int) # E?: Literal[3] is also acceptable diff --git a/conformance/tests/generics_base_class.py b/conformance/tests/generics_base_class.py index bfcb63476..f58162108 100644 --- a/conformance/tests/generics_base_class.py +++ b/conformance/tests/generics_base_class.py @@ -1,6 +1,6 @@ # Specification: https://typing.readthedocs.io/en/latest/spec/generics.html#arbitrary-generic-types-as-base-classes -from typing import Generic, TypeVar, Iterable, assert_type +from typing import Generic, TypeVar, assert_type T = TypeVar("T") @@ -71,3 +71,28 @@ class BadClass1(Generic[T, T]): # E class GoodClass1(dict[T, T]): # OK pass + +# > Type variables are applied to the defined class in the order in which +# > they first appear in any generic base classes. + +T1 = TypeVar("T1") +T2 = TypeVar("T2") +T3 = TypeVar("T3") + +class Parent1(Generic[T1, T2]): ... +class Parent2(Generic[T1, T2]): ... +class Child(Parent1[T1, T3], Parent2[T2, T3]): ... + +def takes_parent1(x: Parent1[int, bytes]): ... +def takes_parent2(x: Parent2[str, bytes]): ... + +child: Child[int, bytes, str] = Child() +takes_parent1(child) # OK +takes_parent2(child) # OK + +# > A type checker should report an error when the type variable order is +# > inconsistent. + +class Grandparent(Generic[T1, T2]): ... +class Parent(Grandparent[T1, T2]): ... +class BadChild(Parent[T1, T2], Grandparent[T2, T1]): ... # E diff --git a/conformance/tests/generics_basic.py b/conformance/tests/generics_basic.py index 0a35336bd..45f85f59f 100644 --- a/conformance/tests/generics_basic.py +++ b/conformance/tests/generics_basic.py @@ -7,7 +7,7 @@ from __future__ import annotations from collections.abc import Sequence -from typing import Any, Generic, TypeVar, assert_type +from typing import Any, Generic, Protocol, TypeVar, assert_type T = TypeVar("T") @@ -157,6 +157,23 @@ def test_my_map(m1: MyMap1[str, int], m2: MyMap2[int, str]): m1[0] # E m2[0] # E +# > All arguments to ``Generic`` or ``Protocol`` must be type variables. + +class Bad1(Generic[int]): ... # E +class Bad2(Protocol[int]): ... # E + +# > All type parameters for the class must appear within the ``Generic`` or +# > ``Protocol`` type argument list. + +T_co = TypeVar("T_co", covariant=True) +S_co = TypeVar("S_co", covariant=True) + +class Bad3(Iterable[T_co], Generic[S_co]): ... # E +class Bad4(Iterable[T_co], Protocol[S_co]): ... # E + +# > The above rule does not apply to a bare ``Protocol`` base class. + +class MyIterator(Iterator[T_co], Protocol): ... # OK # > You can use multiple inheritance with ``Generic`` @@ -190,3 +207,45 @@ class GenericMeta(type, Generic[T]): ... class GenericMetaInstance(metaclass=GenericMeta[T]): # E ... + + +# When a typevar appears in multiple parameters, we can (but are not required +# to) infer a "combined" specialization that satisfies all of the corresponding +# arguments. This is especially interesting for list literals, since `list` is +# invariant in its typevar. We can use the surrounding context of the generic +# function call to infer a wider type for the list literals that allows the call +# to succeed. + +def takes_two_lists(x: list[T], y: list[T]) -> T: + return x[0] + + +takes_two_lists([1], "not a list") # E: no assignment of T makes the second argument valid +takes_two_lists([""], [""]) # T = str or T = Literal[""] +takes_two_lists([1], [""]) # E?: T = int | str is a potential solution + +def test_specific_lists() -> None: + x: list[int] = [1] + y: list[int] = [1] + z: list[str] = [""] + assert_type(takes_two_lists(x, y), int) + takes_two_lists(x, z) # E: because lists are invariant, no assignment of T makes both arguments valid + + +T_int = TypeVar("T_int", bound=int) + +def takes_two_int_lists(x: list[T_int], y: list[T_int]) -> T_int: + return x[0] + +takes_two_int_lists([1], "not a list") # E: no assignment of T_int makes the second argument valid +takes_two_int_lists([1], [""]) # E: no assignment of T_int makes the second argument valid +takes_two_int_lists([1], [1]) # T = int or T = Literal[1] +takes_two_int_lists([True], [True]) # T = bool or T = Literal[True] +takes_two_int_lists([1], [True]) # E?: T = int | bool = int is a potential solution + +def test_specific_int_lists() -> None: + x: list[int] = [1] + y: list[int] = [1] + z: list[bool] = [True] + assert_type(takes_two_int_lists(x, y), int) + takes_two_int_lists(x, z) # E: because lists are invariant, no assignment of T makes both arguments valid diff --git a/conformance/tests/generics_defaults.py b/conformance/tests/generics_defaults.py index 0857b9291..14eafa2bf 100644 --- a/conformance/tests/generics_defaults.py +++ b/conformance/tests/generics_defaults.py @@ -24,46 +24,87 @@ class NonDefaultFollowsDefault(Generic[DefaultStrT, T]): ... # E: non-default TypeVars cannot follow ones with defaults -class NoNonDefaults(Generic[DefaultStrT, DefaultIntT]): ... +class NoNonDefaults(Generic[DefaultStrT, DefaultIntT]): + x: DefaultStrT + y: DefaultIntT -assert_type(NoNonDefaults, type[NoNonDefaults[str, int]]) -assert_type(NoNonDefaults[str], type[NoNonDefaults[str, int]]) -assert_type(NoNonDefaults[str, int], type[NoNonDefaults[str, int]]) +def test_no_non_defaults(a: NoNonDefaults, b: NoNonDefaults[str], c: NoNonDefaults[str, int]): + assert_type(a.x, str) + assert_type(a.y, int) + assert_type(b.x, str) + assert_type(b.y, int) -class OneDefault(Generic[T, DefaultBoolT]): ... + assert_type(c.x, str) + assert_type(c.y, int) -assert_type(OneDefault[float], type[OneDefault[float, bool]]) -assert_type(OneDefault[float](), OneDefault[float, bool]) +class OneDefault(Generic[T, DefaultBoolT]): + x: T + y: DefaultBoolT -class AllTheDefaults(Generic[T1, T2, DefaultStrT, DefaultIntT, DefaultBoolT]): ... +def test_one_default(a: OneDefault[float], b: OneDefault[float, bool]): + assert_type(a.x, float) + assert_type(a.y, bool) + assert_type(b.x, float) + assert_type(b.y, bool) -assert_type(AllTheDefaults, type[AllTheDefaults[Any, Any, str, int, bool]]) -assert_type( - AllTheDefaults[int, complex], type[AllTheDefaults[int, complex, str, int, bool]] -) -AllTheDefaults[int] # E: expected 2 arguments to AllTheDefaults +class AllTheDefaults(Generic[T1, T2, DefaultStrT, DefaultIntT, DefaultBoolT]): + x1: T1 + x2: T2 + x3: DefaultStrT + x4: DefaultIntT + x5: DefaultBoolT -assert_type( - AllTheDefaults[int, complex], type[AllTheDefaults[int, complex, str, int, bool]] -) -assert_type( - AllTheDefaults[int, complex, str], - type[AllTheDefaults[int, complex, str, int, bool]], -) -assert_type( - AllTheDefaults[int, complex, str, int], - type[AllTheDefaults[int, complex, str, int, bool]], -) -assert_type( - AllTheDefaults[int, complex, str, int, bool], - type[AllTheDefaults[int, complex, str, int, bool]], -) + +def test_all_the_defaults( + a: AllTheDefaults, + b: AllTheDefaults[int], # E: expected 2 arguments to AllTheDefaults + c: AllTheDefaults[int, complex], + d: AllTheDefaults[int, complex, str, int, bool], + e: AllTheDefaults[int, complex, str], + f: AllTheDefaults[int, complex, str, int], + g: AllTheDefaults[int, complex, str, int, bool], +): + assert_type(a.x1, Any) + assert_type(a.x2, Any) + assert_type(a.x3, str) + assert_type(a.x4, int) + assert_type(a.x5, bool) + + assert_type(c.x1, int) + assert_type(c.x2, complex) + assert_type(c.x3, str) + assert_type(c.x4, int) + assert_type(c.x5, bool) + + assert_type(d.x1, int) + assert_type(d.x2, complex) + assert_type(d.x3, str) + assert_type(d.x4, int) + assert_type(d.x5, bool) + + assert_type(e.x1, int) + assert_type(e.x2, complex) + assert_type(e.x3, str) + assert_type(e.x4, int) + assert_type(e.x5, bool) + + assert_type(f.x1, int) + assert_type(f.x2, complex) + assert_type(f.x3, str) + assert_type(f.x4, int) + assert_type(f.x5, bool) + + assert_type(g.x1, int) + assert_type(g.x2, complex) + assert_type(g.x3, str) + assert_type(g.x4, int) + assert_type(g.x5, bool) # > ``ParamSpec`` defaults are defined using the same syntax as @@ -73,42 +114,49 @@ class AllTheDefaults(Generic[T1, T2, DefaultStrT, DefaultIntT, DefaultBoolT]): . DefaultP = ParamSpec("DefaultP", default=[str, int]) -class Class_ParamSpec(Generic[DefaultP]): ... +class Class_ParamSpec(Generic[DefaultP]): + x: Callable[DefaultP, None] -assert_type(Class_ParamSpec, type[Class_ParamSpec[str, int]]) -assert_type(Class_ParamSpec(), Class_ParamSpec[str, int]) -assert_type(Class_ParamSpec[[bool, bool]](), Class_ParamSpec[bool, bool]) +def test_param_spec_defaults(a: Class_ParamSpec): + assert_type(a.x, Callable[[str, int], None]) + assert_type(Class_ParamSpec(), Class_ParamSpec[str, int]) + assert_type(Class_ParamSpec[[bool, bool]](), Class_ParamSpec[bool, bool]) # > ``TypeVarTuple`` defaults are defined using the same syntax as -# > ``TypeVar`` \ s but use an unpacked tuple of types instead of a single type -# > or another in-scope ``TypeVarTuple`` (see `Scoping Rules`_). +# > ``TypeVar`` \ s, but instead of a single type, they use an unpacked tuple +# > of types or an unpacked, in-scope ``TypeVarTuple`` (see `Scoping Rules`_). DefaultTs = TypeVarTuple("DefaultTs", default=Unpack[tuple[str, int]]) -class Class_TypeVarTuple(Generic[*DefaultTs]): ... +class Class_TypeVarTuple(Generic[*DefaultTs]): + x: tuple[*DefaultTs] + +def test_type_var_tuple_defaults(a: Class_TypeVarTuple): + assert_type(a.x, tuple[str, int]) + assert_type(Class_TypeVarTuple(), Class_TypeVarTuple[str, int]) + assert_type(Class_TypeVarTuple[int, bool](), Class_TypeVarTuple[int, bool]) -assert_type(Class_TypeVarTuple, type[Class_TypeVarTuple[*tuple[str, int]]]) -assert_type(Class_TypeVarTuple(), Class_TypeVarTuple[str, int]) -assert_type(Class_TypeVarTuple[int, bool](), Class_TypeVarTuple[int, bool]) + +AnotherDefaultTs = TypeVarTuple("AnotherDefaultTs", default=Unpack[DefaultTs]) # > If both ``bound`` and ``default`` are passed, ``default`` must be a # > subtype of ``bound``. If not, the type checker should generate an # > error. -TypeVar("Ok", bound=float, default=int) # OK -TypeVar("Invalid", bound=str, default=int) # E: the bound and default are incompatible +Ok1 = TypeVar("Ok1", bound=float, default=int) # OK +Invalid1 = TypeVar("Invalid1", bound=str, default=int) # E: the bound and default are incompatible # > For constrained ``TypeVar``\ s, the default needs to be one of the # > constraints. A type checker should generate an error even if it is a # > subtype of one of the constraints. -TypeVar("Ok", float, str, default=float) # OK -TypeVar("Invalid", float, str, default=int) # E: expected one of float or str got int +Ok2 = TypeVar("Ok2", float, str, default=float) # OK +Invalid2 = TypeVar("Invalid2", float, str, default=int) # E: expected one of float or str got int # > In generic functions, type checkers may use a type parameter's default when the @@ -121,10 +169,12 @@ class Class_TypeVarTuple(Generic[*DefaultTs]): ... T4 = TypeVar("T4", default=int) -def func1(x: int | set[T4]) -> T4: ... +def func1(x: int | set[T4]) -> T4: + raise NotImplementedError -assert_type(func1(0), int) +assert_type(func1(0), int) # E[optional-default-use] +assert_type(func1(0), Any) # E[optional-default-use] # > A ``TypeVar`` that immediately follows a ``TypeVarTuple`` is not allowed @@ -145,11 +195,17 @@ class Foo5(Generic[*Ts, T5]): ... # E P = ParamSpec("P", default=[float, bool]) -class Foo6(Generic[*Ts, P]): ... # OK +class Foo6(Generic[*Ts, P]): + x: tuple[*Ts] + y: Callable[P, None] + +def test_foo6(a: Foo6[int, str], b: Foo6[int, str, [bytes]]): + assert_type(a.x, tuple[int, str]) + assert_type(a.y, Callable[[float, bool], None]) -assert_type(Foo6[int, str], type[Foo6[int, str, [float, bool]]]) -assert_type(Foo6[int, str, [bytes]], type[Foo6[int, str, [bytes]]]) + assert_type(b.x, tuple[int, str]) + assert_type(b.y, Callable[[bytes], None]) # > Type parameter defaults should be bound by attribute access @@ -163,5 +219,6 @@ def meth(self, /) -> Self: attr: DefaultIntT -assert_type(Foo7.meth, Callable[[Foo7[int]], Foo7[int]]) -assert_type(Foo7.attr, int) +foo7 = Foo7() +assert_type(Foo7.meth(foo7), Foo7[int]) +assert_type(Foo7().attr, int) diff --git a/conformance/tests/generics_defaults_referential.py b/conformance/tests/generics_defaults_referential.py index 34b236007..ee2d9594f 100644 --- a/conformance/tests/generics_defaults_referential.py +++ b/conformance/tests/generics_defaults_referential.py @@ -20,7 +20,6 @@ class slice(Generic[StartT, StopT, StepT]): ... -assert_type(slice, type[slice[int, int, int | None]]) assert_type(slice(), slice[int, int, int | None]) assert_type(slice[str](), slice[str, str, int | None]) assert_type(slice[str, bool, complex](), slice[str, bool, complex]) @@ -32,9 +31,10 @@ class Foo(Generic[DefaultStrT, T2]): def __init__(self, a: DefaultStrT, b: T2) -> None: ... -assert_type(Foo(1, ""), Foo[int, str]) -Foo[int](1, "") # E: Foo[int, str] cannot be assigned to self: Foo[int, int] in Foo.__init__ -Foo[int]("", 1) # E: Foo[str, int] cannot be assigned to self: Foo[int, int] in Foo.__init__ +def func1(i: int, s: str) -> None: + assert_type(Foo(i, s), Foo[int, str]) + Foo[int](i, s) # E: Foo[int, str] cannot be assigned to self: Foo[int, int] in Foo.__init__ + Foo[int](s, i) # E: Foo[str, int] cannot be assigned to self: Foo[int, int] in Foo.__init__ # > ``T1`` must be used before ``T2`` in the parameter list of the generic. @@ -63,19 +63,19 @@ class Bar2(Generic[S2]): ... # E # > ``T1``'s bound must be a subtype of ``T2``'s bound. X1 = TypeVar("X1", bound=int) -TypeVar("Ok1", default=X1, bound=float) # OK -TypeVar("AlsoOk1", default=X1, bound=int) # OK -TypeVar("Invalid1", default=X1, bound=str) # E: int is not a subtype of str +Ok1 = TypeVar("Ok1", default=X1, bound=float) # OK +AlsoOk1 = TypeVar("AlsoOk1", default=X1, bound=int) # OK +Invalid1 = TypeVar("Invalid1", default=X1, bound=str) # E: int is not a subtype of str # > The constraints of ``T2`` must be a superset of the constraints of ``T1``. Y1 = TypeVar("Y1", bound=int) -TypeVar("Invalid2", float, str, default=Y1) # E: upper bound int is incompatible with constraints float or str +Invalid2 = TypeVar("Invalid2", float, str, default=Y1) # E: upper bound int is incompatible with constraints float or str Y2 = TypeVar("Y2", int, str) -TypeVar("AlsoOk2", int, str, bool, default=Y2) # OK -TypeVar("AlsoInvalid2", bool, complex, default=Y2) # E: {bool, complex} is not a superset of {int, str} +AlsoOk2 = TypeVar("AlsoOk2", int, str, bool, default=Y2) # OK +AlsoInvalid2 = TypeVar("AlsoInvalid2", bool, complex, default=Y2) # E: {bool, complex} is not a superset of {int, str} # > Type parameters are valid as parameters to generics inside of a @@ -88,11 +88,18 @@ class Bar2(Generic[S2]): ... # E class Bar(Generic[Z1, ListDefaultT]): # OK + x: Z1 + y: ListDefaultT def __init__(self, x: Z1, y: ListDefaultT): ... -assert_type(Bar, type[Bar[Any, list[Any]]]) -assert_type(Bar[int], type[Bar[int, list[int]]]) +def f(b1: Bar, b2: Bar[int]): + assert_type(b1.x, Any) + assert_type(b1.y, list[Any]) + assert_type(b2.x, int) + assert_type(b2.y, list[int]) + + assert_type(Bar[int](0, []), Bar[int, list[int]]) assert_type(Bar[int, list[str]](0, []), Bar[int, list[str]]) assert_type(Bar[int, str](0, ""), Bar[int, str]) diff --git a/conformance/tests/generics_defaults_specialization.py b/conformance/tests/generics_defaults_specialization.py index a663d3bdf..c131f8e3a 100644 --- a/conformance/tests/generics_defaults_specialization.py +++ b/conformance/tests/generics_defaults_specialization.py @@ -42,7 +42,10 @@ class SubclassMe(Generic[T1, DefaultStrT]): class Bar(SubclassMe[int, DefaultStrT]): ... -assert_type(Bar, type[Bar[str]]) +x1: type[Bar[str]] = Bar # ok +# Type checkers may take type context into account when deciding how to +# specialize a bare runtime reference to a generic class. +x2: type[Bar[int]] = Bar # E? assert_type(Bar(), Bar[str]) assert_type(Bar[bool](), Bar[bool]) diff --git a/conformance/tests/generics_mixed_variance_inference.py b/conformance/tests/generics_mixed_variance_inference.py new file mode 100644 index 000000000..e7cbfd752 --- /dev/null +++ b/conformance/tests/generics_mixed_variance_inference.py @@ -0,0 +1,21 @@ +""" +Tests variance inference for mixed type parameters. +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/generics.html#variance-inference + +class Mixed[T, *Ts, **P]: + def f(self, x: T, /, *args: P.args, **kwargs: P.kwargs) -> tuple[*Ts]: + raise NotImplementedError + +# T should be contra +_1: Mixed[int, []] = Mixed[object, []]() # OK +_2: Mixed[int, []] = Mixed[bool, []]() # E + +# Ts should be co +_3: Mixed[int, int, []] = Mixed[int, object, []]() # E +_4: Mixed[int, int, []] = Mixed[int, bool, []]() # OK + +# P should be contra +_5: Mixed[int, [int]] = Mixed[int, [object]]() # OK +_6: Mixed[int, [int]] = Mixed[int, [bool]]() # E diff --git a/conformance/tests/generics_paramspec_basic.py b/conformance/tests/generics_paramspec_basic.py index 01da2db31..e2c622583 100644 --- a/conformance/tests/generics_paramspec_basic.py +++ b/conformance/tests/generics_paramspec_basic.py @@ -21,11 +21,11 @@ def func1(x: P) -> P: # E - ... + raise NotImplementedError def func2(x: Concatenate[int, P]) -> int: # E - ... + raise NotImplementedError def func3(x: list[P]) -> None: # E diff --git a/conformance/tests/generics_paramspec_semantics.py b/conformance/tests/generics_paramspec_semantics.py index 63bbac80d..836d461d0 100644 --- a/conformance/tests/generics_paramspec_semantics.py +++ b/conformance/tests/generics_paramspec_semantics.py @@ -11,11 +11,11 @@ def changes_return_type_to_str(x: Callable[P, int]) -> Callable[P, str]: - ... + raise NotImplementedError def returns_int(a: str, b: bool, /) -> int: - ... + raise NotImplementedError f1 = changes_return_type_to_str(returns_int) @@ -28,15 +28,15 @@ def returns_int(a: str, b: bool, /) -> int: def func1(x: Callable[P, int], y: Callable[P, int]) -> Callable[P, bool]: - ... + raise NotImplementedError def x_y(x: int, y: str) -> int: - ... + raise NotImplementedError def y_x(y: int, x: str) -> int: - ... + raise NotImplementedError f2 = func1(x_y, x_y) @@ -51,11 +51,11 @@ def y_x(y: int, x: str) -> int: def keyword_only_x(*, x: int) -> int: - ... + raise NotImplementedError def keyword_only_y(*, y: int) -> int: - ... + raise NotImplementedError func1(keyword_only_x, keyword_only_y) # E @@ -74,21 +74,22 @@ def __init__(self, f: Callable[P, str], prop: U) -> None: def callback_a(q: int, /) -> str: - ... + raise NotImplementedError -y1 = Y(callback_a, 1) -assert_type(y1, Y[int, [int]]) -y2 = y1.f -assert_type(y2, Callable[[int], str]) +def func(x: int) -> None: + y1 = Y(callback_a, x) + assert_type(y1, Y[int, [int]]) + y2 = y1.f + assert_type(y2, Callable[[int], str]) def bar(x: int, *args: bool) -> int: - ... + raise NotImplementedError def add(x: Callable[P, int]) -> Callable[Concatenate[str, P], bool]: - ... + raise NotImplementedError a1 = add(bar) # Should return (a: str, /, x: int, *args: bool) -> bool @@ -98,7 +99,7 @@ def add(x: Callable[P, int]) -> Callable[Concatenate[str, P], bool]: def remove(x: Callable[Concatenate[int, P], int]) -> Callable[P, bool]: - ... + raise NotImplementedError r1 = remove(bar) # Should return (*args: bool) -> bool @@ -110,7 +111,7 @@ def remove(x: Callable[Concatenate[int, P], int]) -> Callable[P, bool]: def transform( x: Callable[Concatenate[int, P], int] ) -> Callable[Concatenate[str, P], bool]: - ... + raise NotImplementedError t1 = transform(bar) # Should return (a: str, /, *args: bool) -> bool @@ -125,19 +126,19 @@ def expects_int_first(x: Callable[Concatenate[int, P], int]) -> None: @expects_int_first # E def one(x: str) -> int: - ... + raise NotImplementedError @expects_int_first # E def two(*, x: int) -> int: - ... + raise NotImplementedError @expects_int_first # E def three(**kwargs: int) -> int: - ... + raise NotImplementedError @expects_int_first # OK def four(*args: int) -> int: - ... + raise NotImplementedError diff --git a/conformance/tests/generics_paramspec_specialization.py b/conformance/tests/generics_paramspec_specialization.py index e6eb27653..34ed734fd 100644 --- a/conformance/tests/generics_paramspec_specialization.py +++ b/conformance/tests/generics_paramspec_specialization.py @@ -2,8 +2,7 @@ Tests the handling of a ParamSpec specialization. """ - -from typing import Callable, Concatenate, Generic, ParamSpec, TypeVar +from typing import Any, Callable, Concatenate, Generic, ParamSpec, TypeVar, cast T = TypeVar("T") @@ -12,14 +11,14 @@ class ClassA(Generic[T, P1]): - f: Callable[P1, int] - x: T + f: Callable[P1, int] = cast(Any, "") + x: T = cast(Any, "") class ClassB(ClassA[T, P1], Generic[T, P1, P2]): - f1: Callable[P1, int] - f2: Callable[P2, int] - x: T + f1: Callable[P1, int] = cast(Any, "") + f2: Callable[P2, int] = cast(Any, "") + x: T = cast(Any, "") def func20(x: ClassA[int, P2]) -> str: # OK @@ -47,7 +46,7 @@ def func25(x: ClassA[int, int]) -> str: # E class ClassC(Generic[P1]): - f: Callable[P1, int] + f: Callable[P1, int] = cast(Any, "") def func30(x: ClassC[[int, str, bool]]) -> None: # OK diff --git a/conformance/tests/generics_paramspec_variance.py b/conformance/tests/generics_paramspec_variance.py new file mode 100644 index 000000000..04866e941 --- /dev/null +++ b/conformance/tests/generics_paramspec_variance.py @@ -0,0 +1,152 @@ +""" +Tests variance of ParamSpec. +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/generics.html#variance-inference + + +from typing import Callable, Generic, ParamSpec + + +class InvariantParamSpec[**InOutP]: + a: Callable[InOutP, None] + +in_out_obj: InvariantParamSpec[object] = InvariantParamSpec[int]() # E +in_out_int: InvariantParamSpec[int] = InvariantParamSpec[object]() # E + + +class ContravariantParamSpec[**InP]: + def f(self, *args: InP.args, **kwargs: InP.kwargs): ... + +in_obj: ContravariantParamSpec[object] = ContravariantParamSpec[int]() # E +in_int: ContravariantParamSpec[int] = ContravariantParamSpec[object]() # OK + + +class CovariantParamSpec[**OutP]: + def f(self, fn: Callable[OutP, None]) -> None: + raise NotImplementedError + + +out_int: CovariantParamSpec[int] = CovariantParamSpec[object]() # E +out_obj: CovariantParamSpec[object] = CovariantParamSpec[int]() # OK + +# cases involving keyword-only, positional-only parameters, parameter names, defaults and differing callable arities +class Box[T]: + t: T + + def __init__(self, t: T): ... + + +def f(a: int): ... +def kw(*, a: int): ... +def pos(a: int, /): ... +def names(b: int): ... +def default(a: int = 1): ... +def arity(a: int, b: str): ... + + +class InitP[**P]: # contravariant + def __init__(self, fn: Callable[P, None]): ... + + def usage(self) -> Callable[P, None]: + """infer contravariance""" + raise NotImplementedError + + +# `InitP` produces a `Callable[P, None]`, so a replacement is only safe if it +# accepts every call form that `InitP[(a: int)]` accepts. +in_box = Box(InitP(f)) + +in_kw_p = InitP(kw) +in_box.t = in_kw_p # E +in_pos_p = InitP(pos) +in_box.t = in_pos_p # E +in_names_p = InitP(names) +in_box.t = in_names_p # E +in_default_p = InitP(default) +in_box.t = in_default_p # OK +in_arity_p = InitP(arity) +in_box.t = in_arity_p # E + + +class OutitP[**P]: # covariant + def __init__(self, fn: Callable[P, None]): ... + + def usage(self, fn: Callable[P, None]): + """infer covariance""" + + +# `OutitP` consumes a `Callable[P, None]`, so the safe direction is reversed: a +# replacement is only safe if `Callable[(a: int), None]` can be passed to it. +out_box = Box(OutitP(f)) + +out_kw_p = OutitP(kw) +out_box.t = out_kw_p # OK +out_pos_p = OutitP(pos) +out_box.t = out_pos_p # OK +out_names_p = OutitP(names) +out_box.t = out_names_p # E +out_default_p = OutitP(default) +out_box.t = out_default_p # E +out_arity_p = OutitP(arity) +out_box.t = out_arity_p # E + + +# old style +P = ParamSpec("P") # OK +InP = ParamSpec("InP", contravariant=True) # OK +OutP = ParamSpec("OutP", covariant=True) # OK +InferP = ParamSpec("InferP", infer_variance=True) # OK +InvP1 = ParamSpec("InvP1", covariant=True, contravariant=True) # E +InvP2 = ParamSpec("InvP2", covariant=True, infer_variance=True) # E +InvP3 = ParamSpec("InvP3", contravariant=True, infer_variance=True) # E + +class InvariantParamSpecOld(Generic[P]): + def f(self, fn: Callable[P, None]) -> Callable[P, None]: # OK + raise NotImplementedError + +in_out_old: InvariantParamSpecOld[int] +in_out_old = InvariantParamSpecOld[int]() # OK +in_out_old = InvariantParamSpecOld[bool]() # E +in_out_old = InvariantParamSpecOld[object]() # E + +class ContravariantParamSpecOld(Generic[InP]): + def in_f(self) -> Callable[InP, None]: # OK + raise NotImplementedError + + def out_f(self, fn: Callable[InP, None]) -> None: # E + raise NotImplementedError + + +in_obj_old: ContravariantParamSpecOld[object] = ContravariantParamSpecOld[int]() # E +in_int_old: ContravariantParamSpecOld[int] = ContravariantParamSpecOld[object]() # OK + + +class CovariantParamSpecOld(Generic[OutP]): + def in_f(self) -> Callable[OutP, None]: # E + raise NotImplementedError + def out_f(self, fn: Callable[OutP, None]) -> None: # OK + raise NotImplementedError + + +out_int_old: CovariantParamSpecOld[int] = CovariantParamSpecOld[object]() # E +out_obj_old: CovariantParamSpecOld[object] = CovariantParamSpecOld[int]() # OK + + +# `infer_variance=True` on a traditional `ParamSpec` +class InferredContravariantParamSpecOld(Generic[InferP]): + def in_f(self) -> Callable[InferP, None]: # OK + raise NotImplementedError + + +infer_in_obj_old: InferredContravariantParamSpecOld[object] = InferredContravariantParamSpecOld[int]() # E +infer_in_int_old: InferredContravariantParamSpecOld[int] = InferredContravariantParamSpecOld[object]() # OK + + +class InferredCovariantParamSpecOld(Generic[InferP]): + def out_f(self, fn: Callable[InferP, None]) -> None: # OK + raise NotImplementedError + + +infer_out_int_old: InferredCovariantParamSpecOld[int] = InferredCovariantParamSpecOld[object]() # E +infer_out_obj_old: InferredCovariantParamSpecOld[object] = InferredCovariantParamSpecOld[int]() # OK diff --git a/conformance/tests/generics_scoping.py b/conformance/tests/generics_scoping.py index fcdb1957e..56a8795ad 100644 --- a/conformance/tests/generics_scoping.py +++ b/conformance/tests/generics_scoping.py @@ -1,6 +1,6 @@ # Specification: https://typing.readthedocs.io/en/latest/spec/generics.html#scoping-rules-for-type-variables -from typing import TypeVar, Generic, Iterable, TypeAlias, assert_type +from typing import TypeVar, Generic, Iterable, TypeAlias, assert_type, Literal # > A type variable used in a generic function could be inferred to represent # > different types in the same code block. @@ -11,8 +11,13 @@ def fun_1(x: T) -> T: # T here def fun_2(x: T) -> T: # and here could be different return x -assert_type(fun_1(1), int) -assert_type(fun_2('a'), str) +# One of these two should pass; either is acceptable: +assert_type(fun_1(1), int) # E[fun1] +assert_type(fun_1(1), Literal[1]) # E[fun1] + +# One of these two should pass; either is acceptable: +assert_type(fun_2("a"), str) # E[fun2] +assert_type(fun_2("a"), Literal["a"]) # E[fun2] # > A type variable used in a method of a generic class that coincides # > with one of the variables that parameterize this class is always bound @@ -39,8 +44,14 @@ def method(self, x: T, y: S) -> S: return y x: Foo[int] = Foo() -assert_type(x.method(0, "abc"), str) -assert_type(x.method(0, b"abc"), bytes) + +# Either of these is acceptable; one of the two should pass: +assert_type(x.method(0, "abc"), str) # E[method-str] +assert_type(x.method(0, "abc"), Literal["abc"]) # E[method-str] + +# Either of these is acceptable; one of the two should pass: +assert_type(x.method(0, b"abc"), bytes) # E[method-bytes] +assert_type(x.method(0, b"abc"), Literal[b"abc"]) # E[method-bytes] # > Unbound type variables should not appear in the bodies of generic functions, # > or in the class bodies apart from method definitions. @@ -77,12 +88,18 @@ class Bad(Iterable[T]): # E class AlsoBad: x: list[T] # E + def __init__(self, x: list[T]) -> None: # E? + self.x = x + class Inner(Iterable[S]): # OK ... attr: Inner[T] # OK alias: TypeAlias = list[T] # E + def __init__(self, attr: Inner[T]) -> None: + self.attr = attr + # Test unbound type variables at global scope global_var1: T # E diff --git a/conformance/tests/generics_self_advanced.py b/conformance/tests/generics_self_advanced.py index ef4f6af70..acf680c25 100644 --- a/conformance/tests/generics_self_advanced.py +++ b/conformance/tests/generics_self_advanced.py @@ -9,7 +9,7 @@ class ParentA: # Test for property that returns Self. @property def prop1(self) -> Self: - ... + raise NotImplementedError class ChildA(ParentA): ... @@ -26,20 +26,26 @@ class ParentB: @classmethod def method1(cls) -> Self: - ... + raise NotImplementedError class ChildB(ParentB): b: int = 0 def method2(self) -> None: assert_type(self, Self) - assert_type(self.a, list[Self]) - assert_type(self.a[0], Self) + # Allow type checkers to error here, since Self definitions on + # non-final classes are unsound. + a = self.a # E? + assert_type(a, list[Self]) + assert_type(a[0], Self) assert_type(self.method1(), Self) @classmethod def method3(cls) -> None: assert_type(cls, type[Self]) - assert_type(cls.a, list[Self]) - assert_type(cls.a[0], Self) + # Allow type checkers to error here, since Self definitions on + # non-final classes are unsound. + a = cls.a # E? + assert_type(a, list[Self]) + assert_type(a[0], Self) assert_type(cls.method1(), Self) diff --git a/conformance/tests/generics_self_basic.py b/conformance/tests/generics_self_basic.py index fd6a78719..d5712383e 100644 --- a/conformance/tests/generics_self_basic.py +++ b/conformance/tests/generics_self_basic.py @@ -58,7 +58,11 @@ class Circle(Shape): class Container(Generic[T]): value: T - def set_value(self, value: T) -> Self: ... + def __init__(self, value: T) -> None: + self.value = value + + def set_value(self, value: T) -> Self: + raise NotImplementedError # This should generate an error because Self isn't subscriptable. def foo(self, other: Self[int]) -> None: # E diff --git a/conformance/tests/generics_self_usage.py b/conformance/tests/generics_self_usage.py index 6990cbd18..99f36a811 100644 --- a/conformance/tests/generics_self_usage.py +++ b/conformance/tests/generics_self_usage.py @@ -79,7 +79,8 @@ def foo(bar: Self) -> Self: ... # E: not within a class class Foo2: # Rejected (Self is treated as unknown). - def has_existing_self_annotation(self: TFoo2) -> Self: ... # E + def has_existing_self_annotation(self: TFoo2) -> Self: # E + raise NotImplementedError class Foo3: def return_concrete_type(self) -> Self: @@ -95,7 +96,8 @@ def child_method(self) -> None: T = TypeVar("T") class Bar(Generic[T]): - def bar(self) -> T: ... + def bar(self) -> T: + raise NotImplementedError # This should generate an error. class Baz(Bar[Self]): ... # E @@ -109,18 +111,18 @@ class Base: @staticmethod # This should generate an error. def make() -> Self: # E - ... + raise NotImplementedError @staticmethod # This should generate an error. def return_parameter(foo: Self) -> Self: # E - ... + raise NotImplementedError class MyMetaclass(type): # This should generate an error. def __new__(cls, *args: Any) -> Self: # E - ... + raise NotImplementedError # This should generate an error. def __mul__(cls, count: int) -> list[Self]: # E - ... + raise NotImplementedError diff --git a/conformance/tests/generics_syntax_compatibility.py b/conformance/tests/generics_syntax_compatibility.py index 506d26d4e..144cbb78c 100644 --- a/conformance/tests/generics_syntax_compatibility.py +++ b/conformance/tests/generics_syntax_compatibility.py @@ -21,7 +21,7 @@ class ClassB[K, V](dict[K, V]): # OK class ClassC[V]: def method1(self, a: V, b: K) -> V | K: # OK - ... + raise NotImplementedError def method2[M](self, a: M, b: K) -> M | K: # E - ... + raise NotImplementedError diff --git a/conformance/tests/generics_syntax_declarations.py b/conformance/tests/generics_syntax_declarations.py index 21ab84cba..62d2d1019 100644 --- a/conformance/tests/generics_syntax_declarations.py +++ b/conformance/tests/generics_syntax_declarations.py @@ -7,13 +7,11 @@ # This generic class is parameterized by a TypeVar T, a # TypeVarTuple Ts, and a ParamSpec P. -from typing import Generic, ParamSpec, Protocol, TypeVar, TypeVarTuple, assert_type +from typing import Generic, Protocol class ChildClass[T, *Ts, **P]: - assert_type(T, TypeVar) - assert_type(Ts, TypeVarTuple) - assert_type(P, ParamSpec) + pass class ClassA[T](Generic[T]): # E: Runtime error diff --git a/conformance/tests/generics_syntax_infer_variance.py b/conformance/tests/generics_syntax_infer_variance.py index f19b6a181..e0f50a3b7 100644 --- a/conformance/tests/generics_syntax_infer_variance.py +++ b/conformance/tests/generics_syntax_infer_variance.py @@ -4,7 +4,7 @@ # Specification: https://peps.python.org/pep-0695/#auto-variance-for-typevar -from typing import Final, Generic, Iterator, Sequence, TypeVar +from typing import Final, Generic, Iterator, overload, Sequence, TypeVar from dataclasses import dataclass @@ -19,10 +19,10 @@ class ShouldBeCovariant1(Generic[T]): def __getitem__(self, index: int) -> T: - ... + raise NotImplementedError def __iter__(self) -> Iterator[T]: - ... + raise NotImplementedError vco1_1: ShouldBeCovariant1[float] = ShouldBeCovariant1[int]() # OK @@ -30,7 +30,17 @@ def __iter__(self) -> Iterator[T]: class ShouldBeCovariant2(Sequence[T]): - pass + @overload + def __getitem__(self, index: int) -> T: + ... + @overload + def __getitem__(self, index: slice) -> Sequence[T]: + ... + def __getitem__(self, index: int | slice) -> T | Sequence[T]: + raise NotImplementedError + + def __len__(self) -> int: + raise NotImplementedError vco2_1: ShouldBeCovariant2[float] = ShouldBeCovariant2[int]() # OK @@ -39,7 +49,7 @@ class ShouldBeCovariant2(Sequence[T]): class ShouldBeCovariant3(Generic[T]): def method1(self) -> "ShouldBeCovariant2[T]": - ... + raise NotImplementedError vco3_1: ShouldBeCovariant3[float] = ShouldBeCovariant3[int]() # OK @@ -51,8 +61,15 @@ class ShouldBeCovariant4(Generic[T]): x: T -vo4_1: ShouldBeCovariant4[float] = ShouldBeCovariant4[int](1) # OK -vo4_4: ShouldBeCovariant4[int] = ShouldBeCovariant4[float](1.0) # E +# This test is problematic as of Python 3.13 because of the +# newly synthesized "__replace__" method, which causes the type +# variable to be inferred as invariant rather than covariant. +# See https://github.com/python/mypy/issues/17623#issuecomment-2266312738 +# for details. Until we sort this out, we'll leave this test commented +# out. + +# vo4_1: ShouldBeCovariant4[float] = ShouldBeCovariant4[int](1) # OK +# vo4_4: ShouldBeCovariant4[int] = ShouldBeCovariant4[float](1.0) # E class ShouldBeCovariant5(Generic[T]): @@ -84,7 +101,7 @@ def __init__(self, value: T) -> None: self._value = value @property - def value(self): + def value(self) -> T: return self._value @value.setter diff --git a/conformance/tests/generics_syntax_scoping.py b/conformance/tests/generics_syntax_scoping.py index f2f1bc297..38c277db1 100644 --- a/conformance/tests/generics_syntax_scoping.py +++ b/conformance/tests/generics_syntax_scoping.py @@ -23,22 +23,13 @@ class Foo[T]: ... -class BaseClassC[T]: - def __init_subclass__(cls, param: type[Foo[T]]) -> None: - ... - - -class ClassC[T](BaseClassC[T], param=Foo[T]): # OK - ... - - print(T) # E: Runtime error: 'T' is not defined def decorator1[ T, **P, R ](x: type[Foo[T]]) -> Callable[[Callable[P, R]], Callable[P, R]]: - ... + raise NotImplementedError @decorator1(Foo[T]) # E: Runtime error: 'T' is not defined @@ -79,7 +70,7 @@ def method1[T](self, a: Inner[T]) -> Inner[T]: # OK def decorator2[**P, R](x: int) -> Callable[[Callable[P, R]], Callable[P, R]]: - ... + raise NotImplementedError T = int(0) @@ -102,23 +93,24 @@ def method3[T](self, x: T): # E T = int(0) -class Outer2[T]: - T = int(1) +def f(a: int, b: str, c: complex): + class Outer2[T]: + T = a - assert_type(T, int) + assert_type(T, int) - class Inner1: - T = str("") + class Inner1: + T = b - assert_type(T, str) + assert_type(T, str) - def inner_method(self): - assert_type(T, TypeVar) + def inner_method(self): + assert_type(T, TypeVar) - def outer_method(self): - T = 3j + def outer_method(self): + T = c - assert_type(T, complex) - - def inner_func(): assert_type(T, complex) + + def inner_func(): + assert_type(T, complex) diff --git a/conformance/tests/generics_type_erasure.py b/conformance/tests/generics_type_erasure.py index f88af0e59..b78f29249 100644 --- a/conformance/tests/generics_type_erasure.py +++ b/conformance/tests/generics_type_erasure.py @@ -10,7 +10,9 @@ class Node(Generic[T]): label: T - def __init__(self, label: T | None = None) -> None: ... + def __init__(self, label: T | None = None) -> None: + if label is not None: + self.label = label assert_type(Node(''), Node[str]) assert_type(Node(0), Node[int]) @@ -41,7 +43,7 @@ def __init__(self, label: T | None = None) -> None: ... Node[int].label # E Node.label = 1 # E Node.label # E -type(n1).label # E +type(n1).label # E? assert_type(n1.label, int) assert_type(Node[int]().label, int) n1.label = 1 # OK diff --git a/conformance/tests/generics_typevartuple_args.py b/conformance/tests/generics_typevartuple_args.py index fdc0e55a0..6d692d942 100644 --- a/conformance/tests/generics_typevartuple_args.py +++ b/conformance/tests/generics_typevartuple_args.py @@ -14,24 +14,24 @@ def args_to_tuple(*args: *Ts) -> tuple[*Ts]: - ... - - -assert_type(args_to_tuple(1, "a"), tuple[int, str]) + raise NotImplementedError class Env: ... -def exec_le(path: str, *args: * tuple[*Ts, Env], env: Env | None = None) -> tuple[*Ts]: - ... +def exec_le(path: str, *args: *tuple[*Ts, Env], env: Env | None = None) -> tuple[*Ts]: + raise NotImplementedError + +def has_int_and_str(x: int, y: str): + assert_type(args_to_tuple(x, y), tuple[int, str]) -assert_type(exec_le("", Env()), tuple[()]) # OK -assert_type(exec_le("", 0, "", Env()), tuple[int, str]) # OK -exec_le("", 0, "") # E -exec_le("", 0, "", env=Env()) # E + assert_type(exec_le("", Env()), tuple[()]) # OK + assert_type(exec_le(y, x, y, Env()), tuple[int, str]) # OK + exec_le("", 0, "") # E + exec_le("", 0, "", env=Env()) # E # > Using an unpacked unbounded tuple is equivalent to the @@ -39,7 +39,7 @@ def exec_le(path: str, *args: * tuple[*Ts, Env], env: Env | None = None) -> tupl # > *args: int, which accepts zero or more values of type int. -def func1(*args: * tuple[int, ...]) -> None: +def func1(*args: *tuple[int, ...]) -> None: ... @@ -48,7 +48,7 @@ def func1(*args: * tuple[int, ...]) -> None: func1(1, "2", 3) # E -def func2(*args: * tuple[int, *tuple[str, ...], str]) -> None: +def func2(*args: *tuple[int, *tuple[str, ...], str]) -> None: ... @@ -59,7 +59,7 @@ def func2(*args: * tuple[int, *tuple[str, ...], str]) -> None: func2("") # E -def func3(*args: * tuple[int, str]) -> None: +def func3(*args: *tuple[int, str]) -> None: ... @@ -72,8 +72,8 @@ def func4(*args: tuple[*Ts]): func4((0,), (1,)) # OK -func4((0,), (1, 2)) # E -func4((0,), ("1",)) # E +func4((0,), (1, 2)) # E (length mismatch) +func4((0,), ("1",)) # OK # This is a syntax error, so leave it commented out. diff --git a/conformance/tests/generics_typevartuple_basic.py b/conformance/tests/generics_typevartuple_basic.py index 77a07c1ff..672960270 100644 --- a/conformance/tests/generics_typevartuple_basic.py +++ b/conformance/tests/generics_typevartuple_basic.py @@ -7,6 +7,7 @@ from typing import Generic, NewType, TypeVarTuple, assert_type Ts = TypeVarTuple("Ts") +Ts1 = TypeVarTuple("Ts1") class Array1(Generic[*Ts]): @@ -14,7 +15,7 @@ class Array1(Generic[*Ts]): def func1(*args: *Ts) -> tuple[*Ts]: - ... + raise NotImplementedError Shape = TypeVarTuple("Shape") @@ -41,8 +42,8 @@ def get_shape(self) -> tuple[*Shape]: v4: Array[Height, Width] = Array(Height(1)) # E v5: Array[Batch, Height, Width] = Array((Batch(1), Width(1))) # E -v6: Array[Time, Batch, Height, Width] = Array( # E - (Time(1), Batch(1), Width(1), Height(1)) +v6: Array[Time, Batch, Height, Width] = Array( # E[v6] + (Time(1), Batch(1), Width(1), Height(1)) # E[v6] ) @@ -54,17 +55,16 @@ def __init__(self, shape: tuple[Shape]): # E: not unpacked self._shape: tuple[*Shape] = shape def get_shape(self) -> tuple[Shape]: # E: not unpacked - return self._shape + raise NotImplementedError def method1(*args: Shape) -> None: # E: not unpacked ... -# > TypeVarTuple does not yet support specification of variance, bounds, constraints. +# > TypeVarTuple does not support type constraints. -Ts1 = TypeVarTuple("Ts1", covariant=True) # E Ts2 = TypeVarTuple("Ts2", int, float) # E -Ts3 = TypeVarTuple("Ts3", bound=int) # E +Ts3 = TypeVarTuple("Ts3", bound=int) # E: bound is unavailable in Python 3.12 # > If the same TypeVarTuple instance is used in multiple places in a signature @@ -73,7 +73,7 @@ def method1(*args: Shape) -> None: # E: not unpacked def func2(arg1: tuple[*Ts], arg2: tuple[*Ts]) -> tuple[*Ts]: - ... + raise NotImplementedError # > We do not allow this; type unions may not appear within the tuple. @@ -81,17 +81,18 @@ def func2(arg1: tuple[*Ts], arg2: tuple[*Ts]) -> tuple[*Ts]: # > the types must match exactly (the list of type parameters must be the # > same length, and the type parameters themselves must be identical) -assert_type(func2((0,), (1,)), tuple[int]) # OK +def check_func2(x: int): + assert_type(func2((x,), (1,)), tuple[int]) # OK func2((0,), (0.0,)) # OK func2((0.0,), (0,)) # OK func2((0,), (1,)) # OK -func2((0,), ("0",)) # E +func2((0,), ("0",)) # OK func2((0, 0), (0,)) # E def multiply(x: Array[*Shape], y: Array[*Shape]) -> Array[*Shape]: - ... + raise NotImplementedError def func3(x: Array[Height], y: Array[Width], z: Array[Height, Width]): @@ -103,5 +104,9 @@ def func3(x: Array[Height], y: Array[Width], z: Array[Height, Width]): # > Only a single type variable tuple may appear in a type parameter list. -class Array3(Generic[*Ts1, *Ts2]): # E +class Array3(Generic[*Ts, *Ts1]): # E + ... + + +class Array4[*Ts1, *Ts2]: # E ... diff --git a/conformance/tests/generics_typevartuple_callable.py b/conformance/tests/generics_typevartuple_callable.py index 4ece6a97d..b8a9f577e 100644 --- a/conformance/tests/generics_typevartuple_callable.py +++ b/conformance/tests/generics_typevartuple_callable.py @@ -27,23 +27,24 @@ def func1(arg1: int, arg2: str) -> None: def func2(f: Callable[[int, *Ts, T], tuple[T, *Ts]]) -> tuple[*Ts, T]: - ... + raise NotImplementedError def callback1(a: int, b: str, c: int, d: complex) -> tuple[complex, str, int]: - ... + raise NotImplementedError def callback2(a: int, d: str) -> tuple[str]: - ... + raise NotImplementedError assert_type(func2(callback1), tuple[str, int, complex]) assert_type(func2(callback2), tuple[str]) -def func3(*args: * tuple[int, *Ts, T]) -> tuple[T, *Ts]: - ... +def func3(*args: *tuple[int, *Ts, T]) -> tuple[T, *Ts]: + raise NotImplementedError -assert_type(func3(1, "", 3j, 3.4), tuple[float, str, complex]) +def has_int_and_str(a: int, b: str, c: float, d: complex): + assert_type(func3(a, b, c, d), tuple[complex, str, float]) diff --git a/conformance/tests/generics_typevartuple_concat.py b/conformance/tests/generics_typevartuple_concat.py index 3f24821bf..1fb23f6d9 100644 --- a/conformance/tests/generics_typevartuple_concat.py +++ b/conformance/tests/generics_typevartuple_concat.py @@ -24,15 +24,15 @@ class Array(Generic[*Ts]): def add_batch_axis(x: Array[*Shape]) -> Array[Batch, *Shape]: - ... + raise NotImplementedError def del_batch_axis(x: Array[Batch, *Shape]) -> Array[*Shape]: - ... + raise NotImplementedError def add_batch_channels(x: Array[*Shape]) -> Array[Batch, *Shape, Channels]: - ... + raise NotImplementedError def func1(a: Array[Height, Width]): @@ -45,11 +45,12 @@ def func1(a: Array[Height, Width]): def prefix_tuple(x: T, y: tuple[*Ts]) -> tuple[T, *Ts]: - ... + raise NotImplementedError -z = prefix_tuple(x=0, y=(True, "a")) -assert_type(z, tuple[int, bool, str]) +def call_prefix_tuple(x: int, y: bool, z: str): + result = prefix_tuple(x=x, y=(y, z)) + assert_type(result, tuple[int, bool, str]) def move_first_element_to_last(tup: tuple[T, *Ts]) -> tuple[*Ts, T]: diff --git a/conformance/tests/generics_typevartuple_overloads.py b/conformance/tests/generics_typevartuple_overloads.py index 26c38a674..7f6fa0301 100644 --- a/conformance/tests/generics_typevartuple_overloads.py +++ b/conformance/tests/generics_typevartuple_overloads.py @@ -23,7 +23,7 @@ def transpose(self: "Array[Axis1, Axis2, Axis3]") -> "Array[Axis3, Axis2, Axis1] ... def transpose(self) -> Any: - pass + raise NotImplementedError def func1(a: Array[Axis1, Axis2], b: Array[Axis1, Axis2, Axis3]): diff --git a/conformance/tests/generics_typevartuple_specialization.py b/conformance/tests/generics_typevartuple_specialization.py index 0f53c85b9..3277e40b8 100644 --- a/conformance/tests/generics_typevartuple_specialization.py +++ b/conformance/tests/generics_typevartuple_specialization.py @@ -128,7 +128,7 @@ def func6(a: VariadicTuple[str, int], b: VariadicTuple[float], c: VariadicTuple) def func7(a: TA7[*Ts, T1, T2]) -> tuple[tuple[*Ts], T1, T2]: - ... + raise NotImplementedError def func8(a: TA7[str, bool], b: TA7[str, bool, float], c: TA7[str, bool, float, int]): @@ -141,7 +141,7 @@ def func8(a: TA7[str, bool], b: TA7[str, bool, float], c: TA7[str, bool, float, def func9(a: TA8[T1, *Ts, T2, T3]) -> tuple[tuple[*Ts], T1, T2, T3]: - ... + raise NotImplementedError def func10(a: TA8[str, bool, float], b: TA8[str, bool, float, int]): diff --git a/conformance/tests/generics_typevartuple_variance.py b/conformance/tests/generics_typevartuple_variance.py new file mode 100644 index 000000000..ace05d773 --- /dev/null +++ b/conformance/tests/generics_typevartuple_variance.py @@ -0,0 +1,117 @@ +""" +Tests variance of TypeVarTuple. +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/generics.html#variance-inference + + +from typing import Generic +from typing_extensions import TypeVarTuple + +class InvariantTypeVarTuple[*InOutTs]: + a: tuple[*InOutTs] + +in_out_obj: InvariantTypeVarTuple[object] = InvariantTypeVarTuple[int]() # E +in_out_int: InvariantTypeVarTuple[int] = InvariantTypeVarTuple[object]() # E +in_out_int = InvariantTypeVarTuple[int]() +in_out_variadic_int: InvariantTypeVarTuple[*tuple[int, ...]] = InvariantTypeVarTuple[*tuple[object, ...]]() # E +in_out_variadic_object: InvariantTypeVarTuple[*tuple[object, ...]] = InvariantTypeVarTuple[*tuple[int, ...]]() # E +in_out_empty: InvariantTypeVarTuple[()] = InvariantTypeVarTuple[()]() # OK +in_out_fixed_from_variadic: InvariantTypeVarTuple[int] = InvariantTypeVarTuple[*tuple[int, ...]]() # E +in_out_variadic_from_fixed: InvariantTypeVarTuple[*tuple[int, ...]] = InvariantTypeVarTuple[int]() # E + + +class ContravariantTypeVarTuple[*InTs]: + def f(self, t: tuple[*InTs]): + raise NotImplementedError + +in_obj: ContravariantTypeVarTuple[object, object] = ContravariantTypeVarTuple[object, int]() # E +in_int: ContravariantTypeVarTuple[int] = ContravariantTypeVarTuple[object]() # OK +in_variadic_int: ContravariantTypeVarTuple[*tuple[int, ...]] = ContravariantTypeVarTuple[*tuple[object, ...]]() # OK +in_variadic_object: ContravariantTypeVarTuple[*tuple[object, ...]] = ContravariantTypeVarTuple[*tuple[int, ...]]() # E +in_empty: ContravariantTypeVarTuple[()] = ContravariantTypeVarTuple[()]() # OK +in_fixed_from_variadic: ContravariantTypeVarTuple[int] = ContravariantTypeVarTuple[*tuple[int, ...]]() # OK +in_variadic_from_fixed: ContravariantTypeVarTuple[*tuple[int, ...]] = ContravariantTypeVarTuple[int]() # E + + +class CovariantTypeVarTuple[*OutTs]: + def f(self) -> tuple[*OutTs]: + raise NotImplementedError + + +out_int: CovariantTypeVarTuple[int] = CovariantTypeVarTuple[object]() # E +out_obj: CovariantTypeVarTuple[object] = CovariantTypeVarTuple[int]() # OK +out_multiple1: CovariantTypeVarTuple[int, int] = CovariantTypeVarTuple[bool, bool]() # OK +out_multiple2: CovariantTypeVarTuple[int, int] = CovariantTypeVarTuple[bool, object]() # E +out_multiple3: CovariantTypeVarTuple[int, int] = CovariantTypeVarTuple[object, bool]() # E +out_multiple4: CovariantTypeVarTuple[int, int] = CovariantTypeVarTuple[object, object]() # E +out_variadic_int: CovariantTypeVarTuple[*tuple[int, ...]] = CovariantTypeVarTuple[*tuple[object, ...]]() # E +out_variadic_object: CovariantTypeVarTuple[*tuple[object, ...]] = CovariantTypeVarTuple[*tuple[int, ...]]() # OK +out_empty: CovariantTypeVarTuple[()] = CovariantTypeVarTuple[()]() # OK +out_fixed_from_variadic: CovariantTypeVarTuple[int] = CovariantTypeVarTuple[*tuple[int, ...]]() # E +out_variadic_from_fixed: CovariantTypeVarTuple[*tuple[int, ...]] = CovariantTypeVarTuple[int]() # OK + +Ts = TypeVarTuple("Ts") # OK +InferTs = TypeVarTuple("InferTs", infer_variance=True) # OK +InvTs1 = TypeVarTuple("InvTs1", covariant=True, contravariant=True) # E +InvTs2 = TypeVarTuple("InvTs2", covariant=True, infer_variance=True) # E +InvTs3 = TypeVarTuple("InvTs3", contravariant=True, infer_variance=True) # E + +class InvariantTypeVarTupleOld(Generic[*Ts]): + def in_f(self, *args: *Ts) -> None: # OK + raise NotImplementedError + + def out_f(self) -> tuple[*Ts]: # OK + raise NotImplementedError + + +obj_old: InvariantTypeVarTupleOld[object] = InvariantTypeVarTupleOld[int]() # E +int_old: InvariantTypeVarTupleOld[int] = InvariantTypeVarTupleOld[object]() # E +int_old = InvariantTypeVarTupleOld[int]() + + +InTs = TypeVarTuple("InTs", contravariant=True) + +class ContravariantTypeVarTupleOld(Generic[*InTs]): + def in_f(self, *args: *InTs) -> None: # OK + raise NotImplementedError + + def out_f(self) -> tuple[*InTs]: # E + raise NotImplementedError + + +in_obj_old: ContravariantTypeVarTupleOld[object] = ContravariantTypeVarTupleOld[int]() # E +in_int_old: ContravariantTypeVarTupleOld[int] = ContravariantTypeVarTupleOld[object]() # OK + + +OutTs = TypeVarTuple("OutTs", covariant=True) + +class CovariantTypeVarTupleOld(Generic[*OutTs]): + def in_f(self, *args: *OutTs) -> None: # E + raise NotImplementedError + + def out_f(self) -> tuple[*OutTs]: # OK + raise NotImplementedError + + +out_int_old: CovariantTypeVarTupleOld[int] = CovariantTypeVarTupleOld[object]() # E +out_obj_old: CovariantTypeVarTupleOld[object] = CovariantTypeVarTupleOld[int]() # OK + + +# `infer_variance=True` on a traditional `TypeVarTuple` +class InferredContravariantTypeVarTupleOld(Generic[*InferTs]): + def in_f(self, *args: *InferTs) -> None: # OK + raise NotImplementedError + + +infer_in_obj_old: InferredContravariantTypeVarTupleOld[object] = InferredContravariantTypeVarTupleOld[int]() # E +infer_in_int_old: InferredContravariantTypeVarTupleOld[int] = InferredContravariantTypeVarTupleOld[object]() # OK + + +class InferredCovariantTypeVarTupleOld(Generic[*InferTs]): + def out_f(self) -> tuple[*InferTs]: # OK + raise NotImplementedError + + +infer_out_int_old: InferredCovariantTypeVarTupleOld[int] = InferredCovariantTypeVarTupleOld[object]() # E +infer_out_obj_old: InferredCovariantTypeVarTupleOld[object] = InferredCovariantTypeVarTupleOld[int]() # OK diff --git a/conformance/tests/generics_upper_bound.py b/conformance/tests/generics_upper_bound.py index 9813bde3d..c2208c6ef 100644 --- a/conformance/tests/generics_upper_bound.py +++ b/conformance/tests/generics_upper_bound.py @@ -34,13 +34,14 @@ def longer(x: ST, y: ST) -> ST: return y -assert_type(longer([1], [1, 2]), list[int]) -assert_type(longer({1}, {1, 2}), set[int]) - -# Type checkers that use a join rather than a union (like mypy) -# will produce Collection[int] here instead of list[int] | set[int]. -# Both answers are conformant with the spec. -assert_type(longer([1], {1, 2}), list[int] | set[int]) # E? +def f(list1: list[int], list2: list[int], set1: set[int], set2: set[int]): + assert_type(longer(list1, list2), list[int]) + assert_type(longer(set1, set2), set[int]) + + # Either answer here is conformant with the spec; + # exactly one should pass: + assert_type(longer(list1, set1), list[int] | set[int]) # E[mixed-collections] + assert_type(longer(list1, set1), Collection[int]) # E[mixed-collections] def requires_collection(c: Collection[int]) -> None: ... diff --git a/conformance/tests/generics_variance.py b/conformance/tests/generics_variance.py index c4b8682c4..9f2f143ea 100644 --- a/conformance/tests/generics_variance.py +++ b/conformance/tests/generics_variance.py @@ -24,7 +24,7 @@ def __init__(self, items: Iterable[T_co]) -> None: ... def __iter__(self) -> Iterator[T_co]: - ... + raise NotImplementedError class Employee: @@ -55,7 +55,7 @@ def dump_employee(e: E) -> E: # > Variance has no meaning, and should therefore be ignored by type checkers, # > if a type variable is bound to a generic function or type alias. def func(x: list[B_co]) -> B_co: # OK - ... + raise NotImplementedError class Co(Generic[T_co]): @@ -122,14 +122,14 @@ class CoContra_Child1(CoContra[T_co, T_contra]): # OK ... -class CoContra_Child2( - CoContra[T_co, T_co] # E: Second type arg must be contravariant +class CoContra_Child2( # E[CoContra_Child2]: Second type arg must be contravariant + CoContra[T_co, T_co] # E[CoContra_Child2]: Second type arg must be contravariant ): ... -class CoContra_Child3( - CoContra[T_contra, T_contra] # E: First type arg must be covariant +class CoContra_Child3( # E[CoContra_Child3]: First type arg must be covariant + CoContra[T_contra, T_contra] # E[CoContra_Child3]: First type arg must be covariant ): ... @@ -138,8 +138,8 @@ class CoContra_Child4(CoContra[T, T]): # OK ... -class CoContra_Child5( - CoContra[Co[T_co], Co[T_co]] # E: Second type arg must be contravariant +class CoContra_Child5( # E[CoContra_Child5]: Second type arg must be contravariant + CoContra[Co[T_co], Co[T_co]] # E[CoContra_Child5]: Second type arg must be contravariant ): ... @@ -192,7 +192,7 @@ class CoToContraToContra_WithTA(Contra_TA[Co_TA[Contra_TA[T_contra]]]): # E ... -class ContraToContraToContra_WithTA( - Contra_TA[Contra_TA[Contra_TA[T_co]]] # E +class ContraToContraToContra_WithTA( # E[ContraToContraToContra_WithTA] + Contra_TA[Contra_TA[Contra_TA[T_co]]] # E[ContraToContraToContra_WithTA] ): ... diff --git a/conformance/tests/generics_variance_inference.py b/conformance/tests/generics_variance_inference.py index c2de93767..a1fde4da7 100644 --- a/conformance/tests/generics_variance_inference.py +++ b/conformance/tests/generics_variance_inference.py @@ -17,7 +17,7 @@ def method1(self, a: T2) -> None: ... def method2(self) -> T3: - ... + raise NotImplementedError def func_a(p1: ClassA[float, int, int], p2: ClassA[int, float, float]): @@ -31,17 +31,17 @@ def func_a(p1: ClassA[float, int, int], p2: ClassA[int, float, float]): class ShouldBeCovariant1[T]: def __getitem__(self, index: int) -> T: - ... + raise NotImplementedError def __iter__(self) -> Iterator[T]: - ... + raise NotImplementedError vco1_1: ShouldBeCovariant1[float] = ShouldBeCovariant1[int]() # OK vco1_2: ShouldBeCovariant1[int] = ShouldBeCovariant1[float]() # E -class ShouldBeCovariant2[T](Sequence[T]): +class ShouldBeCovariant2[T](ShouldBeCovariant1[T]): pass @@ -51,7 +51,7 @@ class ShouldBeCovariant2[T](Sequence[T]): class ShouldBeCovariant3[T]: def method1(self) -> "ShouldBeCovariant2[T]": - ... + raise NotImplementedError vco3_1: ShouldBeCovariant3[float] = ShouldBeCovariant3[int]() # OK @@ -85,7 +85,7 @@ def __init__(self, value: T) -> None: self._value = value @property - def value(self): + def value(self) -> T: return self._value @value.setter @@ -192,3 +192,14 @@ class ShouldBeContravariant2[T](Parent_Contravariant[T]): c1: ShouldBeContravariant2[int] = ShouldBeContravariant2[float]() # OK c2: ShouldBeContravariant2[float] = ShouldBeContravariant2[int]() # E + +class ShouldBeCovariant7[T]: + def get(self) -> T: + raise NotImplementedError + + def add[S](self: "ShouldBeCovariant7[S]", other: list[S]) -> "ShouldBeCovariant7[S]": + raise NotImplementedError + + +d1: ShouldBeCovariant7[object] = ShouldBeCovariant7[int]() # OK +d2: ShouldBeCovariant7[int] = ShouldBeCovariant7[object]() # E diff --git a/conformance/tests/historical_positional.py b/conformance/tests/historical_positional.py index 4fc0aaa6a..915a6770b 100644 --- a/conformance/tests/historical_positional.py +++ b/conformance/tests/historical_positional.py @@ -26,7 +26,23 @@ def f1(__x: int, __y__: int = 0) -> None: ... def f2(x: int, __y: int) -> None: ... # E -def f3(x: int, *args: int, __y: int) -> None: ... # OK +# `x` is a positional-or-keyword parameter, so, +# according to a literal reading of the above rule, `__y` +# should be flagged as an error since it uses the historical +# convention for positional-only parameters but appears after +# a positional-or-keyword parameter that does not. We therefore +# permit type checkers to emit an error on this definition. +# +# Note that `x` can only be passed with a keyword argument if +# no arguments are passed positionally: +# +# ```pycon +# >>> def f3(x: int, *args: int, __y: int) -> None: ... +# ... +# >>> f3(x=1, __y=2) +# >>> +# ``` +def f3(x: int, *args: int, __y: int) -> None: ... # E? f3(3, __y=3) # OK diff --git a/conformance/tests/literals_interactions.py b/conformance/tests/literals_interactions.py index 5d0a286e3..474126768 100644 --- a/conformance/tests/literals_interactions.py +++ b/conformance/tests/literals_interactions.py @@ -3,9 +3,8 @@ """ # Specification: https://typing.readthedocs.io/en/latest/spec/literal.html#interactions-with-other-types-and-features - from enum import Enum -from typing import IO, Any, Final, Generic, Literal, TypeVar, assert_type, overload +from typing import IO, Any, Final, Generic, Literal, TypeVar, LiteralString, assert_type, overload def func1(v: tuple[int, str, list[bool]], a: Literal[0], b: Literal[5], c: Literal[-5]): @@ -43,7 +42,7 @@ def open(path: _PathType, mode: str) -> IO[Any]: def open(path: _PathType, mode: Any) -> Any: - pass + raise NotImplementedError assert_type(open("path", "r"), IO[str]) @@ -58,13 +57,13 @@ def open(path: _PathType, mode: Any) -> Any: class Matrix(Generic[A, B]): def __add__(self, other: "Matrix[A, B]") -> "Matrix[A, B]": - ... + raise NotImplementedError def __matmul__(self, other: "Matrix[B, C]") -> "Matrix[A, C]": - ... + raise NotImplementedError def transpose(self) -> "Matrix[B, A]": - ... + raise NotImplementedError def func2(a: Matrix[Literal[2], Literal[3]], b: Matrix[Literal[3], Literal[7]]): @@ -93,6 +92,12 @@ def parse_status1(s: str | Status) -> None: assert_type(s, str) +# > Type checkers may optionally perform additional analysis for both +# > enum and non-enum Literal types beyond what is described in the section above. +# +# > For example, it may be useful to perform narrowing based on things +# > like containment or equality checks: + def expects_bad_status(status: Literal["MALFORMED", "ABORTED"]): ... @@ -101,12 +106,34 @@ def expects_pending_status(status: Literal["PENDING"]): ... -def parse_status2(status: str) -> None: +def parse_status2(status: LiteralString) -> None: + if status == "MALFORMED": + expects_bad_status(status) # E? narrowing the type here is sound, but optional per the spec + elif status == "ABORTED": + expects_bad_status(status) # E? narrowing the type here is sound, but optional per the spec + + if status in ("MALFORMED", "ABORTED"): + expects_bad_status(status) # E? narrowing the type here is sound, but optional per the spec + + if status == "PENDING": + expects_pending_status(status) # E? narrowing the type here is sound, but optional per the spec + + +# Narrowing `str` to `Literal` strings is unsound given the possiblity of +# user-defined `str` subclasses that could have custom equality semantics, +# but is explicitly listed by the spec as optional analysis that type checkers +# may perform. +def parse_status3(status: str) -> None: + if status == "MALFORMED": + expects_bad_status(status) # E? narrowing the type here is unsound, but allowed per the spec + elif status == "ABORTED": + expects_bad_status(status) # E? narrowing the type here is unsound, but allowed per the spec + if status in ("MALFORMED", "ABORTED"): - return expects_bad_status(status) + expects_bad_status(status) # E? narrowing the type here is unsound, but allowed per the spec if status == "PENDING": - expects_pending_status(status) + expects_pending_status(status) # E? narrowing the type here is unsound, but allowed per the spec final_val1: Final = 3 diff --git a/conformance/tests/literals_literalstring.py b/conformance/tests/literals_literalstring.py index 25461dd11..798c6c7a6 100644 --- a/conformance/tests/literals_literalstring.py +++ b/conformance/tests/literals_literalstring.py @@ -21,7 +21,7 @@ def my_function(literal_string: LiteralString) -> LiteralString: - ... + raise NotImplementedError class Foo: @@ -43,14 +43,14 @@ def func1(a: Literal["one"], b: Literal["two"]): x2: Literal[""] = b # E -def func2(a: LiteralString, b: LiteralString): +def func2(a: LiteralString, b: LiteralString, non_literal: str): # > Addition: x + y is of type LiteralString if both x and y are compatible with LiteralString. assert_type(a + b, LiteralString) # > Joining: sep.join(xs) is of type LiteralString if sep’s type is # > compatible with LiteralString and xs’s type is compatible with Iterable[LiteralString]. assert_type(",".join((a, b)), LiteralString) - assert_type(",".join((a, str(b))), str) + assert_type(",".join((a, non_literal)), str) # > In-place addition: If s has type LiteralString and x has type compatible with # > LiteralString, then s += x preserves s’s type as LiteralString. @@ -62,10 +62,9 @@ def func2(a: LiteralString, b: LiteralString): # > s and the arguments have types compatible with LiteralString. assert_type(f"{a} {b}", LiteralString) - variable = 3 - x1: LiteralString = f"{a} {str(variable)}" # E + x1: LiteralString = f"{a} {non_literal}" # E - assert_type(a + str(1), str) + assert_type(a + non_literal, str) # > LiteralString is compatible with the type str x2: str = a @@ -77,7 +76,7 @@ def func2(a: LiteralString, b: LiteralString): # > Conditional statements and expressions work as expected. def condition1() -> bool: - ... + raise NotImplementedError def return_literal_string() -> LiteralString: @@ -159,12 +158,13 @@ def func8(x: str) -> A: def func8(x: Any) -> Any: - ... + raise NotImplementedError -assert_type(func8("foo"), C) # First overload -assert_type(func8("bar"), B) # Second overload -assert_type(func8(str(1)), A) # Third overload +def call_func8(x: str) -> None: + assert_type(func8("foo"), C) # First overload + assert_type(func8("bar"), B) # Second overload + assert_type(func8(x), A) # Third overload def func9(val: list[LiteralString]): diff --git a/conformance/tests/namedtuples_define_class.py b/conformance/tests/namedtuples_define_class.py index e345a197d..03a631bfc 100644 --- a/conformance/tests/namedtuples_define_class.py +++ b/conformance/tests/namedtuples_define_class.py @@ -7,6 +7,7 @@ # > Type checkers should support the class syntax from typing import Generic, NamedTuple, TypeVar, assert_type +import sys class Point(NamedTuple): @@ -49,6 +50,33 @@ class Point(NamedTuple): p10 = Point(1, 2, "", other="") # E +# > Fields must be annotated attributes - methods and un-annotated attributes are not +# > considered fields. + + +class Point2(NamedTuple): + x: int + y: int + units = "meters" # Not a field + + def is_origin(self) -> int: # Not a field + return self.x == 0 and self.y == 0 + + +p11 = Point2(1, 2) +assert_type(p11, Point2) +x, y = p11 + +p12 = Point2(1, 2, "") # E + + +# > Field names may not start with an underscore. + +class Point3(NamedTuple): + x: int + _y: int # E: illegal field name + + # > The runtime implementation of ``NamedTuple`` enforces that fields with default # > values must come after fields without default values. Type checkers should # > likewise enforce this restriction:: @@ -78,6 +106,20 @@ class BadPointWithName(Point): name: str = "" # OK x: int = 0 # E +# > Namedtuple fields may be conditional, via checks of the same statically-known +# > conditions that a type-checker understands elsewhere, such as Python version:: + +class ConditionalField(NamedTuple): + x: int + if sys.version_info >= (3, 12): + y: int + if sys.version_info >= (4, 0): + z: int + +# The conformance suite runs type checkers configured to Python 3.12 or later: +ConditionalField(1, 2) +ConditionalField(1, 2, 3) # E + # > In Python 3.11 and newer, the class syntax supports generic named tuple classes. # > Type checkers should support this. diff --git a/conformance/tests/namedtuples_define_functional.py b/conformance/tests/namedtuples_define_functional.py index 432dff735..49f7c1b0c 100644 --- a/conformance/tests/namedtuples_define_functional.py +++ b/conformance/tests/namedtuples_define_functional.py @@ -43,24 +43,27 @@ p6_4 = Point6(x=1.1, y=2) # E -# > At runtime, the ``namedtuple`` function disallows field names that are -# > illegal Python identifiers and either raises an exception or replaces these -# > fields with a parameter name of the form ``_N``. The behavior depends on -# > the value of the ``rename`` argument. Type checkers may replicate this -# > behavior statically. +# > At runtime, the ``namedtuple`` function disallows field names that begin with +# > an underscore or are illegal Python identifiers, and either raises an exception +# > or replaces these fields with a parameter name of the form ``_N``. The behavior +# > depends on the value of the ``rename`` argument. Type checkers may replicate +# > this behavior statically. NT1 = namedtuple("NT1", ["a", "a"]) # E?: duplicate field name NT2 = namedtuple("NT2", ["abc", "def"]) # E?: illegal field name NT3 = namedtuple("NT3", ["abc", "def"], rename=False) # E?: illegal field name +NT4 = namedtuple("NT4", ["abc", "_d"], rename=False) # E?: illegal field name -NT4 = namedtuple("NT4", ["abc", "def"], rename=True) # OK -NT4(abc="", _1="") # OK +NT5 = namedtuple("NT5", ["abc", "def"], rename=True) # OK +NT5(abc="", _1="") # OK +NT6 = namedtuple("NT6", ["abc", "_d"], rename=True) # OK +NT6(abc="", _1="") # OK # > The ``namedtuple`` function also supports a ``defaults`` keyword argument that # > specifies default values for the fields. Type checkers may support this. -NT5 = namedtuple("NT5", "a b c", defaults=(1, 2)) -NT5(1) # OK -NT5(1, 2, 3) # OK -NT5() # E: too few arguments +NT7 = namedtuple("NT7", "a b c", defaults=(1, 2)) +NT7(1) # OK +NT7(1, 2, 3) # OK +NT7() # E: too few arguments diff --git a/conformance/tests/narrowing_typeis.py b/conformance/tests/narrowing_typeis.py index 8632e67a3..9a2e62cde 100644 --- a/conformance/tests/narrowing_typeis.py +++ b/conformance/tests/narrowing_typeis.py @@ -14,11 +14,11 @@ def is_two_element_tuple(val: tuple[T, ...]) -> TypeIs[tuple[T, T]]: return len(val) == 2 -def func1(names: tuple[str, ...]): +def func1(names: tuple[str, str] | tuple[str, str, str]): if is_two_element_tuple(names): assert_type(names, tuple[str, str]) else: - assert_type(names, tuple[str, ...]) + assert_type(names, tuple[str, str, str]) # > The final narrowed type may be narrower than **R**, due to the constraints of the @@ -35,7 +35,12 @@ async def func2(val: int | Awaitable[int]): x: int = await val return x else: - assert_type(val, int) + # We can't say much here. The strictly correct answer is + # (int | Awaitable[int]) & ~Awaitable[Any], but conformant implementations + # may simplify this. + # But it should definitely remain assignable to `int | Awaitable[int]`. + y: int | Awaitable[int] = val + return y T_A = TypeVar("T_A", bound="A") diff --git a/conformance/tests/overloads_basic.py b/conformance/tests/overloads_basic.py index 86c81765d..51f722dbe 100644 --- a/conformance/tests/overloads_basic.py +++ b/conformance/tests/overloads_basic.py @@ -1,16 +1,18 @@ """ -Tests the basic typing.overload behavior described in PEP 484. +Tests the behavior of typing.overload. """ # Specification: https://typing.readthedocs.io/en/latest/spec/overload.html#overload -# Note: The behavior of @overload is severely under-specified by PEP 484 leading -# to significant divergence in behavior across type checkers. This is something -# we will likely want to address in a future update to the typing spec. For now, -# this conformance test will cover only the most basic functionality described -# in PEP 484. - -from typing import Any, Callable, Iterable, Iterator, TypeVar, assert_type, overload +from typing import ( + Any, + Callable, + Iterable, + Iterator, + TypeVar, + assert_type, + overload, +) class Bytes: @@ -55,27 +57,4 @@ def map( def map(func: Any, iter1: Any, iter2: Any = ...) -> Any: - pass - - -# At least two overload signatures should be provided. -@overload # E[func1] -def func1() -> None: # E[func1]: At least two overloads must be present - ... - - -def func1() -> None: - pass - - -# > In regular modules, a series of @overload-decorated definitions must be -# > followed by exactly one non-@overload-decorated definition (for the same -# > function/method). -@overload # E[func2] -def func2(x: int) -> int: # E[func2]: no implementation - ... - - -@overload -def func2(x: str) -> str: - ... + raise NotImplementedError diff --git a/conformance/tests/overloads_consistency.py b/conformance/tests/overloads_consistency.py new file mode 100644 index 000000000..540e0146a --- /dev/null +++ b/conformance/tests/overloads_consistency.py @@ -0,0 +1,117 @@ +""" +Tests consistency of overloads with implementation. +""" + +from typing import Callable, Coroutine, overload +from types import CoroutineType + +# > If an overload implementation is defined, type checkers should validate +# > that it is consistent with all of its associated overload signatures. +# > The implementation should accept all potential sets of arguments +# > that are accepted by the overloads and should produce all potential return +# > types produced by the overloads. In typing terms, this means the input +# > signature of the implementation should be :term:`assignable` to the input +# > signatures of all overloads, and the return type of all overloads should be +# > assignable to the return type of the implementation. + +# Return type of all overloads must be assignable to return type of +# implementation: + +@overload +def return_type(x: int) -> int: + ... + +@overload +def return_type(x: str) -> str: # E[return_type] + ... + +def return_type(x: int | str) -> int: # E[return_type] an overload returns `str`, not assignable to `int` + return 1 + + +# Input signature of implementation must be assignable to signature of each +# overload. We don't attempt a thorough testing of input signature +# assignability here; see `callables_subtyping.py` for that: + +@overload +def parameter_type(x: int) -> int: + ... + +@overload +def parameter_type(x: str) -> str: # E[parameter_type] + ... + +def parameter_type(x: int) -> int | str: # E[parameter_type] impl type of `x` must be assignable from overload types of `x` + return 1 + + +# > Overloads are allowed to use a mixture of ``async def`` and ``def`` statements +# > within the same overload definition. Type checkers should convert +# > ``async def`` statements to a non-async signature (wrapping the return +# > type in a ``Coroutine``) before testing for implementation consistency +# > and overlapping overloads (described below). + +# ...and also... + +# > When a type checker checks the implementation for consistency with overloads, +# > it should first apply any transforms that change the effective type of the +# > implementation including the presence of a ``yield`` statement in the +# > implementation body, the use of ``async def``, and the presence of additional +# > decorators. + +# An overload can explicitly return `Coroutine`, while the implementation is an +# `async def`: + +@overload +def returns_coroutine(x: int) -> CoroutineType[None, None, int]: + ... + +@overload +async def returns_coroutine(x: str) -> str: + ... + +async def returns_coroutine(x: int | str) -> int | str: + return 1 + + +# The implementation can explicitly return `Coroutine`, while overloads are +# `async def`: + +@overload +async def returns_coroutine_2(x: int) -> int: + ... + +@overload +async def returns_coroutine_2(x: str) -> str: + ... + +def returns_coroutine_2(x: int | str) -> Coroutine[None, None, int | str]: + return _wrapped(x) + +async def _wrapped(x: int | str) -> int | str: + return 2 + +# Decorator transforms are applied before checking overload consistency: + +def _deco_1(f: Callable) -> Callable[[int], int]: + def wrapped(_x: int, /) -> int: + return 1 + return wrapped + +def _deco_2(f: Callable) -> Callable[[int | str], int | str]: + def wrapped(_x: int | str, /) -> int | str: + return 1 + return wrapped + +@overload +@_deco_1 +def decorated() -> None: + ... + +@overload +def decorated(x: str, /) -> str: + ... + +@_deco_2 +def decorated(y: bytes, z: bytes) -> bytes: + return b"" diff --git a/conformance/tests/overloads_definitions.py b/conformance/tests/overloads_definitions.py new file mode 100644 index 000000000..67a62e61b --- /dev/null +++ b/conformance/tests/overloads_definitions.py @@ -0,0 +1,236 @@ +""" +Tests valid/invalid definition of overloaded functions. +""" + +from abc import ABC, abstractmethod +from typing import ( + final, + Protocol, + overload, + override, +) + + +# > At least two @overload-decorated definitions must be present. +@overload # E[func1] +def func1() -> None: # E[func1]: At least two overloads must be present + ... + + +def func1() -> None: + pass + + +# > The ``@overload``-decorated definitions must be followed by an overload +# > implementation, which does not include an ``@overload`` decorator. Type +# > checkers should report an error or warning if an implementation is missing. +@overload # E[func2] +def func2(x: int) -> int: # E[func2]: no implementation + ... + + +@overload +def func2(x: str) -> str: ... + + +# > Overload definitions within stub files, protocols, and on abstract methods +# > within abstract base classes are exempt from this check. +class MyProto(Protocol): + @overload + def func3(self, x: int) -> int: ... + + @overload + def func3(self, x: str) -> str: ... + + +class MyAbstractBase(ABC): + @overload + @abstractmethod + def func4(self, x: int) -> int: ... + + @overload + @abstractmethod + def func4(self, x: str) -> str: ... + + # A non-abstract method in an abstract base class still requires an + # implementation: + + @overload # E[not_abstract] + def not_abstract(self, x: int) -> int: # E[not_abstract] no implementation + ... + + @overload + def not_abstract(self, x: str) -> str: ... + + +# > If one overload signature is decorated with ``@staticmethod`` or +# > ``@classmethod``, all overload signatures must be similarly decorated. The +# > implementation, if present, must also have a consistent decorator. Type +# > checkers should report an error if these conditions are not met. +class C: + @overload # E[func5] + @staticmethod + def func5(x: int, /) -> int: # E[func5] + ... + + @overload + @staticmethod + def func5(x: str, /) -> str: # E[func5] + ... + + def func5(*args: object) -> int | str: # E[func5] + return 1 + + @overload # E[func6+] + @classmethod + def func6(cls, x: int, /) -> int: # E[func6+] + ... + + @overload + def func6(self, x: str, /) -> str: # E[func6+] + ... + + @classmethod # E[func6+] + def func6(cls, *args: int | str) -> int | str: # E[func6+] + return 1 + + +# > If a ``@final`` or ``@override`` decorator is supplied for a function with +# > overloads, the decorator should be applied only to the overload +# > implementation if it is present. If an overload implementation isn't present +# > (for example, in a stub file), the ``@final`` or ``@override`` decorator +# > should be applied only to the first overload. Type checkers should enforce +# > these rules and generate an error when they are violated. If a ``@final`` or +# > ``@override`` decorator follows these rules, a type checker should treat the +# > decorator as if it is present on all overloads. +class Base: + # This is a good definition of an overloaded final method (@final decorator + # on implementation only): + + @overload + def final_method(self, x: int) -> int: ... + + @overload + def final_method(self, x: str) -> str: ... + + @final + def final_method(self, x: int | str) -> int | str: + raise NotImplementedError + + # The @final decorator should not be on one of the overloads: + + @overload # E[invalid_final] @final should be on implementation only + @final # E[invalid_final] + def invalid_final(self, x: int) -> int: # E[invalid_final] + ... + + @overload + def invalid_final(self, x: str) -> str: # E[invalid_final] + ... + + def invalid_final(self, x: int | str) -> int | str: + raise NotImplementedError + + # The @final decorator should not be on multiple overloads and + # implementation: + + @overload # E[invalid_final_2+]: @final should be on implementation only + @final # E[invalid_final_2+] + def invalid_final_2(self, x: int) -> int: # E[invalid_final_2+] + ... + + @overload + @final # E[invalid_final_2+] + def invalid_final_2(self, x: str) -> str: # E[invalid_final_2+] + ... + + @final + def invalid_final_2(self, x: int | str) -> int | str: + raise NotImplementedError + + # These methods are just here for the @override test below. We use an + # overload because mypy doesn't like overriding a non-overloaded method + # with an overloaded one, even if LSP isn't violated. That could be its own + # specification question, but it's not what we're trying to test here: + + @overload + def good_override(self, x: int) -> int: ... + + @overload + def good_override(self, x: str) -> str: ... + + def good_override(self, x: int | str) -> int | str: + raise NotImplementedError + + @overload + def to_override(self, x: int) -> int: ... + + @overload + def to_override(self, x: str) -> str: ... + + def to_override(self, x: int | str) -> int | str: + raise NotImplementedError + + +class Child(Base): # E[override-final] + # The correctly-decorated @final method `Base.final_method` should cause an + # error if overridden in a child class (we use an overload here to avoid + # questions of override LSP compatibility and focus only on the override): + + @overload # E[override-final] + def final_method(self, x: int) -> int: ... # E[override-final] + + @overload + def final_method(self, x: str) -> str: ... + + def final_method( # E[override-final] can't override final method + self, x: int | str + ) -> int | str: # E[override-final] can't override final method + raise NotImplementedError + + # This is the right way to mark an overload as @override (decorate + # implementation only), so the use of @override should cause an error + # (because there's no `Base.bad_override` method): + + @overload # E[bad_override] marked as override but doesn't exist in base + def bad_override(self, x: int) -> int: # E[bad_override] + ... + + @overload + def bad_override(self, x: str) -> str: ... + + @override # E[bad_override] + def bad_override(self, x: int | str) -> int | str: # E[bad_override] + raise NotImplementedError + + # This is also a correctly-decorated overloaded @override, which is + # overriding a method that does exist in the base, so there should be no + # error. We need both this test and the previous one, because in the + # previous test, an incorrect error about the use of @override decorator + # could appear on the same line as the expected error about overriding a + # method that doesn't exist in base: + + @overload + def good_override(self, x: int) -> int: ... + + @overload + def good_override(self, x: str) -> str: ... + + @override + def good_override(self, x: int | str) -> int | str: + raise NotImplementedError + + # This is the wrong way to use @override with an overloaded method, and + # should emit an error: + + @overload # E[override_impl+]: @override should appear only on implementation + @override # E[override_impl+] + def to_override(self, x: int) -> int: ... # E[override_impl+] + + @overload + @override # E[override_impl+] + def to_override(self, x: str) -> str: ... # E[override_impl+] + + @override + def to_override(self, x: int | str) -> int | str: + raise NotImplementedError diff --git a/conformance/tests/overloads_definitions_stub.pyi b/conformance/tests/overloads_definitions_stub.pyi new file mode 100644 index 000000000..b9bd7eb61 --- /dev/null +++ b/conformance/tests/overloads_definitions_stub.pyi @@ -0,0 +1,150 @@ +""" +Tests valid/invalid definition of overloaded functions in stub files, where the +rules differ from non-stubs, since an implementation is not required. +""" + +from typing import ( + final, + overload, + override, +) + +# > At least two @overload-decorated definitions must be present. +@overload # E[func1] +def func1() -> None: # E[func1]: At least two overloads must be present + ... + +# > The ``@overload``-decorated definitions must be followed by an overload +# > implementation, which does not include an ``@overload`` decorator. Type +# > checkers should report an error or warning if an implementation is missing. +# > Overload definitions within stub files, protocols, and on abstract methods +# > within abstract base classes are exempt from this check. +@overload +def func2(x: int) -> int: ... +@overload +def func2(x: str) -> str: ... + +# > If one overload signature is decorated with ``@staticmethod`` or +# > ``@classmethod``, all overload signatures must be similarly decorated. The +# > implementation, if present, must also have a consistent decorator. Type +# > checkers should report an error if these conditions are not met. +class C: + @overload # E[func5] + def func5(self, x: int, /) -> int: # E[func5] + ... + @overload + @staticmethod + def func5(x: str, /) -> str: # E[func5] + ... + @overload # E[func6] + @classmethod + def func6(cls, x: int, /) -> int: # E[func6] + ... + @overload + def func6(self, *args: str) -> str: # E[func6] + ... + +# > If a ``@final`` or ``@override`` decorator is supplied for a function with +# > overloads, the decorator should be applied only to the overload +# > implementation if it is present. If an overload implementation isn't present +# > (for example, in a stub file), the ``@final`` or ``@override`` decorator +# > should be applied only to the first overload. Type checkers should enforce +# > these rules and generate an error when they are violated. If a ``@final`` or +# > ``@override`` decorator follows these rules, a type checker should treat the +# > decorator as if it is present on all overloads. +class Base: + # This is a good definition of an overloaded final method in a stub (@final + # decorator on first overload only): + + @overload + @final + def final_method(self, x: int) -> int: ... + @overload + def final_method(self, x: str) -> str: ... + + # The @final decorator should not be on multiple overloads: + + @overload # E[invalid_final] @final should be on first overload + @final + def invalid_final(self, x: int) -> int: # E[invalid_final] + ... + @overload # E[invalid_final] + @final # E[invalid_final] + def invalid_final(self, x: str) -> str: # E[invalid_final] + ... + @overload + def invalid_final(self, x: bytes) -> bytes: ... + + # The @final decorator should not be on all overloads: + + @overload # E[invalid_final_2] @final should be on first overload + @final + def invalid_final_2(self, x: int) -> int: # E[invalid_final_2] + ... + @overload # E[invalid_final_2] + @final # E[invalid_final_2] + def invalid_final_2(self, x: str) -> str: ... # E[invalid_final_2] + + # These methods are just here for the @override test below. We use an + # overload because mypy doesn't like overriding a non-overloaded method + # with an overloaded one, even if LSP isn't violated. That could be its own + # specification question, but it's not what we're trying to test here: + + @overload + def good_override(self, x: int) -> int: ... + @overload + def good_override(self, x: str) -> str: ... + @overload + def to_override(self, x: int) -> int: ... + @overload + def to_override(self, x: str) -> str: ... + +class Child(Base): # E[override-final] + # The correctly-decorated @final method `Base.final_method` should cause an + # error if overridden in a child class (we use an overload here to avoid + # questions of override LSP compatibility and focus only on the override): + + @overload # E[override-final] + def final_method(self, x: int) -> int: # E[override-final] + ... + @overload + def final_method( # E[override-final] can't override final method + self, x: str + ) -> str: # E[override-final] can't override final method + ... + + # This is the right way to mark an overload as @override (decorate first + # overload only), so the use of @override should cause an error (because + # there's no `Base.bad_override` method): + + @overload # E[bad_override] marked as override but doesn't exist in base + @override # E[bad_override] + def bad_override(self, x: int) -> int: # E[bad_override] + ... + @overload + def bad_override(self, x: str) -> str: ... + + # This is also a correctly-decorated overloaded @override, which is + # overriding a method that does exist in the base, so there should be no + # error. We need both this test and the previous one, because in the + # previous test, an incorrect error about the use of @override decorator + # could appear on the same line as the expected error about overriding a + # method that doesn't exist in base: + + @overload + @override + def good_override(self, x: int) -> int: ... + @overload + def good_override(self, x: str) -> str: ... + + # This is the wrong way to use @override with an overloaded method, and + # should emit an error: + + @overload # E[override_impl]: @override should appear only on first overload + def to_override(self, x: int) -> int: ... + @overload + @override # E[override_impl]: @override should appear only on first overload + def to_override( # E[override_impl]: @override should appear only on first overload + self, x: str + ) -> str: # E[override_impl]: @override should appear only on first overload + ... diff --git a/conformance/tests/overloads_evaluation.py b/conformance/tests/overloads_evaluation.py new file mode 100644 index 000000000..d9ba88d56 --- /dev/null +++ b/conformance/tests/overloads_evaluation.py @@ -0,0 +1,369 @@ +""" +Tests for evaluation of calls to overloaded functions. +""" + +from enum import Enum +from typing import Any, assert_type, Literal, overload, TypeVar + +# mypy: disable-error-code=overload-overlap + + +T = TypeVar("T") + +# > Step 1: Examine the argument list to determine the number of +# > positional and keyword arguments. Use this information to eliminate any +# > overload candidates that are not plausible based on their +# > input signatures. + +# (There is no way to observe via conformance tests whether an implementation +# performs this step separately from the argument-type-testing step 2 below, so +# the separation of step 1 from step 2 is purely a presentation choice for the +# algorithm, not a conformance requirement.) + + +@overload +def example1_1(x: int, y: str) -> int: ... + + +@overload +def example1_1(x: str) -> str: ... + + +def example1_1(x: int | str, y: str = "") -> int | str: + return 1 + + +# > - If no candidate overloads remain, generate an error and stop. + +example1_1() # E: no matching overload + +# > - If only one candidate overload remains, it is the winning match. Evaluate +# > it as if it were a non-overloaded function call and stop. + +ret1 = example1_1(1, "") +assert_type(ret1, int) + +example1_1(1, 1) # E: Literal[1] not assignable to str + +ret3 = example1_1("") +assert_type(ret3, str) + +example1_1(1) # E: Literal[1] not assignable to str + + +@overload +def example1_2(b: Literal[True] = ...) -> int: ... + + +@overload +def example1_2(b: bool) -> float: ... + + +def example1_2(b: bool = True) -> float: + raise NotImplementedError + + +def check_example1_2() -> None: + assert_type(example1_2(), int) + + +# > Step 2: Evaluate each remaining overload as a regular (non-overloaded) +# > call to determine whether it is compatible with the supplied +# > argument list. Unlike step 1, this step considers the types of the parameters +# > and arguments. During this step, do not generate any user-visible errors. +# > Simply record which of the overloads result in evaluation errors. + + +@overload +def example2(x: int, y: str, z: int) -> str: ... + + +@overload +def example2(x: int, y: int, z: int) -> int: ... + + +def example2(x: int, y: int | str, z: int) -> int | str: + return 1 + + +# > - If only one overload evaluates without error, it is the winning match. +# > Evaluate it as if it were a non-overloaded function call and stop. + +ret5 = example2(1, 2, 3) +assert_type(ret5, int) + +# > Step 3: If step 2 produces errors for all overloads, perform +# > "argument type expansion". Union types can be expanded +# > into their constituent subtypes. For example, the type ``int | str`` can +# > be expanded into ``int`` and ``str``. + +# > - If all argument lists evaluate successfully, combine their +# > respective return types by union to determine the final return type +# > for the call, and stop. + + +def check_expand_union(v: int | str) -> None: + ret1 = example2(1, v, 1) + assert_type(ret1, int | str) + + +# > - If argument expansion has been applied to all arguments and one or +# > more of the expanded argument lists cannot be evaluated successfully, +# > generate an error and stop. + + +def check_expand_union_2(v: int | str) -> None: + example2(v, v, 1) # E: no overload matches (str, ..., ...) + + +# > 2. ``bool`` should be expanded into ``Literal[True]`` and ``Literal[False]``. + + +@overload +def expand_bool(x: Literal[False]) -> Literal[0]: ... + + +@overload +def expand_bool(x: Literal[True]) -> Literal[1]: ... + + +def expand_bool(x: bool) -> int: + return int(x) + + +def check_expand_bool(v: bool) -> None: + ret1 = expand_bool(v) + assert_type(ret1, Literal[0, 1]) + + +# > 3. ``Enum`` types (other than those that derive from ``enum.Flag``) should +# > be expanded into their literal members. + + +class Color(Enum): + RED = 1 + BLUE = 2 + + +@overload +def expand_enum(x: Literal[Color.RED]) -> Literal[0]: ... + + +@overload +def expand_enum(x: Literal[Color.BLUE]) -> Literal[1]: ... + + +def expand_enum(x: Color) -> int: + return x.value + + +def check_expand_enum(v: Color) -> None: + ret1 = expand_enum(v) + assert_type(ret1, Literal[0, 1]) + + +# > 4. ``type[A | B]`` should be expanded into ``type[A]`` and ``type[B]``. + + +@overload +def expand_type_union(x: type[int]) -> int: ... + + +@overload +def expand_type_union(x: type[str]) -> str: ... + + +def expand_type_union(x: type[int] | type[str]) -> int | str: + return 1 + + +def check_expand_type_union(v: type[int | str]) -> None: + ret1 = expand_type_union(v) + assert_type(ret1, int | str) + + +# > 5. Tuples of known length that contain expandable types should be expanded +# > into all possible combinations of their element types. For example, the type +# > ``tuple[int | str, bool]`` should be expanded into ``(int, Literal[True])``, +# > ``(int, Literal[False])``, ``(str, Literal[True])``, and +# > ``(str, Literal[False])``. + + +@overload +def expand_tuple(x: tuple[int, int]) -> int: ... + + +@overload +def expand_tuple(x: tuple[int, str]) -> str: ... + + +def expand_tuple(x: tuple[int, int | str]) -> int | str: + return 1 + + +def check_expand_tuple(v: int | str) -> None: + ret1 = expand_tuple((1, v)) + assert_type(ret1, int | str) + + +# > Step 4: If the argument list is compatible with two or more overloads, +# > determine whether one or more of the overloads has a variadic parameter +# > (either ``*args`` or ``**kwargs``) that maps to a corresponding argument +# > that supplies an indeterminate number of positional or keyword arguments. +# > If so, eliminate overloads that do not have a variadic parameter. + + +@overload +def variadic(x: int, /) -> str: ... + + +@overload +def variadic(x: int, y: int, /, *args: int) -> int: ... + + +def variadic(*args: int) -> int | str: + return 1 + + +# > - If this results in only one remaining candidate overload, it is +# > the winning match. Evaluate it as if it were a non-overloaded function +# > call and stop. + + +def check_variadic(v: list[int]) -> None: + ret1 = variadic(*v) + assert_type(ret1, int) + + +# > Step 5: For all arguments, determine whether all possible +# > :term:`materializations ` of the argument's type are assignable to +# > the corresponding parameter type for each of the remaining overloads. If so, +# > eliminate all of the subsequent remaining overloads. +# > +# > If the return types are not equivalent, overload matching is ambiguous. In +# > this case, infer a return type that is :term:`assignable` to each of the +# > remaining return types and permits operations supported by any of them without +# > errors, then stop. A type checker may infer ``Any`` or a more precise gradual +# > type that satisfies these requirements. + + +@overload +def example4(x: list[int], y: int) -> list[int]: ... + + +@overload +def example4(x: list[str], y: str) -> list[int]: ... + + +@overload +def example4(x: int, y: int) -> list[str]: ... + + +def example4(x: list[int] | list[str] | int, y: int | str) -> list[int] | list[str]: + return [] + + +def check_example4(v1: list[Any], v2: Any) -> None: + ret1 = example4(v1, v2) + assert_type(ret1, list[int]) + + ret2 = example4(v2, 1) + int_list: list[int] = ret2 + str_list: list[str] = ret2 + + +@overload +def example5(obj: list[int]) -> list[int]: ... + + +@overload +def example5(obj: list[str]) -> list[str]: ... + + +def example5(obj: Any) -> list[Any]: + return [] + + +def check_example5(b: list[Any]) -> None: + ret = example5(b) + int_list: list[int] = ret + str_list: list[str] = ret + + +@overload +def example6(a: int, b: Any) -> float: ... + + +@overload +def example6(a: float, b: T) -> T: ... + + +def example6(a: float, b: T) -> T: + raise NotImplementedError + + +def check_example6(a: list[Any], b: Any, c: str) -> None: + m: list[int] = [] + + # All possible materializations of list[Any] are + # assignable to Any, so this matches the first overload + # and eliminates all subsequent overloads. + v1 = example6(1, a) + assert_type(v1, float) + + # All possible materializations of Any are + # assignable to Any, so this matches the first overload + # and eliminates all subsequent overloads. + v2 = example6(1, b) + assert_type(v2, float) + + # All possible materializations of list[int] are + # assignable to Any, so this matches the first overload + # and eliminates all subsequent overloads. + v3 = example6(1, m) + assert_type(v3, float) + + v4 = example6(1.0, c) + assert_type(v4, str) + + v5 = example6(1.0, b) + assert_type(v5, Any) + + v6 = example6(1.0, m) + assert_type(v6, list[int]) + + +@overload +def example7(x: list[Any], y: int) -> list[int]: ... + + +@overload +def example7(x: list[Any], y: str) -> list[str]: ... + + +def example7(x: list[Any], y: int | str) -> list[int] | list[str]: + return [] + + +def check_example7(v1: list[Any], v2: Any) -> None: + ret1 = example7(v1, 1) + assert_type(ret1, list[int]) + + ret2 = example7(v1, "") + assert_type(ret2, list[str]) + + ret3 = example7(v1, v2) + int_list: list[int] = ret3 + str_list: list[str] = ret3 + + +# The earlier ambiguity cases check assignability of list return types. This +# checks distinct scalar return types and operations specific to each type. + + +def check_ambiguous_scalar_return(v: Any) -> None: + ret = example2(1, v, 1) + int_result: int = ret + str_result: str = ret + _ = ret + 1 + ret.upper() diff --git a/conformance/tests/protocols_class_objects.py b/conformance/tests/protocols_class_objects.py index 73dc35775..2a498438b 100644 --- a/conformance/tests/protocols_class_objects.py +++ b/conformance/tests/protocols_class_objects.py @@ -93,6 +93,9 @@ class ConcreteC2: class CMeta(type): attr1: int + def __init__(self, *args, **kwargs) -> None: + self.attr1: int = 1 + class ConcreteC3(metaclass=CMeta): pass @@ -102,5 +105,5 @@ class ConcreteC3(metaclass=CMeta): pc2: ProtoC2 = ConcreteC1 # OK pc3: ProtoC1 = ConcreteC2 # E pc4: ProtoC2 = ConcreteC2 # E -pc5: ProtoC1 = ConcreteC3 # E +pc5: ProtoC1 = ConcreteC3 # E?: Explicit ClassVar matching is unspecified pc6: ProtoC2 = ConcreteC3 # OK diff --git a/conformance/tests/protocols_definition.py b/conformance/tests/protocols_definition.py index 30b5cbcd9..7252dfc16 100644 --- a/conformance/tests/protocols_definition.py +++ b/conformance/tests/protocols_definition.py @@ -114,7 +114,7 @@ class Concrete2_Bad4: v2_bad1: Template2 = Concrete2_Bad1() # E v2_bad2: Template2 = Concrete2_Bad2() # E v2_bad3: Template2 = Concrete2_Bad3() # E -v2_bad4: Template2 = Concrete2_Bad4() # E +v2_bad4: Template2 = Concrete2_Bad4() # E?: Explicit ClassVar matching is unspecified class Template3(Protocol): @@ -196,7 +196,7 @@ class Concrete4_Good6(NamedTuple): @dataclass(frozen=False) class Concrete4_Good7: - val1: Sequence[float] = [0] + val1: Sequence[float] = (0,) class Concrete4_Bad1: @@ -315,7 +315,7 @@ class Concrete6_Good2: @dataclass(frozen=False) class Concrete6_Good3: - val1: Sequence[float] = [0] + val1: Sequence[float] = (0,) class Concrete6_Bad1: @@ -330,7 +330,7 @@ class Concrete6_Bad2(NamedTuple): @dataclass(frozen=True) class Concrete6_Bad3: - val1: Sequence[float] = [0] + val1: Sequence[float] = (0,) v6_good1: Template6 = Concrete6_Good1() # OK @@ -339,3 +339,32 @@ class Concrete6_Bad3: v6_bad1: Template6 = Concrete6_Bad1() # E v6_bad2: Template6 = Concrete6_Bad2() # E: named tuple is immutable v6_bad3: Template6 = Concrete6_Bad3() # E: dataclass is frozen + + +# The specification leaves two possible interpretations of a ClassVar protocol +# member. One interpretation requires the implementing attribute to be explicitly +# declared with ClassVar. The other interpretation imposes only structural +# requirements: the attribute must be readable and writable on the class object +# and readable on instances of the class. Both interpretations therefore require +# the following assignments to be rejected. + + +class Template7(Protocol): + val1: ClassVar[int] + + +class Concrete7_Bad1: + def __init__(self) -> None: + self.val1: int = 42 + + +class Concrete7Meta(type): + val1: int = 42 + + +class Concrete7_Bad2(metaclass=Concrete7Meta): + pass + + +v7_bad1: Template7 = Concrete7_Bad1() # E: val1 is not readable on the class object +v7_bad2: Template7 = Concrete7_Bad2() # E: val1 is not readable on instances diff --git a/conformance/tests/protocols_explicit.py b/conformance/tests/protocols_explicit.py index 98f88dce3..70fd56445 100644 --- a/conformance/tests/protocols_explicit.py +++ b/conformance/tests/protocols_explicit.py @@ -54,6 +54,7 @@ def transparency(self) -> int: class Point(RGB): def __init__(self, red: int, green: int, blue: str) -> None: self.rgb = red, green, blue # E: 'blue' must be 'int' + self.other = 0 p = Point(0, 0, "") # E: Cannot instantiate abstract class @@ -80,7 +81,9 @@ class Proto3(Proto2, Protocol): class Concrete1(Proto1): - ... + def __init__(self): + self.im1 = 1 + self.im3 = 3 c1 = Concrete1() # E: cannot instantiate abstract class @@ -98,10 +101,12 @@ class Concrete3(Proto1, Proto3): cm1 = 3 def __init__(self): - im1 = 0 + self.im1 = 0 + self.cm10 = 10 + self.cm11 = 11 -c3 = Concrete3() # E: cannot instantiate abstract class +c3 = Concrete3() class Concrete4(Proto1, Proto3): diff --git a/conformance/tests/protocols_generic.py b/conformance/tests/protocols_generic.py index d3bbf8a0c..be7525e56 100644 --- a/conformance/tests/protocols_generic.py +++ b/conformance/tests/protocols_generic.py @@ -40,7 +40,7 @@ def method1(self, x: str) -> str: p2: Proto1[int, str] = Concrete1() # E: incompatible type -# Runtime error: Protocol and Generic cannot be used together as base classes. +# > It is an error to combine the shorthand with Generic[T, S, ...] class Proto2(Protocol[T_co], Generic[T_co]): # E ... @@ -75,8 +75,19 @@ def func3(attr_int: AttrProto[int], attr_float: AttrProto[float]): v2: AttrProto[int] = attr_float # E +# Specification: https://typing.readthedocs.io/en/latest/spec/protocol.html#self-types-in-protocols +# > The self-types in protocols follow the rules for other methods. +# Specification: https://typing.readthedocs.io/en/latest/spec/annotations.html#annotating-instance-and-class-methods +# > In addition, the first argument in an instance method can be annotated +# > with a type variable. In this case the return type may use the same +# > type variable, thus making that method a generic function. + + +T_bounded = TypeVar("T_bounded", bound="HasParent") + + class HasParent(Protocol): - def get_parent(self: T) -> T: + def get_parent(self: T_bounded) -> T_bounded: ... @@ -96,52 +107,79 @@ def get_parent(self) -> Self: assert_type(parent, ConcreteHasParent) -class HasPropertyProto(Protocol): - @property - def f(self: T) -> T: - ... +# Specification: https://typing.readthedocs.io/en/latest/spec/generics.html#use-in-protocols +# > `Self` is valid within Protocols, similar to its use in classes: - def m(self, item: T, callback: Callable[[T], str]) -> str: + +class HasParentProperty(Protocol): + @property + def parent(self) -> Self: ... -class ConcreteHasProperty1: +class ConcreteParentProperty: @property - def f(self: T) -> T: + def parent(self) -> Self: return self + +class InvalidParentProperty: + @property + def parent(self) -> HasParentProperty: + return ConcreteParentProperty() + + +hp1: HasParentProperty = ConcreteParentProperty() # OK +hp2: HasParentProperty = InvalidParentProperty() # E + + + +class HasMethod(Protocol): def m(self, item: T, callback: Callable[[T], str]) -> str: - return "" + ... -class ConcreteHasProperty2: - @property - def f(self) -> Self: - return self +class ConcreteHasMethod: + def m(self, item: T, callback: Callable[[T], str]) -> str: + return "" + +class InvalidHasMethod: def m(self, item: int, callback: Callable[[int], str]) -> str: return "" -class ConcreteHasProperty3: - @property - def f(self) -> int: - return 0 +hm1: HasMethod = ConcreteHasMethod() # OK +hm2: HasMethod = InvalidHasMethod() # E - def m(self, item: int, callback: Callable[[int], str]) -> str: - return "" +# Specification: https://typing.readthedocs.io/en/latest/spec/generics.html#use-in-protocols +# > Checking a class for assignability to a protocol: If a protocol uses `Self` +# > in methods or attribute annotations, then a class `Foo` is assignable +# > to the protocol if its corresponding methods and attribute annotations use +# > either `Self` or `Foo` or any of `Foo`'s subclasses. -class ConcreteHasProperty4: - @property - def f(self) -> Self: - return self - def m(self, item: str, callback: Callable[[int], str]) -> str: - return "" +class HasGreaterThan(Protocol): + def __gt__(self, other: Self) -> bool: + ... + + +class ConcreteGreaterThan1: + def __gt__(self, other: Self) -> bool: + return False + + +class ConcreteGreaterThan2: + def __gt__(self, other: "ConcreteGreaterThan2") -> bool: + return False + + +class InvalidGreaterThan: + def __gt__(self, other: int) -> bool: + return False -hp1: HasPropertyProto = ConcreteHasProperty1() # OK -hp2: HasPropertyProto = ConcreteHasProperty2() # OK -hp3: HasPropertyProto = ConcreteHasProperty3() # E -hp4: HasPropertyProto = ConcreteHasProperty4() # E +hg1: HasGreaterThan = ConcreteGreaterThan1() # OK +hg2: HasGreaterThan = ConcreteGreaterThan2() # OK +hg3: HasGreaterThan = InvalidGreaterThan() # E diff --git a/conformance/tests/protocols_merging.py b/conformance/tests/protocols_merging.py index 6540de7ed..e989e4ef8 100644 --- a/conformance/tests/protocols_merging.py +++ b/conformance/tests/protocols_merging.py @@ -49,8 +49,8 @@ def close(self) -> None: s4: SizedAndClosable2 = SizedAndClosable3() # OK s5: Sized = SCConcrete1() # OK -s6: SizedAndClosable1 = SCConcrete2() # E: doesn't implement close -s7: SizedAndClosable2 = SCConcrete2() # E: doesn't implement close +s6: SizedAndClosable1 = SCConcrete2() # E: doesn't implement `__len__` +s7: SizedAndClosable2 = SCConcrete2() # E: doesn't implement `__len__` s8: SizedAndClosable3 = SCConcrete2() # E: SizedAndClosable3 is not a protocol diff --git a/conformance/tests/protocols_recursive.py b/conformance/tests/protocols_recursive.py index 9b6c9f03a..9461f4a60 100644 --- a/conformance/tests/protocols_recursive.py +++ b/conformance/tests/protocols_recursive.py @@ -74,7 +74,7 @@ def method2(cls: type[ProtoB[object, T]], value: list[T]) -> None: def func1(x: ProtoA[Never, T]) -> T: - ... + raise NotImplementedError v1 = func1(ImplB()) diff --git a/conformance/tests/protocols_runtime_checkable.py b/conformance/tests/protocols_runtime_checkable.py index 68fdf8fe8..8f5782f87 100644 --- a/conformance/tests/protocols_runtime_checkable.py +++ b/conformance/tests/protocols_runtime_checkable.py @@ -88,9 +88,7 @@ def func3(): if isinstance(Concrete3A(), Proto3): # E: unsafe overlap pass - if isinstance( - Concrete3B(), (Proto3, NonDataProtocol) # E: unsafe overlap - ): + if isinstance(Concrete3B(), (Proto3, NonDataProtocol)): # E: unsafe overlap pass if issubclass(Concrete3A, (Proto3, NonDataProtocol)): # E: unsafe overlap diff --git a/conformance/tests/protocols_variance.py b/conformance/tests/protocols_variance.py index cc3f715d3..724692b60 100644 --- a/conformance/tests/protocols_variance.py +++ b/conformance/tests/protocols_variance.py @@ -4,14 +4,15 @@ # Specification: https://typing.readthedocs.io/en/latest/spec/protocol.html#generic-protocols -from typing import ParamSpec, Protocol, TypeVar +from typing import Protocol, TypeVar +from typing_extensions import ParamSpec T1 = TypeVar("T1") T2 = TypeVar("T2", bound=int) T3 = TypeVar("T3", bytes, str) T1_co = TypeVar("T1_co", covariant=True) T1_contra = TypeVar("T1_contra", contravariant=True) -P = ParamSpec("P") +P = ParamSpec("P", contravariant=True) R = TypeVar("R", covariant=True) # > Type checkers will warn if the inferred variance is different from the @@ -58,8 +59,8 @@ def m1(self, p0: T1) -> None: ... -class Protocol5(Protocol[T1_co]): # E: T1_co should be contravariant - def m1(self, p0: T1_co) -> None: # E?: Incorrect use of covariant TypeVar +class Protocol5(Protocol[T1_co]): # E[covariant_in_input+] + def m1(self, p0: T1_co) -> None: # E[covariant_in_input+] ... @@ -68,8 +69,8 @@ def m1(self) -> T1: ... -class Protocol7(Protocol[T1_contra]): # E: T1_contra should be covariant - def m1(self) -> T1_contra: # E?: Incorrect use of contravariant TypeVar +class Protocol7(Protocol[T1_contra]): # E[contravariant_in_output+] + def m1(self) -> T1_contra: # E[contravariant_in_output+] ... diff --git a/conformance/tests/pyrefly.toml b/conformance/tests/pyrefly.toml new file mode 100644 index 000000000..c9c44e591 --- /dev/null +++ b/conformance/tests/pyrefly.toml @@ -0,0 +1 @@ +# Empty configuration file to make sure pyrefly treats this directory as the project root. diff --git a/conformance/tests/qualifiers_annotated.py b/conformance/tests/qualifiers_annotated.py index adc4f78db..1b2b61a73 100644 --- a/conformance/tests/qualifiers_annotated.py +++ b/conformance/tests/qualifiers_annotated.py @@ -33,11 +33,6 @@ Good6: Annotated[Callable[..., int], ""] Good7: Annotated["int | str", ""] Good8: Annotated[list["int | str"], ""] -Good9: Annotated[Literal[3, 4, 5, None], x := 3] - - -async def func3() -> None: - Good10: Annotated[str, await func3()] Bad1: Annotated[[int, str], ""] # E: invalid type expression @@ -115,7 +110,4 @@ class ClassC(TypedDict): TA1: TypeAlias = Annotated[int | str, ""] TA2 = Annotated[Literal[1, 2], ""] - -T = TypeVar("T") - TA3 = Annotated[T, ""] diff --git a/conformance/tests/qualifiers_final_annotation.py b/conformance/tests/qualifiers_final_annotation.py index c20a82528..0dc611211 100644 --- a/conformance/tests/qualifiers_final_annotation.py +++ b/conformance/tests/qualifiers_final_annotation.py @@ -2,7 +2,7 @@ Tests the typing.Final special form. """ -from typing import ClassVar, Final, Literal, NamedTuple, assert_type +from typing import ClassVar, Final, Literal, NamedTuple, TypedDict, assert_type # Specification: https://typing.readthedocs.io/en/latest/spec/qualifiers.html#id1 @@ -122,6 +122,20 @@ def func1(x: Final[list[int]]) -> None: # E ... +# > ``Final`` cannot be used as a qualifier for a TypedDict item or a +# > NamedTuple field. Such usage also generates an error at runtime. + + +class TDWithFinal(TypedDict): + a: int + b: Final[int] # E: Final not allowed in a TypedDict + + +class NTWithFinal(NamedTuple): + a: int + b: Final[int] # E: Final not allowed in a NamedTuple + + # > Type checkers should treat uses of a final name that was initialized with # > a literal as if it was replaced by the literal. For example, the following # > should be allowed: @@ -138,18 +152,33 @@ def func1(x: Final[list[int]]) -> None: # E def func2() -> None: global ID1 - ID1 = 2 # E: cannot modify Final value + ID1 = 2 # E: cannot modify Final value x: Final = 3 - x += 1 # E: cannot modify Final value + x += 1 # E: cannot modify Final value a = (x := 4) # E: cannot modify Final value - for x in [1, 2, 3]: # E: cannot modify Final value + for x in [1, 2, 3]: # E: cannot modify Final value pass - with open("FileName") as x: # E: cannot modify Final value + with open("FileName") as x: # E: cannot modify Final value pass (a, x) = (1, 2) # E: cannot modify Final value + + +# > If a module declares a ``Final`` variable and another module imports that +# > variable in an import statement by name or wildcard, the imported symbol +# > inherits the ``Final`` type qualifier. Any attempt to assign a different value +# > to this symbol should be flagged as an error by a type checker. + + +from _qualifiers_final_annotation_1 import TEN + +TEN = 9 # E: Cannot redefine Final value + +from _qualifiers_final_annotation_2 import * + +PI = 3.14159 # E: Cannot redefine Final value diff --git a/conformance/tests/qualifiers_final_decorator.py b/conformance/tests/qualifiers_final_decorator.py index 3523ae531..5f131f462 100644 --- a/conformance/tests/qualifiers_final_decorator.py +++ b/conformance/tests/qualifiers_final_decorator.py @@ -65,7 +65,7 @@ def method3() -> None: # E[method3] pass @overload # E[method4] - def method4(self, x: int) -> int: + def method4(self, x: int) -> int: # E[method4] ... @overload @@ -78,7 +78,7 @@ def method4(self, x: int | str) -> int | str: # E[method4] class Derived3(Base3): @overload # E[Derived3] - def method(self, x: int) -> int: + def method(self, x: int) -> int: # E[Derived3] ... @overload # E[Derived3-2] @@ -92,7 +92,7 @@ def method(self, x: int | str) -> int | str: # E[Derived3] class Derived4(Base4): @overload # E[Derived4] - def method(self, x: int) -> int: + def method(self, x: int) -> int: # E[Derived4] ... @overload diff --git a/conformance/tests/specialtypes_never.py b/conformance/tests/specialtypes_never.py index 339c6f000..a3ffb4cc1 100644 --- a/conformance/tests/specialtypes_never.py +++ b/conformance/tests/specialtypes_never.py @@ -24,12 +24,11 @@ def func1(x: int) -> NoReturn: # E: implicitly returns None # > The checkers will also recognize that the code after calls to such functions # > is unreachable and will behave accordingly. - +# No error on implicit None return after stop() def func2(x: int) -> int: if x > 0: return x stop() - return "whatever works" # No type error # The spec previously said that NoReturn is only valid in a function return type, @@ -56,6 +55,10 @@ class ClassA: x: NoReturn y: list[NoReturn] + def __init__(self, x: NoReturn, y: list[NoReturn]) -> None: + self.x = x + self.y = y + # Never is compatible with all types. diff --git a/conformance/tests/specialtypes_sentinels.py b/conformance/tests/specialtypes_sentinels.py new file mode 100644 index 000000000..73c257017 --- /dev/null +++ b/conformance/tests/specialtypes_sentinels.py @@ -0,0 +1,40 @@ +from typing_extensions import Sentinel, assert_type + +# > Sentinel objects may be used in type annotations if they are defined using +# > a simple assignment of the form ``NAME = sentinel('NAME')`` in the +# > global scope or in a class body that is not within a function. + +MISSING = Sentinel("") # name is not required to match the variable name +SPECIAL = Sentinel("SPECIAL") + +class Cls: + IN_CLASS = Sentinel("Cls.IN_CLASS") + + +def func1(x: int = MISSING) -> None: # E: incompatible default + pass + +# > Type checkers must support narrowing union types involving sentinels using the +# > ``is`` and ``is not`` operators + +def func2(x: int | MISSING | SPECIAL = MISSING) -> None: + if x is MISSING: + assert_type(x, MISSING) + else: + assert_type(x, int | SPECIAL) + +def func3(x: int | Cls.IN_CLASS = Cls.IN_CLASS) -> None: + if x is Cls.IN_CLASS: + assert_type(x, Cls.IN_CLASS) + else: + assert_type(x, int) + + +func2(1) # ok +func2(MISSING) # ok +func2(SPECIAL) # ok +func2(Cls.IN_CLASS) # E: incompatible argument + +func3(1) # ok +func3(MISSING) # E: incompatible argument +func3(Cls.IN_CLASS) # ok diff --git a/conformance/tests/tuples_type_compat.py b/conformance/tests/tuples_type_compat.py index 73f3b3ad5..27b76921f 100644 --- a/conformance/tests/tuples_type_compat.py +++ b/conformance/tests/tuples_type_compat.py @@ -7,7 +7,7 @@ # > Because tuple contents are immutable, the element types of a tuple are covariant. -from typing import Any, Iterable, Never, Sequence, TypeVar, assert_type +from typing import Any, Iterable, Never, Sequence, TypeAlias, TypeVar, assert_type def func1(t1: tuple[float, complex], t2: tuple[int, int]): @@ -67,19 +67,23 @@ def func4( # NOTE: This type narrowing functionality is optional, not mandated. +Func5Input: TypeAlias = tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int] -def func5(val: tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]): +def func5(val: Func5Input): if len(val) == 1: # Type can be narrowed to tuple[int]. - assert_type(val, tuple[int]) # tuple[int] + assert_type(val, tuple[int]) # E[func5_1] + assert_type(val, Func5Input) # E[func5_1] if len(val) == 2: # Type can be narrowed to tuple[str, str] | tuple[int, int]. - assert_type(val, tuple[str, str] | tuple[int, int]) + assert_type(val, tuple[str, str] | tuple[int, int]) # E[func5_2] + assert_type(val, Func5Input) # E[func5_2] if len(val) == 3: # Type can be narrowed to tuple[int, str, int]. - assert_type(val, tuple[int, str, int]) + assert_type(val, tuple[int, str, int]) # E[func5_3] + assert_type(val, Func5Input) # E[func5_3] # > This property may also be used to safely narrow tuple types within a match @@ -87,20 +91,25 @@ def func5(val: tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]) # NOTE: This type narrowing functionality is optional, not mandated. +Func6Input: TypeAlias = tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int] -def func6(val: tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]): + +def func6(val: Func6Input): match val: case (x,): - # Type can be narrowed to tuple[int]. - assert_type(val, tuple[int]) # tuple[int] + # Type may be narrowed to tuple[int]. + assert_type(val, tuple[int]) # E[func6_1] + assert_type(val, Func6Input) # E[func6_1] case (x, y): - # Type can be narrowed to tuple[str, str] | tuple[int, int]. - assert_type(val, tuple[str, str] | tuple[int, int]) + # Type may be narrowed to tuple[str, str] | tuple[int, int]. + assert_type(val, tuple[str, str] | tuple[int, int]) # E[func6_2] + assert_type(val, Func6Input) # E[func6_2] case (x, y, z): - # Type can be narrowed to tuple[int, str, int]. - assert_type(val, tuple[int, str, int]) + # Type may be narrowed to tuple[int, str, int]. + assert_type(val, tuple[int, str, int]) # E[func6_3] + assert_type(val, Func6Input) # E[func6_3] # > Type checkers may safely use this equivalency rule (tuple expansion) @@ -108,13 +117,17 @@ def func6(val: tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]) # NOTE: This type narrowing functionality is optional, not mandated. +Func7Input: TypeAlias = tuple[int | str, int | str] + -def func7(subj: tuple[int | str, int | str]): +def func7(subj: Func7Input): match subj: case x, str(): - assert_type(subj, tuple[int | str, str]) + assert_type(subj, tuple[int | str, str]) # E[func7_1] + assert_type(subj, Func7Input) # E[func7_1] case y: - assert_type(subj, tuple[int | str, int]) + assert_type(subj, tuple[int | str, int]) # E[func7_2] + assert_type(subj, Func7Input) # E[func7_2] # > The tuple class derives from Sequence[T_co] where ``T_co`` is a covariant diff --git a/conformance/tests/tuples_unpacked.py b/conformance/tests/tuples_unpacked.py index ca58af7a7..706b58f83 100644 --- a/conformance/tests/tuples_unpacked.py +++ b/conformance/tests/tuples_unpacked.py @@ -57,6 +57,6 @@ def func3(t: tuple[*Ts]): t11: tuple[Unpack[tuple[str]], Unpack[tuple[str]]] # OK t12: tuple[Unpack[tuple[str, Unpack[tuple[str, ...]]]]] # OK t13: tuple[Unpack[tuple[str, ...]], Unpack[tuple[int, ...]]] # E -t14: tuple[ - Unpack[tuple[str, Unpack[tuple[str, ...]]]], Unpack[tuple[int, ...]] # E +t14: tuple[ # E[t14] + Unpack[tuple[str, Unpack[tuple[str, ...]]]], Unpack[tuple[int, ...]] # E[t14] ] diff --git a/conformance/tests/ty.toml b/conformance/tests/ty.toml new file mode 100644 index 000000000..dcd178048 --- /dev/null +++ b/conformance/tests/ty.toml @@ -0,0 +1,12 @@ +[environment] +python-version = "3.12" + +[rules] +deprecated = "error" +invalid-legacy-positional-parameter = "error" +redundant-final-classvar = "error" +assert-type-unspellable-subtype = "ignore" +invalid-enum-member-annotation = "error" +mismatched-type-name = "error" +invalid-named-tuple-override = "error" +ambiguous-protocol-member = "error" diff --git a/conformance/tests/typeddicts_alt_syntax.py b/conformance/tests/typeddicts_alt_syntax.py index a08b10555..93d1b4334 100644 --- a/conformance/tests/typeddicts_alt_syntax.py +++ b/conformance/tests/typeddicts_alt_syntax.py @@ -42,4 +42,4 @@ movie2: Movie2 movie2 = {"name": "Blade Runner", "year": 1982} # E?: May generate errors if keyword-argument syntax is unsupported -movie2 = {"name": "Blade Runner", "year": ""} # E: Incorrect type for year +movie2 = {"name": "Blade Runner", "year": ""} # E?: Incorrect type for year diff --git a/conformance/tests/typeddicts_class_syntax.py b/conformance/tests/typeddicts_class_syntax.py index d2983b76a..b2ebf12b6 100644 --- a/conformance/tests/typeddicts_class_syntax.py +++ b/conformance/tests/typeddicts_class_syntax.py @@ -5,6 +5,7 @@ # Specification: https://typing.readthedocs.io/en/latest/spec/typeddict.html#typeddict from typing import Generic, TypeVar, TypedDict +import sys class Movie(TypedDict): @@ -30,18 +31,22 @@ def method1(self): # E pass # Methods are not allowed, so this should generate an error. - @classmethod # E - def method2(cls): + @classmethod # E[method2] + def method2(cls): # E[method2] pass # Methods are not allowed, so this should generate an error. - @staticmethod # E - def method3(): + @staticmethod # E[method3] + def method3(): # E[method3] pass -# > Specifying a metaclass is not allowed. -class BadTypedDict2(TypedDict, metaclass=type): # E +class CustomMeta(type): + pass + + +# > Specifying a custom metaclass is not allowed. +class BadTypedDict2(TypedDict, metaclass=CustomMeta): # E name: str @@ -49,12 +54,26 @@ class BadTypedDict2(TypedDict, metaclass=type): # E class BadTypedDict3(TypedDict, other=True): # E name: str +# > `if` conditions that the type checker is able to +# > statically evaluate are also permitted (e.g. `if sys.version_info > (3, 14)`), +# > in order to specify items that exist only under the given conditions. +class ConditionalField(TypedDict): + x: int + if sys.version_info >= (3, 12): + y: int + if sys.version_info >= (4, 0): + z: int + +# The conformance suite runs type checkers configured to Python 3.12 or later: +ConditionalField(x=1, y=2) +ConditionalField(x=1, y=2, z=3) # E + # > TypedDicts may be made generic by adding Generic[T] among the bases. T = TypeVar("T") -class GenericTypedDict(Generic[T]): +class GenericTypedDict(TypedDict, Generic[T]): name: str value: T diff --git a/conformance/tests/typeddicts_extra_items.py b/conformance/tests/typeddicts_extra_items.py new file mode 100644 index 000000000..20354bb8a --- /dev/null +++ b/conformance/tests/typeddicts_extra_items.py @@ -0,0 +1,356 @@ +# pyright: enableExperimentalFeatures=true +from collections.abc import Mapping +from typing_extensions import ReadOnly, TypedDict, Unpack +from typing import assert_type, Required, NotRequired, Never + + +# > For a TypedDict type that specifies +# > ``extra_items``, during construction, the value type of each unknown item +# is expected to be non-required and assignable to the ``extra_items`` argument. + +class Movie(TypedDict, extra_items=bool): + name: str + +a: Movie = {"name": "Blade Runner", "novel_adaptation": True} # OK +b: Movie = {"name": "Blade Runner", "year": 1982} # E: 'int' is not assignable to 'bool' + +# > The alternative inline syntax is also supported:: + +MovieFunctional = TypedDict("MovieFunctional", {"name": str}, extra_items=bool) + +c: MovieFunctional = {"name": "Blade Runner", "novel_adaptation": True} # OK +d: MovieFunctional = {"name": "Blade Runner", "year": 1982} # E: 'int' is not assignable to 'bool' + +# > Accessing extra items is allowed. Type checkers must infer their value type from +# > the ``extra_items`` argument + +def movie_keys(movie: Movie) -> None: + assert_type(movie["name"], str) + assert_type(movie["novel_adaptation"], bool) + +# > ``extra_items`` is inherited through subclassing + +class MovieBase(TypedDict, extra_items=ReadOnly[int | None]): + name: str + +class InheritedMovie(MovieBase): + year: int + +e: InheritedMovie = {"name": "Blade Runner", "year": None} # E: 'None' is incompatible with 'int' +f: InheritedMovie = { + "name": "Blade Runner", + "year": 1982, + "other_extra_key": None, +} # OK + +# > Similar to ``total``, only a literal ``True`` or ``False`` is supported as the +# > value of the ``closed`` argument. Type checkers should reject any non-literal value. + +class IllegalTD(TypedDict, closed=42 == 42): # E: Argument to "closed" must be a literal True or False + name: str + +# > Passing ``closed=False`` explicitly requests the default TypedDict behavior, +# > where arbitrary other keys may be present and subclasses may add arbitrary items. + +class BaseTD(TypedDict, closed=False): + name: str + +class ChildTD(BaseTD): # OK + age: int + +# > It is a type checker error to pass ``closed=False`` if a superclass has +# > ``closed=True`` or sets ``extra_items``. + +class ClosedBase(TypedDict, closed=True): + name: str + +class IllegalChild1(ClosedBase, closed=False): # E: Cannot set 'closed=False' when superclass is 'closed=True' + pass + +class ExtraItemsBase(TypedDict, extra_items=int): + name: str + +class IllegalChild2(ExtraItemsBase, closed=False): # E: Cannot set 'closed=False' when superclass has 'extra_items' + pass + +# > If ``closed`` is not provided, the behavior is inherited from the superclass. +# > If the superclass is TypedDict itself or the superclass does not have ``closed=True`` +# > or the ``extra_items`` parameter, the previous TypedDict behavior is preserved: +# > arbitrary extra items are allowed. If the superclass has ``closed=True``, the +# > child class is also closed. + +class BaseMovie(TypedDict, closed=True): + name: str + +class MovieA(BaseMovie): # OK, still closed + pass + +class MovieB(BaseMovie, closed=True): # OK, but redundant + pass + +class MovieC(MovieA): # E[MovieC] + age: int # E[MovieC]: "MovieC" is a closed TypedDict; extra key "age" not allowed + +class MovieD(MovieB): # E[MovieD] + age: int # E[MovieD]: "MovieD" is a closed TypedDict; extra key "age" not allowed + +# > It is possible to use ``closed=True`` when subclassing if the ``extra_items`` +# > argument is a read-only type. + +class MovieES(TypedDict, extra_items=ReadOnly[str]): + pass + +class MovieClosed(MovieES, closed=True): # OK + pass + +class MovieNever(MovieES, extra_items=Never): # OK, but 'closed=True' is preferred + pass + +class IllegalCloseNonReadOnly(ExtraItemsBase, closed=True): # E: Cannot set 'closed=True' when superclass has non-read-only 'extra_items' + pass + +# > It is an error to use ``Required[]`` or ``NotRequired[]`` with ``extra_items``. + +class IllegalExtraItemsTD(TypedDict, extra_items=Required[int]): # E: 'extra_items' value cannot be 'Required[...]' + name: str + +class AnotherIllegalExtraItemsTD(TypedDict, extra_items=NotRequired[int]): # E: 'extra_items' value cannot be 'NotRequired[...]' + name: str + +# > The extra items are non-required, regardless of the totality of the +# > TypedDict. Operations that are available to ``NotRequired`` items should also be available to the +# > extra items. + +class MovieEI(TypedDict, extra_items=int): + name: str + +def del_items(movie: MovieEI) -> None: + del movie["name"] # E: The value type of 'name' is 'Required[str]' + del movie["year"] # OK: The value type of 'year' is 'NotRequired[int]' + +# > For type checking purposes, ``Unpack[SomeTypedDict]`` with extra items should be +# > treated as its equivalent in regular parameters. + +class MovieNoExtra(TypedDict): + name: str + +class MovieExtra(TypedDict, extra_items=int): + name: str + +def unpack_no_extra(**kwargs: Unpack[MovieNoExtra]) -> None: ... +def unpack_extra(**kwargs: Unpack[MovieExtra]) -> None: ... + +unpack_no_extra(name="No Country for Old Men", year=2007) # E?: Unrecognized item +unpack_extra(name="No Country for Old Men", year=2007) # OK + +# > Notably, if the TypedDict type specifies ``extra_items`` to be read-only, +# > subclasses of the TypedDict type may redeclare ``extra_items``. + +class ReadOnlyBase(TypedDict, extra_items=ReadOnly[int]): + pass + +class ReadOnlyChild(ReadOnlyBase, extra_items=ReadOnly[bool]): # OK + pass + +class MutableChild(ReadOnlyBase, extra_items=int): # OK + pass + +# > Because a non-closed TypedDict type implicitly allows non-required extra items +# > of value type ``ReadOnly[object]``, its subclass can override the +# > ``extra_items`` argument with more specific types. + +class NonClosedBase(TypedDict): + name: str + +class SpecificExtraItems(NonClosedBase, extra_items=bytes): # OK + year: int + +# > First, it is not allowed to change the value of ``extra_items`` in a subclass +# > unless it is declared to be ``ReadOnly`` in the superclass. + +class Parent(TypedDict, extra_items=int | None): + pass + +class Child(Parent, extra_items=int): # E: Cannot change 'extra_items' type unless it is 'ReadOnly' in the superclass + pass + +# > Second, ``extra_items=T`` effectively defines the value type of any unnamed +# > items accepted to the TypedDict and marks them as non-required. Thus, the above +# > restriction applies to any additional items defined in a subclass. + +class MovieBase2(TypedDict, extra_items=int | None): + name: str + +class MovieRequiredYear(MovieBase2): # E[MovieRequiredYear]: Required key 'year' is not known to 'MovieBase2' + year: int | None # E[MovieRequiredYear] + +class MovieNotRequiredYear(MovieBase2): # E[MovieNotRequiredYear]: 'int | None' is not consistent with 'int' + year: NotRequired[int] # E[MovieNotRequiredYear] + +class MovieWithYear(MovieBase2): # OK + year: NotRequired[int | None] + +class BookBase(TypedDict, extra_items=ReadOnly[int | None]): + name: str + +class BookWithPublisher(BookBase): # E[BookWithPublisher]: 'str' is not assignable to 'int | None' + publisher: str # E[BookWithPublisher] + +# > Let ``S`` be the set of keys of the explicitly defined items on a TypedDict +# > type. If it specifies ``extra_items=T``, the TypedDict type is considered to +# > have an infinite set of items that all satisfy the following conditions. +# > - If ``extra_items`` is read-only: +# > - The key's value type is :term:`assignable` to ``T``. +# > - The key is not in ``S``. +# > - If ``extra_items`` is not read-only: +# > - The key is non-required. +# > - The key's value type is :term:`consistent` with ``T``. +# > - The key is not in ``S``. + +class MovieDetails(TypedDict, extra_items=int | None): + name: str + year: NotRequired[int] + +details2: MovieDetails = {"name": "Kill Bill Vol. 1", "year": 2003} +movie2: MovieBase2 = details2 # E: While 'int' is not consistent with 'int | None' + +class MovieWithYear2(TypedDict, extra_items=int | None): + name: str + year: int | None + +details3: MovieWithYear2 = {"name": "Kill Bill Vol. 1", "year": 2003} +movie3: MovieBase2 = details3 # E: 'year' is not required in 'MovieBase2', but it is required in 'MovieWithYear2' + +# > When ``extra_items`` is specified to be read-only on a TypedDict type, it is +# > possible for an item to have a :term:`narrower ` type than the +# > ``extra_items`` argument. + +class MovieSI(TypedDict, extra_items=ReadOnly[str | int]): + name: str + +class MovieDetails4(TypedDict, extra_items=int): + name: str + year: NotRequired[int] + +class MovieDetails5(TypedDict, extra_items=int): + name: str + actors: list[str] + +details4: MovieDetails4 = {"name": "Kill Bill Vol. 2", "year": 2004} +details5: MovieDetails5 = {"name": "Kill Bill Vol. 2", "actors": ["Uma Thurman"]} +movie4: MovieSI = details4 # OK. 'int' is assignable to 'str | int'. +movie5: MovieSI = details5 # E: 'list[str]' is not assignable to 'str | int'. + +# > ``extra_items`` as a pseudo-item follows the same rules that other items have, +# > so when both TypedDicts types specify ``extra_items``, this check is naturally +# > enforced. + +class MovieExtraInt(TypedDict, extra_items=int): + name: str + +class MovieExtraStr(TypedDict, extra_items=str): + name: str + +extra_int: MovieExtraInt = {"name": "No Country for Old Men", "year": 2007} +extra_str: MovieExtraStr = {"name": "No Country for Old Men", "description": ""} +extra_int = extra_str # E: 'str' is not assignable to extra items type 'int' +extra_str = extra_int # E: 'int' is not assignable to extra items type 'str' + +# > A non-closed TypedDict type implicitly allows non-required extra keys of value +# > type ``ReadOnly[object]``. Applying the assignability rules between this type +# > and a closed TypedDict type is allowed. + +class MovieNotClosed(TypedDict): + name: str + +extra_int2: MovieExtraInt = {"name": "No Country for Old Men", "year": 2007} +not_closed: MovieNotClosed = {"name": "No Country for Old Men"} +extra_int2 = not_closed # E: 'extra_items=ReadOnly[object]' implicitly on 'MovieNotClosed' is not assignable to with 'extra_items=int' +not_closed = extra_int2 # OK + +# > TypedDicts that allow extra items of type ``T`` also allow arbitrary keyword +# > arguments of this type when constructed by calling the class object. + +class NonClosedMovie(TypedDict): + name: str + +NonClosedMovie(name="No Country for Old Men") # OK +NonClosedMovie(name="No Country for Old Men", year=2007) # E: Unrecognized item + +class ExtraMovie(TypedDict, extra_items=int): + name: str + +ExtraMovie(name="No Country for Old Men") # OK +ExtraMovie(name="No Country for Old Men", year=2007) # OK +ExtraMovie(name="No Country for Old Men", language="English") # E: Wrong type for extra item 'language' + +# This implies 'extra_items=Never', +# so extra keyword arguments would produce an error +class ClosedMovie(TypedDict, closed=True): + name: str + +ClosedMovie(name="No Country for Old Men") # OK +ClosedMovie(name="No Country for Old Men", year=2007) # E: Extra items not allowed + +# > A TypedDict type is :term:`assignable` to a type of the form ``Mapping[str, VT]`` +# > when all value types of the items in the TypedDict +# > are assignable to ``VT``. + +extra_str3: MovieExtraStr = {"name": "Blade Runner", "summary": ""} +str_mapping: Mapping[str, str] = extra_str3 # OK + +extra_int3: MovieExtraInt = {"name": "Blade Runner", "year": 1982} +int_mapping: Mapping[str, int] = extra_int3 # E: 'int | str' is not assignable with 'int' +int_str_mapping: Mapping[str, int | str] = extra_int3 # OK + +# > Type checkers should infer the precise signatures of ``values()`` and ``items()`` +# > on such TypedDict types. + +def foo(movie: MovieExtraInt) -> None: + assert_type(list(movie.items()), list[tuple[str, int | str]]) + assert_type(list(movie.values()), list[int | str]) + +# > The TypedDict type is :term:`assignable` to ``dict[str, VT]`` if all +# > items on the TypedDict type satisfy the following conditions: +# > - The value type of the item is :term:`consistent` with ``VT``. +# > - The item is not read-only. +# > - The item is not required. + +class IntDict(TypedDict, extra_items=int): + pass + +class IntDictWithNum(IntDict): + num: NotRequired[int] + +def clear_intdict(x: IntDict) -> None: + v: dict[str, int] = x # OK + v.clear() # OK + +not_required_num_dict: IntDictWithNum = {"num": 1, "bar": 2} +regular_dict: dict[str, int] = not_required_num_dict # OK +clear_intdict(not_required_num_dict) # OK + +# > In this case, methods that are previously unavailable on a TypedDict are allowed, +# > with signatures matching ``dict[str, VT]`` +# > (e.g.: ``__setitem__(self, key: str, value: VT) -> None``). + +not_required_num_dict.clear() # OK + +assert_type(not_required_num_dict.popitem(), tuple[str, int]) + +def nrnd(not_required_num_dict: IntDictWithNum, key: str): + not_required_num_dict[key] = 42 # OK + del not_required_num_dict[key] # OK + +# > ``dict[str, VT]`` is not assignable to a TypedDict type, +# > because such dict can be a subtype of dict. + +class CustomDict(dict[str, int]): + pass + +def might_not_be(might_not_be_a_builtin_dict: dict[str, int]): + int_dict: IntDict = might_not_be_a_builtin_dict # E + print(int_dict) + +not_a_builtin_dict = CustomDict({"num": 1}) +might_not_be(not_a_builtin_dict) diff --git a/conformance/tests/typeddicts_required.py b/conformance/tests/typeddicts_required.py index d4cef0142..42cecaae8 100644 --- a/conformance/tests/typeddicts_required.py +++ b/conformance/tests/typeddicts_required.py @@ -56,12 +56,13 @@ class TD5(TypedDict, total=True): class TD6(TypedDict): + # > It is also an error to nest a qualifier within itself (e.g., ``Required[Required[T]]``). a: Required[Required[int]] # E: Nesting not allowed b: Required[NotRequired[int]] # E: Nesting not allowed class TD7(TypedDict): - # > Required[] and NotRequired[] can be used with Annotated[], in any nesting order. + # > These type qualifiers may be nested arbitrarily or wrapped in ``Annotated[]``. x: Annotated[Required[int], ""] y: Required[Annotated[int, ""]] z: Annotated[Required[Annotated[int, ""]], ""] diff --git a/conformance/tests/typeforms_typeform.py b/conformance/tests/typeforms_typeform.py new file mode 100644 index 000000000..51b55ca31 --- /dev/null +++ b/conformance/tests/typeforms_typeform.py @@ -0,0 +1,108 @@ +""" +Tests TypeForm functionality. +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/type-forms.html#typeform + +import types +from typing import Annotated, Any, ClassVar, Final, Literal, Optional, Self, TypeVarTuple, Unpack, assert_type +from typing_extensions import TypeForm + + +# > ``TypeForm[T]`` describes the set of all type form objects that represent +# > the type ``T`` or types that are assignable to ``T``. + +ok1: TypeForm[str | None] = str | None # OK +ok2: TypeForm[str | None] = str # OK +ok3: TypeForm[str | None] = None # OK +ok4: TypeForm[str | None] = Literal[None] # OK +ok5: TypeForm[str | None] = Optional[str] # OK +ok6: TypeForm[str | None] = "str | None" # OK +ok7: TypeForm[str | None] = Any # OK + +err1: TypeForm[str | None] = str | int # E +err2: TypeForm[str | None] = list[str | None] # E + + +# > ``TypeForm[Any]`` is assignable both to and from any other ``TypeForm`` type. + +v_any: TypeForm[Any] = int | str +v_str: TypeForm[str] = str +assert_type(v_any, TypeForm[Any]) +assert_type(v_str, TypeForm[str]) + +v_any = v_str # OK +v_str = v_any # OK + +# > The type expression ``TypeForm``, with no type argument provided, is +# > equivalent to ``TypeForm[Any]``. + +def func1(x: TypeForm) -> None: + assert_type(x, TypeForm[Any]) + + +# > Valid type expressions are assignable to ``TypeForm`` through implicit TypeForm evaluation. + +v1_actual: types.UnionType = str | None # OK +v1_type_form: TypeForm[str | None] = str | None # OK + +v2_actual: types.GenericAlias = list[int] # OK +v2_type_form: TypeForm = list[int] # OK + +v3: TypeForm[int | str] = Annotated[int | str, "metadata"] # OK +v4: TypeForm[set[str]] = "set[str]" # OK + +func1(v3) # OK +func1(v4) # OK +func1(int) # OK +func1("int") # OK +func1("not a type") # E + + +# > Expressions that are not valid type expressions should not evaluate to a ``TypeForm`` type. + +Ts = TypeVarTuple("Ts") +var = 1 + +bad1: TypeForm = tuple() # E +bad2: TypeForm = (1, 2) # E +bad3: TypeForm = 1 # E +bad4: TypeForm = Self # E +bad5: TypeForm = ClassVar[int] # E +bad6: TypeForm = Final[int] # E +bad7: TypeForm = Unpack[Ts] # E +bad8: TypeForm = Optional # E +bad9: TypeForm = "int + str" # E + + +# > ``TypeForm`` acts as a function that can be called with a single valid type expression. + +x1 = TypeForm(str | None) +assert_type(x1, TypeForm[str | None]) + +x2 = TypeForm("list[int]") +assert_type(x2, TypeForm[list[int]]) + +x3 = TypeForm("type(1)") # E +x4 = type(1) # OK +x5 = TypeForm(type(1)) # E + + +# > ``TypeForm`` is covariant in its single type parameter. + +def get_type_form() -> TypeForm[int]: + return int + + +t1: TypeForm[int | str] = get_type_form() # OK +t2: TypeForm[str] = get_type_form() # E + + +# > ``type[T]`` is a subtype of ``TypeForm[T]``. + +def get_type() -> type[int]: + return int + + +t3: TypeForm[int | str] = get_type() # OK +t4: TypeForm[str] = get_type() # E diff --git a/conformance/uv.lock b/conformance/uv.lock new file mode 100644 index 000000000..e82462d9a --- /dev/null +++ b/conformance/uv.lock @@ -0,0 +1,330 @@ +version = 1 +revision = 5 +requires-python = "==3.12.*" + +[[package]] +name = "ast-serialize" +version = "0.13.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/21/d5/5dc1ee8a80c3b20a0b63c61b43ba6bc53517faecd1def47bcd752d22268e/ast_serialize-0.13.1.tar.gz", hash = "sha256:401cc84e8888d4d76f2c8d296fa006ed1a5ff993b6aff90dd777c03973efd025", size = 955137, upload-time = "2026-10-17T00:04:17.183Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2b/e2/b0c140fe50fa39dd249e382f7733af6f816c90021fe7959a0b026f86237f/ast_serialize-0.13.1-cp315-abi3.abi3t-macosx_10_12_x86_64.whl", hash = "sha256:23d768369b89d551077dc173da6892fad00443338417523b6732f4e8ba4a7ed5", size = 1236160, upload-time = "2026-10-17T00:03:21.945Z" }, + { url = "https://files.pythonhosted.org/packages/23/c4/a8a2ca21e3943555b48221f8fba546877a7ad39efaf6505506524967d7c4/ast_serialize-0.13.1-cp315-abi3.abi3t-macosx_11_0_arm64.whl", hash = "sha256:68f8829d114dab6c9db4a8bbb8d0e342958faee1b5e15a29022678df639960f8", size = 1222214, upload-time = "2026-10-17T00:03:23.462Z" }, + { url = "https://files.pythonhosted.org/packages/15/19/2f58f2ba64e4799b39de85c140aef09a03aa6ea53be75dd292a9d9b9d8ae/ast_serialize-0.13.1-cp315-abi3.abi3t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4e385b17d5bde892a6184003a9aff3518387908b73f8f5ea539313c07c8c0ede", size = 1282979, upload-time = "2026-10-17T00:03:24.695Z" }, + { url = "https://files.pythonhosted.org/packages/b1/af/ca6087fe84210c1ccd43e3182917bb70649fa1e69745a90c1d59ba08fea8/ast_serialize-0.13.1-cp315-abi3.abi3t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:02686b281ec9b8e9614f6f0db27e12e4cac515f336c5d05b678bc9eb73ff2af5", size = 1288596, upload-time = "2026-10-17T00:03:26.04Z" }, + { url = "https://files.pythonhosted.org/packages/b0/2c/4ef964c763329a0347125e745ec0451ba4fbaceec9efe2ac729b7cd55f17/ast_serialize-0.13.1-cp315-abi3.abi3t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a8ab2c2585b2e22e48cd4aff2136fce4eab4ced569b85f150ef9a5a5d6f34d49", size = 1545540, upload-time = "2026-10-17T00:03:27.52Z" }, + { url = "https://files.pythonhosted.org/packages/bb/85/aa961dbb75813cfa94de0ce9a16a9510c226b95f604c405421e727f44bb0/ast_serialize-0.13.1-cp315-abi3.abi3t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c652d9f5d52d8b81eff3ff2c95c9dd0f281de45f6ad5d3fa95527550c396454a", size = 1309374, upload-time = "2026-10-17T00:03:29.091Z" }, + { url = "https://files.pythonhosted.org/packages/b4/e6/f2b67c327d9f9533e41791804403ccc2dc457821195a2e51f0b587a90b90/ast_serialize-0.13.1-cp315-abi3.abi3t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:121e1d08d58b75c15491cc3003609cbad71ac2b0016043c36d30a6b2032b6605", size = 1303466, upload-time = "2026-10-17T00:03:30.451Z" }, + { url = "https://files.pythonhosted.org/packages/73/1d/33f18b81d1bb1f5d682943ea92fda8130a6593627f12f6201668d40824fd/ast_serialize-0.13.1-cp315-abi3.abi3t-manylinux_2_31_riscv64.whl", hash = "sha256:30cf89b6a6844542d116c758725d13de5b97b9410a51ee577715f761270d0c1c", size = 1300576, upload-time = "2026-10-17T00:03:32.102Z" }, + { url = "https://files.pythonhosted.org/packages/25/cb/64914144925f1a4abdd9217e717b122255c38fc5ebe4342f92052f3bacbc/ast_serialize-0.13.1-cp315-abi3.abi3t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:732aaae9e498c973fc63fd7f308009b57c4afa6ff59d0b674d894e57d0bca01a", size = 1355960, upload-time = "2026-10-17T00:03:33.676Z" }, + { url = "https://files.pythonhosted.org/packages/ee/80/bd29379fab2bce19adc0bf9177002b11b23dfe8d8fecf409998b458b4624/ast_serialize-0.13.1-cp315-abi3.abi3t-musllinux_1_2_aarch64.whl", hash = "sha256:d9c1a920b2aa0c1e016bed7721689717034ca0dba64ac3a3ff243b003d4e8dd8", size = 1459779, upload-time = "2026-10-17T00:03:35.09Z" }, + { url = "https://files.pythonhosted.org/packages/83/89/012dbe733de05ffdf8e40ca0f9fa5d417cb16ec93a74463c57c001914198/ast_serialize-0.13.1-cp315-abi3.abi3t-musllinux_1_2_armv7l.whl", hash = "sha256:847cad4c22953823f5e76d0b126c6f9da670cfa45b1df41b9324e22189d77611", size = 1563399, upload-time = "2026-10-17T00:03:37.285Z" }, + { url = "https://files.pythonhosted.org/packages/69/37/ee4bcb0358bee38744eb0f18560446572d095fe3bf6b63d6f739d08a839c/ast_serialize-0.13.1-cp315-abi3.abi3t-musllinux_1_2_i686.whl", hash = "sha256:aca07de3ca8e3d9f2b716c3c31f4f384fe4bd2d03e09912417cff7a3e08036f7", size = 1558808, upload-time = "2026-10-17T00:03:38.711Z" }, + { url = "https://files.pythonhosted.org/packages/54/1c/ff44c5355251d61ef22934c4430bb31a61de4781d25a992154aac9b8c82a/ast_serialize-0.13.1-cp315-abi3.abi3t-musllinux_1_2_ppc64le.whl", hash = "sha256:5db12d843d931b9d1f1519ce66b9cbfe72d8563b75c1204d255322254d1964dd", size = 1666324, upload-time = "2026-10-17T00:03:40.376Z" }, + { url = "https://files.pythonhosted.org/packages/c8/bb/6da4bfc8aa3403e6447607131bf3463acaf954d990c6c8b6787c1902ddfe/ast_serialize-0.13.1-cp315-abi3.abi3t-musllinux_1_2_riscv64.whl", hash = "sha256:fb8021f4dc3296de18737e3b8b34994411da725374d74a0b9eb32a738f2a23d0", size = 1474089, upload-time = "2026-10-17T00:03:41.715Z" }, + { url = "https://files.pythonhosted.org/packages/21/97/897e33bef2eefd880e6350e375cc66bc5bcd00a139be480fd655f5b3f095/ast_serialize-0.13.1-cp315-abi3.abi3t-musllinux_1_2_x86_64.whl", hash = "sha256:0d764913374ba21df8cd618045b371ed104ce55c6276de7c59e554a4f5ba26fd", size = 1501542, upload-time = "2026-10-17T00:03:43.08Z" }, + { url = "https://files.pythonhosted.org/packages/8d/4c/821211ac83870c27e4412381b7c7838336456b40575bf840e4680b2018d9/ast_serialize-0.13.1-cp315-abi3.abi3t-win32.whl", hash = "sha256:2bad302ae2427454ef9dab71bd5c3ad67188860c39d36daee38f72031edb39c4", size = 1126118, upload-time = "2026-10-17T00:03:44.616Z" }, + { url = "https://files.pythonhosted.org/packages/1f/86/2b2d5e6c4fa352874a80618e742ffd32d249dee6c119f4233b51afc6b8f4/ast_serialize-0.13.1-cp315-abi3.abi3t-win_amd64.whl", hash = "sha256:032b09d86c785c3984e975378b7861f2a68ac44e22ba7b07b93a536b2524eeb8", size = 1163766, upload-time = "2026-10-17T00:03:45.986Z" }, + { url = "https://files.pythonhosted.org/packages/77/a3/d610cfcdabaa44fd62a54ca1fc57a7dba120643798b089a14914973562de/ast_serialize-0.13.1-cp315-abi3.abi3t-win_arm64.whl", hash = "sha256:929eda0c419e622ab49df3a4c45f81c57dcc10874bbad55d0470a4a03324dac3", size = 1134043, upload-time = "2026-10-17T00:03:48.453Z" }, + { url = "https://files.pythonhosted.org/packages/81/92/d705be88ff452b9ba0088b554a0cbd308fd01879da092b33fd2ad7d1aa60/ast_serialize-0.13.1-cp39-abi3-macosx_10_12_x86_64.whl", hash = "sha256:4bcf1d5f4eefecaa325a34ecf079b2741189e7d0821523f92cb343a389a67489", size = 1242416, upload-time = "2026-10-17T00:03:51.521Z" }, + { url = "https://files.pythonhosted.org/packages/60/c2/98370845a7f35cb8a25782e78284b48e01bf3128339881d48d613f304f8f/ast_serialize-0.13.1-cp39-abi3-macosx_11_0_arm64.whl", hash = "sha256:1b158f1c9e3a0d386913924c57995d6df78224868a4d0f215bdd41587c97b34a", size = 1229729, upload-time = "2026-10-17T00:03:52.825Z" }, + { url = "https://files.pythonhosted.org/packages/d8/8b/2d7ffed76addd9d3fcf37fb171400942735c8912264c763561a85407f6a8/ast_serialize-0.13.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:77a6201b69ce42e919f2fd9a559138d5410b5d8afff7c3a6b1f500b0481ff7d8", size = 1292255, upload-time = "2026-10-17T00:03:54.148Z" }, + { url = "https://files.pythonhosted.org/packages/6b/2a/bb9e0e719d89cc950fadfcfcc9cb4bc7640419c4228c852f031ab8abf440/ast_serialize-0.13.1-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:6eb0be64c9b8f1ed26637eef345abe75ea90351c92c85a8aec7838b3af971011", size = 1298501, upload-time = "2026-10-17T00:03:55.559Z" }, + { url = "https://files.pythonhosted.org/packages/7a/32/13ce07dce48226f5bd9cfd8f708ec101a8be05aa430cda4918ce31ce8c82/ast_serialize-0.13.1-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7f2427bddfca208e84de700044fadf9aef2769a70bae740a1bdabb89ee9e1117", size = 1553758, upload-time = "2026-10-17T00:03:56.952Z" }, + { url = "https://files.pythonhosted.org/packages/e2/fb/9b51d186db0c20ca28cbaaefd50f03b573c89327b9a2627820cbce22196b/ast_serialize-0.13.1-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:88df960e67184a71874e5b2ee014f87d1254a0dbc1f903c7bd7b1ab7733ecaef", size = 1318258, upload-time = "2026-10-17T00:03:58.418Z" }, + { url = "https://files.pythonhosted.org/packages/c5/fa/da311559dd3dae9af5825cf21660775a929b970f72e3786af3f2cd667944/ast_serialize-0.13.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9f99786e0d62082a5b121b3437f3167562133711df22128de1e9886f57f0b226", size = 1313260, upload-time = "2026-10-17T00:04:00.194Z" }, + { url = "https://files.pythonhosted.org/packages/2b/11/97a4b9e5b4776d72f47fcd9a09a497bbf68ec8c1ae074307a2c51e410d85/ast_serialize-0.13.1-cp39-abi3-manylinux_2_31_riscv64.whl", hash = "sha256:a01b515b25a03184eff4acef25b981ae007916379682e908fc8785b342a0bf3e", size = 1309992, upload-time = "2026-10-17T00:04:01.575Z" }, + { url = "https://files.pythonhosted.org/packages/2e/c4/62f85121a80cd451ef04f550cf0f7ea0ad9ff46cc4e9a5b9ae439b6527b1/ast_serialize-0.13.1-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:29422d7bcd9e7f39411571c36cec45ce8a7a9b3ad4b2e7aa64497c15a9e397f6", size = 1362715, upload-time = "2026-10-17T00:04:02.881Z" }, + { url = "https://files.pythonhosted.org/packages/c1/fa/c5f4a545f72a7681e3295bab6e3600ee0862ec4391bed961fe9f735b67e0/ast_serialize-0.13.1-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:6ffb0f548a7dc126067fdfb7b2325ab5dfcdeecc29faf5e0f0461c96d6ebfa3d", size = 1469931, upload-time = "2026-10-17T00:04:04.181Z" }, + { url = "https://files.pythonhosted.org/packages/38/a9/65aed4f8fa7a001a7cfdc03e68e844517ab041ba6fb614b7d78a1d6ac056/ast_serialize-0.13.1-cp39-abi3-musllinux_1_2_armv7l.whl", hash = "sha256:2876444a5f87a7c76f371af3c07c2fda563a08bc8af52568df812e8aba4bf568", size = 1570945, upload-time = "2026-10-17T00:04:05.778Z" }, + { url = "https://files.pythonhosted.org/packages/fb/8c/44b2da991cede79bfbf52089f33a5f0168945466b3d9cd38b5dcf08e7130/ast_serialize-0.13.1-cp39-abi3-musllinux_1_2_i686.whl", hash = "sha256:885a62ec6481ce58ab24c6357360d7a82023b62dd7e5e7ceccf59e9662a3272b", size = 1569978, upload-time = "2026-10-17T00:04:07.347Z" }, + { url = "https://files.pythonhosted.org/packages/46/e4/109b2a5beca700237767d5add920c2f8e1ba9bd5799b0faf143d0e9cf4ef/ast_serialize-0.13.1-cp39-abi3-musllinux_1_2_ppc64le.whl", hash = "sha256:2015fd0165e463aac3b1aadc6a1fa1e5820c14ca950821f4fe02f8a3f6a388d6", size = 1676082, upload-time = "2026-10-17T00:04:08.7Z" }, + { url = "https://files.pythonhosted.org/packages/73/e0/7df70f6dbb11b5762da5416318f08316a1c51348e0d69ec79ca5f98f836a/ast_serialize-0.13.1-cp39-abi3-musllinux_1_2_riscv64.whl", hash = "sha256:eb41e1906502ac80d24ff343f45008552a3f5b5158607959fe6a07dbfc6eb037", size = 1483207, upload-time = "2026-10-17T00:04:10.162Z" }, + { url = "https://files.pythonhosted.org/packages/1f/bc/523aa1c08bd69b5654621beb3dc1a9035715a4a63762fb8d219d6fb3eb81/ast_serialize-0.13.1-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:ca9acc67f796aa2554fa3037dccc022a4b08b38b2ad153edfac9c9bb7cb1f3c6", size = 1512140, upload-time = "2026-10-17T00:04:11.589Z" }, + { url = "https://files.pythonhosted.org/packages/66/83/6607060659998f00afdea0d8375c1e6e2b7d515ab905090d9a5a02f48851/ast_serialize-0.13.1-cp39-abi3-win32.whl", hash = "sha256:4f98da562e5901d69c7dd30885594c5438f859edf354e9ac7517d188fb026c3a", size = 1131889, upload-time = "2026-10-17T00:04:12.953Z" }, + { url = "https://files.pythonhosted.org/packages/9f/6f/bafd6490fe7b355627fabe95f4417e3d02da93102c8552550eb9a0774e1e/ast_serialize-0.13.1-cp39-abi3-win_amd64.whl", hash = "sha256:ddf7cbc9c8abf70102c4a088efe154bb86bfb825b0a10e556d2b15972cf99bd7", size = 1171153, upload-time = "2026-10-17T00:04:14.362Z" }, + { url = "https://files.pythonhosted.org/packages/11/25/4235f4b375a67a37ac595bf478a5407a744eaf7b64113c1c3a5432b8d954/ast_serialize-0.13.1-cp39-abi3-win_arm64.whl", hash = "sha256:48f11d96c9ec71119612f8e79a8c55c12f2b136716d68347433c561d27a25f43", size = 1139035, upload-time = "2026-10-17T00:04:15.767Z" }, +] + +[[package]] +name = "importlib-resources" +version = "7.1.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/e4/06/b56dfa750b44e86157093bc8fca0ab81dccbf5260510de4eaf1cb69b5b99/importlib_resources-7.1.0.tar.gz", hash = "sha256:0722d4c6212489c530f2a145a34c0a7a3b4721bc96a15fada5930e2a0b760708", size = 44985, upload-time = "2026-04-12T16:36:09.232Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/8a/db/55a262f3606bebcae07cc14095338471ad7c0bbcaa37707e6f0ee49725b7/importlib_resources-7.1.0-py3-none-any.whl", hash = "sha256:1bd7b48b4088eddb2cd16382150bb515af0bd2c70128194392725f82ad2c96a1", size = 37232, upload-time = "2026-04-12T16:36:08.219Z" }, +] + +[[package]] +name = "jinja2" +version = "3.1.6" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "markupsafe" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/df/bf/f7da0350254c0ed7c72f3e33cef02e048281fec7ecec5f032d4aac52226b/jinja2-3.1.6.tar.gz", hash = "sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d", size = 245115, upload-time = "2025-03-05T20:05:02.478Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/62/a1/3d680cbfd5f4b8f15abc1d571870c5fc3e594bb582bc3b64ea099db13e56/jinja2-3.1.6-py3-none-any.whl", hash = "sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67", size = 134899, upload-time = "2025-03-05T20:05:00.369Z" }, +] + +[[package]] +name = "librt" +version = "0.16.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/04/f5/9dc696772d241814bacac7880bac32f2930b5a6ebc1f85317b83161a011c/librt-0.16.0.tar.gz", hash = "sha256:ac38d6d8d66bf3d744148dbbc0b8e193e195a51e364ed55e224631f5721891fc", size = 219839, upload-time = "2026-09-29T00:55:32.891Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ad/76/bbdaeb87b7c47b5c7343e90222b9bfa4e4a8a83f647e02933ad0129225b1/librt-0.16.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:fe52bf4641069e7978a14253b036cb9002def1926317e710f2e249f8a8c47742", size = 151028, upload-time = "2026-09-29T00:52:41.508Z" }, + { url = "https://files.pythonhosted.org/packages/fd/0c/ab8ed3dab0085931aec4a792c7eaac8dc6c5ff4691fda3a5360d9d8a9cd2/librt-0.16.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:5bcc2c4726ced915b00de0c9856a4eeabfb3fddb93e10e0b8f735b7709358b6d", size = 155283, upload-time = "2026-09-29T00:52:42.873Z" }, + { url = "https://files.pythonhosted.org/packages/eb/36/494e79d460c80c1f030661e8287c9eca5e1ad652dc2b2180b6cd42abce0a/librt-0.16.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ff7baa55f8e7c69851419e50a666015d02a74198716fd45c0125a2112e0a389f", size = 503185, upload-time = "2026-09-29T00:52:44.638Z" }, + { url = "https://files.pythonhosted.org/packages/9b/34/a8464038dd9db6e4381fa2b6eb73dc9a50888d77102c4c139304ac35cddc/librt-0.16.0-cp312-cp312-manylinux2014_i686.manylinux_2_17_i686.manylinux_2_28_i686.whl", hash = "sha256:b95d5d92ab83d39e760a52091bb1baba664f3a2351e39b1e16801e5747c2f0e9", size = 496738, upload-time = "2026-09-29T00:52:46.441Z" }, + { url = "https://files.pythonhosted.org/packages/6a/53/e0e5e334ef0c6ed27039d323819368b9ef6712be87d55ee2bf9799398afd/librt-0.16.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:b6d085d70bce51d43c5c7c36d63490770180d8779e71c49305c87b4213918de7", size = 513818, upload-time = "2026-09-29T00:52:48.068Z" }, + { url = "https://files.pythonhosted.org/packages/ad/f7/7ce72cbf19d0addd05090b339152fd0548a02562c2866a603e6e3b3da2df/librt-0.16.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:36e53948e99bbe3ffea257124cfcae1cfb01831555c9a9c903c9f9a72db7fd07", size = 531952, upload-time = "2026-09-29T00:52:49.816Z" }, + { url = "https://files.pythonhosted.org/packages/83/22/0b1bcb6a8e723c8b4fd60dfc8ae8ec6461c54073fbc8685efeb8d900d407/librt-0.16.0-cp312-cp312-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:54d11f726aae9df5a6ffbbf0a03a52449bbac84a53ef03669cb41cdfd4ae41bf", size = 524465, upload-time = "2026-09-29T00:52:51.354Z" }, + { url = "https://files.pythonhosted.org/packages/64/2e/e9c23b8b9df1813da1be205deca9606beb7ddd033972246cd426d05374a0/librt-0.16.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:4323193ac0cd025f85af531df8ba91bf24d1973b401697347a6282e8fd3fcf5e", size = 543191, upload-time = "2026-09-29T00:52:53.284Z" }, + { url = "https://files.pythonhosted.org/packages/bc/e5/6a8b21b342c03ed7e230fa3afbfd2edc58e6e87ef1f0d11fa2b9a748c252/librt-0.16.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:e42f8e098b9c5396fefa05fb1cc7e33b0e08fc51da106b5de4a45fd22aac6743", size = 546979, upload-time = "2026-09-29T00:52:54.932Z" }, + { url = "https://files.pythonhosted.org/packages/84/9e/b5129023eced1be01e01c22757f53be551d463b1bb7264f787927404c1d6/librt-0.16.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:39ec1d5a14e37baf1450a6cabf03fe552340808bf1ad9d71824ab90117716459", size = 555317, upload-time = "2026-09-29T00:52:56.869Z" }, + { url = "https://files.pythonhosted.org/packages/71/89/28bba5938c725fe91f06bf93f7fa6c6b150229df53a87b454b0d5c2a796e/librt-0.16.0-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:d1aabe3925cbb4a08d15b7b20ba4011b53019da0c4173a25155139b7b1baed65", size = 535846, upload-time = "2026-09-29T00:52:58.475Z" }, + { url = "https://files.pythonhosted.org/packages/22/92/63773026614f888c5d4e370e395ce42ca604b89f70b3acdfedbf94851b80/librt-0.16.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:300c3ffdc459f4a779a8411ecb188e3ac0b1ff3a3a7b099642555dedae06c69b", size = 573700, upload-time = "2026-09-29T00:53:00.127Z" }, + { url = "https://files.pythonhosted.org/packages/66/8f/347d4677eefb57cd9f8e01d95a1dcee9a91b4e44e664173c32ff6f3752e5/librt-0.16.0-cp312-cp312-win32.whl", hash = "sha256:c17194318e4c0c0348b36f36c2ec7534436fe0a4c15582403162a4f08c80797a", size = 106158, upload-time = "2026-09-29T00:53:02.031Z" }, + { url = "https://files.pythonhosted.org/packages/f0/2c/5193dc81127cd5ddfad031391b046bf32dda219b38463ab872407ca30646/librt-0.16.0-cp312-cp312-win_amd64.whl", hash = "sha256:25a58a19ea8d83b68209f04912df765e9260635ef77646542ed4b4abe6bc7940", size = 126176, upload-time = "2026-09-29T00:53:03.445Z" }, + { url = "https://files.pythonhosted.org/packages/ff/3d/9668a400c8dd81d162eba38b33fa49fa6205f1a64493570a13fbb815c3ee/librt-0.16.0-cp312-cp312-win_arm64.whl", hash = "sha256:f7be7cf555bc30ec12622e9447299cc4a9b8ff307548b634794353db0c2065dc", size = 116572, upload-time = "2026-09-29T00:53:04.815Z" }, +] + +[[package]] +name = "markdown" +version = "3.10.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/2b/f4/69fa6ed85ae003c2378ffa8f6d2e3234662abd02c10d216c0ba96081a238/markdown-3.10.2.tar.gz", hash = "sha256:994d51325d25ad8aa7ce4ebaec003febcce822c3f8c911e3b17c52f7f589f950", size = 368805, upload-time = "2026-02-09T14:57:26.942Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/de/1f/77fa3081e4f66ca3576c896ae5d31c3002ac6607f9747d2e3aa49227e464/markdown-3.10.2-py3-none-any.whl", hash = "sha256:e91464b71ae3ee7afd3017d9f358ef0baf158fd9a298db92f1d4761133824c36", size = 108180, upload-time = "2026-02-09T14:57:25.787Z" }, +] + +[[package]] +name = "markupsafe" +version = "3.0.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/7e/99/7690b6d4034fffd95959cbe0c02de8deb3098cc577c67bb6a24fe5d7caa7/markupsafe-3.0.3.tar.gz", hash = "sha256:722695808f4b6457b320fdc131280796bdceb04ab50fe1795cd540799ebe1698", size = 80313, upload-time = "2025-09-27T18:37:40.426Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/5a/72/147da192e38635ada20e0a2e1a51cf8823d2119ce8883f7053879c2199b5/markupsafe-3.0.3-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:d53197da72cc091b024dd97249dfc7794d6a56530370992a5e1a08983ad9230e", size = 11615, upload-time = "2025-09-27T18:36:30.854Z" }, + { url = "https://files.pythonhosted.org/packages/9a/81/7e4e08678a1f98521201c3079f77db69fb552acd56067661f8c2f534a718/markupsafe-3.0.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:1872df69a4de6aead3491198eaf13810b565bdbeec3ae2dc8780f14458ec73ce", size = 12020, upload-time = "2025-09-27T18:36:31.971Z" }, + { url = "https://files.pythonhosted.org/packages/1e/2c/799f4742efc39633a1b54a92eec4082e4f815314869865d876824c257c1e/markupsafe-3.0.3-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:3a7e8ae81ae39e62a41ec302f972ba6ae23a5c5396c8e60113e9066ef893da0d", size = 24332, upload-time = "2025-09-27T18:36:32.813Z" }, + { url = "https://files.pythonhosted.org/packages/3c/2e/8d0c2ab90a8c1d9a24f0399058ab8519a3279d1bd4289511d74e909f060e/markupsafe-3.0.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d6dd0be5b5b189d31db7cda48b91d7e0a9795f31430b7f271219ab30f1d3ac9d", size = 22947, upload-time = "2025-09-27T18:36:33.86Z" }, + { url = "https://files.pythonhosted.org/packages/2c/54/887f3092a85238093a0b2154bd629c89444f395618842e8b0c41783898ea/markupsafe-3.0.3-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:94c6f0bb423f739146aec64595853541634bde58b2135f27f61c1ffd1cd4d16a", size = 21962, upload-time = "2025-09-27T18:36:35.099Z" }, + { url = "https://files.pythonhosted.org/packages/c9/2f/336b8c7b6f4a4d95e91119dc8521402461b74a485558d8f238a68312f11c/markupsafe-3.0.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:be8813b57049a7dc738189df53d69395eba14fb99345e0a5994914a3864c8a4b", size = 23760, upload-time = "2025-09-27T18:36:36.001Z" }, + { url = "https://files.pythonhosted.org/packages/32/43/67935f2b7e4982ffb50a4d169b724d74b62a3964bc1a9a527f5ac4f1ee2b/markupsafe-3.0.3-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:83891d0e9fb81a825d9a6d61e3f07550ca70a076484292a70fde82c4b807286f", size = 21529, upload-time = "2025-09-27T18:36:36.906Z" }, + { url = "https://files.pythonhosted.org/packages/89/e0/4486f11e51bbba8b0c041098859e869e304d1c261e59244baa3d295d47b7/markupsafe-3.0.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:77f0643abe7495da77fb436f50f8dab76dbc6e5fd25d39589a0f1fe6548bfa2b", size = 23015, upload-time = "2025-09-27T18:36:37.868Z" }, + { url = "https://files.pythonhosted.org/packages/2f/e1/78ee7a023dac597a5825441ebd17170785a9dab23de95d2c7508ade94e0e/markupsafe-3.0.3-cp312-cp312-win32.whl", hash = "sha256:d88b440e37a16e651bda4c7c2b930eb586fd15ca7406cb39e211fcff3bf3017d", size = 14540, upload-time = "2025-09-27T18:36:38.761Z" }, + { url = "https://files.pythonhosted.org/packages/aa/5b/bec5aa9bbbb2c946ca2733ef9c4ca91c91b6a24580193e891b5f7dbe8e1e/markupsafe-3.0.3-cp312-cp312-win_amd64.whl", hash = "sha256:26a5784ded40c9e318cfc2bdb30fe164bdb8665ded9cd64d500a34fb42067b1c", size = 15105, upload-time = "2025-09-27T18:36:39.701Z" }, + { url = "https://files.pythonhosted.org/packages/e5/f1/216fc1bbfd74011693a4fd837e7026152e89c4bcf3e77b6692fba9923123/markupsafe-3.0.3-cp312-cp312-win_arm64.whl", hash = "sha256:35add3b638a5d900e807944a078b51922212fb3dedb01633a8defc4b01a3c85f", size = 13906, upload-time = "2025-09-27T18:36:40.689Z" }, +] + +[[package]] +name = "mypy" +version = "2.4.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "ast-serialize" }, + { name = "librt", marker = "platform_python_implementation != 'PyPy'" }, + { name = "mypy-extensions" }, + { name = "pathspec" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/34/4e/64300736cf0a0373a27b94a91b664ee7382e36f77b0621bae6381da3e180/mypy-2.4.0.tar.gz", hash = "sha256:77bdaebd452f43fcfc4cc3ba94352a3ea537cd01e3f2d0879f48673d2ec00d6e", size = 4064425, upload-time = "2026-10-01T20:40:39.229Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/68/ed/e5d7cf4017e74a1c1e1c4058ce8f614fc1e3e7606564f47166e22bfc9f95/mypy-2.4.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:e05ff2925d8b37ad26c80c1b9dc43ae5d455da2df1e23c24c095a6425917c57e", size = 14378593, upload-time = "2026-10-01T20:38:48.222Z" }, + { url = "https://files.pythonhosted.org/packages/30/7d/12d994886a922f0f1997becc9c6625198d61eeb5962558a886af7dd38d54/mypy-2.4.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:29243242cf72582b65f9582ad9e56e8cb281566ed3519f4cd70bb8b9f2977e90", size = 14464697, upload-time = "2026-10-01T20:39:11.059Z" }, + { url = "https://files.pythonhosted.org/packages/f3/9e/bcc9af755425ad17790bf11d73c2ea7592914cf309ee1340997670f9d57a/mypy-2.4.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:29eb0b9427a6b11b992e452f6cceb8af724f4dceb47e779d0b35e405e996ea5e", size = 15552257, upload-time = "2026-10-01T20:39:56.269Z" }, + { url = "https://files.pythonhosted.org/packages/af/0c/3343fc4525d6f00d75ad17a93a9f052d5163641cb8911840d4a12cb59ff2/mypy-2.4.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:e3ebe2f72a2a1156065a9851570ffbf50c0a93cdccadef9c6e05c508a4fd10b1", size = 15800443, upload-time = "2026-10-01T20:38:54.815Z" }, + { url = "https://files.pythonhosted.org/packages/8f/0e/69aac6b8159da7c53e6115a2be1bf48e85503402cadbf506dd708e8b2ad7/mypy-2.4.0-cp312-cp312-win_amd64.whl", hash = "sha256:236e0d68f6941992b0811128e652590f590db444ab29ad8f1324765b9298b946", size = 11381574, upload-time = "2026-10-01T20:39:49.406Z" }, + { url = "https://files.pythonhosted.org/packages/6e/d3/d32ce4feb5993eec09d2024bef16cedc9b93701b1446b86092f08b24491b/mypy-2.4.0-cp312-cp312-win_arm64.whl", hash = "sha256:82d0f94c8587ccb472622ee7795280aaa38a06640d5f45b3f16909d6dd86a989", size = 10944729, upload-time = "2026-10-01T20:40:15.203Z" }, + { url = "https://files.pythonhosted.org/packages/81/12/46ae8670c98a3cd0286ca5645c2f918f8f6be65edfed81b916010619f668/mypy-2.4.0-py3-none-any.whl", hash = "sha256:d01c5d26a352acc6d5cf3128225477e1e8465e8d3029d4c345807fbf7f3cf093", size = 2800734, upload-time = "2026-10-01T20:39:26.837Z" }, +] + +[[package]] +name = "mypy-extensions" +version = "1.1.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a2/6e/371856a3fb9d31ca8dac321cda606860fa4548858c0cc45d9d1d4ca2628b/mypy_extensions-1.1.0.tar.gz", hash = "sha256:52e68efc3284861e772bbcd66823fde5ae21fd2fdb51c62a211403730b916558", size = 6343, upload-time = "2025-04-22T14:54:24.164Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/79/7b/2c79738432f5c924bef5071f933bcc9efd0473bac3b4aa584a6f7c1c8df8/mypy_extensions-1.1.0-py3-none-any.whl", hash = "sha256:1be4cccdb0f2482337c4743e60421de3a356cd97508abadd57d47403e94f5505", size = 4963, upload-time = "2025-04-22T14:54:22.983Z" }, +] + +[[package]] +name = "nodeenv" +version = "1.10.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/24/bf/d1bda4f6168e0b2e9e5958945e01910052158313224ada5ce1fb2e1113b8/nodeenv-1.10.0.tar.gz", hash = "sha256:996c191ad80897d076bdfba80a41994c2b47c68e224c542b48feba42ba00f8bb", size = 55611, upload-time = "2025-12-20T14:08:54.006Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/88/b2/d0896bdcdc8d28a7fc5717c305f1a861c26e18c05047949fb371034d98bd/nodeenv-1.10.0-py2.py3-none-any.whl", hash = "sha256:5bb13e3eed2923615535339b3c620e76779af4cb4c6a90deccc9e36b274d3827", size = 23438, upload-time = "2025-12-20T14:08:52.782Z" }, +] + +[[package]] +name = "pathspec" +version = "1.0.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/fa/36/e27608899f9b8d4dff0617b2d9ab17ca5608956ca44461ac14ac48b44015/pathspec-1.0.4.tar.gz", hash = "sha256:0210e2ae8a21a9137c0d470578cb0e595af87edaa6ebf12ff176f14a02e0e645", size = 131200, upload-time = "2026-01-27T03:59:46.938Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ef/3c/2c197d226f9ea224a9ab8d197933f9da0ae0aac5b6e0f884e2b8d9c8e9f7/pathspec-1.0.4-py3-none-any.whl", hash = "sha256:fb6ae2fd4e7c921a165808a552060e722767cfa526f99ca5156ed2ce45a5c723", size = 55206, upload-time = "2026-01-27T03:59:45.137Z" }, +] + +[[package]] +name = "pycroscope" +version = "0.5.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typeshed-client" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/9d/67/c5cb4c78c1f50f905902fb8f5ff7dcd5c321b75f1ee123354ae9f26b364f/pycroscope-0.5.0.tar.gz", hash = "sha256:573eb605f49b97e6ff5d85af115de0406b475a239d9cb3db00ccec2ef97a62ba", size = 696137, upload-time = "2026-08-27T18:13:38.707Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/4c/d1/873dac15d2a9f059b5dfb2fdae56d57378023f137d73d61bea5d085e0835/pycroscope-0.5.0-py3-none-any.whl", hash = "sha256:effc2fc347c2b6175bacdd5aad8e242392eba075d22832b441c0c6ecbc7f6517", size = 747967, upload-time = "2026-08-27T18:13:37.043Z" }, +] + +[[package]] +name = "pyrefly" +version = "1.4.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/b3/3e/ea6893be167fa14307d7f9a924bed9ecbbbd91b01953890b9b3c58ed5359/pyrefly-1.4.0.tar.gz", hash = "sha256:bb57c004a4842cfe93f93aebb5203ca6209a5f0c8bda47e8bc289e70940fd910", size = 6962062, upload-time = "2026-10-15T16:54:11.819Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6a/17/dfce6611acc00cb26667e5e1011438cc510f3067f961e0f07f7a0c68f416/pyrefly-1.4.0-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:460cec39bc8743915e9c2c8c10ba926ad0b29b099d89c1859fb97e0059f42fa7", size = 15705624, upload-time = "2026-10-15T16:53:43.412Z" }, + { url = "https://files.pythonhosted.org/packages/a6/78/a7b96442123fa6ed733de0d1ea933e35d6fc6b7c9cf16e05279abb493493/pyrefly-1.4.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:5a6370d686b6cbbac8869832f09a52012888371956fbc68d446a349bc85ccd43", size = 14978669, upload-time = "2026-10-15T16:53:46.546Z" }, + { url = "https://files.pythonhosted.org/packages/23/97/dfcfec6a9d8948ab4b2746f7e87558a82bffabb7a54c22e7d3ce4bdc1932/pyrefly-1.4.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8f1b16923a6583a6764e8aec07787e2ef4df644c7030294cba71339783a9451c", size = 15438858, upload-time = "2026-10-15T16:53:48.904Z" }, + { url = "https://files.pythonhosted.org/packages/31/12/6fa414aa87e398d6ddc7145a5d993b0975fc3511198dbb72c47873653ab6/pyrefly-1.4.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:688ad4cb4d6e711d67026fdcfb37b599f86061efe11ba5704287330e7041a69e", size = 16852241, upload-time = "2026-10-15T16:53:51.496Z" }, + { url = "https://files.pythonhosted.org/packages/a8/73/2d7312262cf6481d6ad46eed55b8f2592c3cff60f95cc2f30a114cd1484e/pyrefly-1.4.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f5f3c9dddb6f3128beb49cf4e0f5cb88d4d17f039008d8e0c2be653966acd234", size = 16751917, upload-time = "2026-10-15T16:53:54.39Z" }, + { url = "https://files.pythonhosted.org/packages/2c/65/b44a1cb23667bcbcdc88558cbef79fa9e07a1152c2a1da148036b1a2e0d1/pyrefly-1.4.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b6951f51687304caebfedf13dd1a943aeafdbc95abcc4e24a683b97467a77007", size = 16066345, upload-time = "2026-10-15T16:53:57.436Z" }, + { url = "https://files.pythonhosted.org/packages/a6/07/7ca6ff0c53e3a90ecdab05790d33f430fca5c48687613a0b182744166d98/pyrefly-1.4.0-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:838de4d4a8b9b8ed39bedd0b8b55629c69661d73a6fa3a3a4adff24b9dbeb399", size = 15461223, upload-time = "2026-10-15T16:54:00.364Z" }, + { url = "https://files.pythonhosted.org/packages/61/be/ec7b2f38a898ce5b2219dda730e87d31fc8cfb2108a3d5844f9d590f1281/pyrefly-1.4.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:afb9ce2e0ae3e6106fb45f6d47536ac92b6423e601e08401cdefa850066444f5", size = 16119099, upload-time = "2026-10-15T16:54:02.664Z" }, + { url = "https://files.pythonhosted.org/packages/6e/16/1b9549168b38a575d9c168e17b4b4ee30028d602ec0f7b07c198ef265dbe/pyrefly-1.4.0-py3-none-win32.whl", hash = "sha256:839db536d0ac29f1b23e2d974fb911075c2283e3e623755c45d826aafac175bc", size = 14858880, upload-time = "2026-10-15T16:54:05.114Z" }, + { url = "https://files.pythonhosted.org/packages/03/02/18f075d4de0e255f184f42fc28c1f0ecc9f49dd528678479fc90cf12246c/pyrefly-1.4.0-py3-none-win_amd64.whl", hash = "sha256:7aff37c2b711c8240ed650da0c6148237b327bf7e5dfacee65884f1adea22305", size = 15726220, upload-time = "2026-10-15T16:54:07.452Z" }, + { url = "https://files.pythonhosted.org/packages/92/62/92947076681550904c72a9dd03b24e92694ede9a48548f5e487c849e66ea/pyrefly-1.4.0-py3-none-win_arm64.whl", hash = "sha256:88879f0cb749e5fea81d9ff4c2d5431a70349c458bcdf0b61de72c79214d90a5", size = 14943690, upload-time = "2026-10-15T16:54:09.689Z" }, +] + +[[package]] +name = "pyright" +version = "1.1.414" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "nodeenv" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/e1/1b/244c7b710031ada80f27e579ec20d28a2285dfc318fed0339866b1047f12/pyright-1.1.414.tar.gz", hash = "sha256:523c0a97c60da6333234955c277730c9cf4f5bd6d5399e7b7d2b0fc5d3599524", size = 4154638, upload-time = "2026-09-10T12:26:53.181Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d7/ba/18b6e682ead424ad24bcc134339ae5d1b931cd9ae260540592a058a91279/pyright-1.1.414-py3-none-any.whl", hash = "sha256:2a6b4b3298c9eec174c5ed83bd338de6eee82df2992f3e1930e6199d381be36f", size = 6225049, upload-time = "2026-09-10T12:26:51.427Z" }, +] + +[[package]] +name = "tomlkit" +version = "0.14.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/c3/af/14b24e41977adb296d6bd1fb59402cf7d60ce364f90c890bd2ec65c43b5a/tomlkit-0.14.0.tar.gz", hash = "sha256:cf00efca415dbd57575befb1f6634c4f42d2d87dbba376128adb42c121b87064", size = 187167, upload-time = "2026-01-13T01:14:53.304Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b5/11/87d6d29fb5d237229d67973a6c9e06e048f01cf4994dee194ab0ea841814/tomlkit-0.14.0-py3-none-any.whl", hash = "sha256:592064ed85b40fa213469f81ac584f67a4f2992509a7c3ea2d632208623a3680", size = 39310, upload-time = "2026-01-13T01:14:51.965Z" }, +] + +[[package]] +name = "ty" +version = "0.0.93" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/78/35/e1cbce56e80f6d911b6b6821d211b4150d0e061d426df038cad78d2800f4/ty-0.0.93.tar.gz", hash = "sha256:18b99060d7f1d601fd4ce1acdcc336d1b3345fea8561307948827e8809c31c25", size = 8105272, upload-time = "2026-10-28T00:52:42.089Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/4e/16/5b0766d3de2b531f47d6f24986f21607546b6ee1861d294ccec69a750b45/ty-0.0.93-py3-none-linux_armv6l.whl", hash = "sha256:74fad0e17d96076364be426b15ed3f052f068ec6e37b9d8dbf9c9c424fcb6f0d", size = 14510907, upload-time = "2026-10-28T00:52:04.298Z" }, + { url = "https://files.pythonhosted.org/packages/14/4a/ba4e9586f22b42f86e95c5f06798d30b288e1d6557b29c137384031c561c/ty-0.0.93-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:83beb545d52c38deb910d977679dcac1c274f5cf8ee0a1868b10d390042c40df", size = 14074052, upload-time = "2026-10-28T00:52:07.324Z" }, + { url = "https://files.pythonhosted.org/packages/ce/3c/00e4195634b61a6ec1f53a2c70777df644a3ee79f6579b48c4e2f6e884d0/ty-0.0.93-py3-none-macosx_11_0_arm64.whl", hash = "sha256:47d6be14343a997c6f828d812513f940929c906f6cf83ca4cdd74db6e16ef261", size = 13132684, upload-time = "2026-10-28T00:52:09.528Z" }, + { url = "https://files.pythonhosted.org/packages/3e/f4/36fb44a79e2d7c8b2d5f2c42cab6d2c1d4d0e8b9fb7e51acb82648fc4d3e/ty-0.0.93-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d696b82ade77500826d84874d46658020486daa9d39eabc71b94a641247ce484", size = 13955788, upload-time = "2026-10-28T00:52:11.478Z" }, + { url = "https://files.pythonhosted.org/packages/49/21/ae904789846d93e4b01faa33ef9a73f28657dd88b8b99619dbae05f30f1d/ty-0.0.93-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:9882e7b55ee025feceaf8f1210acda368f931c3f597771385f97a460292a9c8b", size = 14252702, upload-time = "2026-10-28T00:52:13.466Z" }, + { url = "https://files.pythonhosted.org/packages/13/8e/fecf0492b20f1e28fafac944f5a6c7a404d8408f2e6fb0fb5666550f994f/ty-0.0.93-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:318871545c28f22564b445cadd022650e0fa892c913c0c1eb4cf6345d72037a2", size = 15192511, upload-time = "2026-10-28T00:52:15.923Z" }, + { url = "https://files.pythonhosted.org/packages/97/1f/67d3284747800456e96892d51df3fefc9f98b844653a86cfc6312902a490/ty-0.0.93-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1f9c494291a7c83706b380e31606f88b6dcf801499623645861c3099c17edc01", size = 15594668, upload-time = "2026-10-28T00:52:18.133Z" }, + { url = "https://files.pythonhosted.org/packages/ed/1f/2a903b2309c8ea265a0cef1edc00fa9223be42d004171f7f87aded4b1bed/ty-0.0.93-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:43ff1ee239c94260cf2146e23537fb069b7267423723096603051bb7d36ce165", size = 15533756, upload-time = "2026-10-28T00:52:20.271Z" }, + { url = "https://files.pythonhosted.org/packages/dc/75/99bdbbd00220703c51af60160fb1c080f653b45ddb585baf8468588f70ef/ty-0.0.93-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1c278c86adeb82374e0f5142b44bb628e9dcb663d98e8f274707300d926e0997", size = 16236455, upload-time = "2026-10-28T00:52:22.244Z" }, + { url = "https://files.pythonhosted.org/packages/ca/7d/edbcce5e504275b3574272629c2c7d657c666312fd5a74a5a3202f256e0a/ty-0.0.93-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:02c7cc6f1d9d2fe49eff5b230d243c696ac798ecce034998e3d67872ab2a5236", size = 15065832, upload-time = "2026-10-28T00:52:24.23Z" }, + { url = "https://files.pythonhosted.org/packages/e6/ce/201c42e84b49a8bb6473edfd3e16e311b942178cefd9678f98dda36f25a4/ty-0.0.93-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:50c580e31da3e4dd3f1b7ab1969497996ab55e61ee06d90132ab46a2964249ef", size = 13919356, upload-time = "2026-10-28T00:52:26.893Z" }, + { url = "https://files.pythonhosted.org/packages/68/5c/f323a70974bd57274d4315d1894586498557e21d4d78cd35b550deaf7878/ty-0.0.93-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:7f037c1761a6874cc0072c39950a987cd6d1563d6df3c94bb131b3e727e921c9", size = 14258573, upload-time = "2026-10-28T00:52:29.049Z" }, + { url = "https://files.pythonhosted.org/packages/c8/ba/0d2a2f0892d19c91cef7785ac1bac5de555059f1bad2a0009d83f2df1d0d/ty-0.0.93-py3-none-musllinux_1_2_i686.whl", hash = "sha256:a8bfbcc8a715a5497210cc89eb134476f511b2de3004697c96b5f6eaa0f1602b", size = 14613304, upload-time = "2026-10-28T00:52:31.474Z" }, + { url = "https://files.pythonhosted.org/packages/b8/02/b0f7b83ef79c85b8813e54ed73189995e3d4ec2f1dda791a8d0acd051386/ty-0.0.93-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:19ae7e56c9021d7eafbc305926ca174183b431c63c27e9d2b7db342d45142446", size = 14937750, upload-time = "2026-10-28T00:52:33.528Z" }, + { url = "https://files.pythonhosted.org/packages/06/ad/d2ece9e2ec588394d0ea0c12b683ff68540f5534988b4e4412664bb87a56/ty-0.0.93-py3-none-win32.whl", hash = "sha256:1c677be05fb0ef0864a305fa4a5258190fc0fc9d79f53c1ce93a0342256f21f1", size = 13464721, upload-time = "2026-10-28T00:52:35.916Z" }, + { url = "https://files.pythonhosted.org/packages/a9/17/ef0c1180498564f08331f4be35aea9de09b37c6ca12fa50ad1959d9d1e38/ty-0.0.93-py3-none-win_amd64.whl", hash = "sha256:65072e0a71f9af81a31a4656521c96eaf539452c37287b9e14a81504b22e0864", size = 14091561, upload-time = "2026-10-28T00:52:38.008Z" }, + { url = "https://files.pythonhosted.org/packages/ef/f8/13fb149c7c5a33be119ecea9c56033b32cc1f87c5ac84d577f2236b7c964/ty-0.0.93-py3-none-win_arm64.whl", hash = "sha256:47991915f6a2101cc63da1dd07b2f3bbd226ab4a14ff3c858b20764c38376166", size = 13552165, upload-time = "2026-10-28T00:52:40.111Z" }, +] + +[[package]] +name = "types-markdown" +version = "3.10.2.20260508" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/24/62/4ca11db82799590117d9b6ef8fcd6515039cff80838304face5440f7d95c/types_markdown-3.10.2.20260508.tar.gz", hash = "sha256:64c405a30decd46cf78443bbcde8331f561f83752cc6d962ff3f5ccaabe26a8e", size = 19818, upload-time = "2026-05-08T04:49:45.095Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cf/9d/eae7125bcf063ff5f79aadad58f3d37675263941f84e025bf53de1735fe1/types_markdown-3.10.2.20260508-py3-none-any.whl", hash = "sha256:2ee5e462c7b821c27c3d8f75f4da873d3e3c87d24d7f2d741f8f4261e4024a99", size = 25811, upload-time = "2026-05-08T04:49:43.962Z" }, +] + +[[package]] +name = "typeshed-client" +version = "2.11.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "importlib-resources" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/85/7d/62fbae352d5fb7ce5ef4d9ca73bf7a9b02b790d2524ab6ef1e0e799a5d1b/typeshed_client-2.11.0.tar.gz", hash = "sha256:0b8f2ab88f611f5e97b70d2a8123942d3d7d5c74cee8ae694db83422f32f9481", size = 522774, upload-time = "2026-05-01T14:51:52.38Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/4f/22/fa16b462157bd869dfad528f5637506b9430ca63d48fb536ecf4cc78481a/typeshed_client-2.11.0-py3-none-any.whl", hash = "sha256:5745e0990b80b29a286b22d68f81779c5c7adf1cac8969eeafba44b73b486c36", size = 787609, upload-time = "2026-05-01T14:51:51.005Z" }, +] + +[[package]] +name = "typing-conformance" +version = "0.1.0" +source = { virtual = "." } +dependencies = [ + { name = "jinja2" }, + { name = "markdown" }, + { name = "mypy" }, + { name = "pycroscope" }, + { name = "pyrefly" }, + { name = "pyright" }, + { name = "tomlkit" }, + { name = "ty" }, + { name = "types-markdown" }, + { name = "typing-extensions" }, + { name = "zuban" }, +] + +[package.metadata] +requires-dist = [ + { name = "jinja2" }, + { name = "markdown" }, + { name = "mypy" }, + { name = "pycroscope" }, + { name = "pyrefly" }, + { name = "pyright" }, + { name = "tomlkit" }, + { name = "ty" }, + { name = "types-markdown" }, + { name = "typing-extensions", specifier = ">=4.16.0" }, + { name = "zuban" }, +] + +[[package]] +name = "typing-extensions" +version = "4.16.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f6/cc/6253133b5bb138fc3306cebfbda2c520f545d36b5be2c7255cc528bb45d6/typing_extensions-4.16.0.tar.gz", hash = "sha256:dc983d19a509c94dba722ee6abd33940f7c05a89e243c47e907eb4db6f1a43e5", size = 113555, upload-time = "2026-07-02T08:40:05.92Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/49/d3/b8441a820a491ddfc024b0b0cf0393375b75ea13866d9c66727e54c2fc80/typing_extensions-4.16.0-py3-none-any.whl", hash = "sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8", size = 45571, upload-time = "2026-07-02T08:40:04.659Z" }, +] + +[[package]] +name = "zuban" +version = "0.10.2" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/04/eb/5b15139d92e667ed98d41d07c62f815709b85d960e3e5a41dce90f080f78/zuban-0.10.2-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:bf32f741a7b579a7b3500803729144493c0016364bc852feaa8db44f9fe13f7d", size = 11617429, upload-time = "2026-10-29T15:44:54.423Z" }, + { url = "https://files.pythonhosted.org/packages/ab/a1/1fd1f5e94be99d3d2a7cb6bfd8dd8a0872905f3980dffb6cb6ce00872840/zuban-0.10.2-py3-none-macosx_11_0_arm64.whl", hash = "sha256:ae00078be67ca93bca9b25bb39f4abebe3cf1a1cda8aa3c7b142d25bed75bc38", size = 11409605, upload-time = "2026-10-29T15:44:57.195Z" }, + { url = "https://files.pythonhosted.org/packages/c3/8c/dd342810155db2aac880e077b9fbba56e07ce759ab723ea1e11f4edb695c/zuban-0.10.2-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:a9be001e140d9b86bb6f09298e4ad21a01073a1d47e5171f9cc7de65d1d54c73", size = 28803766, upload-time = "2026-10-29T15:44:59.84Z" }, + { url = "https://files.pythonhosted.org/packages/36/18/17d95ed7d800230970bdc90872f36e9f3a1a5ec7296fa7ba4bf7b2fdcca4/zuban-0.10.2-py3-none-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:097b5abb799207cbfeea233accbd8bf440742bfe482a064e47b17ce698a66799", size = 28997359, upload-time = "2026-10-29T15:45:02.91Z" }, + { url = "https://files.pythonhosted.org/packages/92/bf/d3b1dae8163eb9d86ed6797c39ce5b50f377defcd9a917ba9d97a330936a/zuban-0.10.2-py3-none-manylinux2014_i686.manylinux_2_17_i686.whl", hash = "sha256:1d247a12d60dae489372074c7a5695b5d7b32b2e324e6445f54aebda2512a11c", size = 30199005, upload-time = "2026-10-29T15:45:05.877Z" }, + { url = "https://files.pythonhosted.org/packages/2c/a9/8a4542e31be2c09292f431015055015f0c918d0f0232264672d545f115d5/zuban-0.10.2-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:c8b4a34e46ac3ee89cea9783c2a1f4fa6fa271bb59e99e7146d8233566ff8a29", size = 32199078, upload-time = "2026-10-29T15:45:08.892Z" }, + { url = "https://files.pythonhosted.org/packages/e4/55/a68158322cf3cf7ae6d2b56e41683a6104f325c50ed1fcf4dccc0395c2cc/zuban-0.10.2-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:2a023e4583020bf8e7109aaca391055b75f96b3d98ca6e714ccad55e58340e4a", size = 28992978, upload-time = "2026-10-29T15:45:12.16Z" }, + { url = "https://files.pythonhosted.org/packages/3a/71/798d0f33d3821f4bf1cfd73a4b9c71742b1c3b811c02a966703a6a95c89d/zuban-0.10.2-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:0b1d159d75f5d525ef25f305e5dc29eb8ba1596195e04bf8b66b8b031b01e8da", size = 29443939, upload-time = "2026-10-29T15:45:15.393Z" }, + { url = "https://files.pythonhosted.org/packages/84/44/ce29964021ba394600e0713918883501da4db90d2d80af9429040c0b59d6/zuban-0.10.2-py3-none-musllinux_1_2_i686.whl", hash = "sha256:dbab08b9ab53468f9ac28774b89dfaae695c4f9326b680771fe152b778987d89", size = 30101210, upload-time = "2026-10-29T15:45:18.33Z" }, + { url = "https://files.pythonhosted.org/packages/b9/32/b4a93835cb83bd99faba0362e2a560595fc365179529c2190094bb184c81/zuban-0.10.2-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:b2a2fcdeeab56f091a376e65a7b26c044b6be44e1360214de65db7908248ddb9", size = 29419261, upload-time = "2026-10-29T15:45:21.176Z" }, + { url = "https://files.pythonhosted.org/packages/08/a3/50554f3857c449921b635575745fe590055df6e8fe7e6482488df6673c0c/zuban-0.10.2-py3-none-win32.whl", hash = "sha256:97779d50273efdf75ed6edefbfd71a9bb6045467ac21a6e83a15933e4a8ec7bc", size = 10275468, upload-time = "2026-10-29T15:45:23.919Z" }, + { url = "https://files.pythonhosted.org/packages/a3/c2/dc2fff9bb2adcff092d9314096c5e0d7215f6358dccc4bcdf1c18b11c39d/zuban-0.10.2-py3-none-win_amd64.whl", hash = "sha256:48483b9ec019da045b7f826c496f2ab1639c3f036fcab6e9e74b42d4e2fa3d34", size = 11017736, upload-time = "2026-10-29T15:45:27.151Z" }, +] diff --git a/docs/Makefile b/docs/Makefile index 4f7c95a88..418d93680 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -5,12 +5,13 @@ # from the environment for the first two. SOURCEDIR = . SOURCES = +ROOTDIR = .. BUILDDIR = _build PYTHON = python3 VENVDIR = ./venv SPHINXBUILD = PATH=$(VENVDIR)/bin:$$PATH sphinx-build -ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees $(SPHINXOPTS) . build/$(BUILDER) $(SOURCES) +ALLSPHINXOPTS = -W -b $(BUILDER) -d build/doctrees $(SPHINXOPTS) . build/$(BUILDER) $(SOURCES) .PHONY: help clean build html text venv Makefile @@ -29,6 +30,8 @@ build: html: BUILDER = html html: build @echo "Build finished. The HTML pages are in build/html." + @echo "file://$(shell pwd)/build/html/index.html" + @echo text: BUILDER = text text: build @@ -36,8 +39,8 @@ text: build venv: $(PYTHON) -m venv $(VENVDIR) - $(VENVDIR)/bin/python3 -m pip install -U pip setuptools - $(VENVDIR)/bin/python3 -m pip install -r requirements.txt + $(VENVDIR)/bin/python3 -m pip install -U pip + $(VENVDIR)/bin/python3 -m pip install --group $(ROOTDIR)/pyproject.toml:docs @echo "The venv has been created in the $(VENVDIR) directory" # Catch-all target: route all unknown targets to Sphinx using the new diff --git a/docs/README.rst b/docs/README.rst index 6b431c811..c2f4cdf08 100644 --- a/docs/README.rst +++ b/docs/README.rst @@ -5,7 +5,7 @@ Reading the docs ================= The live documentation for Python's static typing can be found at -`typing.readthedocs.io `_. +`typing.python.org `_. Building the docs ================= diff --git a/docs/guides/index.rst b/docs/guides/index.rst new file mode 100644 index 000000000..70dfdac98 --- /dev/null +++ b/docs/guides/index.rst @@ -0,0 +1,20 @@ +:orphan: + +****************** +Type System Guides +****************** + +.. + Keep in sync with docs/index.rst. + +.. toctree:: + :maxdepth: 1 + :caption: Contents: + + libraries + lambda + writing_stubs + modernizing + unreachable + type_narrowing + typing_anti_pitch diff --git a/docs/guides/lambda.rst b/docs/guides/lambda.rst new file mode 100644 index 000000000..65c6074a9 --- /dev/null +++ b/docs/guides/lambda.rst @@ -0,0 +1,88 @@ +***************************************** +The Trouble (Or Lack Thereof) With Lambda +***************************************** + +Lambda expressions are a common and useful part of the Python programming language. +However, there is one problem with them: syntactically, they do not allow for type +annotations. While it is perfectly simple to write ``lambda x: x``, you cannot directly +indicate a type for x. (Type annotations are indicated by a colon, and so is the end +of the lambda parameter list. Where would the type annotation go?) + +However, despite this infelicity, lambda expressions are not immune from static typing, +and in fact follow the same static type rules as everything else. Type checkers try +to deduce the type of the lambda arguments and return value, and if they can't they +fall back to ``Any``. Due to the inability to directly indicate types for these, +``Any`` tends to pop up quite often here. This means that many type errors may occur +here unnoticed, which is bad. For instance, the following example is a runtime type +error, but is uncaught in most (perhaps all) type checkers: + +.. code-block:: python + + f1 = lambda a, b: a + b + f1(1, "a") + +(The alternative way of writing this, ``(lambda a, b: a + b)(1, "a")``, is typically +caught by type checkers, because it is simple and immediate enough that they are able +to deduce that a type error will occur.) + +.. + (This is an RST comment.) + A slightly more realistic example of an uncaught lambda type error is + + .. code-block :: python + def apply(f, *x): + f(*x) + apply((lambda a, b: a + b), 1, "a") + + since it doesn't immediately defeat the purpose of a lambda by binding it. + It also fails to get caught by mypy and pyright in their default modes, as + required for the example. However, it's a little bit harder to understand, + so we went with the other one. + +There are some workarounds to this problem, which all involve assigning the lambda to +something, in one way or another, and annotating that. This is a bit unfortunate, +because the idiomatic use of a lambda involves not doing that. In fact, at that point +you might as well just define a normal function. Let's call that our first workaround. + +``def f(x: object) -> object: return x`` + +The second workaround is equivalent: assigning the lambda to a variable, and annotating +the type of that variable with a Callable. + +``f: Callable[[object], object] = lambda x: x`` + +.. + (This is an RST comment. The following paragraph has been excised from the guide, + as most beginners will not know what a type comment is anyway — especially a function + type comment. However, the paragraph is left in this comment for greater context for + you, the future editor:) + + Type comments on function definitions do not actually work on lambda, nor do + normal type comments help (although you can use a type comment on an assignment + to a variable with a lambda, of course; however this will have to be the Callable + syntax and not the function-arrow special one). + +Most type checkers include an option to emit a warning if they aren't able to deduce +the type of an expression; this should be helpful if you want to avoid silent uncaught +type errors resulting from lambda expressions being deduced as ``Any``. For instance, +Mypy includes ``disallow_any_expr``/``--disallow-any-expr`` and Pyright includes +``reportUnknownLambdaType``. Both of those options are set to true in the respective +strict modes of those type checkers. + +In conclusion: + +1. There is no way to explicitly annotate lambda arguments or return values in the +lambdas themselves. + +2. However, static typing rules still apply to lambdas, including type deduction. + +3. Many lambdas get deduced as ``Any``, which might suppress the reporting of other +type errors. + +4. However, many lambdas get deduced fine, and for those it's not a problem. + +5. If you want to annotate the type of lambdas, you can bind them and annotate them +there. + +6. Most type checkers have a setting that will warn you if anything gets deduced as +``Any``, and you can use that to avoid false negatives relating to lambda. diff --git a/docs/source/libraries.rst b/docs/guides/libraries.rst similarity index 78% rename from docs/source/libraries.rst rename to docs/guides/libraries.rst index 376811ad0..66404aac8 100644 --- a/docs/source/libraries.rst +++ b/docs/guides/libraries.rst @@ -43,7 +43,7 @@ library: Inline type annotations simply refers to the use of annotations within your ``.py`` files. In contrast, with type stub files, type information lives in -separate ``.pyi`` files; see :ref:`stubs` and :ref:`writing_stubs` for more +separate ``.pyi`` files; see :ref:`stub-files` and :ref:`writing_stubs` for more details. We recommend using the inline type annotations approach, since it has the @@ -82,26 +82,13 @@ A typical directory structure would look like: .. code-block:: text - setup.py + pyproject.toml my_great_package/ __init__.py stuff.py py.typed -It's important to ensure that the ``py.typed`` marker file is included in the -distributed package. If using ``setuptools``, this can be achieved like so: - -.. code-block:: python - - from setuptools import setup - - setup( - name="my_great_distribution", - version="0.1", - package_data={"my_great_package": ["py.typed"]}, - packages=["my_great_package"], - ) - +Note the py.typed should be located inside the package, along with ``__init__.py``. Type stub files included in the package ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -113,27 +100,13 @@ directory structure would look like: .. code-block:: text - setup.py + pyproject.toml my_great_package/ __init__.py stuff.py stuff.pyi py.typed -If using ``setuptools``, we can ensure the ``.pyi`` and ``py.typed`` files are -included like so: - -.. code-block:: python - - from setuptools import setup - - setup( - name="my_great_distribution", - version="0.1", - package_data={"my_great_package": ["py.typed", "stuff.pyi"]}, - packages=["my_great_package"], - ) - The presence of ``.pyi`` files does not affect the Python interpreter at runtime in any way. However, static type checkers will only look at the ``.pyi`` file and ignore the corresponding ``.py`` file. @@ -150,41 +123,25 @@ For example: .. code-block:: text - setup.py + pyproject.toml my_great_package-stubs/ __init__.pyi stuff.pyi +.. code-block:: toml -.. code-block:: python - - from setuptools import setup - - setup( - name="my_great_package-stubs", - version="0.1", - package_data={"my_great_package-stubs": ["__init__.pyi", "stuff.pyi"]}, - packages=["my_great_package-stubs"] - ) + [project] + name = "my-great-package-stubs" + version = "0.1.0" + requires-python = ">=3.10" + [build-system] + requires = ["uv_build>=0.9.18,<0.10.0"] + build-backend = "uv_build" Users are then able to install the stubs-only package separately to provide types for the original library. -Inclusion in sdist -^^^^^^^^^^^^^^^^^^ - -Note that to ensure inclusion of ``.pyi`` and ``py.typed`` files in an sdist -(.tar.gz archive), you may also need to modify the inclusion rules in your -``MANIFEST.in`` (see the -`packaging guide `__ -for more details on ``MANIFEST.in``). For example: - -.. code-block:: text - - global-include *.pyi - global-include py.typed - .. _type_completeness: How much of my library needs types? @@ -193,51 +150,8 @@ How much of my library needs types? A "py.typed" library should aim to be type complete so that type checking and inspection can work to their full extent. Here we say that a library is “type complete” if all of the symbols -that comprise its interface have type annotations that refer to types -that are fully known. Private symbols are exempt. - -Library interface (public and private symbols) ----------------------------------------------- - -If a ``py.typed`` module is present, a type checker will treat all modules -within that package (i.e. all files that end in ``.py`` or ``.pyi``) as -importable unless the file name begins with an underscore. These modules -comprise the supported interface for the library. - -Each module exposes a set of symbols. Some of these symbols are -considered "private” — implementation details that are not part of the -library’s interface. Type checkers can use the following rules -to determine which symbols are visible outside of the package. - -- Symbols whose names begin with an underscore (but are not dunder - names) are considered private. -- Imported symbols are considered private by default. If they use the - ``import A as A`` (a redundant module alias), ``from X import A as A`` (a - redundant symbol alias), or ``from . import A`` forms, symbol ``A`` is - not private unless the name begins with an underscore. If a file - ``__init__.py`` uses form ``from .A import X``, symbol ``A`` is treated - likewise. If a wildcard import (of the form ``from X import *``) is - used, all symbols referenced by the wildcard are not private. -- A module can expose an ``__all__`` symbol at the module level that - provides a list of names that are considered part of the interface. - This overrides all other rules above, allowing imported symbols or - symbols whose names begin with an underscore to be included in the - interface. -- Local variables within a function (including nested functions) are - always considered private. - -The following idioms are supported for defining the values contained -within ``__all__``. These restrictions allow type checkers to statically -determine the value of ``__all__``. - -- ``__all__ = ('a', b')`` -- ``__all__ = ['a', b']`` -- ``__all__ += ['a', b']`` -- ``__all__ += submodule.__all__`` -- ``__all__.extend(['a', b'])`` -- ``__all__.extend(submodule.__all__)`` -- ``__all__.append('a')`` -- ``__all__.remove('a')`` +that comprise its :ref:`interface ` have type annotations +that refer to types that are fully known. Private symbols are exempt. Type Completeness ----------------- @@ -275,15 +189,15 @@ is obvious from the context: assigned only once and is either annotated with ``Final`` or is named in all-caps. A constant that is not assigned a simple literal value requires explicit annotations, preferably with a ``Final`` annotation - (e.g. ``WOODWINDS: Final[List[str]] = ['Oboe', 'Bassoon']``). + (e.g. ``WOODWINDS: Final[list[str]] = ['Oboe', 'Bassoon']``). - Enum values within an Enum class do not require annotations because they take on the type of the Enum class. - Type aliases do not require annotations. A type alias is a symbol that is defined at a module level with a single assignment where the assigned value is an instantiable type, as opposed to a class instance - (e.g. ``Foo = Callable[[Literal["a", "b"]], Union[int, str]]`` or - ``Bar = Optional[MyGenericClass[int]]``). + (e.g. ``Foo = Callable[[Literal["a", "b"]], int | str]`` or + ``Bar = MyGenericClass[int] | None``). - The “self” parameter in an instance method and the “cls” parameter in a class method do not require an explicit annotation. - The return type for an ``__init__`` method does not need to be @@ -305,21 +219,21 @@ Examples of known and unknown types a = [3, 4, 5] # Variable with known type - a: List[int] = [3, 4, 5] + a: list[int] = [3, 4, 5] # Type alias with partially unknown type (because type # arguments are missing for list and dict) - DictOrList = Union[list, dict] + DictOrList = list | dict # Type alias with known type - DictOrList = Union[List[Any], Dict[str, Any]] + DictOrList = list[Any] | dict[str, Any] # Generic type alias with known type _T = TypeVar("_T") - DictOrList = Union[List[_T], Dict[str, _T]] + DictOrList = list[_T] | dict[str, _T] # Function with known type - def func(a: Optional[int], b: Dict[str, float] = {}) -> None: + def func(a: int | None, b: dict[str, float] = {}) -> None: pass # Function with partially unknown type (because type annotations @@ -334,7 +248,7 @@ Examples of known and unknown types # Function with partially unknown type (because return type # annotation is missing) - def func(a: int, b: Dict[str, float]): + def func(a: int, b: dict[str, float]): pass # Decorator with partially unknown type (because type annotations @@ -409,7 +323,7 @@ Wide vs. Narrow Types In type theory, when comparing two types that are related to each other, the “wider” type is the one that is more general, and the “narrower” type is more specific. For example, ``Sequence[str]`` is a wider type -than ``List[str]`` because all ``List`` objects are also ``Sequence`` +than ``list[str]`` because all ``list`` objects are also ``Sequence`` objects, but the converse is not true. A subclass is narrower than a class it derives from. A union of types is wider than the individual types that comprise the union. @@ -418,7 +332,7 @@ In general, a function input parameter should be annotated with the widest possible type supported by the implementation. For example, if the implementation requires the caller to provide an iterable collection of strings, the parameter should be annotated as ``Iterable[str]``, not -as ``List[str]``. The latter type is narrower than necessary, so if a +as ``list[str]``. The latter type is narrower than necessary, so if a user attempts to pass a tuple of strings (which is supported by the implementation), a type checker will complain about a type incompatibility. @@ -426,21 +340,21 @@ incompatibility. As a specific application of the “use the widest type possible” rule, libraries should generally use immutable forms of container types instead of mutable forms (unless the function needs to modify the -container). Use ``Sequence`` rather than ``List``, ``Mapping`` rather -than ``Dict``, etc. Immutable containers allow for more flexibility +container). Use ``Sequence`` rather than ``list``, ``Mapping`` rather +than ``dict``, etc. Immutable containers allow for more flexibility because their type parameters are covariant rather than invariant. A -parameter that is typed as ``Sequence[Union[str, int]]`` can accept a -``List[int]``, ``Sequence[str]``, and a ``Sequence[int]``. But a -parameter typed as ``List[Union[str, int]]`` is much more restrictive -and accepts only a ``List[Union[str, int]]``. +parameter that is typed as ``Sequence[str | int]`` can accept a +``list[int]``, ``Sequence[str]``, and a ``Sequence[int]``. But a +parameter typed as ``list[str | int]`` is much more restrictive +and accepts only a ``list[str | int]``. Overloads --------- If a function or method can return multiple different types and those types can be determined based on the presence or types of certain -parameters, use the ``@overload`` mechanism defined in `PEP -484 `__. When overloads +parameters, use the ``@overload`` mechanism described in the +:py:data:`typing.overload` documentation. When overloads are used within a “.py” file, they must appear prior to the function implementation, which should not have an ``@overload`` decorator. @@ -452,9 +366,11 @@ specified only by name, use the keyword-only separator (``*``). .. code:: python - def create_user(age: int, *, dob: Optional[date] = None): + def create_user(age: int, *, dob: date | None = None): ... +.. _annotating-decorators: + Annotating Decorators --------------------- @@ -491,12 +407,72 @@ original signature, thus blinding type checkers and other tools that provide signature assistance. As such, library authors are discouraged from creating decorators that mutate function signatures in this manner. +.. _aliasing-decorators: + +Aliasing Decorators +------------------- + +When writing a library with a couple of decorator factories +(i.e. functions returning decorators, like ``complex_decorator`` from the +:ref:`annotating-decorators` section) it may be tempting to create a shortcut +for a decorator. + +Different type checkers handle :data:`TypeAlias ` involving +:class:`Callable ` in a +different manner, so the most portable and easy way to create a shortcut +is to define a callable :class:`Protocol ` as described in the +:ref:`callback-protocols` section of the Typing Specification. + +There is already a :class:`Protocol ` called +``IdentityFunction`` defined in +`_typeshed `_: + +.. code:: python + + from typing import TYPE_CHECKING + + if TYPE_CHECKING: + from _typeshed import IdentityFunction + + def decorator_factory(*, mode: str) -> "IdentityFunction": + """ + Decorator factory is invoked with arguments like this: + @decorator_factory(mode="easy") + def my_function(): ... + """ + ... + +For non-trivial decorators with custom logic, it is still possible +to define a custom protocol using :class:`ParamSpec ` +and :data:`Concatenate ` mechanisms: + +.. code:: python + + class Client: ... + + P = ParamSpec("P") + R = TypeVar("R") + + class PClientInjector(Protocol): + def __call__(self, _: Callable[Concatenate[Client, P], R], /) -> Callable[P, R]: + ... + + def inject_client(service: str) -> PClientInjector: + """ + Decorator factory is invoked with arguments like this: + @inject_client("testing") + def my_function(client: Client, value: int): ... + + my_function then takes only value + """ + + Generic Classes and Functions ----------------------------- Classes and functions that can operate in a generic manner on various -types should declare themselves as generic using the mechanisms -described in :pep:`484`. +types should declare themselves as generic using standard typing +mechanisms such as ``TypeVar``. This includes the use of ``TypeVar`` symbols. Typically, a ``TypeVar`` should be private to the file that declares it, and should therefore begin with an underscore. @@ -515,16 +491,16 @@ annotation. .. code:: python # Simple type alias - FamilyPet = Union[Cat, Dog, GoldFish] + FamilyPet = Cat | Dog | GoldFish # Generic type alias - ListOrTuple = Union[List[_T], Tuple[_T, ...]] + ListOrTuple = list[_T] | tuple[_T, ...] # Recursive type alias - TreeNode = Union[LeafNode, List["TreeNode"]] + TreeNode = LeafNode | list["TreeNode"] - # Explicit type alias using PEP 613 syntax - StrOrInt: TypeAlias = Union[str, int] + # Explicit type alias using TypeAlias + StrOrInt: TypeAlias = str | int Abstract Classes and Methods ---------------------------- @@ -590,14 +566,14 @@ type annotation would be redundant. # All-caps constant with explicit type COLOR_FORMAT_RGB: Literal["rgb"] = "rgb" - LATEST_VERSION: Tuple[int, int] = (4, 5) + LATEST_VERSION: tuple[int, int] = (4, 5) - # Final variable with inferred type + # Bare Final variable with inferred type ColorFormatRgb: Final = "rgb" - # Final variable with explicit type + # Explicitly typed Final variable ColorFormatRgb: Final[Literal["rgb"]] = "rgb" - LATEST_VERSION: Final[Tuple[int, int]] = (4, 5) + LATEST_VERSION: Final[tuple[int, int]] = (4, 5) Typed Dictionaries, Data Classes, and Named Tuples -------------------------------------------------- diff --git a/docs/source/modernizing.rst b/docs/guides/modernizing.rst similarity index 85% rename from docs/source/modernizing.rst rename to docs/guides/modernizing.rst index 0c6309a3d..1ce82fc58 100644 --- a/docs/source/modernizing.rst +++ b/docs/guides/modernizing.rst @@ -19,11 +19,19 @@ but they are superseded by more modern alternatives, which are recommended to us These newer features are not available in all Python versions, although some features are available as backports from the `typing-extensions `_ -package, or require quoting or using :python:`from __future__ import annotations`. +package, or require quoting or using :python:`from __future__ import annotations` +when running on Python 3.13 or below. Each section states the minimum Python version required to use the feature, whether it is available in typing-extensions, and whether it is available using quoting. +.. tip:: + + Tools such as `pyupgrade `__, + `ruff `__ and/or + `com2ann `__ can automatically perform + some of these refactorings for you. + .. note:: The latest version of typing-extensions is available for all Python @@ -32,16 +40,18 @@ available using quoting. .. note:: - :python:`from __future__ import annotations` is available since Python 3.7. + :python:`from __future__ import annotations` is available since Python 3.7 + and became unnecessary starting with Python 3.14. This only has an effect inside type annotations, while quoting is still - required outside. For example, this example runs on Python 3.7 and up, - although the pipe operator was only introduced in Python 3.10:: + required outside. For example:: from __future__ import annotations from typing_extensions import TypeAlias - def f(x: int | None) -> int | str: ... # the future import is sufficient - Alias: TypeAlias = "int | str" # this requires quoting + def f(x: Foo) -> Foo: ... # the future import is sufficient + Alias: TypeAlias = "Foo" # this forward reference requires quoting + + class Foo: pass .. _modernizing-type-comments: @@ -75,6 +85,9 @@ it's necessary to either use :python:`from __future__ import annotations` class Parrot: ... +When using Python 3.14 and up, quoting forward references is no longer +necessary inside type annotations. + .. _modernizing-typing-text: ``typing.Text`` @@ -236,18 +249,14 @@ return types. For example, replace:: from typing import NoReturn def f(x: int, y: NoReturn) -> None: ... + def g() -> NoReturn: ... with:: from typing import Never # or typing_extensions.Never def f(x: int, y: Never) -> None: ... - -But keep ``NoReturn`` for return types:: - - from typing import NoReturn - - def f(x: int) -> NoReturn: ... + def g() -> Never: ... .. _modernizing-type-aliases: @@ -334,3 +343,31 @@ Update your imports to use the new locations:: from collections.abc import Hashable, Sized def f(x: Hashable) -> Sized: ... + +``typing.TypeGuard`` +==================== + +*Available since:* Python 3.13, typing-extensions + +:data:`TypeIs ` is an alternative to +:data:`TypeGuard ` that usually has more intuitive +behavior, but has other restrictions. See the documentation for +:data:`TypeIs ` for more information. + +Review existing uses of :data:`TypeGuard ` to see if they +should be replaced with :data:`TypeIs `. + +``from __future__ import annotations`` +====================================== + +*Available since:* Python 3.14 + +Starting with Python 3.14, behavior similar to using +``from __future__ import annotations`` became the default. When running on +Python 3.14 and up, it's no longer necessary to use the future import to defer +evaluation of annotations. However, quoting is still necessary for types used +outside of annotations and :keyword:`type` statements, for example when using +:data:`TypeAlias `. + +Remove unnecessary uses of ``from __future__ import annotations`` for code +only supporting Python 3.14 and up. diff --git a/docs/guides/type_narrowing.rst b/docs/guides/type_narrowing.rst new file mode 100644 index 000000000..c359d9314 --- /dev/null +++ b/docs/guides/type_narrowing.rst @@ -0,0 +1,342 @@ +************** +Type Narrowing +************** + +Python programs often contain symbols that take on multiple types within a +single given scope and that are distinguished by a conditional check at +runtime. For example, here the variable *name* can be either a ``str`` or +``None``, and the ``if name is not None`` narrows it down to just ``str``:: + + def maybe_greet(name: str | None) -> None: + if name is not None: + print("Hello, " + name) + +This technique is called *type narrowing*. +To avoid false positives on such code, type checkers understand +various kinds of conditional checks that are used to narrow types in Python code. +The exact set of type narrowing constructs that a type checker understands +is not specified and varies across type checkers. Commonly understood +patterns include: + +* ``if x is not None`` +* ``if x`` +* ``if isinstance(x, SomeType)`` +* ``if callable(x)`` + +In addition to narrowing local variables, type checkers usually also support +narrowing instance attributes and sequence members, such as +``if x.some_attribute is not None`` or ``if x[0] is not None``, though the exact +conditions for this behavior differ between type checkers. + +Consult your type checker's documentation for more information on the type +narrowing constructs it supports. + +The type system also includes two ways to create *user-defined* type narrowing +functions: :py:data:`typing.TypeIs` and :py:data:`typing.TypeGuard`. These +are useful if you want to reuse a more complicated check in multiple places, or +you use a check that the type checker doesn't understand. In these cases, you +can define a ``TypeIs`` or ``TypeGuard`` function to perform the check and allow type checkers +to use it to narrow the type of a variable. Between the two, ``TypeIs`` usually +has the more intuitive behavior, so we'll talk about it more; see +:ref:`below ` for a comparison. + +How to use ``TypeIs`` and ``TypeGuard`` +--------------------------------------- + +A ``TypeIs`` function takes a single argument and is annotated as returning +``TypeIs[T]``, where ``T`` is the type that you want to narrow to. The function +must return ``True`` if the argument is of type ``T``, and ``False`` otherwise. +The function can then be used in ``if`` checks, just like you would use ``isinstance()``. +For example:: + + from typing import Literal, TypeIs + + type Direction = Literal["N", "E", "S", "W"] + + def is_direction(x: str) -> TypeIs[Direction]: + return x in {"N", "E", "S", "W"} + + def maybe_direction(x: str) -> None: + if is_direction(x): + print(f"{x} is a cardinal direction") + else: + print(f"{x} is not a cardinal direction") + +A ``TypeGuard`` function looks similar and is used in the same way, but the +type narrowing behavior is different, as discussed in :ref:`the section below `. + +Depending on the version of Python you are running, you will be able to +import ``TypeIs`` and ``TypeGuard`` either from the standard library :py:mod:`typing` +module or from the third-party ``typing_extensions`` module: + +* ``TypeIs`` is in ``typing`` starting from Python 3.13 and in ``typing_extensions`` + starting from version 4.10.0. +* ``TypeGuard`` is in ``typing`` starting from Python 3.10 and in ``typing_extensions`` + starting from version 3.10.0.0. + + +Writing a correct ``TypeIs`` function +------------------------------------- + +A ``TypeIs`` function allows you to override your type checker's type narrowing +behavior. This is a powerful tool, but it can be dangerous because an incorrectly +written ``TypeIs`` function can lead to unsound type checking, and type checkers +cannot detect such errors. + +For a function returning ``TypeIs[T]`` to be correct, it must return ``True`` if and only if +the argument is of type ``T``, and ``False`` otherwise. If this condition is +not met, the type checker may infer incorrect types. + +Below are some examples of correct and incorrect ``TypeIs`` functions:: + + from typing import TypeIs + + # Correct + def is_int(x: object) -> TypeIs[int]: + return isinstance(x, int) + + # Incorrect: does not return True for all ints + def is_positive_int(x: object) -> TypeIs[int]: + return isinstance(x, int) and x > 0 + + # Incorrect: returns True for some non-ints + def is_real_number(x: object) -> TypeIs[int]: + return isinstance(x, (int, float)) + +This function demonstrates some errors that can occur when using a poorly written +``TypeIs`` function. These errors are not detected by type checkers:: + + def caller(x: int | str, y: int | float) -> None: + if is_positive_int(x): # narrowed to int + print(x + 1) + else: # narrowed to str (incorrectly) + print("Hello " + x) # runtime error if x is a negative int + + if is_real_number(y): # narrowed to int + # Because of the incorrect TypeIs, this branch is taken at runtime if + # y is a float. + print(y.bit_count()) # runtime error: this method exists only on int, not float + else: # narrowed to float (though never executed at runtime) + pass + +Here is an example of a correct ``TypeIs`` function for a more complicated type:: + + from typing import TypedDict, TypeIs + + class Point(TypedDict): + x: int + y: int + + def is_point(obj: object) -> TypeIs[Point]: + return ( + isinstance(obj, dict) + and all(isinstance(key, str) for key in obj) + and isinstance(obj.get("x"), int) + and isinstance(obj.get("y"), int) + ) + +.. _`guide-type-narrowing-typeis-typeguard`: + +``TypeIs`` and ``TypeGuard`` +---------------------------- + +:py:data:`typing.TypeIs` and :py:data:`typing.TypeGuard` are both tools for narrowing the type of a variable +based on a user-defined function. Both can be used to annotate functions that take an +argument and return a boolean depending on whether the input argument is compatible with +the narrowed type. These functions can then be used in ``if`` checks to narrow the type +of a variable. + +``TypeIs`` usually has the more intuitive behavior, but it +introduces more restrictions. ``TypeGuard`` is the right tool to use if: + +* You want to narrow to a type that is not :term:`assignable` to the input type, for example + from ``list[object]`` to ``list[int]``. ``TypeIs`` only allows narrowing between + compatible types. +* Your function does not return ``True`` for all input values that are members of + the narrowed type. For example, you could have a ``TypeGuard[int]`` that returns ``True`` + only for positive integers. + +``TypeIs`` and ``TypeGuard`` differ in the following ways: + +* ``TypeIs`` requires the narrowed type to be :term:`assignable` to the input type, while + ``TypeGuard`` does not. +* When a ``TypeGuard`` function returns ``True``, type checkers narrow the type of the + variable to exactly the ``TypeGuard`` type. When a ``TypeIs`` function returns ``True``, + type checkers can infer a more precise type combining the previously known type of the + variable with the ``TypeIs`` type. (This is known as an "intersection type".) +* When a ``TypeGuard`` function returns ``False``, type checkers cannot narrow the type of + the variable at all. When a ``TypeIs`` function returns ``False``, type checkers can narrow + the type of the variable to exclude the ``TypeIs`` type. + +This behavior can be seen in the following example:: + + from typing import TypeGuard, TypeIs, reveal_type, final + + class Base: ... + class Child(Base): ... + @final + class Unrelated: ... + + def is_base_typeguard(x: object) -> TypeGuard[Base]: + return isinstance(x, Base) + + def is_base_typeis(x: object) -> TypeIs[Base]: + return isinstance(x, Base) + + def use_typeguard(x: Child | Unrelated) -> None: + if is_base_typeguard(x): + reveal_type(x) # Base + else: + reveal_type(x) # Child | Unrelated + + def use_typeis(x: Child | Unrelated) -> None: + if is_base_typeis(x): + reveal_type(x) # Child + else: + reveal_type(x) # Unrelated + + +Safety and soundness +-------------------- + +While type narrowing is important for typing real-world Python code, many +forms of type narrowing are unsafe in the presence of mutability. Type checkers +attempt to limit type narrowing in a way that minimizes unsafety while remaining +useful, but not all safety violations can be detected. + +``isinstance()`` and ``issubclass()`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +While the exact behavior is not standardized, type checkers usually support +narrowing terms based on calls to ``isinstance()`` and ``issubclass()``. However, +these functions have complex runtime behavior that type checkers cannot fully +capture: they call the :py:meth:`__instancecheck__` and :py:meth:`__subclasscheck__` +special methods, which may include arbitrarily complex logic. + +This affects some parts of the standard library that rely on these methods. +:py:class:`abc.ABC` allows registration of subclasses using the ``.register()`` method, +but type checkers usually will not recognize this method. :ref:`Runtime-checkable +protocols ` support runtime ``isinstance()`` checks, but their +behavior does not exactly match the type system (for example, the types of method +parameters are not checked). + +Incorrect ``TypeIs`` and ``TypeGuard`` functions +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Both ``TypeIs`` and ``TypeGuard`` rely on the user writing a function that +returns whether an object is of a particular type. However, the type checker +does not validate whether the function actually behaves as expected. If it +does not, the type checker's narrowing behavior will not match what happens +at runtime.:: + + from typing import TypeIs + + def is_str(x: object) -> TypeIs[str]: + return True + + def takes_str_or_int(x: str | int) -> None: + if is_str(x): + print(x + " is a string") # runtime error + +To avoid this problem, every ``TypeIs`` and ``TypeGuard`` function should be +carefully reviewed and tested. + +Unsound ``TypeGuard`` narrowing +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Unlike ``TypeIs``, ``TypeGuard`` can narrow to a type that is not a subtype of the +original type. This allows for unsafe behavior with invariant data structures:: + + from typing import Any, TypeGuard + + def is_int_list(x: list[Any]) -> TypeGuard[list[int]]: + return all(isinstance(i, int) for i in x) + + def maybe_mutate_list(x: list[Any]) -> None: + if is_int_list(x): + x.append(0) # OK, x is narrowed to list[int] + + def takes_bool_list(x: list[bool]) -> None: + maybe_mutate_list(x) + reveal_type(x) # list[bool] + assert all(isinstance(i, bool) for i in x) # fails at runtime + + takes_bool_list([True, False]) + +To avoid this problem, use ``TypeIs`` instead of ``TypeGuard`` where possible. +If you must use ``TypeGuard``, avoid narrowing across incompatible types. +Prefer using covariant, immutable types in parameter annotations (e.g., +``Sequence`` or ``Iterable`` instead of ``list``). If you do this, it is more likely +that you'll be able to use ``TypeIs`` to implement your type narrowing functions. + +Invalidated assumptions +~~~~~~~~~~~~~~~~~~~~~~~ + +One category of safety issues relates to the fact that type narrowing relies +on a condition that was established at one point in the code and is then relied +on later: we first check ``if x is not None``, then rely on ``x`` not being ``None``. +However, in the meantime other code may have run (for example, in another thread, +another coroutine, or simply some code that was invoked by a function call) and +invalidated the earlier condition. + +Such problems are most likely when narrowing is performed on elements of mutable +objects, but it is possible to construct unsafe examples even using only narrowing +of local variables:: + + def maybe_greet(name: str | None) -> None: + def set_it_to_none(): + nonlocal name + name = None + + if name is not None: + set_it_to_none() + # fails at runtime, no error in current type checkers + print("Hello " + name) + + maybe_greet("Guido") + +A more realistic example might involve multiple coroutines mutating a list:: + + import asyncio + from typing import Sequence, TypeIs + + def is_int_sequence(x: Sequence[object]) -> TypeIs[Sequence[int]]: + return all(isinstance(i, int) for i in x) + + async def takes_seq(x: Sequence[int | None]): + if is_int_sequence(x): + await asyncio.sleep(2) + print("The total is", sum(x)) # fails at runtime + + async def takes_list(x: list[int | None]): + t = asyncio.create_task(takes_seq(x)) + await asyncio.sleep(1) + x.append(None) + await t + + if __name__ == "__main__": + lst: list[int | None] = [1, 2, 3] + asyncio.run(takes_list(lst)) + +These issues unfortunately cannot be fully detected by the current +Python type system. (An example of a different programming language that +does solve this problem is Rust, which uses a system called +`ownership `__.) +To avoid such issues, avoid using type narrowing on objects that are mutated +from other parts of the code. + + +See also +-------- + +* Type checker documentation on type narrowing + + * `Mypy `__ + * `Pyright `__ + +* PEPs related to type narrowing. These contain additional discussion + and motivation for current type checker behaviors. + + * :pep:`647` (introduced ``TypeGuard``) + * (*withdrawn*) :pep:`724` (proposed change to ``TypeGuard`` behavior) + * :pep:`742` (introduced ``TypeIs``) diff --git a/docs/source/typing_anti_pitch.rst b/docs/guides/typing_anti_pitch.rst similarity index 100% rename from docs/source/typing_anti_pitch.rst rename to docs/guides/typing_anti_pitch.rst diff --git a/docs/source/unreachable.rst b/docs/guides/unreachable.rst similarity index 89% rename from docs/source/unreachable.rst rename to docs/guides/unreachable.rst index d14e3cf06..e72fe2f6b 100644 --- a/docs/source/unreachable.rst +++ b/docs/guides/unreachable.rst @@ -54,7 +54,7 @@ As an example, consider this simple calculator: .. code:: python import enum - from typing_extensions import Never + from typing import Never def assert_never(arg: Never) -> Never: raise AssertionError("Expected code to be unreachable") @@ -72,6 +72,11 @@ As an example, consider this simple calculator: case _: assert_never(op) +.. note:: + + To use this feature on Python versions earlier than 3.11, you will need to + import ``Never`` from ``typing_extensions`` (version 4.1 or newer). + The ``match`` statement covers all members of the ``Op`` enum, so the ``assert_never()`` call is unreachable and the type checker will accept this code. However, if you add another member to the @@ -86,6 +91,14 @@ and is also present in ``typing_extensions`` starting at version 4.1. However, it is also possible to define a similar function in your own code, for example if you want to customize the runtime error message. +This use of match statements for comprehensive matching is common +enough that some typecheckers have direct support for checking all match +statements for exhaustiveness, regardless of whether or not they have an +``assert_never``-style function in their default arm. For instance, in pyright +this can be enabled by enabling the diagnostic code ``reportMatchNotExhaustive`` +(on by default in strict mode), and in mypy it can be enabled by enabling +the error code ``exhaustive-match``. + You can also use ``assert_never()`` with a sequence of ``if`` statements: .. code:: python diff --git a/docs/guides/writing_stubs.rst b/docs/guides/writing_stubs.rst new file mode 100644 index 000000000..f8e7e5852 --- /dev/null +++ b/docs/guides/writing_stubs.rst @@ -0,0 +1,901 @@ +.. _writing_stubs: + +********************************** +Writing and Maintaining Stub Files +********************************** + +Stub files are a means of providing type information for Python modules. +For a quick introduction, see :ref:`external_libraries`. For a full reference, +refer to :ref:`distributing-type`. + +Maintaining stubs can be a little cumbersome because they are separated from the +implementation. This page lists some tools that make writing and maintaining +stubs less painful, as well as some best practices on stub contents and style. + +Tools for generating stubs +========================== + +stubgen +------- + +stubgen is a tool bundled with `mypy `__ +that can be used to generate basic stubs. These stubs serve as a +basic starting point; most types will default to ``Any``. + +.. code-block:: console + + stubgen -p my_great_package + +For more details, see `stubgen docs `__. + +pyright +------- + +pyright contains a tool that generates basic stubs. Like stubgen, these generated +stubs serve more as a starting point. + +.. code-block:: console + + pyright --createstub my_great_package + +For more details, see `pyright docs `__. + +pyrefly +------- + +Pyrefly also contains a tool to generate stubs. Unlike stubgen and pyright, this tool will aggressively infer types for un-annotated code, including function parameters, resulting in stubs that contain more non-``Any`` annotations. + +.. code-block:: console + + pyrefly stubgen path/to/directory/ + +For more details, see `pyrefly docs `__. + +monkeytype +---------- + +monkeytype takes a slightly different approach — you run your code (perhaps via +your tests) and monkeytype collects the types it observes at runtime to generate +stubs. + +.. code-block:: console + + monkeytype run script.py + monkeytype stub my_great_package + +For more details, see `monkeytype docs `__. + +Tools for maintaining stubs +=========================== + +stubtest +-------- + +stubtest is a tool bundled with `mypy `__. + +stubtest finds inconsistencies between stub files and the implementation. It +does this by comparing stub definitions to what it finds from importing your +code and using runtime introspection (via the ``inspect`` module). + +.. code-block:: console + + stubtest my_great_package + +For more details, see `stubtest docs `__. + +flake8-pyi +---------- + +flake8-pyi is a `flake8 `__ plugin that +lints common issues in stub files. + +.. code-block:: console + + flake8 my_great_package + +For more details, see `flake8-pyi docs `__. + +Running a type checker on the stubs +----------------------------------- + +Simply running a type checker on the stubs can catch several issues, from simple +things like detecting missing annotations to more complex things like ensuring +Liskov substitutability or detecting problematic overloads. + +It may be instructive to examine `typeshed `__'s +`setup for testing stubs `__. + +To suppress type errors in stubs, use ``# type: ignore`` comments. Refer to the :ref:`type-checker-error-suppression` section of the style guide for +error suppression formats specific to individual typecheckers. + +.. + TODO: consider adding examples and configurations for specific type checkers + +Type checking usage of your package +----------------------------------- + +If you have access to a codebase that uses your package — perhaps tests for your +package — running a type checker against it can help you detect issues, +particularly with false positives. + +If your package has some particularly complex aspects, you could even consider +writing dedicated typing tests for tricky definitions. For more details, see +:ref:`testing`. + +Stub Content +============ + +This section documents best practices on what elements to include or +leave out of stub files. + +Public Interface +---------------- + +Stubs should include the complete public interface (classes, functions, +constants, etc.) of the module they cover, but it is not always +clear exactly what is part of the interface. + +The following should always be included: + +* All objects listed in the module's documentation. +* All objects included in ``__all__`` (if present). + +Other objects may be included if they are not prefixed with an underscore +or if they are being used in practice. + +Modules excluded from stubs +--------------------------- + +The following should not be included in stubs: + +1. Implementation details, with `multiprocessing/popen_spawn_win32.py `_ as a notable example +2. Modules that are not supposed to be imported, such as ``__main__.py`` +3. Protected modules that start with a single ``_`` char. However, when needed protected modules can still be added (see :ref:`undocumented-objects` section below) +4. Tests + +.. _undocumented-objects: + +Undocumented Objects +-------------------- + +Undocumented objects may be included as long as they are marked with a comment +of the form ``# undocumented``. + +Example:: + + def list2cmdline(seq: Sequence[str]) -> str: ... # undocumented + +Such undocumented objects are allowed because omitting objects can confuse +users. Users who see an error like "module X has no attribute Y" will +not know whether the error appeared because their code had a bug or +because the stub is wrong. Although it may also be helpful for a type +checker to point out usage of private objects, false negatives (no errors for +wrong code) are preferable over false positives (type errors +for correct code). In addition, even for private objects a type checker +can be helpful in pointing out that an incorrect type was used. + +``__all__`` +------------ + +A stub file should contain an ``__all__`` variable if and only if it is also +present at runtime. In that case, the contents of ``__all__`` should be +identical in the stub and at runtime. If the runtime dynamically adds +or removes elements (for example if certain functions are only available on +some system configurations), include all possible elements in the stubs. + +Stub-Only Objects +----------------- + +Definitions that do not exist at runtime may be included in stubs to aid in +expressing types. Unless intentionally exposed to users (see below), such +definitions should be marked as private by prefixing their names with an +underscore. + +Yes:: + + _T = TypeVar("_T") + _DictList: TypeAlias = dict[str, list[int | None]] + +No:: + + T = TypeVar("T") + DictList: TypeAlias = dict[str, list[int | None]] + +Sometimes, it is desirable to make a stub-only class available +to a stub's users — for example, to allow them to type the return value of a +public method for which a library does not provide a usable runtime type. Use +the ``typing.type_check_only`` decorator to mark such objects:: + + from typing import Protocol, type_check_only + + @type_check_only + class Readable(Protocol): + def read(self) -> str: ... + + def get_reader() -> Readable: ... + +Structural Types +---------------- + +As seen in the example with ``Readable`` in the previous section, a common use +of stub-only objects is to model types that are best described by their +structure. These objects are called protocols (:pep:`544`), and it is encouraged +to use them freely to describe simple structural types. + +Incomplete Stubs +---------------- + +When writing new stubs, it is not necessary to fully annotate all arguments, +return types, and fields. Some items may be left unannotated or +annotated with ``_typeshed.Incomplete`` (`documentation `_):: + + from _typeshed import Incomplete + + field: Incomplete # unannotated + + def foo(x): ... # unannotated argument and return type + +``_typeshed.Incomplete`` can also be used for partially known types:: + + def foo(x: Incomplete | None = None) -> list[Incomplete]: ... + +Partial stubs can be useful, especially for larger packages, but they should +follow the following guidelines: + +* Included functions and methods should list all arguments, but the arguments + can be left unannotated. +* Do not use ``Any`` to mark unannotated or partially annotated values. Leave + function parameters and return values unannotated. In all other cases, use + ``_typeshed.Incomplete``. +* Partial classes should include a ``__getattr__()`` method marked with + ``_typeshed.Incomplete`` (see example below). +* Partial modules (i.e. modules that are missing some or all classes, + functions, or attributes) should include a top-level ``__getattr__()`` + function marked with ``_typeshed.Incomplete`` (see example below). +* Partial packages (i.e. packages that are missing one or more sub-modules) + should have a ``__init__.pyi`` stub that is marked as incomplete (see above). + A better alternative is to create empty stubs for all sub-modules and + mark them as incomplete individually. + +Example of a partial module with a partial class ``Foo`` and a partially +annotated function ``bar()``:: + + from _typeshed import Incomplete + + def __getattr__(name: str) -> Incomplete: ... + + class Foo: + def __getattr__(self, name: str) -> Incomplete: ... + x: int + y: str + + def bar(x: str, y, *, z=...): ... + +``Any`` vs. ``Incomplete`` +-------------------------- + +While ``Incomplete`` is a type alias of ``Any``, they serve different purposes: +``Incomplete`` is a placeholder where a proper type might be substituted. +It's a "to do" item and should be replaced if possible. + +``Any`` is used when it's not possible to accurately type an item using the current +type system. It should be used sparingly, as described in the :ref:`using-any` +section of the style guide. + +Attribute Access +---------------- + +Python has several methods for customizing attribute access: ``__getattr__``, +``__getattribute__``, ``__setattr__``, and ``__delattr__``. Of these, +``__getattr__`` and ``__setattr__`` should sometimes be included in stubs. + +In addition to marking incomplete definitions, ``__getattr__`` should be +included when a class or module allows any name to be accessed. For example, consider +the following class:: + + class Foo: + def __getattribute__(self, name): + return self.__dict__.setdefault(name) + +An appropriate stub definition is:: + + from typing import Any + + class Foo: + def __getattr__(self, name: str) -> Any | None: ... + +Note that only ``__getattr__``, not ``__getattribute__``, is guaranteed to be +supported in stubs. + +On the other hand, ``__getattr__`` should be omitted even if the source code +includes it, if only limited names are allowed. For example, consider this class:: + + class ComplexNumber: + def __init__(self, n): + self._n = n + def __getattr__(self, name): + if name in ("real", "imag"): + return getattr(self._n, name) + raise AttributeError(name) + +In this case, the stub should list the attributes individually:: + + class ComplexNumber: + @property + def real(self) -> float: ... + @property + def imag(self) -> float: ... + def __init__(self, n: complex) -> None: ... + +``__setattr__`` should be included when a class allows any name to be set and +restricts the type. For example:: + + class IntHolder: + def __setattr__(self, name, value): + if isinstance(value, int): + return super().__setattr__(name, value) + raise ValueError(value) + +A good stub definition would be:: + + class IntHolder: + def __setattr__(self, name: str, value: int) -> None: ... + +``__delattr__`` should not be included in stubs. + +Finally, even in the presence of ``__getattr__`` and ``__setattr__``, it is +still recommended to separately define known attributes. + +Constants +--------- + +When the value of a constant is important, mark it as a :term:`bare Final` and +assign it to its value. + +Yes:: + + TEL_LANDLINE: Final = "landline" + TEL_MOBILE: Final = "mobile" + DAY_FLAG: Final = 0x01 + NIGHT_FLAG: Final = 0x02 + +No:: + + TEL_LANDLINE: str + TEL_MOBILE: str + DAY_FLAG: int + NIGHT_FLAG: int + +Overloads +--------- + +All variants of overloaded functions and methods must have an ``@overload`` +decorator. Do not include the implementation's final non-`@overload`-decorated +definition. + +Yes:: + + @overload + def foo(x: str) -> str: ... + @overload + def foo(x: float) -> int: ... + +No:: + + @overload + def foo(x: str) -> str: ... + @overload + def foo(x: float) -> int: ... + def foo(x: str | float) -> Any: ... + +Decorators +---------- + +Include only the decorators listed :ref:`here `, whose effects +are understood by all of the major type checkers. The behavior of other +decorators should instead be incorporated into the types. For example, for the +following function:: + + import contextlib + @contextlib.contextmanager + def f(): + yield 42 + +the stub definition should be:: + + from contextlib import AbstractContextManager + def f() -> AbstractContextManager[int]: ... + +Documentation or Implementation +------------------------------- + +Sometimes a library's documented types will differ from the actual types in the +code. In such cases, stub authors should use their best judgment. Consider these +two examples:: + + def print_elements(x): + """Print every element of list x.""" + for y in x: + print(y) + + def maybe_raise(x): + """Raise an error if x (a boolean) is true.""" + if x: + raise ValueError() + +The implementation of ``print_elements`` takes any iterable, despite the +documented type of ``list``. In this case, annotate the argument as +``Iterable[object]``, to follow the :ref:`best practice` +of preferring abstract types for arguments. + +For ``maybe_raise``, on the other hand, it is better to annotate the argument as +``bool`` even though the implementation accepts any object. This guards against +common mistakes like unintentionally passing in ``None``. + +If in doubt, consider asking the library maintainers about their intent. + +Common Patterns +=============== + +.. _stub-patterns: + +This section documents common patterns that are useful in stub files. + +Overloads and Flags +------------------- + +.. _overloads-and-flags: + +Sometimes a function or method has a flag argument that changes the return type +or other accepted argument types. For example, take the following function:: + + def open(name: str, mode: Literal["r", "w"] = "r") -> Reader | Writer: + ... + +We can express this case easily with two overloads:: + + @overload + def open(name: str, mode: Literal["r"] = "r") -> Reader: ... + @overload + def open(name: str, mode: Literal["w"]) -> Writer: ... + +The first overload is picked when the mode is ``"r"`` or not given, and the +second overload is picked when the mode is ``"w"``. But what if the first +argument is optional? + +:: + + def open(name: str | None = None, mode: Literal["r", "w"] = "r") -> Reader | Writer: + ... + +Ideally we would be able to use the following overloads:: + + @overload + def open(name: str | None = None, mode: Literal["r"] = "r") -> Reader: ... + @overload + def open(name: str | None = None, mode: Literal["w"]) -> Writer: ... + +And while the first overload is fine, the second is a syntax error in Python, +because non-default arguments cannot follow default arguments. To work around +this, we need an extra overload:: + + @overload + def open(name: str | None = None, mode: Literal["r"] = "r") -> Reader: ... + @overload + def open(name: str | None, mode: Literal["w"]) -> Writer: ... + @overload + def open(*, mode: Literal["w"]) -> Writer: ... + +As before, the first overload is picked when the mode is ``"r"`` or not given. +Otherwise, the second overload is used when ``open`` is called with an explicit +``name``, e.g. ``open("file.txt", "w")`` or ``open(None, "w")``. The third +overload is used when ``open`` is called without a name, e.g. +``open(mode="w")``. + +Style Guide +=========== + +The recommendations in this section are aimed at stub authors who wish to +provide a consistent style for stubs. Type checkers should not reject stubs that +do not follow these recommendations, but linters can warn about them. + +Stub files should generally follow the Style Guide for Python Code (:pep:`8`) +and the :ref:`best-practices`. There are a few exceptions, outlined below, that take the +different structure of stub files into account and aim to create +more concise files. + +Syntax Example +-------------- + +The below is an excerpt from the types for the ``datetime`` module:: + + MAXYEAR: int + MINYEAR: int + + class date: + def __new__(cls, year: SupportsIndex, month: SupportsIndex, day: SupportsIndex) -> Self: ... + @classmethod + def fromtimestamp(cls, timestamp: float, /) -> Self: ... + @classmethod + def today(cls) -> Self: ... + @classmethod + def fromordinal(cls, n: int, /) -> Self: ... + @property + def year(self) -> int: ... + def replace(self, year: SupportsIndex = ..., month: SupportsIndex = ..., day: SupportsIndex = ...) -> Self: ... + def ctime(self) -> str: ... + def weekday(self) -> int: ... + +Maximum Line Length +------------------- + +Stub files should be limited to 130 characters per line. + +Blank Lines +----------- + +Do not use empty lines between functions, methods, and fields, except to +group them with one empty line. Use one empty line around classes with non-empty +bodies. Do not use empty lines between body-less classes, except for grouping. + +Yes:: + + def time_func() -> None: ... + def date_func() -> None: ... + + def ip_func() -> None: ... + + class Foo: + x: int + y: int + def __init__(self) -> None: ... + + class MyError(Exception): ... + class AnotherError(Exception): ... + +No:: + + def time_func() -> None: ... + + def date_func() -> None: ... # do not leave unnecessary empty lines + + def ip_func() -> None: ... + + + class Foo: # leave only one empty line above + x: int + class MyError(Exception): ... # leave an empty line between the classes + +Module Level Attributes +----------------------- + +Do not unnecessarily use an assignment for module-level attributes. + +Yes:: + + CONST: Literal["const"] + x: int + y: Final = 0 # this assignment conveys additional type information + +No:: + + CONST = "const" + x: int = 0 + y: float = ... + z = 0 # type: int + a = ... # type: int + +.. _stub-style-classes: + +Classes +------- + +Classes without bodies should use the ellipsis literal ``...`` in place +of the body on the same line as the class definition. + +Yes:: + + class MyError(Exception): ... + +No:: + + class MyError(Exception): + ... + class AnotherError(Exception): pass + +Instance attributes and class variables follow the same recommendations as +module level attributes: + +Yes:: + + class Foo: + c: ClassVar[str] + x: int + + class Color(Enum): + # An assignment with no type annotation is a convention used to indicate + # an enum member. + RED = 1 + +No:: + + class Foo: + c: ClassVar[str] = "" + d: ClassVar[int] = ... + x = 4 + y: int = ... + +Functions and Methods +--------------------- + +For keyword-only and positional-or-keyword arguments, use the same +argument names as in the implementation, because otherwise using +keyword arguments will fail. + +For default values, use the literal values of "simple" default values (``None``, +bools, ints, bytes, strings, and floats). Use the ellipsis literal ``...`` in +place of more complex default values. Use an explicit ``X | None`` annotation +when the default is ``None``. + +Yes:: + + def foo(x: int = 0) -> None: ... + def bar(y: str | None = None) -> None: ... + +No:: + + def foo(x: X = X()) -> None: ... + def bar(y: str = None) -> None: ... + +Do not annotate ``self`` and ``cls`` in method definitions unless an explicit +annotation is needed to constrain or relax the receiver type. + +Yes:: + + class Foo: + def bar(self) -> None: ... + @classmethod + def create(cls) -> Self: ... + + _T = TypeVar("_T") + + class Box(Generic[_T]): + # This method is only available on boxes containing strings. + def upper(self: Box[str]) -> str: ... + +No:: + + class Foo: + def bar1(self: Self) -> None: ... + def bar2(self: Foo) -> None: ... + @classmethod + def create(cls: type[Self]) -> Self: ... + +The bodies of functions and methods should consist of only the ellipsis +literal ``...`` on the same line as the closing parenthesis and colon. + +Yes:: + + def to_int1(x: str) -> int: ... + def to_int2( + x: str, + ) -> int: ... + +No:: + + def to_int1(x: str) -> int: + return int(x) + def to_int2(x: str) -> int: + ... + def to_int3(x: str) -> int: pass + +Avoid invariant collection types (``list``, ``dict``) for function parameters, +in favor of covariant types like ``Mapping`` or ``Sequence``. + +Avoid union return types. See https://github.com/python/mypy/issues/1693 + +Use ``float`` instead of ``int | float`` for parameter annotations. See :pep:`484` for more details. + +Language Features +----------------- + +Use the latest language features available, even for stubs targeting older +Python versions. For example, Python 3.7 added the ``async`` keyword (see +:pep:`492`). Stubs should use it to mark coroutines, even if the implementation +still uses the ``@coroutine`` decorator. On the other hand, the ``type`` soft +keyword from :pep:`695`, introduced in Python 3.12, should not be used in stubs +until Python 3.11 reaches end-of-life in October 2027. + +Do not use quotes around forward references and do not use ``__future__`` +imports. See :ref:`stub-file-syntax` for more information. + +Yes:: + + class Py35Class: + x: int + forward_reference: OtherClass + + class OtherClass: ... + +No:: + + class Py35Class: + x = 0 # type: int + forward_reference: 'OtherClass' + + class OtherClass: ... + +Use variable annotations instead of type comments, even for stubs that target +older versions of Python. + +Platform-dependent APIs +----------------------- + +Use :ref:`platform checks` like ``if sys.platform == 'win32'`` to denote platform-dependent APIs. + +NamedTuple and TypedDict +------------------------ + +Use the class-based syntax for ``typing.NamedTuple`` and +``typing.TypedDict``, following the :ref:`stub-style-classes` section of this style guide. + +Yes:: + + from typing import NamedTuple, TypedDict + + class Point(NamedTuple): + x: float + y: float + + class Thing(TypedDict): + stuff: str + index: int + +No:: + + from typing import NamedTuple, TypedDict + Point = NamedTuple("Point", [('x', float), ('y', float)]) + Thing = TypedDict("Thing", {'stuff': str, 'index': int}) + +Built-in Generics +----------------- + +:pep:`585` built-in generics (such as ``list``, ``dict``, ``tuple``, ``set``) are supported and should be used instead +of the corresponding types from ``typing``:: + + from collections import defaultdict + + def foo(t: type[MyClass]) -> list[int]: ... + x: defaultdict[int] + +Using imports from ``collections.abc`` instead of ``typing`` is +generally possible and recommended:: + + from collections.abc import Iterable + + def foo(iter: Iterable[int]) -> None: ... + +Unions +------ + +Declaring unions with the shorthand ``|`` syntax is recommended and supported by +all type checkers:: + + def foo(x: int | str) -> int | None: ... # recommended + def foo(x: Union[int, str]) -> Optional[int]: ... # ok + +.. _using-any: + +Using ``Any`` and ``object`` +---------------------------- + +When adding type hints, avoid using the :ref:`Any` type when possible. Reserve +the use of :ref:`Any` for when: + +* the correct type cannot be expressed in the current type system; and +* to avoid union returns (see above). + +Note that :ref:`Any` is not the correct type to use if you want to indicate +that some function can accept literally anything: in those cases use +:class:`object` instead. + +When using :ref:`Any`, document the reason for using it in a comment, unless the +reason is obvious. Ideally, document what types could be used. Obvious +reasons can include: + +* Using :ref:`Any` as a type argument for a generic with invariant type variables + to say "any object of this type is allowed", e.g. ``Future[Any]``. +* Using the expression ``Callable[..., Any]`` to say "any callable". +* Using ``dict[str, Any]`` or ``Mapping[str, Any]`` when the value types + depend on the keys. But consider using :ref:`TypedDict` or + ``dict[str, Incomplete]`` (temporarily) when the keys of the dictionary are + fixed. + +The ``Any`` Trick +----------------- + +In cases where a function or method can return ``None``, but where forcing the +user to explicitly check for ``None`` can be detrimental, use +``_typeshed.MaybeNone`` (an alias to ``Any``), instead of ``None``. + +Consider the following (simplified) signature of ``re.Match[str].group``:: + + class Match: + def group(self, group: str | int, /) -> str | MaybeNone: ... + +This avoids forcing the user to check for ``None``:: + + match = re.fullmatch(r"\d+_(.*)", some_string) + assert match is not None + name_group = match.group(1) # The user knows that this will never be None + name_group.uper() # This typo will be flagged by the type checker + +In this case, the user of ``match.group()`` must be prepared to handle a ``str``, +but type checkers are happy with ``if name_group is None`` checks, because we're +saying it can also be something other than a ``str``. + +This is sometimes called "the Any trick". + +Context Managers +---------------- + +When adding type annotations for context manager classes, annotate +the return type of ``__exit__`` as bool only if the context manager +sometimes suppresses exceptions -- if it sometimes returns ``True`` +at runtime. If the context manager never suppresses exceptions, +have the return type be either ``None`` or ``bool | None``. If you +are not sure whether exceptions are suppressed or not or if the +context manager is meant to be subclassed, pick ``bool | None``. +See https://github.com/python/mypy/issues/7214 for more details. + +``__enter__`` methods and other methods that return ``self`` or ``cls(...)`` +should be annotated with ``typing.Self`` +(`example `_). + +Naming +------ + +Type variables and aliases you introduce purely for legibility reasons +should be prefixed with an underscore to make it obvious to the reader +they are not part of the stubbed API. + +A few guidelines for protocol names below. In cases that don't fall +into any of those categories, use your best judgement. + +* Use plain names for protocols that represent a clear concept + (e.g. ``Iterator``, ``Container``). +* Use ``SupportsX`` for protocols that provide callable methods (e.g. + ``SupportsInt``, ``SupportsRead``, ``SupportsReadSeek``). +* Use ``HasX`` for protocols that have readable and/or writable attributes + or getter/setter methods (e.g. ``HasItems``, ``HasFileno``). + +.. _type-checker-error-suppression: + +Type Checker Error Suppression Formats +-------------------------------------- + +* Use mypy error codes for mypy-specific ``# type: ignore`` annotations, e.g. ``# type: ignore[override]`` for Liskov Substitution Principle violations. +* Use pyright error codes for pyright-specific suppressions, e.g. ``# pyright: ignore[reportGeneralTypeIssues]``. +* If you need both on the same line, mypy's annotation needs to go first, e.g. ``# type: ignore[override] # pyright: ignore[reportGeneralTypeIssues]``. + + +``@deprecated`` +--------------- + +The ``@typing_extensions.deprecated`` decorator (``@warnings.deprecated`` +since Python 3.13) can be used to mark deprecated functionality; see +:pep:`702`. + +Keep the deprecation message concise, but try to mention the projected +version when the functionality is to be removed, and a suggested +replacement. + +Docstrings +---------- + +There are several tradeoffs around including docstrings in type stubs. Consider the intended purpose +of your stubs when deciding whether to include docstrings in your project's stubs. + +* They do not affect type checking results and will be ignored by type checkers. +* Docstrings can improve certain IDE functionality, such as hover info. +* Duplicating docstrings between source code and stubs requires extra work to keep them in sync. diff --git a/docs/index.rst b/docs/index.rst index 84f0a71ec..308274384 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -2,36 +2,53 @@ Static Typing with Python ************************* -.. Introduction -.. ============ -.. -.. .. toctree:: -.. :maxdepth: 2 +Tutorials +========= + .. -.. source/introduction + Keep in sync with tutorials/index.rst. + +.. toctree:: + :maxdepth: 1 + + tutorials/external_libraries Guides ====== +.. + Keep in sync with docs/guides/index.rst. + .. toctree:: - :maxdepth: 2 + :maxdepth: 1 - source/guides + guides/libraries + guides/lambda + guides/writing_stubs + guides/modernizing + guides/unreachable + guides/type_narrowing + guides/typing_anti_pitch Reference ========= +.. + Keep in sync with docs/reference/index.rst. + .. toctree:: - :maxdepth: 2 + :maxdepth: 1 - source/reference + reference/generics + reference/protocols + reference/best_practices + reference/quality + typing Module Documentation .. seealso:: The documentation at https://mypy.readthedocs.io/ is relatively accessible - and complete. Particularly refer to the "Type System Reference" section of - the docs -- since the Python typing system is standardised via PEPs, this - information should apply to most Python type checkers. + and complete. Specification ============= @@ -41,6 +58,15 @@ Specification spec/index + +Typing PEPs +----------- + +Significant changes to the Python Type System Specification are proposed and +discussed in Python Enhancement Proposals (PEPs). See +https://peps.python.org/topic/typing for a list of all current and historical +typing-related PEPs. + Indices and tables ================== @@ -53,8 +79,13 @@ Discussions and Support ======================= * `User help forum `_ -* `User chat on Gitter `_ -* `Developer mailing list `_ +* `Developer forum `_ +* The `#type-hinting channel `_ + on the `Python Discord server `_ + +The former developer mailing list has been archived: + +* `Archive of typing-sig `_ Typing-related Tools ==================== @@ -62,14 +93,15 @@ Typing-related Tools Type Checkers ------------- -* `mypy `_, the reference implementation for type - checkers. -* `pyre `_, written in OCaml and optimized for - performance. -* `pyright `_, a type checker that - emphasizes speed. -* `pytype `_, checks and infers types for - unannotated code. +* `mypy `_ +* `pyrefly `_ +* `pyright `_ +* `ty `_ +* `Zuban `_ + +The extent to which these adhere to the specification is monitored by a +`conformance test suite `_ +(`results `_). Development Environments ------------------------ @@ -77,7 +109,7 @@ Development Environments * `PyCharm `_, an IDE that supports type stubs both for type checking and code completion. * `Visual Studio Code `_, a code editor that - supports type checking using mypy, pyright, or the + supports type checking using mypy, pyrefly, pyright, ty, Zuban, or the `Pylance `_ extension. @@ -89,15 +121,18 @@ Linters and Formatters * `flake8-pyi `_, a plugin for the `flake8 `_ linter that adds support for type stubs. +* `ruff `_, a linter built for speed, with support for + most of the ``flake8-pyi`` rules. Type-Hint and Stub Integration ------------------------------ -* `autotyping `_, a tool which infers simple types from their context and inserts them as inline type-hints. -* `merge_pyi `_, integrates .pyi signatures as inline type-hints in Python source code. - This is a thin wrapper around ``ApplyTypeAnnotationsVisitor`` from `libCST `_. - -Typing PEPs -=========== - -See https://peps.python.org/topic/typing for a list of all typing-related PEPs. +* `autotyping `_, a tool which + infers simple types from their context and inserts them as inline type-hints. +* `merge-pyi + `_, + a thin wrapper around ``ApplyTypeAnnotationsVisitor`` from + `libCST `_ that integrates .pyi + signatures as inline type-hints in Python source code. +* `pyrefly infer `_, a sub-command of Pyrefly which + inserts the types that Pyrefly infers as inline type-hints. diff --git a/docs/make.bat b/docs/make.bat index 2119f5109..11c18e5e6 100644 --- a/docs/make.bat +++ b/docs/make.bat @@ -25,7 +25,7 @@ if errorlevel 9009 ( exit /b 1 ) -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +%SPHINXBUILD% -W -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% goto end :help diff --git a/docs/source/best_practices.rst b/docs/reference/best_practices.rst similarity index 91% rename from docs/source/best_practices.rst rename to docs/reference/best_practices.rst index 24a6ff880..ebf58dfc9 100644 --- a/docs/source/best_practices.rst +++ b/docs/reference/best_practices.rst @@ -52,12 +52,20 @@ with the current type system or using the correct type is unergonomic. If a function accepts every possible object as an argument, for example because it's only passed to ``str()``, use ``object`` instead of ``Any`` as -type annotation. Similarly, if the return value of a callback is ignored, -annotate it with ``object``:: +type annotation:: - def call_cb_if_int(cb: Callable[[int], object], o: object) -> None: + def print_formatted(o: object) -> None: if isinstance(o, int): - cb(o) + o = f"{o:02}" + print(o) + +Similarly, if the return value of a callback is ignored, +annotate it with ``object``, not ``Any`` or ``None``:: + + def call_cb(cb: Callable[[int], object]) -> None: + cb(42) + +.. _argument-return-practices: Arguments and Return Types -------------------------- diff --git a/docs/source/generics.rst b/docs/reference/generics.rst similarity index 98% rename from docs/source/generics.rst rename to docs/reference/generics.rst index 120124566..c39d2bc11 100644 --- a/docs/source/generics.rst +++ b/docs/reference/generics.rst @@ -651,8 +651,7 @@ for a more faithful type annotation: .. code-block:: python - from typing import Callable, TypeVar - from typing_extensions import ParamSpec + from typing import Callable, ParamSpec, TypeVar P = ParamSpec('P') T = TypeVar('T') @@ -663,13 +662,17 @@ for a more faithful type annotation: return func(*args, **kwds) return wrapper +.. note:: + + To use this feature on Python versions earlier than 3.10, you will need to + import ``ParamSpec`` and ``Concatenate`` from ``typing_extensions``. + Parameter specifications also allow you to describe decorators that alter the signature of the input function: .. code-block:: python - from typing import Callable, TypeVar - from typing_extensions import ParamSpec + from typing import Callable, ParamSpec, TypeVar P = ParamSpec('P') T = TypeVar('T') @@ -692,8 +695,7 @@ Or insert an argument: .. code-block:: python - from typing import Callable, TypeVar - from typing_extensions import Concatenate, ParamSpec + from typing import Callable, Concatenate, ParamSpec, TypeVar P = ParamSpec('P') T = TypeVar('T') @@ -774,8 +776,7 @@ Example: .. code-block:: python - from typing import TypeVar - from typing_extensions import Protocol + from typing import Protocol, TypeVar T = TypeVar('T') diff --git a/docs/reference/index.rst b/docs/reference/index.rst new file mode 100644 index 000000000..bab77a268 --- /dev/null +++ b/docs/reference/index.rst @@ -0,0 +1,18 @@ +:orphan: + +********************* +Type System Reference +********************* + +.. + Keep in sync with docs/index.rst. + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + generics + protocols + best_practices + quality + typing Module Documentation diff --git a/docs/source/protocols.rst b/docs/reference/protocols.rst similarity index 97% rename from docs/source/protocols.rst rename to docs/reference/protocols.rst index 13b2e9ca8..72d1a3e80 100644 --- a/docs/source/protocols.rst +++ b/docs/reference/protocols.rst @@ -71,8 +71,7 @@ You can define your own protocol class by inheriting from the special .. code-block:: python - from typing import Iterable - from typing_extensions import Protocol + from typing import Iterable, Protocol class SupportsClose(Protocol): # Empty method body (explicit '...') @@ -231,8 +230,7 @@ such as trees and linked lists: .. code-block:: python - from typing import TypeVar, Optional - from typing_extensions import Protocol + from typing import TypeVar, Optional, Protocol class TreeLike(Protocol): value: int @@ -260,7 +258,7 @@ rudimentary support for runtime structural checks: .. code-block:: python - from typing_extensions import Protocol, runtime_checkable + from typing import Protocol, runtime_checkable @runtime_checkable class Portable(Protocol): @@ -303,8 +301,7 @@ member: .. code-block:: python - from typing import Optional, Iterable - from typing_extensions import Protocol + from typing import Optional, Iterable, Protocol class Combiner(Protocol): def __call__(self, *vals: bytes, maxlen: Optional[int] = None) -> list[bytes]: ... @@ -328,8 +325,7 @@ a double underscore prefix is used. For example: .. code-block:: python - from typing import Callable, TypeVar - from typing_extensions import Protocol + from typing import Callable, TypeVar, Protocol T = TypeVar('T') diff --git a/docs/source/quality.rst b/docs/reference/quality.rst similarity index 89% rename from docs/source/quality.rst rename to docs/reference/quality.rst index 8ec08aed8..19918fcb4 100644 --- a/docs/source/quality.rst +++ b/docs/reference/quality.rst @@ -40,10 +40,15 @@ then the following file tests ``foo.py``: .. code-block:: python - from typing_extensions import assert_type + from typing import assert_type assert_type(bar(42), str) +.. note:: + + To use this feature on Python versions earlier than 3.11, you will need to + import ``assert_type`` from ``typing_extensions`` (version 4.2 or newer). + Clever use of ``mypy --warn-unused-ignores`` can be used to check that certain expressions are or are not well-typed. The idea is to have valid expressions along with invalid expressions annotated with ``type: ignore`` comments. When @@ -190,10 +195,10 @@ library: better type coverage may differ. Some of the above recommendations may or may not be helpful to you, depending on which type checking tools you use. -``mypy`` disallow options +Mypy disallow options ------------------------- -``mypy`` offers several options which can detect untyped code. +Mypy offers several options which can detect untyped code. More details can be found in `the mypy documentation on these options `_. @@ -202,17 +207,29 @@ Some basic usages which make ``mypy`` error on untyped data are:: mypy --disallow-untyped-defs mypy --disallow-incomplete-defs -``pyright`` type verification +Pyright type verification ----------------------------- -pyright has a special command line flag, ``--verifytypes``, for verifying +Pyright has a special command-line flag, ``--verifytypes``, for verifying type completeness. You can learn more about it from `the pyright documentation on verifying type completeness `_. -``mypy`` reports +Mypy reports ---------------- -``mypy`` offers several options options for generating reports on its analysis. +Mypy offers several options for generating reports on its analysis. See `the mypy documentation on report generation `_ for details. + + +Pyrefly coverage +---------------- + +Pyrefly offers a sub-command for measuring and checking type coverage. + +- ``pyrefly coverage check`` fails when coverage is below a threshold, useful as a CI gate. +- ``pyrefly coverage report`` emits a JSON report with per-module statistics. + +See `the Pyrefly docs on measuring type coverage +`_ for details. diff --git a/docs/reference/stubs.rst b/docs/reference/stubs.rst new file mode 100644 index 000000000..b0ce56711 --- /dev/null +++ b/docs/reference/stubs.rst @@ -0,0 +1,8 @@ +:orphan: + +********** +Type Stubs +********** + +The contents of this document have been moved to :ref:`stub-files` and +:ref:`writing_stubs`. diff --git a/docs/requirements.txt b/docs/requirements.txt deleted file mode 100644 index e1598b5e2..000000000 --- a/docs/requirements.txt +++ /dev/null @@ -1,10 +0,0 @@ -# Requirements to build the Python documentation - -# Sphinx version is pinned so that new versions that introduce new warnings -# won't suddenly cause build failures. Updating the version is fine as long -# as no warnings are raised by doing so. -sphinx==7.2.6 - -# The theme used by the documentation is stored separately, so we need -# to install that as well. -python-docs-theme diff --git a/docs/source/annotations.rst b/docs/source/annotations.rst deleted file mode 100644 index ea5c471fa..000000000 --- a/docs/source/annotations.rst +++ /dev/null @@ -1,68 +0,0 @@ -**************** -Type Annotations -**************** - -Functions -========= - -Parameters ----------- - -Asynchronous Functions ----------------------- - -Generators ----------- - -Lambdas -------- - - -Classes -======= - -Overloads and Overrides ------------------------ - -Instance vs. Class Attributes ------------------------------ - -Final attributes ----------------- - -Abstract base classes ---------------------- - - -Globals -======= - - -Attributes -========== - - -Locals -====== - -Empty Containers ----------------- - - -Runtime Considerations -====================== - -Comment vs. Inline Support --------------------------- - -Forward References ------------------- - -Generic types that don't implement `__getitem__` ------------------------------------------------- - -Conditioning on static type checking ------------------------------------- - -from `__future__` import annotations ------------------------------------- diff --git a/docs/source/basics.rst b/docs/source/basics.rst deleted file mode 100644 index 9b2bf52a1..000000000 --- a/docs/source/basics.rst +++ /dev/null @@ -1,3 +0,0 @@ -********** -The Basics -********** diff --git a/docs/source/dependencies.rst b/docs/source/dependencies.rst deleted file mode 100644 index b16fa639f..000000000 --- a/docs/source/dependencies.rst +++ /dev/null @@ -1,12 +0,0 @@ -************************** -Libraries and Dependencies -************************** - -:doc:`libraries` - -Typeshed -======== - - -Placeholder Stubs -================= diff --git a/docs/source/faq.rst b/docs/source/faq.rst deleted file mode 100644 index 906e27790..000000000 --- a/docs/source/faq.rst +++ /dev/null @@ -1,23 +0,0 @@ -************************** -Frequently Asked Questions -************************** - - -Why Types? -========== - - -Unsupported Python Features -=========================== - - -Common Errors -============= - - -Typing PEPs -=========== - - -Relevant Talks and Resources -============================ diff --git a/docs/source/guides.rst b/docs/source/guides.rst deleted file mode 100644 index 5ba92d4ff..000000000 --- a/docs/source/guides.rst +++ /dev/null @@ -1,13 +0,0 @@ -****************** -Type System Guides -****************** - -.. toctree:: - :maxdepth: 2 - :caption: Contents: - - libraries - writing_stubs - modernizing - unreachable - typing_anti_pitch diff --git a/docs/source/inference.rst b/docs/source/inference.rst deleted file mode 100644 index 291dec48f..000000000 --- a/docs/source/inference.rst +++ /dev/null @@ -1,28 +0,0 @@ -************** -Type Inference -************** - -Rules for local inference -========================= - -Explicit vs. Implicit Local Types ---------------------------------- - -Changing Types -============== - -Asserts -------- - -Casts ------ - -Type Guards ------------ - - -Protocols and Duck Typing -========================= - -Callback Protocols ------------------- diff --git a/docs/source/introduction.rst b/docs/source/introduction.rst deleted file mode 100644 index fb973559d..000000000 --- a/docs/source/introduction.rst +++ /dev/null @@ -1,41 +0,0 @@ -******************************* -Introduction to Types in Python -******************************* - - -Background -========== - -How to read type annotations ----------------------------- - -When and why types are useful ------------------------------ - - -Gradual Typing: Static Types in a Dynamic Language -================================================== - -Opt-in type checking --------------------- - -Type stubs ----------- - -:doc:`stubs` - -Strategies for increasing coverage ----------------------------------- - - -Getting Started -=============== - -Python type checkers --------------------- - -How to annotate an existing codebase ------------------------------------- - -Typeshed --------- diff --git a/docs/source/reference.rst b/docs/source/reference.rst deleted file mode 100644 index 54afcc7b1..000000000 --- a/docs/source/reference.rst +++ /dev/null @@ -1,25 +0,0 @@ -********************* -Type System Reference -********************* - -.. toctree:: - :maxdepth: 2 - :caption: Contents: - - generics - protocols - stubs - best_practices - quality - typing Module Documentation - -.. The following pages are desired in a new TOC which will cover multiple -.. topics. For now, they are not linked because the pages are empty. -.. -.. basics -.. type_system -.. annotations -.. inference -.. type_compatibility -.. dependencies -.. faq diff --git a/docs/source/stubs.rst b/docs/source/stubs.rst deleted file mode 100644 index 9f207847e..000000000 --- a/docs/source/stubs.rst +++ /dev/null @@ -1,971 +0,0 @@ -.. _stubs: - -********** -Type Stubs -********** - -Introduction -============ - -*type stubs*, also called *stub files*, provide type information for untyped -Python packages and modules. Type stubs serve multiple purposes: - -* They are the only way to add type information to extension modules. -* They can provide type information for packages that do not wish to - add them inline. -* They can be distributed separately from the implementation. - This allows stubs to be developed at a different pace or by different - authors, which is especially useful when adding type annotations to - existing packages. -* They can act as documentation, succinctly explaining the external - API of a package, without including the implementation or private - members. - -This document aims to give guidance to both authors of type stubs and developers -of type checkers and other tools. It describes the constructs that can be used safely in type stubs, -suggests a style guide for them, and lists constructs that type -checkers are expected to support. - -Type stubs that only use constructs described in this document should work with -all type checkers that also follow this document. -Type stub authors can elect to use additional constructs, but -must be prepared that some type checkers will not parse them as expected. - -A type checker that conforms to this document will parse a type stub that only uses -constructs described here without error and will not interpret any -construct in a contradictory manner. However, type checkers are not -required to implement checks for all these constructs, and -can elect to ignore unsupported ones. Additionally type checkers -can support constructs not described in this document and tool authors are -encouraged to experiment with additional features. - -Syntax -====== - -Type stubs are syntactically valid Python 3.8 files with a ``.pyi`` suffix. -The Python syntax used for type stubs is independent from the Python -versions supported by the implementation, and from the Python version the type -checker runs under (if any). Therefore, type stub authors should use the -latest available syntax features in stubs (up to Python 3.8), even if the -implementation supports older, pre-3.8 Python versions. -Type checker authors are encouraged to support syntax features from -post-3.8 Python versions, although type stub authors should not use such -features if they wish to maintain compatibility with all type checkers. - -For example, Python 3.7 added the ``async`` keyword (see :pep:`492`). -Stub authors should use it to mark coroutines, even if the implementation -still uses the ``@coroutine`` decorator. On the other hand, type stubs should -not use the ``type`` soft keyword from :pep:`695`, introduced in -Python 3.12, although type checker authors are encouraged to support it. - -Stubs are treated as if ``from __future__ import annotations`` is enabled. -In particular, built-in generics, pipe union syntax (``X | Y``), and forward -references can be used. - -The :py:mod:`ast` module from the standard library supports -all syntax features required by this document. - -Distribution -============ - -Type stubs can be distributed with or separately from the implementation; -see :ref:`distributing-type` and :ref:`providing-type-annotations` -for more information. - -Supported Constructs -==================== - -This sections lists constructs that type checkers will accept in type stubs. -Type stub authors can safely use these constructs. If a -construct is marked as "unspecified", type checkers may handle it -as they best see fit or report an error. Linters should usually -flag those constructs. Type stub authors should avoid using them to -ensure compatibility across type checkers. - -Unless otherwise mentioned, type stubs support all features from the -``typing`` module of the latest released Python version. If a stub uses -typing features from a later Python version than what the implementation -supports, these features can be imported from ``typing_extensions`` instead -of ``typing``. - -For example, a stub could use ``Literal``, introduced in Python 3.8, -for a library supporting Python 3.7+:: - - from typing_extensions import Literal - - def foo(x: Literal[""]) -> int: ... - -Comments --------- - -Standard Python comments are accepted everywhere Python syntax allows them. - -Two kinds of structured comments are accepted: - -* A ``# type: X`` comment at the end of a line that defines a variable, - declaring that the variable has type ``X``. However, :pep:`526`-style - variable annotations are preferred over type comments. -* A ``# type: ignore`` comment at the end of any line, which suppresses all type - errors in that line. The type checker mypy supports suppressing certain - type errors by using ``# type: ignore[error-type]``. This is not supported - by other type checkers and should not be used in stubs. - -Imports -------- - -Type stubs distinguish between imports that are re-exported and those -that are only used internally. Imports are re-exported if they use one of these -forms (:pep:`484`): - -* ``import X as X`` -* ``from Y import X as X`` -* ``from Y import *`` - -Here are some examples of imports that make names available for internal use in -a stub but do not re-export them:: - - import X - from Y import X - from Y import X as OtherX - -Type aliases can be used to re-export an import under a different name:: - - from foo import bar as _bar - new_bar = _bar # "bar" gets re-exported with the name "new_bar" - -Sub-modules are always exported when they are imported in a module. -For example, consider the following file structure:: - - foo/ - __init__.pyi - bar.pyi - -Then ``foo`` will export ``bar`` when one of the following constructs is used in -``__init__.pyi``:: - - from . import bar - from .bar import Bar - -Stubs support customizing star import semantics by defining a module-level -variable called ``__all__``. In stubs, this must be a string list literal. -Other types are not supported. Neither is the dynamic creation of this -variable (for example by concatenation). - -By default, ``from foo import *`` imports all names in ``foo`` that -do not begin with an underscore. When ``__all__`` is defined, only those names -specified in ``__all__`` are imported:: - - __all__ = ['public_attr', '_private_looking_public_attr'] - - public_attr: int - _private_looking_public_attr: int - private_attr: int - -Type checkers support cyclic imports in stub files. - -Built-in Generics ------------------ - -:pep:`585` built-in generics are supported and should be used instead -of the corresponding types from ``typing``:: - - from collections import defaultdict - - def foo(t: type[MyClass]) -> list[int]: ... - x: defaultdict[int] - -Using imports from ``collections.abc`` instead of ``typing`` is -generally possible and recommended:: - - from collections.abc import Iterable - - def foo(iter: Iterable[int]) -> None: ... - -Unions ------- - -Declaring unions with the shorthand syntax or ``Union`` and ``Optional`` is -supported by all type checkers:: - - def foo(x: int | str) -> int | None: ... # recommended - def foo(x: Union[int, str]) -> Optional[int]: ... # ok - -Module Level Attributes ------------------------ - -Module level variables and constants can be annotated using either -type comments or variable annotation syntax:: - - x: int # recommended - x: int = 0 - x = 0 # type: int - x = ... # type: int - -The type of a variable is unspecified when the variable is unannotated or -when the annotation -and the assigned value disagree. As an exception, the ellipsis literal can -stand in for any type:: - - x = 0 # type is unspecified - x = ... # type is unspecified - x: int = "" # type is unspecified - x: int = ... # type is int - -Classes -------- - -Class definition syntax follows general Python syntax, but type checkers -are only expected to understand the following constructs in class bodies: - -* The ellipsis literal ``...`` is ignored and used for empty - class bodies. Using ``pass`` in class bodies is undefined. -* Instance attributes follow the same rules as module level attributes - (see above). -* Method definitions (see below) and properties. -* Method aliases. -* Inner class definitions. - -More complex statements don't need to be supported:: - - class Simple: ... - - class Complex(Base): - read_write: int - @property - def read_only(self) -> int: ... - def do_stuff(self, y: str) -> None: ... - doStuff = do_stuff - -The type of generic classes can be narrowed by annotating the ``self`` -argument of the ``__init__`` method:: - - class Foo(Generic[_T]): - @overload - def __init__(self: Foo[str], type: Literal["s"]) -> None: ... - @overload - def __init__(self: Foo[int], type: Literal["i"]) -> None: ... - @overload - def __init__(self, type: str) -> None: ... - -The class must match the class in which it is declared. Using other classes, -including sub or super classes, will not work. In addition, the ``self`` -annotation cannot contain type variables. - -.. _supported-functions: - -Functions and Methods ---------------------- - -Function and method definition syntax follows general Python syntax. -For backwards compatibility, positional-only parameters can also be marked by -prefixing their name with two underscores (but not suffixing it with two -underscores):: - - # x is positional-only - # y can be used positionally or as keyword argument - # z is keyword-only - def foo(x, /, y, *, z): ... # recommended - def foo(__x, y, *, z): ... # backwards compatible syntax - -If an argument or return type is unannotated, per :pep:`484` its -type is assumed to be ``Any``. It is preferred to leave unknown -types unannotated rather than explicitly marking them as ``Any``, as some -type checkers can optionally warn about unannotated arguments. - -If an argument has a literal or constant default value, it must match the implementation -and the type of the argument (if specified) must match the default value. -Alternatively, ``...`` can be used in place of any default value:: - - # The following arguments all have type Any. - def unannotated(a, b=42, c=...): ... - # The following arguments all have type int. - def annotated(a: int, b: int = 42, c: int = ...): ... - # The following default values are invalid and the types are unspecified. - def invalid(a: int = "", b: Foo = Foo()): ... - -For a class ``C``, the type of the first argument to a classmethod is -assumed to be ``type[C]``, if unannotated. For other non-static methods, -its type is assumed to be ``C``:: - - class Foo: - def do_things(self): ... # self has type Foo - @classmethod - def create_it(cls): ... # cls has type Type[Foo] - @staticmethod - def utility(x): ... # x has type Any - -But:: - - _T = TypeVar("_T") - - class Foo: - def do_things(self: _T) -> _T: ... # self has type _T - @classmethod - def create_it(cls: _T) -> _T: ... # cls has type _T - -:pep:`612` parameter specification variables (``ParamSpec``) -are supported in argument and return types:: - - _P = ParamSpec("_P") - _R = TypeVar("_R") - - def foo(cb: Callable[_P, _R], *args: _P.args, **kwargs: _P.kwargs) -> _R: ... - -However, ``Concatenate`` from PEP 612 is not yet supported; nor is using -a ``ParamSpec`` to parameterize a generic class. - -:pep:`647` type guards are supported. - -Using a function or method body other than the ellipsis literal is currently -unspecified. Stub authors may experiment with other bodies, but it is up to -individual type checkers how to interpret them:: - - def foo(): ... # compatible - def bar(): pass # behavior undefined - -All variants of overloaded functions and methods must have an ``@overload`` -decorator:: - - @overload - def foo(x: str) -> str: ... - @overload - def foo(x: float) -> int: ... - -The following (which would be used in the implementation) is wrong in -type stubs:: - - @overload - def foo(x: str) -> str: ... - @overload - def foo(x: float) -> int: ... - def foo(x: str | float) -> Any: ... - -Aliases and NewType -------------------- - -Type checkers should accept module-level type aliases, optionally using -``TypeAlias`` (:pep:`613`), e.g.:: - - _IntList = list[int] - _StrList: TypeAlias = list[str] - -Type checkers should also accept regular module-level or class-level aliases, -e.g.:: - - def a() -> None: ... - b = a - - class C: - def f(self) -> int: ... - g = f - -A type alias may contain type variables. As per :pep:`484`, -all type variables must be substituted when the alias is used:: - - _K = TypeVar("_K") - _V = TypeVar("_V") - _MyMap: TypeAlias = dict[str, dict[_K, _V]] - - # either concrete types or other type variables can be substituted - def f(x: _MyMap[str, _V]) -> _V: ... - # explicitly substitute in Any rather than using a bare alias - def g(x: _MyMap[Any, Any]) -> Any: ... - -Otherwise, type variables in aliases follow the same rules as type variables in -generic class definitions. - -``typing.NewType`` is also supported in stubs. - -Decorators ----------- - -Type stubs may only use decorators defined in the ``typing`` module, plus a -fixed set of additional ones: - -* ``classmethod`` -* ``staticmethod`` -* ``property`` (including ``.setter``) -* ``abc.abstractmethod`` -* ``dataclasses.dataclass`` -* ``asyncio.coroutine`` (although ``async`` should be used instead) - -The behavior of other decorators should instead be incorporated into the types. -For example, for the following function:: - - import contextlib - @contextlib.contextmanager - def f(): - yield 42 - -the stub definition should be:: - - from contextlib import AbstractContextManager - def f() -> AbstractContextManager[int]: ... - -Version and Platform Checks ---------------------------- - -Type stubs for libraries that support multiple Python versions can use version -checks to supply version-specific type hints. Type stubs for different Python -versions should still conform to the most recent supported Python version's -syntax, as explain in the Syntax_ section above. - -Version checks are if-statements that use ``sys.version_info`` to determine the -current Python version. Version checks should only check against the ``major`` and -``minor`` parts of ``sys.version_info``. Type checkers are only required to -support the tuple-based version check syntax:: - - if sys.version_info >= (3,): - # Python 3-specific type hints. This tuple-based syntax is recommended. - else: - # Python 2-specific type hints. - - if sys.version_info >= (3, 5): - # Specific minor version features can be easily checked with tuples. - - if sys.version_info < (3,): - # This is only necessary when a feature has no Python 3 equivalent. - -Type stubs should avoid checking against ``sys.version_info.major`` -directly and should not use comparison operators other than ``<`` and ``>=``. - -No:: - - if sys.version_info.major >= 3: - # Semantically the same as the first tuple check. - - if sys.version_info[0] >= 3: - # This is also the same. - - if sys.version_info <= (2, 7): - # This does not work because e.g. (2, 7, 1) > (2, 7). - -Some type stubs also may need to specify type hints for different platforms. -Platform checks must be equality comparisons between ``sys.platform`` and the name -of a platform as a string literal: - -Yes:: - - if sys.platform == 'win32': - # Windows-specific type hints. - else: - # Posix-specific type hints. - -No:: - - if sys.platform.startswith('linux'): - # Not necessary since Python 3.3. - - if sys.platform in ['linux', 'cygwin', 'darwin']: - # Only '==' or '!=' should be used in platform checks. - -Version and platform comparisons can be chained using the ``and`` and ``or`` -operators:: - - if sys.platform == 'linux' and (sys.version_info < (3,) or sys,version_info >= (3, 7)): ... - -Enums ------ - -Enum classes are supported in stubs, regardless of the Python version targeted by -the stubs. - -Enum members may be specified just like other forms of assignments, for example as -``x: int``, ``x = 0``, or ``x = ...``. The first syntax is preferred because it -allows type checkers to correctly type the ``.value`` attribute of enum members, -without providing unnecessary information like the runtime value of the enum member. - -Additional properties on enum members should be specified with ``@property``, so they -do not get interpreted by type checkers as enum members. - -Yes:: - - from enum import Enum - - class Color(Enum): - RED: int - BLUE: int - @property - def rgb_value(self) -> int: ... - - class Color(Enum): - # discouraged; type checkers will not understand that Color.RED.value is an int - RED = ... - BLUE = ... - @property - def rgb_value(self) -> int: ... - -No:: - - from enum import Enum - - class Color(Enum): - RED: int - BLUE: int - rgb_value: int # no way for type checkers to know that this is not an enum member - -Type Stub Content -================= - -This section documents best practices on what elements to include or -leave out of type stubs. - -Modules excluded fom stubs --------------------------- - -Not all modules should be included into stubs. - -It is recommended to exclude: - -1. Implementation details, with `multiprocessing/popen_spawn_win32.py `_ as a notable example -2. Modules that are not supposed to be imported, such as ``__main__.py`` -3. Protected modules that start with a single ``_`` char. However, when needed protected modules can still be added (see :ref:`undocumented-objects` section below) - -Public Interface ----------------- - -Stubs should include the complete public interface (classes, functions, -constants, etc.) of the module they cover, but it is not always -clear exactly what is part of the interface. - -The following should always be included: - -* All objects listed in the module's documentation. -* All objects included in ``__all__`` (if present). - -Other objects may be included if they are not prefixed with an underscore -or if they are being used in practice. (See the next section.) - -.. _undocumented-objects: - -Undocumented Objects --------------------- - -Undocumented objects may be included as long as they are marked with a comment -of the form ``# undocumented``. - -Example:: - - def list2cmdline(seq: Sequence[str]) -> str: ... # undocumented - -Such undocumented objects are allowed because omitting objects can confuse -users. Users who see an error like "module X has no attribute Y" will -not know whether the error appeared because their code had a bug or -because the stub is wrong. Although it may also be helpful for a type -checker to point out usage of private objects, false negatives (no errors for -wrong code) are preferable over false positives (type errors -for correct code). In addition, even for private objects a type checker -can be helpful in pointing out that an incorrect type was used. - -``__all__`` ------------- - -A type stub should contain an ``__all__`` variable if and only if it also -present at runtime. In that case, the contents of ``__all__`` should be -identical in the stub and at runtime. If the runtime dynamically adds -or removes elements (for example if certain functions are only available on -some platforms), include all possible elements in the stubs. - -Stub-Only Objects ------------------ - -Definitions that do not exist at runtime may be included in stubs to aid in -expressing types. Sometimes, it is desirable to make a stub-only class available -to a stub's users - for example, to allow them to type the return value of a -public method for which a library does not provided a usable runtime type:: - - from typing import Protocol - - class _Readable(Protocol): - def read(self) -> str: ... - - def get_reader() -> _Readable: ... - -Structural Types ----------------- - -As seen in the example with ``_Readable`` in the previous section, a common use -of stub-only objects is to model types that are best described by their -structure. These objects are called protocols (:pep:`544`), and it is encouraged -to use them freely to describe simple structural types. - -It is `recommended <#private-definitions>`_ to prefix stubs-only object names with ``_``. - -Incomplete Stubs ----------------- - -Partial stubs can be useful, especially for larger packages, but they should -follow the following guidelines: - -* Included functions and methods should list all arguments, but the arguments - can be left unannotated. -* Do not use ``Any`` to mark unannotated arguments or return values. -* Partial classes should include a ``__getattr__()`` method marked with an - ``# incomplete`` comment (see example below). -* Partial modules (i.e. modules that are missing some or all classes, - functions, or attributes) should include a top-level ``__getattr__()`` - function marked with an ``# incomplete`` comment (see example below). -* Partial packages (i.e. packages that are missing one or more sub-modules) - should have a ``__init__.pyi`` stub that is marked as incomplete (see above). - A better alternative is to create empty stubs for all sub-modules and - mark them as incomplete individually. - -Example of a partial module with a partial class ``Foo`` and a partially -annotated function ``bar()``:: - - def __getattr__(name: str) -> Any: ... # incomplete - - class Foo: - def __getattr__(self, name: str) -> Any: ... # incomplete - x: int - y: str - - def bar(x: str, y, *, z=...): ... - -The ``# incomplete`` comment is mainly intended as a reminder for stub -authors, but can be used by tools to flag such items. - -Attribute Access ----------------- - -Python has several methods for customizing attribute access: ``__getattr__``, -``__getattribute__``, ``__setattr__``, and ``__delattr__``. Of these, -``__getattr__`` and ``__setattr___`` should sometimes be included in stubs. - -In addition to marking incomplete definitions, ``__getattr__`` should be -included when a class or module allows any name to be accessed. For example, consider -the following class:: - - class Foo: - def __getattribute__(self, name): - return self.__dict__.setdefault(name) - -An appropriate stub definition is:: - - from typing import Any - class Foo: - def __getattr__(self, name: str) -> Any | None: ... - -Note that only ``__getattr__``, not ``__getattribute__``, is guaranteed to be -supported in stubs. - -On the other hand, ``__getattr__`` should be omitted even if the source code -includes it, if only limited names are allowed. For example, consider this class:: - - class ComplexNumber: - def __init__(self, n): - self._n = n - def __getattr__(self, name): - if name in ("real", "imag"): - return getattr(self._n, name) - raise AttributeError(name) - -In this case, the stub should list the attributes individually:: - - class ComplexNumber: - @property - def real(self) -> float: ... - @property - def imag(self) -> float: ... - def __init__(self, n: complex) -> None: ... - -``__setattr___`` should be included when a class allows any name to be set and -restricts the type. For example:: - - class IntHolder: - def __setattr__(self, name, value): - if isinstance(value, int): - return super().__setattr__(name, value) - raise ValueError(value) - -A good stub definition would be:: - - class IntHolder: - def __setattr__(self, name: str, value: int) -> None: ... - -``__delattr__`` should not be included in stubs. - -Finally, even in the presence of ``__getattr__`` and ``__setattr__``, it is -still recommended to separately define known attributes. - -Constants ---------- - -When the value of a constant is important, annotate it using ``Literal`` -instead of its type. - -Yes:: - - TEL_LANDLINE: Literal["landline"] - TEL_MOBILE: Literal["mobile"] - DAY_FLAG: Literal[0x01] - NIGHT_FLAG: Literal[0x02] - -No:: - - TEL_LANDLINE: str - TEL_MOBILE: str - DAY_FLAG: int - NIGHT_FLAG: int - -Documentation or Implementation -------------------------------- - -Sometimes a library's documented types will differ from the actual types in the -code. In such cases, type stub authors should use their best judgment. Consider -these two examples:: - - def print_elements(x): - """Print every element of list x.""" - for y in x: - print(y) - - def maybe_raise(x): - """Raise an error if x (a boolean) is true.""" - if x: - raise ValueError() - -The implementation of ``print_elements`` takes any iterable, despite the -documented type of ``list``. In this case, annotate the argument as -``Iterable[Any]``, to follow this PEP's style recommendation of preferring -abstract types. - -For ``maybe_raise``, on the other hand, it is better to annotate the argument as -``bool`` even though the implementation accepts any object. This guards against -common mistakes like unintentionally passing in ``None``. - -If in doubt, consider asking the library maintainers about their intent. - -Style Guide -=========== - -The recommendations in this section are aimed at type stub authors -who wish to provide a consistent style for type stubs. Type checkers -should not reject stubs that do not follow these recommendations, but -linters can warn about them. - -Stub files should generally follow the Style Guide for Python Code (:pep:`8`) -and the :ref:`best-practices`. There are a few exceptions, outlined below, that take the -different structure of stub files into account and are aimed to create -more concise files. - -Maximum Line Length -------------------- - -Type stubs should be limited to 130 characters per line. - -Blank Lines ------------ - -Do not use empty lines between functions, methods, and fields, except to -group them with one empty line. Use one empty line around classes, but do not -use empty lines between body-less classes, except for grouping. - -Yes:: - - def time_func() -> None: ... - def date_func() -> None: ... - - def ip_func() -> None: ... - - class Foo: - x: int - y: int - def __init__(self) -> None: ... - - class MyError(Exception): ... - class AnotherError(Exception): ... - -No:: - - def time_func() -> None: ... - - def date_func() -> None: ... # do no leave unnecessary empty lines - - def ip_func() -> None: ... - - - class Foo: # leave only one empty line above - x: int - class MyError(Exception): ... # leave an empty line between the classes - -Module Level Attributes ------------------------ - -Do not use an assignment for module-level attributes. - -Yes:: - - CONST: Literal["const"] - x: int - -No:: - - CONST = "const" - x: int = 0 - y: float = ... - z = 0 # type: int - a = ... # type: int - -.. _stub-style-classes: - -Classes -------- - -Classes without bodies should use the ellipsis literal ``...`` in place -of the body on the same line as the class definition. - -Yes:: - - class MyError(Exception): ... - -No:: - - class MyError(Exception): - ... - class AnotherError(Exception): pass - -Instance attributes and class variables follow the same recommendations as -module level attributes: - -Yes:: - - class Foo: - c: ClassVar[str] - x: int - -No:: - - class Foo: - c: ClassVar[str] = "" - d: ClassVar[int] = ... - x = 4 - y: int = ... - -Functions and Methods ---------------------- - -Use the same argument names as in the implementation, because -otherwise using keyword arguments will fail. Of course, this -does not apply to positional-only arguments, which are marked with a double -underscore. - -Use the ellipsis literal ``...`` in place of actual default argument -values. Use an explicit ``X | None`` annotation instead of -a ``None`` default. - -Yes:: - - def foo(x: int = ...) -> None: ... - def bar(y: str | None = ...) -> None: ... - -No:: - - def foo(x: int = 0) -> None: ... - def bar(y: str = None) -> None: ... - def baz(z: str | None = None) -> None: ... - -Do not annotate ``self`` and ``cls`` in method definitions, except when -referencing a type variable. - -Yes:: - - _T = TypeVar("_T") - class Foo: - def bar(self) -> None: ... - @classmethod - def create(cls: type[_T]) -> _T: ... - -No:: - - class Foo: - def bar(self: Foo) -> None: ... - @classmethod - def baz(cls: type[Foo]) -> int: ... - -The bodies of functions and methods should consist of only the ellipsis -literal ``...`` on the same line as the closing parenthesis and colon. - -Yes:: - - def to_int1(x: str) -> int: ... - def to_int2( - x: str, - ) -> int: ... - -No:: - - def to_int1(x: str) -> int: - return int(x) - def to_int2(x: str) -> int: - ... - def to_int3(x: str) -> int: pass - -.. _private-definitions: - -Private Definitions -------------------- - -Type variables, type aliases, and other definitions that should not -be used outside the stub should be marked as private by prefixing them -with an underscore. - -Yes:: - - _T = TypeVar("_T") - _DictList = Dict[str, List[Optional[int]] - -No:: - - T = TypeVar("T") - DictList = Dict[str, List[Optional[int]]] - -Language Features ------------------ - -Use the latest language features available as outlined -in the Syntax_ section, even for stubs targeting older Python versions. -Do not use quotes around forward references and do not use ``__future__`` -imports. - -Yes:: - - class Py35Class: - x: int - forward_reference: OtherClass - class OtherClass: ... - -No:: - - class Py35Class: - x = 0 # type: int - forward_reference: 'OtherClass' - class OtherClass: ... - -NamedTuple and TypedDict ------------------------- - -Use the class-based syntax for ``typing.NamedTuple`` and -``typing.TypedDict``, following the :ref:`stub-style-classes` section of this style guide. - -Yes:: - - from typing import NamedTuple, TypedDict - class Point(NamedTuple): - x: float - y: float - - class Thing(TypedDict): - stuff: str - index: int - -No:: - - from typing import NamedTuple, TypedDict - Point = NamedTuple("Point", [('x', float), ('y', float)]) - Thing = TypedDict("Thing", {'stuff': str, 'index': int}) - -Copyright -========= - -This document is placed in the public domain or under the CC0-1.0-Universal license, whichever is more permissive. diff --git a/docs/source/type_compatibility.rst b/docs/source/type_compatibility.rst deleted file mode 100644 index 43ebd32b5..000000000 --- a/docs/source/type_compatibility.rst +++ /dev/null @@ -1,17 +0,0 @@ -****************** -Type Compatibility -****************** - - -The Class Hierarchy -=================== - -Mutable Containers ------------------- - -Comparing Callables: Covariance and Contravariance --------------------------------------------------- - - -Metaclasses -=========== diff --git a/docs/source/type_system.rst b/docs/source/type_system.rst deleted file mode 100644 index 6d7954b82..000000000 --- a/docs/source/type_system.rst +++ /dev/null @@ -1,58 +0,0 @@ -*************** -The Type System -*************** - -Built-in Types -============== - -`typing Module Documentation `__ - -Built-in Primitives -------------------- - -Built-in operators ------------------- - -Advanced Types --------------- - - -Simple User-Defined Types -========================= - - -Type Aliases -============ - -Recursive Aliases ------------------ - - -Data Structures -=============== - -Typed Dictionary ----------------- - -Dataclass ---------- - - -Generic Types -============= - - -Type Variables -============== - -TypeVar -------- - -Variadics ---------- - -ParamSpec -^^^^^^^^^ - -TypeVarTuple -^^^^^^^^^^^^ diff --git a/docs/source/writing_stubs.rst b/docs/source/writing_stubs.rst deleted file mode 100644 index d463a48b7..000000000 --- a/docs/source/writing_stubs.rst +++ /dev/null @@ -1,108 +0,0 @@ -.. _writing_stubs: - -********************************** -Writing and Maintaining Stub Files -********************************** - -Stub files are a means of providing type information for Python modules. -For a full reference, refer to :ref:`stubs`. - -Maintaining stubs can be a little cumbersome because they are separated from the -implementation. This page lists some tools that make writing and maintaining -stubs less painful. - -Tools for generating stubs -========================== - -stubgen -------- - -stubgen is a tool bundled with `mypy `__ -that can be used to generate basic stubs. These stubs serve as a -basic starting point; most types will default to ``Any``. - -.. code-block:: console - - stubgen -p my_great_package - -For more details, see `stubgen docs `__. - -pyright -------- - -pyright contains a tool that generates basic stubs. Like stubgen, these generated -stubs serve more as a starting point. - -.. code-block:: console - - pyright --createstub my_great_package - -For more details, see `pyright docs `__. - -monkeytype ----------- - -monkeytype takes a slightly different approach — you run your code (perhaps via -your tests) and monkeytype collects the types it observes at runtime to generate -stubs. - -.. code-block:: console - - monkeytype run script.py - monkeytype stub my_great_package - -For more details, see `monkeytype docs `__. - -Tools for maintaining stubs -=========================== - -stubtest --------- - -stubtest is a tool bundled with `mypy `__. - -stubtest finds inconsistencies between stub files and the implementation. It -does this by comparing stub definitions to what it finds from importing your -code and using runtime introspection (via the ``inspect`` module). - -.. code-block:: console - - stubtest my_great_package - -For more details, see `stubtest docs `__. - -flake8-pyi ----------- - -flake8-pyi is a `flake8 `__ plugin that -lints common issues in stub files. - -.. code-block:: console - - flake8 my_great_package - -For more details, see `flake8-pyi docs `__. - -Running a type checker on the stubs ------------------------------------ - -Simply running a type checker on the stubs can catch several issues, from simple -things like detecting missing annotations to more complex things like ensuring -Liskov substitutability or detecting problematic overloads. - -It may be instructive to examine `typeshed `__'s -`setup for testing stubs `__. - -.. - TODO: consider adding examples and configurations for specific type checkers - -Type checking usage of your package ------------------------------------ - -If you have access to a codebase that uses your package — perhaps tests for your -package — running a type checker against it can help you detect issues, -particularly with false positives. - -If your package has some particularly complex aspects, you could even consider -writing dedicated typing tests for tricky definitions. For more details, see -:ref:`testing`. diff --git a/docs/spec/aliases.rst b/docs/spec/aliases.rst index adf303440..cc5e70b55 100644 --- a/docs/spec/aliases.rst +++ b/docs/spec/aliases.rst @@ -34,29 +34,24 @@ Type aliases may be as complex as type hints in annotations -- anything that is acceptable as a type hint is acceptable in a type alias:: - from typing import TypeVar from collections.abc import Iterable - T = TypeVar('T', bound=float) - Vector = Iterable[tuple[T, T]] + type Vector[T: float] = Iterable[tuple[T, T]] - def inproduct(v: Vector[T]) -> T: + def inproduct[T: float](v: Vector[T]) -> T: return sum(x*y for x, y in v) - def dilate(v: Vector[T], scale: T) -> Vector[T]: + def dilate[T: float](v: Vector[T], scale: T) -> Vector[T]: return ((x * scale, y * scale) for x, y in v) vec: Vector[float] = [] This is equivalent to:: - from typing import TypeVar from collections.abc import Iterable - T = TypeVar('T', bound=float) - - def inproduct(v: Iterable[tuple[T, T]]) -> T: + def inproduct[T: float](v: Iterable[tuple[T, T]]) -> T: return sum(x*y for x, y in v) - def dilate(v: Iterable[tuple[T, T]], scale: T) -> Iterable[tuple[T, T]]: + def dilate[T: float](v: Iterable[tuple[T, T]], scale: T) -> Iterable[tuple[T, T]]: return ((x * scale, y * scale) for x, y in v) vec: Iterable[tuple[float, float]] = [] @@ -156,9 +151,9 @@ to a definition:: def __init__(self, _x: Base) -> None: ... -While at runtime, ``NewType('Derived', Base)`` returns a dummy function -that simply returns its argument. Type checkers require explicit casts -from ``int`` where ``UserId`` is expected, while implicitly casting +While at runtime, ``NewType('Derived', Base)`` returns a dummy object +that simply returns its argument when called. Type checkers require explicit +casts from ``int`` where ``UserId`` is expected, while implicitly casting from ``UserId`` where ``int`` is expected. Examples:: UserId = NewType('UserId', int) @@ -176,7 +171,7 @@ from ``UserId`` where ``int`` is expected. Examples:: ``NewType`` accepts exactly two arguments: a name for the new unique type, and a base class. The latter should be a proper class (i.e., not a type construct like ``Union``, etc.), or another unique type created -by calling ``NewType``. The function returned by ``NewType`` +by calling ``NewType``. The callable returned by ``NewType`` accepts only one argument; this is equivalent to supporting only one constructor accepting an instance of the base class (see above). Example:: @@ -193,5 +188,8 @@ constructor accepting an instance of the base class (see above). Example:: tcp_packet = TcpPacketId(127, 0) # Fails in type checker and at runtime Both ``isinstance`` and ``issubclass``, as well as subclassing will fail -for ``NewType('Derived', Base)`` since function objects don't support -these operations. +for ``NewType('Derived', Base)``, since the object returned by a call to +``NewType`` is not a class. + +See also :ref:`protocol-newtype-aliases` for a discussion of how +``NewType`` interacts with protocol definitions. diff --git a/docs/spec/annotations.rst b/docs/spec/annotations.rst index 0b0ce6416..813766bd1 100644 --- a/docs/spec/annotations.rst +++ b/docs/spec/annotations.rst @@ -16,25 +16,26 @@ hinting is used by filling function annotation slots with classes:: This states that the expected type of the ``name`` argument is ``str``. Analogically, the expected return type is ``str``. -Expressions whose type is a subtype of a specific argument type are -also accepted for that argument. +Expressions whose type is :term:`assignable` to a specific argument type are +also accepted for that argument. Similarly, an expression whose type is +assignable to the annotated return type can be returned from the function. .. _`missing-annotations`: -Any function without annotations should be treated as having the most -general type possible, or ignored, by any type checker. +Any function without annotations can be treated as having :ref:`Any` +annotations on all arguments and the return type. Type checkers may also +optionally infer more precise types for missing annotations. + +Type checkers may choose to entirely ignore (not type check) the bodies of +functions with no annotations, but this behavior is not required. It is recommended but not required that checked functions have annotations for all arguments and the return type. For a checked function, the default annotation for arguments and for the return type -is ``Any``. An exception is the first argument of instance and -class methods. If it is not annotated, then it is assumed to have the -type of the containing class for instance methods, and a type object -type corresponding to the containing class object for class methods. -For example, in class ``A`` the first argument of an instance method -has the implicit type ``A``. In a class method, the precise type of -the first argument cannot be represented using the available type -notation. +is ``Any``. An exception to the above is the first argument of +instance and class methods (conventionally named ``self`` or ``cls``), +which type checkers should assume to have an appropriate type, as per +:ref:`annotating-methods`. (Note that the return type of ``__init__`` ought to be annotated with ``-> None``. The reason for this is subtle. If ``__init__`` assumed @@ -74,12 +75,16 @@ places. Specifically, type expressions are used in the following locations: * The second argument to :ref:`assert_type() ` * The bounds and constraints of a ``TypeVar`` (whether created through the old syntax or the native syntax in Python 3.12) +* The default of a ``TypeVar``, ``ParamSpec``, or ``TypeVarTuple`` (whether + created through the old syntax or the native syntax in Python 3.12) * The definition of a type alias (whether created through the ``type`` statement, the old assignment syntax, or the ``TypeAliasType`` constructor) * The type arguments of a generic class (which may appear in a base class or in a constructor call) * The definitions of fields in the functional forms for creating :ref:`TypedDict ` and :ref:`NamedTuple ` types +* The value passed to the ``extra_items`` argument in the :ref:`TypedDict ` + constructor * The base type in the definition of a :ref:`NewType ` .. _`annotation-expression`: @@ -104,8 +109,8 @@ The following grammar describes the allowed elements of type and annotation expr annotation_expression: '[' `annotation_expression` ']' : | '[' `annotation_expression` ']' : | '[' `annotation_expression`']' - : | '[' `annotation_expression`']' - : | '[' `annotation_expression`']' + : | ('[' `annotation_expression`']')? + : | ('[' `annotation_expression`']')? : | '[' `annotation_expression` ']' : | '[' `annotation_expression` ',' : expression (',' expression)* ']' @@ -134,7 +139,7 @@ The following grammar describes the allowed elements of type and annotation expr : | : | name : (where name must refer to a valid in-scope class, - : type alias, or TypeVar) + : type alias, TypeVar, or sentinel object) : | name '[' (`maybe_unpacked` | `type_expression_list`) : (',' (`maybe_unpacked` | `type_expression_list`))* ']' : (the `type_expression_list` form is valid only when @@ -165,6 +170,7 @@ The following grammar describes the allowed elements of type and annotation expr : (valid only in some contexts) : | '[' `type_expression` ']' : (valid only in some contexts) + : | ('[' `type_expression` ']')? : | `string_annotation` : (must evaluate to a valid `type_expression`) maybe_unpacked: `type_expression` | `unpacked` @@ -217,32 +223,14 @@ String annotations When a type hint cannot be evaluated at runtime, that definition may be expressed as a string literal, to be resolved later. -A situation where this occurs commonly is the definition of a -container class, where the class being defined occurs in the signature -of some of the methods. For example, the following code (the start of -a simple binary tree implementation) does not work:: - - class Tree: - def __init__(self, left: Tree, right: Tree): - self.left = left - self.right = right - -To address this, we write:: - - class Tree: - def __init__(self, left: 'Tree', right: 'Tree'): - self.left = left - self.right = right - -The string literal should contain a valid Python expression (i.e., -``compile(lit, '', 'eval')`` should be a valid code object) and it -should evaluate without errors once the module has been fully loaded. -The local and global namespace in which it is evaluated should be the -same namespaces in which default arguments to the same function would -be evaluated. - -Moreover, the expression should be parseable as a valid type hint, i.e., -it is constrained by the rules from :ref:`the expression grammar `. +The string literal should contain a syntactically valid Python expression +(i.e., ``compile(lit, '', 'eval')`` should succeed) that is a valid +:term:`annotation expression`. Regardless of the Python version used, names +within the expression are looked up in the same way as they would be looked up +at runtime in Python 3.14 and higher if the annotation was not enclosed in a +string literal. Thus, name lookup follows general rules (e.g., the current +function, class, or module scope first, and the builtin scope last), but names +defined later within the same scope can be used in an earlier annotation. If a triple quote is used, the string should be parsed as though it is implicitly surrounded by parentheses. This allows newline characters to be @@ -302,6 +290,13 @@ _module_._class_ name:: from models.a import A from models.b import B +from __future__ import annotations +---------------------------------- + +For purposes of type checking, annotations in a file containing ``from +__future__ import annotations`` must use the same name-resolution rules as +explicitly stringified annotations, regardless of the target Python version. + Annotating generator functions and coroutines --------------------------------------------- @@ -310,7 +305,7 @@ the generic type ``Generator[yield_type, send_type, return_type]`` provided by ``typing.py`` module:: def echo_round() -> Generator[int, float, str]: - res = yield + res = yield 0 while res: res = yield round(res) return 'OK' @@ -353,17 +348,20 @@ types cannot be specified:: Annotating instance and class methods ------------------------------------- -In most cases the first argument of class and instance methods -does not need to be annotated, and it is assumed to have the -type of the containing class for instance methods, and a type object -type corresponding to the containing class object for class methods. +In most cases the first argument of instance and class methods +(conventionally named ``self`` or ``cls``) does not need to be annotated. + +If the argument is not annotated, then for instance methods it may be +inferred to have either the type of the containing class, or the type :ref:`Self +`. For class methods it may be inferred to have either the type object +type corresponding to the containing class object, or ``type[Self]``. + In addition, the first argument in an instance method can be annotated with a type variable. In this case the return type may use the same type variable, thus making that method a generic function. For example:: - T = TypeVar('T', bound='Copyable') class Copyable: - def copy(self: T) -> T: + def copy[T: Copyable](self: T) -> T: # return a copy of self class C(Copyable): ... @@ -373,10 +371,9 @@ type variable, thus making that method a generic function. For example:: The same applies to class methods using ``type[]`` in an annotation of the first argument:: - T = TypeVar('T', bound='C') class C: @classmethod - def factory(cls: type[T]) -> T: + def factory[T: C](cls: type[T]) -> T: # make a new instance of cls class D(C): ... diff --git a/docs/spec/callables.rst b/docs/spec/callables.rst index 3ec63bfa6..f23220400 100644 --- a/docs/spec/callables.rst +++ b/docs/spec/callables.rst @@ -71,8 +71,8 @@ may be given as an ellipsis. For example:: def func(x: AnyStr, y: AnyStr = ...) -> AnyStr: ... If a non-ellipsis default value is present and its type can be statically -evaluated, a type checker should verify that this type is compatible with the -declared parameter's type:: +evaluated, a type checker should verify that this type is :term:`assignable` to +the declared parameter's type:: def func(x: int = 0): ... # OK def func(x: int | None = None): ... # OK @@ -180,38 +180,74 @@ generated. For example:: # so **kwargs can contain # a "name" keyword. -Required and non-required keys -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -By default all keys in a ``TypedDict`` are required. This behavior can be -overridden by setting the dictionary's ``total`` parameter as ``False``. -Moreover, :pep:`655` introduced new type qualifiers - ``typing.Required`` and -``typing.NotRequired`` - that enable specifying whether a particular key is -required or not:: - - class Movie(TypedDict): - title: str - year: NotRequired[int] +Required and non-required items +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Items in a TypedDict may be either :term:`required` or :term:`non-required`. When using a ``TypedDict`` to type ``**kwargs`` all of the required and non-required keys should correspond to required and non-required function -keyword parameters. Therefore, if a required key is not supported by the +keyword parameters. Therefore, if a required key is not provided by the caller, then an error must be reported by type checkers. +Read-only items +^^^^^^^^^^^^^^^ + +TypedDict items may also be :term:`read-only`. Marking one or more of the items of a TypedDict +used to type ``**kwargs`` as read-only will have no effect on the type signature of the method. +However, it *will* prevent the item from being modified in the body of the function:: + + class Args(TypedDict): + key1: int + key2: str + + class ReadOnlyArgs(TypedDict): + key1: ReadOnly[int] + key2: ReadOnly[str] + + class Function(Protocol): + def __call__(self, **kwargs: Unpack[Args]) -> None: ... + + def impl(**kwargs: Unpack[ReadOnlyArgs]) -> None: + kwargs["key1"] = 3 # Type check error: key1 is readonly + + fn: Function = impl # Accepted by type checker: function signatures are identical + +Extra items +^^^^^^^^^^^ + +If the TypedDict used for annotating ``**kwargs`` is defined to allow +:term:`extra items`, arbitrary additional keyword arguments of the right +type may be passed to the function:: + + class MovieNoExtra(TypedDict): + name: str + + class MovieExtra(TypedDict, extra_items=int): + name: str + + def f(**kwargs: Unpack[MovieNoExtra]) -> None: ... + def g(**kwargs: Unpack[MovieExtra]) -> None: ... + + # Should be equivalent to: + def f(*, name: str) -> None: ... + def g(*, name: str, **kwargs: int) -> None: ... + + f(name="No Country for Old Men", year=2007) # Not OK. Unrecognized item + g(name="No Country for Old Men", year=2007) # OK + Assignment ^^^^^^^^^^ -Assignments of a function typed with ``**kwargs: Unpack[Movie]`` and -another callable type should pass type checking only if they are compatible. -This can happen for the scenarios described below. +Assignments of a function typed with ``**kwargs: Unpack[Movie]`` and another +callable type should pass type checking only for the scenarios described below. Source and destination contain ``**kwargs`` """"""""""""""""""""""""""""""""""""""""""" Both destination and source functions have a ``**kwargs: Unpack[TypedDict]`` -parameter and the destination function's ``TypedDict`` is assignable to the -source function's ``TypedDict`` and the rest of the parameters are -compatible:: +parameter and the destination function's ``TypedDict`` is :term:`assignable` to +the source function's ``TypedDict`` and the rest of the parameters are +assignable:: class Animal(TypedDict): name: str @@ -235,10 +271,10 @@ Source contains ``**kwargs`` and destination doesn't The destination callable doesn't contain ``**kwargs``, the source callable contains ``**kwargs: Unpack[TypedDict]`` and the destination function's keyword -arguments are assignable to the corresponding keys in source function's +arguments are :term:`assignable` to the corresponding keys in source function's ``TypedDict``. Moreover, not required keys should correspond to optional function arguments, whereas required keys should correspond to required -function arguments. Again, the rest of the parameters have to be compatible. +function arguments. Again, the rest of the parameters have to be assignable. Continuing the previous example:: class Example(TypedDict): @@ -252,7 +288,7 @@ Continuing the previous example:: dest = src # OK! It is worth pointing out that the destination function's parameters that are to -be compatible with the keys and values from the ``TypedDict`` must be keyword +be assignable to the keys and values from the ``TypedDict`` must be keyword only:: def dest(dog: Dog, string: str, number: int = ...): ... @@ -282,8 +318,8 @@ unpacked in the destination callable invocation:: dest = src # WRONG! dest(**animal) # Fails at runtime. -Similar situation can happen even without inheritance as compatibility -between ``TypedDict``\s is based on structural subtyping. +A similar situation can happen even without inheritance as :term:`assignability +` between ``TypedDict``\s is :term:`structural`. Source contains untyped ``**kwargs`` """""""""""""""""""""""""""""""""""" @@ -301,8 +337,8 @@ Source contains traditionally typed ``**kwargs: T`` The destination callable contains ``**kwargs: Unpack[TypedDict]``, the source callable contains traditionally typed ``**kwargs: T`` and each of the -destination function ``TypedDict``'s fields is assignable to a variable of -type ``T``:: +destination function ``TypedDict``'s fields is :term:`assignable` to a variable +of type ``T``:: class Vehicle: ... @@ -417,17 +453,15 @@ a function within a type expression. The syntax is Parameters specified using ``Callable`` are assumed to be positional-only. The ``Callable`` form provides no way to specify keyword-only parameters, -variadic parameters, or default argument values. For these use cases, see -the section on `Callback protocols`_. +or default argument values. For these use cases, see the section on +`Callback protocols`_. Meaning of ``...`` in ``Callable`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The ``Callable`` special form supports the use of ``...`` in place of the -list of parameter types. This indicates that the type is consistent with -any input signature. Just as ``Any`` means "any conceivable type that could be -compatible", ``(...)`` means "any conceivable set of parameters that could be -compatible":: +The ``Callable`` special form supports the use of ``...`` in place of the list +of parameter types. This is a :term:`gradual form` indicating that the type is +:term:`consistent` with any input signature:: cb1: Callable[..., str] cb1 = lambda x: str(x) # OK @@ -437,7 +471,7 @@ compatible":: A ``...`` can also be used with ``Concatenate``. In this case, the parameters prior to the ``...`` are required to be present in the input signature and -be compatible in kind and type, but any additional parameters are permitted:: +be assignable, but any additional parameters are permitted:: cb3: Callable[Concatenate[int, ...], str] cb3 = lambda x: str(x) # OK @@ -475,7 +509,7 @@ and are retained as part of the signature:: pass class B(A): - # This override is OK because it is consistent with the parent's method. + # This override is OK because it is assignable to the parent's method. def method(self, a: float, /, b: int, *, k: str, m: str) -> None: pass @@ -490,7 +524,7 @@ For example:: f: Callback[...] = cb # OK If ``...`` is used with signature concatenation, the ``...`` portion continues -to mean "any conceivable set of parameters that could be compatible":: +to be :term:`consistent` with any input parameters:: type CallbackWithInt[**P] = Callable[Concatenate[int, P], str] type CallbackWithStr[**P] = Callable[Concatenate[str, P], str] @@ -501,6 +535,15 @@ to mean "any conceivable set of parameters that could be compatible":: f3: CallbackWithInt[...] = cb # OK f4: CallbackWithStr[...] = cb # Error + +Variadic positional parameter types can be defined with an unpacked tuple +of the form ``*tuple[int, ...]`` in the parameter list. The first argument +specifies the type of the variadic parameters. +For example, the following defines a callable that accepts any number of integer +arguments:: + + type VarCallback = Callable[[*tuple[int, ...]], None] + .. _`callback-protocols`: Callback protocols @@ -522,21 +565,21 @@ and overloads. They can be defined as protocols with a ``__call__`` member:: ... comb: Combiner = good_cb # OK - comb = bad_cb # Error! Argument 2 has incompatible type because of + comb = bad_cb # Error! Argument 2 is not assignable because of # different parameter name and kind in the callback Callback protocols and ``Callable[...]`` types can generally be used interchangeably. -Subtyping rules for callables ------------------------------ +Assignability rules for callables +--------------------------------- -A callable type ``A`` is a subtype of callable type ``B`` if the return type -of ``A`` is a subtype of the return type of ``B`` and the input signature -of ``A`` accepts all possible combinations of arguments that the input -signature of ``B`` accepts. All of the specific subtyping rules described below -derive from this general rule. +A callable type ``B`` is :term:`assignable` to a callable type ``A`` if the +return type of ``B`` is assignable to the return type of ``A`` and the input +signature of ``B`` accepts all possible combinations of arguments that the +input signature of ``A`` accepts. All of the specific assignability rules +described below derive from this general rule. Parameter types @@ -544,9 +587,9 @@ Parameter types Callable types are covariant with respect to their return types but contravariant with respect to their parameter types. This means a callable -``A`` is a subtype of callable ``B`` if the types of the parameters of -``B`` are subtypes of the parameters of ``A``. For example, -``(x: float) -> int`` is a subtype of ``(x: int) -> float``:: +``B`` is :term:`assignable` to callable ``A`` if the types of the parameters of +``A`` are assignable to the parameters of ``B``. For example, ``(x: float) -> +int`` is assignable to ``(x: int) -> float``:: def func(cb: Callable[[float], int]): f1: Callable[[int], float] = cb # OK @@ -555,11 +598,11 @@ contravariant with respect to their parameter types. This means a callable Parameter kinds ^^^^^^^^^^^^^^^ -Callable ``A`` is a subtype of callable ``B`` if all keyword-only parameters -in ``B`` are present in ``A`` as either keyword-only parameters or standard -(positional or keyword) parameters. For example, ``(a: int) -> None`` is a -subtype of ``(*, a: int) -> None``, but the converse is not true. The order -of keyword-only parameters is ignored for purposes of subtyping:: +Callable ``B`` is :term:`assignable` to callable ``A`` only if all keyword-only +parameters in ``A`` are present in ``B`` as either keyword-only parameters or +standard (positional or keyword) parameters. For example, ``(a: int) -> None`` +is assignable to ``(*, a: int) -> None``, but the converse is not true. The +order of keyword-only parameters is ignored for purposes of assignability:: class KwOnly(Protocol): def __call__(self, *, b: int, a: int) -> None: ... @@ -571,10 +614,10 @@ of keyword-only parameters is ignored for purposes of subtyping:: f1: KwOnly = standard # OK f2: Standard = kw_only # Error -Likewise, callable ``A`` is a subtype of callable ``B`` if all positional-only -parameters in ``B`` are present in ``A`` as either positional-only parameters -or standard (positional or keyword) parameters. The names of positional-only -parameters are ignored for purposes of subtyping:: +Likewise, callable ``B`` is assignable to callable ``A`` only if all +positional-only parameters in ``A`` are present in ``B`` as either +positional-only parameters or standard (positional or keyword) parameters. The +names of positional-only parameters are ignored for purposes of assignability:: class PosOnly(Protocol): def __call__(self, not_a: int, /) -> None: ... @@ -590,9 +633,10 @@ parameters are ignored for purposes of subtyping:: ``*args`` parameters ^^^^^^^^^^^^^^^^^^^^ -If a callable ``B`` has a signature with a ``*args`` parameter, callable ``A`` -must also have a ``*args`` parameter to be a subtype of ``B``, and the type of -``B``'s ``*args`` parameter must be a subtype of ``A``'s ``*args`` parameter:: +If a callable ``A`` has a signature with a ``*args`` parameter, callable ``B`` +must also have a ``*args`` parameter to be :term:`assignable` to ``A``, and the +type of ``A``'s ``*args`` parameter must be assignable to ``B``'s ``*args`` +parameter:: class NoArgs(Protocol): def __call__(self) -> None: ... @@ -611,12 +655,12 @@ must also have a ``*args`` parameter to be a subtype of ``B``, and the type of f4: IntArgs = float_args # OK f5: FloatArgs = no_args # Error: missing *args parameter - f6: FloatArgs = int_args # Error: float is not subtype of int + f6: FloatArgs = int_args # Error: float is not assignable to int -If a callable ``B`` has a signature with one or more positional-only parameters, -a callable ``A`` is a subtype of ``B`` if ``A`` has an ``*args`` parameter whose -type is a supertype of the types of any otherwise-unmatched positional-only -parameters in ``B``:: +If a callable ``A`` has a signature with one or more positional-only +parameters, a callable ``B`` is assignable to ``A`` only if ``B`` has an +``*args`` parameter whose type is assignable from the types of any +otherwise-unmatched positional-only parameters in ``A``:: class PosOnly(Protocol): def __call__(self, a: int, b: str, /) -> None: ... @@ -634,15 +678,15 @@ parameters in ``B``:: def __call__(self, a: int, b: str) -> None: ... def func(int_args: IntArgs, int_str_args: IntStrArgs, str_args: StrArgs): - f1: PosOnly = int_args # Error: str is not subtype of int + f1: PosOnly = int_args # Error: str is not assignable to int f2: PosOnly = int_str_args # OK f3: PosOnly = str_args # OK - f4: IntStrArgs = str_args # Error: int | str is not subtype of str - f5: IntStrArgs = int_args # Error: int | str is not subtype of int + f4: IntStrArgs = str_args # Error: int | str is not assignable to str + f5: IntStrArgs = int_args # Error: int | str is not assignable to int f6: StrArgs = int_str_args # OK - f7: StrArgs = int_args # Error: str is not subtype of int + f7: StrArgs = int_args # Error: str is not assignable to int f8: IntArgs = int_str_args # OK - f9: IntArgs = str_args # Error: int is not subtype of str + f9: IntArgs = str_args # Error: int is not assignable to str f10: Standard = int_str_args # Error: keyword parameters a and b missing f11: Standard = str_args # Error: keyword parameter b missing @@ -650,10 +694,10 @@ parameters in ``B``:: ``**kwargs`` parameters ^^^^^^^^^^^^^^^^^^^^^^^ -If a callable ``B`` has a signature with a ``**kwargs`` parameter (without -an unpacked ``TypedDict`` type annotation), callable ``A`` must also have a -``**kwargs`` parameter to be a subtype of ``B``, and the type of -``B``'s ``**kwargs`` parameter must be a subtype of ``A``'s ``**kwargs`` +If a callable ``A`` has a signature with a ``**kwargs`` parameter (without an +unpacked ``TypedDict`` type annotation), callable ``B`` must also have a +``**kwargs`` parameter to be :term:`assignable` to ``A``, and the type of +``A``'s ``**kwargs`` parameter must be assignable to ``B``'s ``**kwargs`` parameter:: class NoKwargs(Protocol): @@ -673,12 +717,12 @@ parameter:: f4: IntKwargs = float_kwargs # OK f5: FloatKwargs = no_kwargs # Error: missing **kwargs parameter - f6: FloatKwargs = int_kwargs # Error: float is not subtype of int + f6: FloatKwargs = int_kwargs # Error: float is not assignable to int -If a callable ``B`` has a signature with one or more keyword-only parameters, -a callable ``A`` is a subtype of ``B`` if ``A`` has a ``**kwargs`` parameter -whose type is a supertype of the types of any otherwise-unmatched keyword-only -parameters in ``B``:: +If a callable ``A`` has a signature with one or more keyword-only parameters, +a callable ``B`` is assignable to ``A`` if ``B`` has a ``**kwargs`` parameter +whose type is assignable from the types of any otherwise-unmatched keyword-only +parameters in ``A``:: class KwOnly(Protocol): def __call__(self, *, a: int, b: str) -> None: ... @@ -696,20 +740,21 @@ parameters in ``B``:: def __call__(self, a: int, b: str) -> None: ... def func(int_kwargs: IntKwargs, int_str_kwargs: IntStrKwargs, str_kwargs: StrKwargs): - f1: KwOnly = int_kwargs # Error: str is not subtype of int + f1: KwOnly = int_kwargs # Error: str is not assignable to int f2: KwOnly = int_str_kwargs # OK f3: KwOnly = str_kwargs # OK - f4: IntStrKwargs = str_kwargs # Error: int | str is not subtype of str - f5: IntStrKwargs = int_kwargs # Error: int | str is not subtype of int + f4: IntStrKwargs = str_kwargs # Error: int | str is not assignable to str + f5: IntStrKwargs = int_kwargs # Error: int | str is not assignable to int f6: StrKwargs = int_str_kwargs # OK - f7: StrKwargs = int_kwargs # Error: str is not subtype of int + f7: StrKwargs = int_kwargs # Error: str is not assignable to int f8: IntKwargs = int_str_kwargs # OK - f9: IntKwargs = str_kwargs # Error: int is not subtype of str + f9: IntKwargs = str_kwargs # Error: int is not assignable to str f10: Standard = int_str_kwargs # Error: Does not accept positional arguments f11: Standard = str_kwargs # Error: Does not accept positional arguments -Subtyping relationships for callable signatures that contain a ``**kwargs`` -with an unpacked ``TypedDict`` are described in the section :ref:`above `. +Assignability rules for callable signatures that contain a ``**kwargs`` with an +unpacked ``TypedDict`` are described in the section :ref:`above +`. Signatures with ParamSpecs @@ -732,10 +777,10 @@ to a ``Callable`` parameterized by ``P``:: Default argument values ^^^^^^^^^^^^^^^^^^^^^^^ -If a callable ``A`` has a parameter ``x`` with a default argument value and -``B`` is the same as ``A`` except that ``x`` has no default argument, then -``A`` is a subtype of ``B``. ``A`` is also a subtype of ``C`` -if ``C`` is the same as ``A`` with parameter ``x`` removed:: +If a callable ``C`` has a parameter ``x`` with a default argument value and +``A`` is the same as ``C`` except that ``x`` has no default argument, then +``C`` is :term:`assignable` to ``A``. ``C`` is also assignable to ``A`` if +``A`` is the same as ``C`` with parameter ``x`` removed:: class DefaultArg(Protocol): def __call__(self, x: int = 0) -> None: ... @@ -754,9 +799,9 @@ if ``C`` is the same as ``A`` with parameter ``x`` removed:: Overloads ^^^^^^^^^ -If a callable ``A`` is overloaded with two or more signatures, it is a subtype -of callable ``B`` if *at least one* of the overloaded signatures in ``A`` is -a subtype of ``B``:: +If a callable ``B`` is overloaded with two or more signatures, it is +:term:`assignable` to callable ``A`` if *at least one* of the overloaded +signatures in ``B`` is assignable to ``A``:: class Overloaded(Protocol): @overload @@ -778,8 +823,9 @@ a subtype of ``B``:: f2: StrArg = overloaded # OK f3: FloatArg = overloaded # Error -If a callable ``B`` is overloaded with two or more signatures, callable ``A`` -is a subtype of ``B`` if ``A`` is a subtype of *all* of the signatures in ``B``:: +If a callable ``A`` is overloaded with two or more signatures, callable ``B`` +is assignable to ``A`` if ``B`` is assignable to *all* of the signatures in +``A``:: class Overloaded(Protocol): @overload diff --git a/docs/spec/class-compat.rst b/docs/spec/class-compat.rst index b49a20348..fe7df968e 100644 --- a/docs/spec/class-compat.rst +++ b/docs/spec/class-compat.rst @@ -1,6 +1,6 @@ .. _`class-compat`: -Class type compatibility +Class type assignability ======================== .. _`classvar`: @@ -10,11 +10,30 @@ Class type compatibility (Originally specified in :pep:`526`.) -A :term:`type qualifier` ``ClassVar[T]`` exists in the :py:mod:`typing` -module. It accepts only a single argument that should be a valid type, -and is used to annotate class variables that should not be set on class -instances. This restriction is enforced by static checkers, -but not at runtime. +The :py:data:`typing.ClassVar` :term:`type qualifier` is used to annotate +class variables that should not be set on class instances. This restriction +is enforced by static checkers, but not at runtime. + +:py:data:`~typing.ClassVar` may be used in one of several forms: + +* With an explicit type, using the syntax ``ClassVar[]``. Example:: + + class C: + x: ClassVar[float] = 1 + +* With no type annotation. Example:: + + class C: + y: ClassVar = 2 + z: ClassVar + + If an assigned value is available (e.g. with ``y``), the type should be + inferred as some type to which this value is :term:`assignable` (for example, + ``int``, ``Literal[2]``, or ``Any``). + + If the bare ``ClassVar`` qualifier is used without any assigned value, the type + should be inferred as :ref:`Any `. Type checkers may error if no assigned + value is present. Type annotations can be used to annotate class and instance variables in class bodies and methods. In particular, the value-less notation ``a: int`` @@ -82,13 +101,14 @@ For example, annotating the discussed class:: As a matter of convenience (and convention), instance variables can be annotated in ``__init__`` or other methods, rather than in the class:: - from typing import Generic, TypeVar - T = TypeVar('T') - - class Box(Generic[T]): - def __init__(self, content): + class Box[T]: + def __init__(self, content: T): self.content: T = content +``ClassVar`` cannot be used as a qualifier for a :ref:`TypedDict ` +item or a :ref:`NamedTuple ` field. Such usage also generates +an error at runtime. + .. _`override`: ``@override`` @@ -97,8 +117,9 @@ annotated in ``__init__`` or other methods, rather than in the class:: (Originally specified by :pep:`698`.) When type checkers encounter a method decorated with ``@typing.override`` they -should treat it as a type error unless that method is overriding a compatible -method or attribute in some ancestor class. +should treat it as a type error unless that method is overriding a method or +attribute in some ancestor class, and the type of the overriding method is +:term:`assignable` to the type of the overridden method. .. code-block:: python diff --git a/docs/spec/concepts.rst b/docs/spec/concepts.rst index c6418c8b6..81fe481fe 100644 --- a/docs/spec/concepts.rst +++ b/docs/spec/concepts.rst @@ -3,6 +3,339 @@ Type system concepts ==================== +Static, dynamic, and gradual typing +----------------------------------- + +A **statically typed** programming language runs a type checker before running +a program. The program is required to be well typed according to the language's +type system. The type system assigns a type to all expressions in the language +and verifies that their uses obey the typing rules. Normally, a program that is +not well typed (i.e., one that contains a type error) will not run. Java and +C++ are examples of statically typed object-oriented languages. + +A **dynamically typed** programming language does not run a type checker before +running a program. Instead, it checks the types of values before performing +operations on them at runtime. This is not to say that the language is +"untyped". Values at runtime have a type and their uses obey typing rules. Not +every operation will be checked, but certain primitive operations in the +language such as attribute access or arithmetic are. Python is a +dynamically typed language. + +**Gradual typing** is a way to combine static and dynamic typing. +Type-annotated Python allows opting in to static type checking at a fine level +of granularity, so that some type errors can be caught statically, without +running the program. Variables, parameters, and returns can optionally be given +static type annotations. Even within the type of a single data structure, +static type checking is optional and granular. For example, a dictionary can be +annotated to enable static checking of the key type but only have dynamic +runtime checking of the value type. + +A **gradual** type system is one in which a special "unknown" or "dynamic" type +is used to describe names or expressions whose types are not known statically. +In Python, this type is spelled :ref:`Any`. Because :ref:`!Any` indicates a +statically unknown type, the static type checker can't check type correctness +of operations on expressions typed as :ref:`!Any`. These operations are still +dynamically checked, via the Python runtime's usual dynamic checking. + +The Python type system also uses ``...`` within :ref:`Callable` types and +within ``tuple[Any, ...]`` (see :ref:`tuples`) to indicate a statically unknown +component of a type. The detailed rules for these usages are discussed in their +respective sections of the specification. Collectively, along with :ref:`Any`, +these are :term:`gradual forms `. + +This specification describes a gradual type system for Python. + +Fully static and gradual types +------------------------------ + +We will refer to types that do not contain a :term:`gradual form` as a sub-part +as **fully static types**. + +A **gradual type** can be a fully static type, :ref:`Any` itself, or a type +that contains a gradual form as a sub-part. All Python types are gradual types; +fully static types are a subset. + +Fully static types +~~~~~~~~~~~~~~~~~~ + +A fully static type denotes a set of potential runtime values. For instance, +the fully static type ``object`` is the set of all Python objects. The fully +static type ``bool`` is the set of values ``{ True, False }``. The fully static +type ``str`` is the set of all Python strings; more precisely, the set of all +Python objects whose runtime type (``__class__`` attribute) is either ``str`` +or a class that inherits directly or indirectly from ``str``. A :ref:`Protocol +` denotes the set of all objects which share a certain set of +attributes and/or methods. + +If an object ``v`` is a member of the set of objects denoted by a fully static +type ``T``, we can say that ``v`` is a "member of" the type ``T``, or ``v`` +":term:`inhabits `" ``T``. + +Gradual types +~~~~~~~~~~~~~ + +:ref:`Any` represents an unknown static type. It denotes some unknown set of +runtime values. + +This may appear similar to the fully static type ``object``, which represents +the set of all Python objects, but it is quite different. + +If an expression has the type ``object``, a static type checker should ensure +that operations on the expression are valid for all Python objects, or else +emit a static type error. This allows very few operations! For example, if +``x`` is typed as ``object``, ``x.foo`` should be a static type error because +not all Python objects have an attribute ``foo``. + +An expression typed as :ref:`Any`, on the other hand, should be assumed to have +_some_ specific static type, but _which_ static type is not known. A static +type checker should not emit static type errors on an expression or statement +if :ref:`!Any` might represent a static type which would avoid the error. (This +is defined more precisely below, in terms of materialization and +assignability.) + +Similarly, a type such as ``tuple[int, Any]`` (see :ref:`tuples`) or ``int | +Any`` (see :ref:`union-types`) does not represent a single set of Python +objects; rather, it represents a (bounded) range of possible sets of values. + +In the same way that :ref:`Any` does not represent "the set of all Python +objects" but rather "an unknown set of objects", ``tuple[int, Any]`` does not +represent "the set of all length-two tuples whose first element is an integer". +That is a fully static type, spelled ``tuple[int, object]``. By contrast, +``tuple[int, Any]`` represents some unknown set of tuple values; it might be +the set of all tuples of two integers, or the set of all tuples of an integer +and a string, or some other set of tuple values. + +In practice, this difference is seen (for example) in the fact that we can +assign an expression of type ``tuple[int, Any]`` to a target typed as +``tuple[int, int]``, whereas assigning ``tuple[int, object]`` to ``tuple[int, +int]`` is a static type error. (Again, we formalize this distinction in the +below definitions of materialization and assignability.) + +In the same way that the fully static type ``object`` is the upper bound for +the possible sets of values represented by :ref:`Any`, the fully static type +``tuple[int, object]`` is the upper bound for the possible sets of values +represented by ``tuple[int, Any]``. + +The gradual guarantee +~~~~~~~~~~~~~~~~~~~~~ + +:ref:`Any` allows gradually adding static types to a dynamically typed program. +In a fully dynamically typed program, a static checker assigns the type +:ref:`!Any` to all expressions, and should emit no errors. Inferring static +types or adding type annotations to the program (making the program more +statically typed) may result in static type errors, if the program is not +correct or if the static types aren't able to fully represent the runtime +types. Removing type annotations (making the program more dynamic) should not +result in additional static type errors. This is often referred to as the +**gradual guarantee**. + +In Python's type system, we don't take the gradual guarantee as a strict +requirement, but it's a useful guideline. + +Subtype, supertype, and type equivalence +---------------------------------------- + +A fully static type ``B`` is a **subtype** of another fully static type ``A`` +if and only if the set of values represented by ``B`` is a subset of the set of +values represented by ``A``. Because the subset relation on sets is transitive +and reflexive, the subtype relation is also transitive (if ``C`` is a subtype +of ``B`` and ``B`` is a subtype of ``A``, then ``C`` is a subtype of ``A``) and +reflexive (``A`` is always a subtype of ``A``). + +The **supertype** relation is the inverse of subtype: ``A`` is a supertype of +``B`` if and only if ``B`` is a subtype of ``A``; or equivalently, if and only +if the set of values represented by ``A`` is a superset of the values +represented by ``B``. The supertype relation is also transitive and reflexive. + +We also define an **equivalence** relation on fully static types: the types +``A`` and ``B`` are equivalent (or "the same type") if and only if ``A`` is a +subtype of ``B`` and ``B`` is a subtype of ``A``. This means that the set of +values represented by ``A`` is both a superset and a subset of the values +represented by ``B``, meaning ``A`` and ``B`` must represent the same set of +values. + +We may describe a type ``B`` as "narrower" than a type ``A`` (or as a "proper +subtype" of ``A``) if ``B`` is a subtype of ``A`` and ``B`` is not equivalent +to ``A``. In the same scenario we can describe the type ``A`` as "wider" than +``B``, or a "proper supertype" of ``B``. + +Nominal and structural types +---------------------------- + +For a type such as ``str`` (or any other class), which describes the set of +values whose ``__class__`` is ``str`` or a direct or indirect subclass of it, +subtyping corresponds directly to subclassing. A subclass ``MyStr`` of ``str`` +is a subtype of ``str``, because ``MyStr`` represents a subset of the values +represented by ``str``. Such types can be called "nominal types" and this is +"nominal subtyping." + +Other types (e.g. :ref:`Protocols` and :ref:`TypedDict`) instead describe a set +of values by the types of their attributes and methods, or the types of their +dictionary keys and values. These are called "structural types". A structural +type may be a subtype of another type without any inheritance or subclassing +relationship, simply because it meets all the requirements of the supertype, +and perhaps adds more, thus representing a subset of the possible values of the +supertype. This is "structural subtyping". + +Although the means of specifying the set of values represented by the types +differs, the fundamental concepts are the same for both nominal and structural +types: a type represents a set of possible values and a subtype represents a +subset of those values. + +Materialization +--------------- + +Since :ref:`Any` represents an unknown static type, it does not represent any +known single set of values (it represents an unknown set of values). Thus it is +not in the domain of the subtype, supertype, or equivalence relations on static +types described above. + +To relate gradual types more generally, we define a **materialization** +relation. Materialization transforms a "more dynamic" type to a "more static" +type. Given a gradual type ``A``, if we replace zero or more occurrences of +``Any`` in ``A`` with some type (which can be different for each occurrence of +``Any``), the resulting gradual type ``B`` is a materialization of ``A``. (We +can also materialize a :ref:`Callable` type by replacing ``...`` with any type +signature, and materialize ``tuple[Any, ...]`` by replacing it with a +determinate-length tuple type.) + +For instance, ``tuple[int, str]`` (a fully static type) and ``tuple[Any, str]`` +(a gradual type) are both materializations of ``tuple[Any, Any]``. ``tuple[int, +str]`` is also a materialization of ``tuple[Any, str]``. + +If ``B`` is a materialization of ``A``, we can say that ``B`` is a "more +static" type than ``A``, and ``A`` is a "more dynamic" type than ``B``. + +The materialization relation is both transitive and reflexive, so it defines a +preorder on gradual types. + +.. _`consistent`: + +Consistency +----------- + +We define a **consistency** relation on gradual types, based on +materialization. + +A fully static type ``A`` is consistent with another fully static type ``B`` if +and only if they are the same type (``A`` is equivalent to ``B``). + +A gradual type ``A`` is consistent with a gradual type ``B``, and ``B`` is +consistent with ``A``, if and only if there exists some fully static type ``C`` +which is a materialization of both ``A`` and ``B``. + +:ref:`Any` is consistent with every type, and every type is consistent with +:ref:`!Any`. (This follows from the definitions of materialization and +consistency but is worth stating explicitly.) + +The consistency relation is not transitive. ``tuple[int, int]`` is consistent +with ``tuple[Any, int]``, and ``tuple[Any, int]`` is consistent with +``tuple[str, int]``, but ``tuple[int, int]`` is not consistent with +``tuple[str, int]``. + +The consistency relation is symmetric. If ``A`` is consistent with ``B``, ``B`` +is also consistent with ``A``. It is also reflexive: ``A`` is always consistent +with ``A``. + +.. _`assignable`: + +The assignable-to (or consistent subtyping) relation +---------------------------------------------------- + +Given the materialization relation and the subtyping relation, we can define +the **consistent subtype** relation over all types. A type ``B`` is a +consistent subtype of a type ``A`` if there exists a materialization ``A'`` of +``A`` and a materialization ``B'`` of ``B``, where ``A'`` and ``B'`` are both +fully static types, and ``B'`` is a subtype of ``A'``. + +Consistent subtyping defines "assignability" for Python. An expression can be +assigned to a variable (including passed as an argument or returned from a +function) if its type is a consistent subtype of the variable's type annotation +(respectively, parameter's type annotation or return type annotation). + +We can say that a type ``B`` is "assignable to" a type ``A`` if ``B`` is a +consistent subtype of ``A``. In this case we can also say that ``A`` is +"assignable from" ``B``. + +In the remainder of this specification, we will usually prefer the term +**assignable to** over "consistent subtype of". The two are synonymous, but +"assignable to" is shorter, and may communicate a clearer intuition to many +readers. + +For example, ``Any`` is :term:`assignable` to ``int``, because ``int`` is a +materialization of ``Any``, and ``int`` is a subtype of ``int``. The same +materialization also shows that ``int`` is assignable to ``Any``. + +The assignable-to relation is not generally symmetric, however. If ``B`` is a +subtype of ``A``, then ``tuple[Any, B]`` is assignable to ``tuple[int, A]``, +because ``tuple[Any, B]`` can materialize to ``tuple[int, B]``, which is a +subtype of ``tuple[int, A]``. But ``tuple[int, A]`` is not assignable to +``tuple[Any, B]``. + +For a gradual structural type, consistency and assignability are also +structural. For example, the structural type "all objects with an attribute +``x`` of type ``Any``" is consistent with (and assignable to) the structural +type "all objects with an attribute ``x`` of type ``int``". + +Summary of type relations +------------------------- + +The subtype, supertype, and equivalence relations establish a partial order on +fully static types. The analogous relations on gradual types (via +materialization) are "assignable-to" (or "consistent subtype"), +"assignable-from" (or "consistent supertype"), and "consistent with". We can +visualize this analogy in the following table: + +.. list-table:: + :header-rows: 1 + + * - Fully static types + - Gradual types + * - ``B`` is a :term:`subtype` of ``A`` + - ``B`` is :term:`assignable` to (or a consistent subtype of) ``A`` + * - ``A`` is a :term:`supertype` of ``B`` + - ``A`` is assignable from (or a consistent supertype of) ``B`` + * - ``B`` is :term:`equivalent` to ``A`` + - ``B`` is :term:`consistent` with ``A`` + +We can also define an **equivalence** relation on gradual types: the gradual +types ``A`` and ``B`` are equivalent (that is, the same gradual type, not +merely consistent with one another) if and only if all materializations of +``A`` are also materializations of ``B``, and all materializations of ``B`` +are also materializations of ``A``. + +Attributes and methods +---------------------- + +In Python, we can do more with objects at runtime than just assign them to +names, pass them to functions, or return them from functions. We can also +get/set attributes and call methods. + +In the Python data model, the operations that can be performed on a value all +desugar to method calls. For example, ``a + b`` is (roughly, eliding some +details) syntactic sugar for either ``type(a).__add__(a, b)`` or +``type(b).__radd__(b, a)``. + +For a static type checker, accessing ``a.foo`` is a type error unless all +possible objects in the set represented by the type of ``a`` have the ``foo`` +attribute. (We consider an implementation of ``__getattr__`` to be a getter for +all attribute names, and similarly for ``__setattr__`` and ``__delattr__``. +There are more `complexities +`_; +a full specification of attribute access belongs in its own chapter.) + +If all objects in the set represented by the fully static type ``A`` have a +``foo`` attribute, we can say that the type ``A`` has the ``foo`` attribute. + +If the type ``A`` of ``a`` in ``a.foo`` is a gradual type, it may not represent +a single set of objects. In this case, ``a.foo`` is a type error if and only if +there does not exist any materialization of ``A`` which has the ``foo`` +attribute. + +Equivalently, ``a.foo`` is a type error unless the type of ``a`` is assignable +to a type that has the ``foo`` attribute. + + .. _`union-types`: Union types @@ -18,17 +351,44 @@ Example:: e = [e] ... -A type factored by ``T1 | T2 | ...`` is a supertype -of all types ``T1``, ``T2``, etc., so that a value that -is a member of one of these types is acceptable for an argument -annotated by ``T1 | T2 | ...``. +A fully static union type ``T1 | T2``, where ``T1`` and ``T2`` are fully static +types, represents the set of values formed by the union of the sets of values +represented by ``T1`` and ``T2``, respectively. Thus, by the definition of the +supertype relation, the union ``T1 | T2`` is a supertype of both ``T1`` and +``T2``, and ``T1`` and ``T2`` are both subtypes of ``T1 | T2``. -One common case of union types are *optional* types. By default, -``None`` is an invalid value for any type, unless a default value of -``None`` has been provided in the function definition. Examples:: +A gradual union type ``S1 | S2``, where ``S1`` and ``S2`` are gradual types, +represents all possible sets of values that could be formed by union of the +possible sets of values represented by materializations of ``S1`` and ``S2``, +respectively. + +For any materialization of ``S1`` to ``T1`` and ``S2`` to ``T2``, ``S1 | S2`` +can likewise be materialized to ``T1 | T2``. Thus, the gradual types ``S1`` and +``S2`` are both assignable to the gradual union type ``S1 | S2``. + +If ``B`` is a subtype of ``A``, ``B | A`` is equivalent to ``A``. + +This rule applies only to subtypes, not assignable-to. The union ``T | Any`` is +not reducible to a simpler form. It represents an unknown static type with +lower bound ``T``. That is, it represents an unknown set of objects which may +be as large as ``object``, or as small as ``T``, but no smaller. + +Equivalent gradual types can, however, be simplified from unions; e.g. +``list[Any] | list[Any]`` is equivalent to ``list[Any]``. Similarly, the union +``Any | Any`` can be simplified to ``Any``: the union of two unknown sets of +objects is an unknown set of objects. + +Union with None +~~~~~~~~~~~~~~~ + +One common case of union types are *optional* types, which are unions with +``None``. Example:: def handle_employee(e: Employee | None) -> None: ... +Either the type ``Employee`` or the type of ``None`` are assignable to the +union ``Employee | None``. + A past version of this specification allowed type checkers to assume an optional type when the default value is ``None``, as in this code:: @@ -42,7 +402,7 @@ This is no longer the recommended behavior. Type checkers should move towards requiring the optional type to be made explicit. Support for singleton types in unions -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A singleton instance is frequently used to mark some special condition, in particular in situations where ``None`` is also a valid value @@ -97,3 +457,12 @@ one value:: else: # response can be only str, all other possible values exhausted return 'PROCESSED: ' + response + +References +---------- + +The concepts presented here are derived from the research literature in gradual +typing. See e.g.: + +* `Giuseppe Castagna, Victor Lanvin, Tommaso Petrucciani, and Jeremy G. Siek. 2019. Gradual Typing: A New Perspective. `_ Proc. ACM Program. Lang. 3, POPL, Article 16 (January 2019), 112 pages +* `Victor Lanvin. A semantic foundation for gradual set-theoretic types. `_ Computer science. Université Paris Cité, 2021. English. NNT : 2021UNIP7159. tel-03853222 diff --git a/docs/spec/constructors.rst b/docs/spec/constructors.rst index 0eb34b84d..c95ecc488 100644 --- a/docs/spec/constructors.rst +++ b/docs/spec/constructors.rst @@ -105,11 +105,11 @@ unrelated class. If the evaluated return type of ``__new__`` is not the class being constructed (or a subclass thereof), a type checker should assume that the ``__init__`` -method will not be called. This is consistent with the runtime behavior of -the ``type.__call__`` method. If the ``__new__`` method return type is -a union with one or more subtypes that are not instances of the class being -constructed (or a subclass thereof), a type checker should likewise assume that -the ``__init__`` method will not be called. +method will not be called. This is consistent with the runtime behavior of the +``type.__call__`` method. If the ``__new__`` method return type is a union with +one or more members that are not the class being constructed (or a subclass +thereof), a type checker should likewise assume that the ``__init__`` method +will not be called. :: @@ -318,16 +318,14 @@ these method evaluations, they should take on their default values. :: - T1 = TypeVar("T1") - T2 = TypeVar("T2") - T3 = TypeVar("T3", default=str) + from typing import Any, Self, assert_type - class MyClass1(Generic[T1, T2]): + class MyClass1[T1, T2]: def __new__(cls, x: T1) -> Self: ... assert_type(MyClass1(1), MyClass1[int, Any]) - class MyClass2(Generic[T1, T3]): + class MyClass2[T1, T3 = str]: def __new__(cls, x: T1) -> Self: ... assert_type(MyClass2(1), MyClass2[int, str]) @@ -337,7 +335,7 @@ Consistency of ``__new__`` and ``__init__`` ------------------------------------------- Type checkers may optionally validate that the ``__new__`` and ``__init__`` -methods for a class have consistent signatures. +methods for a class have :term:`consistent` signatures. :: @@ -353,7 +351,8 @@ methods for a class have consistent signatures. Converting a Constructor to Callable ------------------------------------ -Class objects are callable, which means they are compatible with callable types. +Class objects are callable, which means the type of a class object can be +:term:`assignable` to a callable type. :: diff --git a/docs/spec/dataclasses.rst b/docs/spec/dataclasses.rst index d3229a5d5..3d9648923 100644 --- a/docs/spec/dataclasses.rst +++ b/docs/spec/dataclasses.rst @@ -72,12 +72,10 @@ Decorator function example .. code-block:: python - _T = TypeVar("_T") - # The ``create_model`` decorator is defined by a library. # This could be in a type stub or inline. @typing.dataclass_transform() - def create_model(cls: Type[_T]) -> Type[_T]: + def create_model[T](cls: type[T]) -> type[T]: cls.__init__ = ... cls.__eq__ = ... cls.__ne__ = ... @@ -124,6 +122,19 @@ Metaclass example id: int name: str +Conditional fields +"""""""""""""""""" + +Dataclass fields may be conditional, via checks of the same +:ref:`statically-known conditions` +that a type-checker understands elsewhere, such as Python version:: + + @dataclass + class Person: + name: str + if sys.version_info >= (3, 14): + age: int + Decorator function and class/metaclass parameters ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -148,7 +159,9 @@ customization of default behaviors: .. code-block:: python - _T = TypeVar("_T") + class _IdentityCallable(Protocol): + def __call__[T](self, arg: T, /) -> T: + ... def dataclass_transform( *, @@ -158,7 +171,7 @@ customization of default behaviors: frozen_default: bool = False, field_specifiers: tuple[type | Callable[..., Any], ...] = (), **kwargs: Any, - ) -> Callable[[_T], _T]: ... + ) -> _IdentityCallable: ... * ``eq_default`` indicates whether the ``eq`` parameter is assumed to be True or False if it is omitted by the caller. If not specified, @@ -192,11 +205,6 @@ customization of default behaviors: in ``typing.py``. Type checkers should report errors for any unrecognized parameters. -In the future, we may add additional parameters to -``dataclass_transform`` as needed to support common behaviors in user -code. These additions will be made after reaching consensus on -typing-sig rather than via additional PEPs. - The following sections provide additional examples showing how these parameters are used. @@ -365,6 +373,8 @@ positional and may use other names. * ``alias`` is an optional str parameter that provides an alternative name for the field. This alternative name is used in the synthesized ``__init__`` method. +* ``converter`` is an optional parameter that specifies a + callable used to convert values when assigning to the field. It is an error to specify more than one of ``default``, ``default_factory`` and ``factory``. @@ -488,7 +498,7 @@ This includes, but is not limited to, the following semantics: wheel_count: int * Field ordering and inheritance is assumed to follow the rules - specified in `the Python docs `. This includes the effects of + specified in `the Python docs `__. This includes the effects of overrides (redefining a field in a child class that has already been defined in a parent class). @@ -516,8 +526,9 @@ This includes, but is not limited to, the following semantics: * ClassVar attributes are not considered dataclass fields and are `ignored by dataclass mechanisms `_. -* A dataclass field may be annotated with ``Final[...]``. For example, ``x: - Final[int]`` in a dataclass body specifies a dataclass field ``x``, which +* A dataclass field may be annotated with an :term:`explicitly typed Final` + :term:`type qualifier`. For example, ``x: Final[int]`` + in a dataclass body specifies a dataclass field ``x``, which will be initialized in the generated ``__init__`` and cannot be assigned to thereafter. A ``Final`` dataclass field initialized in the class body is not a class attribute unless explicitly annotated with ``ClassVar``. For example, @@ -526,6 +537,52 @@ This includes, but is not limited to, the following semantics: dataclass must be explicitly annotated as e.g. ``x: ClassVar[Final[int]] = 3``. +Converters +^^^^^^^^^^ + +The ``converter`` parameter can be specified in a field definition to provide a callable +used to convert values when assigning to the associated attribute. This feature allows for automatic type +conversion and validation during attribute assignment. + +Converter behavior: + +* The converter is used for all attribute assignment, including assignment + of default values, assignment in synthesized ``__init__`` methods + and direct attribute setting (e.g., ``obj.attr = value``). +* The converter is not used when reading attributes, as the attributes should already have been converted. + +Typing rules for converters: + +* The ``converter`` must be a callable that must accept a single positional argument + (but may accept other optional arguments, which are ignored for typing purposes). +* The type of the first positional parameter provides the type of the synthesized ``__init__`` parameter + for the field. +* The return type of the callable must be assignable to the field's declared type. +* If ``default`` or ``default_factory`` are provided, the type of the default value should be + assignable to the first positional parameter of the ``converter``. + +Example usage: + +.. code-block:: python + + def str_or_none(x: Any) -> str | None: + return str(x) if x is not None else None + + @custom_dataclass + class Example: + int_field: int = custom_field(converter=int) + str_field: str | None = custom_field(converter=str_or_none) + path_field: pathlib.Path = custom_field( + converter=pathlib.Path, + default="default/path.txt" + ) + + # Usage + example = Example("123", None, "some/path") + # example.int_field == 123 + # example.str_field == None + # example.path_field == pathlib.Path("some/path") + Undefined behavior ^^^^^^^^^^^^^^^^^^ diff --git a/docs/spec/directives.rst b/docs/spec/directives.rst index 01c0f6bdb..488d71a26 100644 --- a/docs/spec/directives.rst +++ b/docs/spec/directives.rst @@ -9,7 +9,8 @@ Type checker directives ----------------- The function ``typing.assert_type(val, typ)`` allows users to -ask a static type checker to confirm that *val* has an inferred type of *typ*. +ask a static type checker to confirm that the inferred type of *val* +is :term:`equivalent` to *typ*. When a type checker encounters a call to ``assert_type()``, it should emit an error if the value is not of the specified type:: @@ -18,6 +19,17 @@ should emit an error if the value is not of the specified type:: assert_type(name, str) # OK, inferred type of `name` is `str` assert_type(name, int) # type checker error +If the two types are :term:`equivalent` but syntactically different, +the type checker may reject the ``assert_type()`` call:: + + from typing import assert_type, Literal + + def greet(name: str) -> None: + assert_type(name, str | Literal["spam"]) # type checker may error + +Type checkers should aim to minimize cases where they reject +``assert_type()`` calls that use equivalent types. + The second argument must be a valid :term:`type expression`. .. _`reveal-type`: @@ -61,6 +73,15 @@ other comments and linting markers: # type: ignore # +The form ``# type: ignore[...]`` may be used to suppress only type errors with a +given error code, though support for this is optional and may vary by type checker: + +- Given ``# type: ignore[my_code1]``, a type checker may ignore the error code + ``my_code1`` and choose to treat this form as equivalent to ``# type: ignore``. +- Alternatively, given ``# type: ignore[my_code1]`` a type checker may suppress the + error only if the error cause matches the error code ``my_code1``. +- A bare ``# type: ignore`` must always suppress all type errors. + .. _`cast`: ``cast()`` @@ -86,12 +107,6 @@ At runtime a cast always returns the expression unchanged -- it does not check the type, and it does not convert or coerce the value. -Casts differ from type comments (see the previous section). When using -a type comment, the type checker should still verify that the inferred -type is consistent with the stated type. When using a cast, the type -checker should blindly believe the programmer. Also, casts can be used -in expressions, while type comments only apply to assignments. - .. _`if-type-checking`: ``TYPE_CHECKING`` @@ -134,6 +149,8 @@ and return type annotations and treat the function as if it were unannotated. The behavior for the ``no_type_check`` decorator when applied to a class is left undefined by the typing spec at this time. +.. _`version-and-platform-checks`: + Version and platform checking ----------------------------- @@ -174,7 +191,8 @@ The decorator takes the following arguments: * A required positional-only argument representing the deprecation message. * Two keyword-only arguments, ``category`` and ``stacklevel``, controlling - runtime behavior (see under "Runtime behavior" below). + runtime behavior. These are not relevant to type checker behavior so they are + not further described in this specification. The positional-only argument is of type ``str`` and contains a message that should be shown by the type checker when it encounters a usage of the decorated object. @@ -285,3 +303,77 @@ deprecated functionality in their CI pipeline. Therefore, it is recommended that type checkers provide configuration options that cover both use cases. As with any other type checker error, it is also possible to ignore deprecations using ``# type: ignore`` comments. + +.. _`disjoint-base`: + +``@disjoint_base`` +------------------ + +(Originally specified in :pep:`800`.) + +The ``@typing.disjoint_base`` decorator may be used to mark a nominal class as +a disjoint base. It may only be used on nominal classes, including ``NamedTuple`` +definitions; it is a type checker error to use the decorator on a function, +``TypedDict`` definition, or ``Protocol`` definition. + +We define two properties on (nominal) classes: a class may or may not *be* a +disjoint base, and every class must *have* a valid disjoint base. + +A nominal class is a disjoint base if it is decorated with ``@typing.disjoint_base``, +or if it contains a non-empty ``__slots__`` definition. +This includes classes that have ``__slots__`` because of the ``@dataclass(slots=True)`` decorator or +because of the use of the ``dataclass_transform`` mechanism to add slots. +The universal base class, ``object``, is also a disjoint base. + +To determine a class's disjoint base, we look at all of its base classes to +determine a set of candidate disjoint bases. For each base +that is itself a disjoint base, the candidate is the base itself; otherwise, +it is the base's disjoint base. If the candidate set contains +a single disjoint base, that is the class's disjoint base. If there are multiple +candidates, but one of them is a subclass of all other candidates, +that class is the disjoint base. If no such candidate exists, the class does not +have a valid disjoint base, and therefore cannot exist. + +Type checkers must check for a valid disjoint base when checking class definitions, +and emit a diagnostic if they encounter a class +definition that lacks a valid disjoint base. Type checkers may also use the disjoint +base mechanism to determine whether types are disjoint, +for example when checking whether a type narrowing construct like ``isinstance()`` +results in an unreachable branch. + +Example:: + + from typing import disjoint_base, assert_never + + @disjoint_base + class Disjoint1: + pass + + @disjoint_base + class Disjoint2: + pass + + @disjoint_base + class DisjointChild(Disjoint1): + pass + + class C1: # disjoint base is `object` + pass + + # OK: candidate disjoint bases are `Disjoint1` and `object`, and `Disjoint1` is a subclass of `object`. + class C2(Disjoint1, C1): # disjoint base is `Disjoint1` + pass + + # OK: candidate disjoint bases are `DisjointChild` and `Disjoint1`, and `DisjointChild` is a subclass of `Disjoint1`. + class C3(DisjointChild, Disjoint1): # disjoint base is `DisjointChild` + pass + + # error: candidate disjoint bases are `Disjoint1` and `Disjoint2`, but neither is a subclass of the other + class C4(Disjoint1, Disjoint2): + pass + + def narrower(obj: Disjoint1) -> None: + if isinstance(obj, Disjoint2): + assert_never(obj) # OK: child class of `Disjoint1` and `Disjoint2` cannot exist + if isinstance(obj, C1): + reveal_type(obj) # Shows a non-empty type, e.g. `Disjoint1 & C1` diff --git a/docs/spec/distributing.rst b/docs/spec/distributing.rst index 9f92c3ad9..93edf5666 100644 --- a/docs/spec/distributing.rst +++ b/docs/spec/distributing.rst @@ -8,72 +8,166 @@ Distributing type information Stub files ---------- -Stub files are files containing type hints that are only for use by -the type checker, not at runtime. There are several use cases for -stub files: +(Originally specified in :pep:`484`.) + +*Stub files*, also called *type stubs*, provide type information for untyped +Python packages and modules. Stub files serve multiple purposes: + +* They are the only way to add type information to extension modules. +* They can provide type information for packages that do not wish to + add them inline. +* They can be distributed separately from the package or module that they + provide types for. The latter is referred to as the *implementation*. + This allows stubs to be developed at a different pace or by different + authors, which is especially useful when adding type annotations to + existing packages. +* They can act as documentation, succinctly explaining the external + API of a package, without including implementation details or private + members. + +Stub files use a subset of the constructs used in Python source files, as +described in :ref:`stub-file-supported-constructs` below. Type checkers should +parse a stub that uses only such constructs without error and not interpret any +construct in a manner contradictory to this specification. However, type +checkers are not required to implement checks for all of these constructs and +can elect to ignore unsupported ones. Additionally, type checkers can support +constructs not described here. + +If a stub file is found for a module, the type checker should not read the +corresponding "real" module. See :ref:`mro` for more information. + +.. _stub-file-syntax: + +Syntax +^^^^^^ + +Stub files are syntactically valid Python files with a ``.pyi`` suffix. They +should be parseable (e.g., with :py:func:`ast.parse`) in all Python versions +that are supported by the implementation and that are still supported +by the CPython project. For example, defining a type alias using the +``type`` keyword is only accepted by the Python parser in Python 3.12 and later, +so stubs supporting Python 3.11 or earlier versions should not use this syntax. +This allows type checkers implemented in Python to parse stub files using +functionality from the standard library. +Type checkers may choose to support syntactic features from newer Python versions +in stub files, but stubs that rely on such features may not be portable to all +type checkers. Type checkers may also choose to support Python versions that +are no longer supported by CPython; if so, they cannot rely on standard library +functionality to parse stub files. + +Type checkers should evaluate all :term:`annotation expressions ` as if they are quoted. +Consequently, forward references do not need to be quoted, and type system +features that do not depend on Python syntax changes are supported in stubs regardless +of the Python version supported. For example, the use of the ``|`` operator +to create unions (``X | Y``) was introduced in Python 3.10, but may be used +even in stubs that support Python 3.9 and older versions. + +.. _stub-file-supported-constructs: + +Supported Constructs +^^^^^^^^^^^^^^^^^^^^ + +Type checkers should fully support these constructs: + +* All features from the ``typing`` module of the latest released Python version + that use :ref:`supported syntax ` +* Comments, including type declaration (``# type: X``) and error suppression + (``# type: ignore``) comments +* Import statements, including the standard :ref:`import-conventions` and cyclic + imports +* Aliases, including type aliases, at both the module and class level +* :ref:`Simple version and platform checks ` + +The constructs in the following subsections may be supported in a more limited +fashion, as described below. + +Value Expressions +""""""""""""""""" + +In locations where value expressions can appear, such as the right-hand side of +assignment statements and function parameter defaults, type checkers should +support the following expressions: + +* The ellipsis literal, ``...``, which can stand in for any value +* Any value that is a + :ref:`legal parameter for typing.Literal ` +* Floating point literals, such as ``3.14`` +* Complex literals, such as ``1 + 2j`` -* Extension modules +Module Level Attributes +""""""""""""""""""""""" -* Third-party modules whose authors have not yet added type hints +Type checkers should support module-level variable annotations, with and without +assignments:: -* Standard library modules for which type hints have not yet been - written + x: int + x: int = 0 + x = 0 # type: int + x = ... # type: int -* Modules that must be compatible with Python 2 and 3 +The :ref:`Literal shortcut using a bare Final ` +should be supported:: -* Modules that use annotations for other purposes + x: Final = 0 # type is Literal[0] -Stub files have the same syntax as regular Python modules. There is one -feature of the ``typing`` module that is different in stub files: -the ``@overload`` decorator described below. +When the type of a variable is omitted or disagrees from the assigned value, +type checker behavior is undefined:: -The type checker should only check function signatures in stub files; -It is recommended that function bodies in stub files just be a single -ellipsis (``...``). + x = 0 # behavior undefined + x: Final = ... # behavior undefined + x: int = "" # behavior undefined -The type checker should have a configurable search path for stub files. -If a stub file is found the type checker should not read the -corresponding "real" module. +Classes +""""""" -While stub files are syntactically valid Python modules, they use the -``.pyi`` extension to make it possible to maintain stub files in the -same directory as the corresponding real module. This also reinforces -the notion that no runtime behavior should be expected of stub files. +Class definition syntax follows general Python syntax, but type checkers +are expected to understand only the following constructs in class bodies: -Additional notes on stub files: +* The ellipsis literal ``...`` is used for empty class bodies. Using ``pass`` in + class bodies is undefined. +* Instance attributes follow the same rules as module level attributes + (see above). +* Method definitions (see below) and properties. +* Aliases. +* Inner class definitions. -* Modules and variables imported into the stub are not considered - exported from the stub unless the import uses the ``import ... as - ...`` form or the equivalent ``from ... import ... as ...`` form. - (*UPDATE:* To clarify, the intention here is that only names - imported using the form ``X as X`` will be exported, i.e. the name - before and after ``as`` must be the same.) +Yes:: -* However, as an exception to the previous bullet, all objects - imported into a stub using ``from ... import *`` are considered - exported. (This makes it easier to re-export all objects from a - given module that may vary by Python version.) + class Simple: ... -* Just like in `normal Python files `_, submodules - automatically become exported attributes of their parent module - when imported. For example, if the ``spam`` package has the - following directory structure:: + class Complex(Base): + read_write: int + @property + def read_only(self) -> int: ... + def do_stuff(self, y: str) -> None: ... + doStuff = do_stuff + IntList: TypeAlias = list[int] + class Inner: ... - spam/ - __init__.pyi - ham.pyi +Functions and Methods +""""""""""""""""""""" + +Function and method definition follows general Python syntax. Using a function +or method body other than the ellipsis literal is undefined:: - where ``__init__.pyi`` contains a line such as ``from . import ham`` - or ``from .ham import Ham``, then ``ham`` is an exported attribute - of ``spam``. + def foo(): ... # compatible + def bar(): pass # behavior undefined -* Stub files may be incomplete. To make type checkers aware of this, the file - can contain the following code:: +.. _stub-decorators: - def __getattr__(name) -> Any: ... +Decorators +"""""""""" - Any identifier not defined in the stub is therefore assumed to be of type - ``Any``. +Type checkers are expected to understand the effects of all decorators defined +in the ``typing`` module, plus these additional ones: + + * ``classmethod`` + * ``staticmethod`` + * ``property`` (including ``.setter`` and ``.deleter``) + * ``abc.abstractmethod`` + * ``dataclasses.dataclass`` + * ``warnings.deprecated`` + * functions decorated with ``@typing.dataclass_transform`` The Typeshed Project ^^^^^^^^^^^^^^^^^^^^ @@ -85,9 +179,13 @@ and type stubs for third-party libraries that don't ship their own type informat stubs collected there are decided separately and described in the project's documentation. +.. _packaging-typed-libraries: + Type information in libraries ----------------------------- +(Originally specified in :pep:`561`.) + There are several motivations and methods of supporting typing in a package. This specification recognizes three types of packages that users of typing wish to create: @@ -193,8 +291,9 @@ Partial Stub Packages Many stub packages will only have part of the type interface for libraries completed, especially initially. For the benefit of type checking and code editors, packages can be "partial". This means modules not found in the stub -package SHOULD be searched for in part four of the module resolution -order below, namely :term:`inline` packages. +package SHOULD be searched for in parts five and six of the module resolution +order below, namely :term:`inline` packages and any third-party stubs the type +checker chooses to vendor. Type checkers should merge the stub package and runtime package directories. This can be thought of as the functional equivalent of copying the @@ -229,19 +328,27 @@ resolve modules containing type information: 2. User code - the files the type checker is running on. -3. :term:`Stub ` packages - these packages SHOULD supersede any installed inline +3. Typeshed stubs for the standard library. These will usually be vendored by + type checkers, but type checkers SHOULD provide an option for users to + provide a path to a directory containing a custom or modified version of + typeshed; if this option is provided, type checkers SHOULD use this as the + canonical source for standard-library types in this step. + +4. :term:`Stub ` packages - these packages SHOULD supersede any installed inline package. They can be found in directories named ``foopkg-stubs`` for package ``foopkg``. -4. Packages with a ``py.typed`` marker file - if there is nothing overriding +5. Packages with a ``py.typed`` marker file - if there is nothing overriding the installed package, *and* it opts into type checking, the types bundled with the package SHOULD be used (be they in ``.pyi`` type stub files or inline in ``.py`` files). -5. Typeshed - only for modules in the standard library. +6. If the type checker chooses to additionally vendor any third-party stubs + (from typeshed or elsewhere), these SHOULD come last in the module + resolution order. If typecheckers identify a stub-only namespace package without the desired module -in step 3, they should continue to step 4/5. Typecheckers should identify namespace packages +in step 4, they should continue to step 5/6. Typecheckers should identify namespace packages by the absence of ``__init__.pyi``. This allows different subpackages to independently opt for inline vs stub-only. @@ -251,3 +358,60 @@ of that Python version. This can be queried e.g. ``pythonX.Y -c 'import site; print(site.getsitepackages())'``. It is also recommended that the type checker allow for the user to point to a particular Python binary, in case it is not in the path. + +.. _library-interface: + +Library interface (public and private symbols) +---------------------------------------------- + +If a ``py.typed`` module is present, a type checker will treat all modules +within that package (i.e. all files that end in ``.py`` or ``.pyi``) as +importable unless the file name begins with an underscore. These modules +comprise the supported interface for the library. + +Each module exposes a set of symbols. Some of these symbols are +considered "private” — implementation details that are not part of the +library’s interface. Type checkers can use the following rules +to determine which symbols are visible outside of the package. + +- Symbols whose names begin with an underscore (but are not dunder + names) are considered private. +- Imported symbols are considered private by default. A fixed set of + :ref:`import forms ` re-export imported symbols. +- A module can expose an ``__all__`` symbol at the module level that + provides a list of names that are considered part of the interface. + This overrides all other rules above, allowing imported symbols or + symbols whose names begin with an underscore to be included in the + interface. +- Local variables within a function (including nested functions) are + always considered private. + +The following idioms are supported for defining the values contained +within ``__all__``. These restrictions allow type checkers to statically +determine the value of ``__all__``. + +- ``__all__ = ('a', 'b')`` +- ``__all__ = ['a', 'b']`` +- ``__all__ += ['a', 'b']`` +- ``__all__ += submodule.__all__`` +- ``__all__.extend(['a', 'b'])`` +- ``__all__.extend(submodule.__all__)`` +- ``__all__.append('a')`` +- ``__all__.remove('a')`` + +.. _import-conventions: + +Import Conventions +------------------ + +By convention, certain import forms indicate to type checkers that an imported +symbol is re-exported and should be considered part of the importing module's +public interface. All other imported symbols are considered private by default. + +The following import forms re-export symbols: + +* ``import X as X`` (a redundant module alias): re-exports ``X``. +* ``from Y import X as X`` (a redundant symbol alias): re-exports ``X``. +* ``from Y import *``: if ``Y`` defines a module-level ``__all__`` list, + re-exports all names in ``__all__``; otherwise, re-exports all public symbols + in ``Y``'s global scope. diff --git a/docs/spec/enums.rst b/docs/spec/enums.rst new file mode 100644 index 000000000..ecb283d55 --- /dev/null +++ b/docs/spec/enums.rst @@ -0,0 +1,373 @@ +Enumerations +============ + +The ``enum.Enum`` class behaves differently from other Python classes in several +ways that require special-case handling in type checkers. This section discusses +the Enum behaviors that should be supported by type checkers and others which +may be supported optionally. It is recommended that library and type stub +authors avoid using optional behaviors because these may not be supported +by some type checkers. + + +Enum Definition +--------------- + +Enum classes can be defined using a "class syntax" or a "function syntax". +The function syntax offers several ways to specify enum members: names passed +as individual arguments, a list or tuple of names, a string of +comma-delimited or space-delimited names, a list or tuple of tuples that contain +name/value pairs, and a dictionary of name/value items. + +Type checkers should support the class syntax, but the function syntax (in +its various forms) is optional:: + + class Color1(Enum): # Supported + RED = 1 + GREEN = 2 + BLUE = 3 + + Color2 = Enum('Color2', 'RED', 'GREEN', 'BLUE') # Optional + Color3 = Enum('Color3', ['RED', 'GREEN', 'BLUE']) # Optional + Color4 = Enum('Color4', ('RED', 'GREEN', 'BLUE')) # Optional + Color5 = Enum('Color5', 'RED, GREEN, BLUE') # Optional + Color6 = Enum('Color6', 'RED GREEN BLUE') # Optional + Color7 = Enum('Color7', [('RED', 1), ('GREEN', 2), ('BLUE', 3)]) # Optional + Color8 = Enum('Color8', (('RED', 1), ('GREEN', 2), ('BLUE', 3))) # Optional + Color9 = Enum('Color9', {'RED': 1, 'GREEN': 2, 'BLUE': 3}) # Optional + +Enum classes can also be defined using a subclass of ``enum.Enum`` or any class +that uses ``enum.EnumType`` (or a subclass thereof) as a metaclass. Note that +``enum.EnumType`` was named ``enum.EnumMeta`` prior to Python 3.11. Type +checkers should treat such classes as enums:: + + class CustomEnum1(Enum): + pass + + class Color7(CustomEnum1): # Supported + RED = 1 + GREEN = 2 + BLUE = 3 + + class CustomEnumType(EnumType): + pass + + class CustomEnum2(metaclass=CustomEnumType): + pass + + class Color8(CustomEnum2): # Supported + RED = 1 + GREEN = 2 + BLUE = 3 + +Enum members may be conditional, via checks of the same +:ref:`statically-known conditions` +that a type-checker understands elsewhere, such as Python version:: + + class Color(Enum): + RED = 1 + if sys.version_info >= (3, 14): + BLUE = 2 + + +Enum Behaviors +-------------- + +Enum classes are iterable and indexable, and they can be called with a value +to look up the enum member with that value. Type checkers should support these +behaviors:: + + class Color(Enum): + RED = 1 + GREEN = 2 + BLUE = 3 + + for color in Color: + reveal_type(color) # Revealed type is 'Color' + + reveal_type(Color["RED"]) # Revealed type is 'Literal[Color.RED]' (or 'Color') + reveal_type(Color(3)) # Revealed type is 'Literal[Color.BLUE]' (or 'Color') + +Unlike most Python classes, calling an enum class does not invoke its constructor. +Instead, the call performs a value-based lookup of an enum member. + +An Enum class with one or more defined members cannot be subclassed. They are +implicitly "final". Type checkers should enforce this:: + + class EnumWithNoMembers(Enum): + pass + + class Shape(EnumWithNoMembers): # OK (because no members are defined) + SQUARE = 1 + CIRCLE = 2 + + class ExtendedShape(Shape): # Type checker error: Shape is implicitly final + TRIANGLE = 3 + + +Defining Members +---------------- + +When using the "class syntax", enum classes can define both members and +other (non-member) attributes. The ``EnumType`` metaclass applies a set +of rules to distinguish between members and non-members. Type checkers +should honor the most common of these rules. The lesser-used rules are +optional. Some of these rules may be impossible to evaluate and enforce +statically in cases where dynamic values are used. + +* If an attribute is defined in the class body with a type annotation but + with no assigned value, a type checker should assume this is a non-member + attribute:: + + class Pet(Enum): + genus: str # Non-member attribute + species: str # Non-member attribute + + CAT = 1 # Member attribute + DOG = 2 # Member attribute + + Within a type stub, members can be defined using the actual runtime values, + or a placeholder of ``...`` can be used:: + + class Pet(Enum): + genus: str # Non-member attribute + species: str # Non-member attribute + + CAT = 1 # Member attribute with known value and type + DOG = cast(int, ...) # Member attribute with unknown value and known type + BIRD = ... # Member attribute with unknown value and type + +* Members defined within an enum class should not include explicit type + annotations. Type checkers should infer a literal type for all members. + A type checker should report an error if a type annotation is used + for an enum member because this type will be incorrect and misleading + to readers of the code:: + + class Pet(Enum): + CAT = 1 # OK + DOG: int = 2 # Type checker error + +* Methods, callables, descriptors (including properties), and nested classes + that are defined in the class are not treated as enum members by the + ``EnumType`` metaclass and should likewise not be treated as enum members by + a type checker:: + + def identity(x): return x + + class Pet(Enum): + CAT = 1 # Member attribute + DOG = 2 # Member attribute + + converter = lambda x: str(x) # Non-member attribute + transform = identity # Non-member attribute + + @property + def species(self) -> str: # Non-member property + return "mammal" + + def speak(self) -> None: # Non-member method + print("meow" if self is Pet.CAT else "woof") + + class Nested: ... # Non-member nested class + +* An attribute that is assigned the value of another member of the same enum + is not a member itself. Instead, it is an alias for the first member:: + + class TrafficLight(Enum): + RED = 1 + GREEN = 2 + YELLOW = 3 + + AMBER = YELLOW # Alias for YELLOW + + reveal_type(TrafficLight.AMBER) # Revealed type is Literal[TrafficLight.YELLOW] + +* If using Python 3.11 or newer, the ``enum.member`` and ``enum.nonmember`` + classes can be used to unambiguously distinguish members from non-members. + Type checkers should support these classes:: + + class Example(Enum): + a = member(1) # Member attribute + b = nonmember(2) # Non-member attribute + + @member + def c(self) -> None: # Member method + pass + + reveal_type(Example.a) # Revealed type is Literal[Example.a] + reveal_type(Example.b) # Revealed type is int or Literal[2] + reveal_type(Example.c) # Revealed type is Literal[Example.c] + +* An attribute with a private name (beginning with, but not ending in, a double + underscore) is treated as a non-member:: + + class Example(Enum): + A = 1 # Member attribute + __B = 2 # Non-member attribute + + reveal_type(Example.A) # Revealed type is Literal[Example.A] + reveal_type(Example.__B) # Type Error: Private name is mangled + +* An enum class can define a class symbol named ``_ignore_``. This can be a list + of names or a string containing a space-delimited list of names that are + deleted from the enum class at runtime. Type checkers may support this + mechanism:: + + class Pet(Enum): + _ignore_ = "DOG FISH" + CAT = 1 # Member attribute + DOG = 2 # temporary variable, will be removed from the final enum class + FISH = 3 # temporary variable, will be removed from the final enum class + + +Member Names +------------ + +All enum member objects have an attribute ``_name_`` that contains the member's +name. They also have a property ``name`` that returns the same name. Type +checkers may infer a literal type for the name of a member:: + + class Color(Enum): + RED = 1 + GREEN = 2 + BLUE = 3 + + reveal_type(Color.RED._name_) # Revealed type is Literal["RED"] (or str) + reveal_type(Color.RED.name) # Revealed type is Literal["RED"] (or str) + + def func1(red_or_blue: Literal[Color.RED, Color.BLUE]): + reveal_type(red_or_blue.name) # Revealed type is Literal["RED", "BLUE"] (or str) + + def func2(any_color: Color): + reveal_type(any_color.name) # Revealed type is Literal["RED", "BLUE", "GREEN"] (or str) + + +Member Values +------------- + +All enum member objects have an attribute ``_value_`` that contains the member's +value. They also have a property ``value`` that returns the same value. Type +checkers may infer the type of a member's value:: + + class Color(Enum): + RED = 1 + GREEN = 2 + BLUE = 3 + + reveal_type(Color.RED._value_) # Revealed type is Literal[1] (or int or object or Any) + reveal_type(Color.RED.value) # Revealed type is Literal[1] (or int or object or Any) + + def func1(red_or_blue: Literal[Color.RED, Color.BLUE]): + reveal_type(red_or_blue.value) # Revealed type is Literal[1, 2] (or int or object or Any) + + def func2(any_color: Color): + reveal_type(any_color.value) # Revealed type is Literal[1, 2, 3] (or int or object or Any) + + +The value of ``_value_`` can be assigned in a constructor method. This technique +is sometimes used to initialize both the member value and non-member attributes. +If the value assigned in the class body is a tuple, the unpacked tuple value is +passed to the constructor. Type checkers may validate consistency between assigned +tuple values and the constructor signature:: + + class Planet(Enum): + def __init__(self, value: int, mass: float, radius: float): + self._value_ = value + self.mass = mass + self.radius = radius + + MERCURY = (1, 3.301e+23, 2.4397e6) + VENUS = (2, 4.867e+24, 6.0518e6) + EARTH = (3, 5.972e+24, 6.37814e6) + MARS = (6.417e+23, 3.3962e6) # Type checker error (optional) + JUPITER = 5 # Type checker error (optional) + + reveal_type(Planet.MERCURY.value) # Revealed type is Literal[1] (or int or object or Any) + + +The class ``enum.auto`` and method ``_generate_next_value_`` can be used within +an enum class to automatically generate values for enum members. Type checkers +may support these to infer literal types for member values:: + + class Color(Enum): + RED = auto() + GREEN = auto() + BLUE = auto() + + reveal_type(Color.RED.value) # Revealed type is Literal[1] (or int or object or Any) + + +If an enum class provides an explicit type annotation for ``_value_``, type +checkers should enforce this declared type when values are assigned to +``_value_``:: + + class Color(Enum): + _value_: int + RED = 1 # OK + GREEN = "green" # Type error + + class Planet(Enum): + _value_: str + + def __init__(self, value: int, mass: float, radius: float): + self._value_ = value # Type error + + MERCURY = (1, 3.301e+23, 2.4397e6) + +If the literal values for enum members are not supplied, as they sometimes +are not within a type stub file, a type checker can use the type of the +``_value_`` attribute:: + + class ColumnType(Enum): + _value_: int + DORIC = ... + IONIC = ... + CORINTHIAN = ... + + reveal_type(ColumnType.DORIC.value) # Revealed type is int (or object or Any) + + +Enum Literal Expansion +---------------------- + +From the perspective of the type system, most enum classes are equivalent +to the union of the literal members within that enum. (This rule +does not apply to classes that derive from ``enum.Flag`` because these enums +allow flags to be combined in arbitrary ways.) Because of the equivalency +between an enum class and the union of literal members within that enum, the +two types may be used interchangeably. Type checkers may therefore expand +an enum type (that does not derive from ``enum.Flag``) into a union of +literal values during type narrowing and exhaustion detection:: + + class Color(Enum): + RED = 1 + GREEN = 2 + BLUE = 3 + + def print_color1(c: Color): + if c is Color.RED or c is Color.BLUE: + print("red or blue") + else: + reveal_type(c) # Revealed type is Literal[Color.GREEN] + + def print_color2(c: Color): + match c: + case Color.RED | Color.BLUE: + print("red or blue") + case Color.GREEN: + print("green") + case _: + reveal_type(c) # Revealed type is Never + + +Likewise, a type checker should treat a complete union of all literal members +as :term:`equivalent` to the enum type:: + + class Answer(Enum): + Yes = 1 + No = 2 + + def func(val: object) -> Answer: + if val is not Answer.Yes and val is not Answer.No: + raise ValueError("Invalid value") + reveal_type(val) # Revealed type is Answer (or Literal[Answer.Yes, Answer.No]) + return val # OK diff --git a/docs/spec/generics.rst b/docs/spec/generics.rst index 53d8626f6..1bb6df6e5 100644 --- a/docs/spec/generics.rst +++ b/docs/spec/generics.rst @@ -93,8 +93,16 @@ This is equivalent to omitting the generic notation and just saying User-defined generic types -------------------------- -You can include a ``Generic`` base class to define a user-defined class -as generic. Example:: +There are several ways to define a user-defined class as generic: + +* Include a ``Generic`` base class. +* Use the new generic class syntax in Python 3.12 and higher. +* Include a ``Protocol`` base class parameterized with type variables. This + approach also marks the class as a protocol - see + :ref:`generic protocols` for more information. +* Include a generic base class parameterized with type variables. + +Example using ``Generic``:: from typing import TypeVar, Generic from logging import Logger @@ -118,21 +126,21 @@ as generic. Example:: def log(self, message: str) -> None: self.logger.info('{}: {}'.format(self.name, message)) -Or, in Python 3.12 and higher, by using the new syntax for generic -classes:: +Or, using the new generic class syntax:: class LoggedVar[T]: # methods as in previous example -This implicitly adds ``Generic[T]`` as a base class and type checkers -should treat the two largely equivalently (except for variance, see below). +This implicitly adds ``Generic[T]`` as a base class, and type checkers +should treat the two definitions of ``LoggedVar`` largely equivalently (except +for variance, see below). ``Generic[T]`` as a base class defines that the class ``LoggedVar`` takes a single type parameter ``T``. This also makes ``T`` valid as a type within the class body. -The ``Generic`` base class uses a metaclass that defines ``__getitem__`` -so that ``LoggedVar[t]`` is valid as a type:: +The ``Generic`` base class implements the :func:`~object.__class_getitem__` +classmethod so that ``LoggedVar[t]`` is valid as a type:: from collections.abc import Iterable @@ -144,7 +152,6 @@ A generic type can have any number of type variables, and type variables may be constrained. This is valid:: from typing import TypeVar, Generic - ... T = TypeVar('T') S = TypeVar('S') @@ -156,29 +163,52 @@ Each type variable argument to ``Generic`` must be distinct. This is thus invalid:: from typing import TypeVar, Generic - ... T = TypeVar('T') class Pair(Generic[T, T]): # INVALID ... -The ``Generic[T]`` base class is redundant in simple cases where you -subclass some other generic class and specify type variables for its -parameters:: +All arguments to ``Generic`` or ``Protocol`` must be type variables:: - from typing import TypeVar - from collections.abc import Iterator + from typing import Generic, Protocol + + class Bad1(Generic[int]): # INVALID + ... + class Bad2(Protocol[int]): # INVALID + ... + +When a ``Generic`` or parameterized ``Protocol`` base class is present, all type +parameters for the class must appear within the ``Generic`` or +``Protocol`` type argument list, respectively. A type checker should report an +error if a type variable that is not included in the type argument list appears +elsewhere in the base class list:: + + from typing import Generic, Protocol, TypeVar + from collections.abc import Iterable T = TypeVar('T') + S = TypeVar('S') - class MyIter(Iterator[T]): + class Bad1(Iterable[T], Generic[S]): # INVALID + ... + class Bad2(Iterable[T], Protocol[S]): # INVALID ... -That class definition is equivalent to:: +Note that the above rule does not apply to a bare ``Protocol`` base class. This +is valid (see below):: - class MyIter(Iterator[T], Generic[T]): - ... + from typing import Protocol, TypeVar + from collections.abc import Iterator + + T = TypeVar('T') + + class MyIterator(Iterator[T], Protocol): ... + +When no ``Generic`` or parameterized ``Protocol`` base class is present, a +defined class is generic if you subclass one or more other generic classes and +specify type variables for their parameters. See :ref:`generic-base-classes` +for details. You can use multiple inheritance with ``Generic``:: @@ -215,8 +245,9 @@ Generic metaclasses are not supported. Scoping rules for type variables -------------------------------- -Type variables follow normal name resolution rules. -However, there are some special cases in the static typechecking context: +When using the generic class syntax introduced in Python 3.12, the location of +its declaration defines its scope. When using the older syntax, the scoping +rules are more subtle and complex: * A type variable used in a generic function could be inferred to represent different types in the same code block. Example:: @@ -314,13 +345,9 @@ Instantiating generic classes and type erasure ---------------------------------------------- User-defined generic classes can be instantiated. Suppose we write -a ``Node`` class inheriting from ``Generic[T]``:: +a ``Node`` class:: - from typing import TypeVar, Generic - - T = TypeVar('T') - - class Node(Generic[T]): + class Node[T]: ... To create ``Node`` instances you call ``Node()`` just as for a regular @@ -332,12 +359,8 @@ corresponding argument value is passed, the type of the corresponding argument(s) is substituted. Otherwise, the default value for the type parameter (or ``Any``, if no default is provided) is assumed. Example:: - from typing import TypeVar, Generic - - T = TypeVar('T') - - class Node(Generic[T]): - x: T # Instance attribute (see below) + class Node[T]: + x: T # Instance attribute (see below) def __init__(self, label: T | None = None) -> None: ... @@ -377,7 +400,6 @@ class instance that does not have an instance attribute with the same name:: Node[int].x # Error Node.x = 1 # Error Node.x # Error - type(p).x # Error p.x # Ok (evaluates to int) Node[int]().x # Ok (evaluates to int) p.x = 1 # Ok, but assigning to instance attribute @@ -402,6 +424,7 @@ instead is preferred. (First, creating the subscripted class, e.g. ``Node[int]``, has a runtime cost. Second, using a type alias is more readable.) +.. _`generic-base-classes`: Arbitrary generic types as base classes --------------------------------------- @@ -458,8 +481,44 @@ Also consider the following example:: class MyDict(Mapping[str, T]): ... -In this case MyDict has a single parameter, T. +In this case ``MyDict`` has a single type parameter, ``T``. + +Type variables are applied to the defined class in the order in which +they first appear in any generic base classes:: + + from typing import Generic, TypeVar + + T1 = TypeVar('T1') + T2 = TypeVar('T2') + T3 = TypeVar('T3') + + class Parent1(Generic[T1, T2]): + ... + class Parent2(Generic[T1, T2]): + ... + class Child(Parent1[T1, T3], Parent2[T2, T3]): + ... + +That ``Child`` definition is equivalent to:: + + class Child(Parent1[T1, T3], Parent2[T2, T3], Generic[T1, T3, T2]): + ... +A type checker should report an error when the type variable order is +inconsistent:: + + from typing import Generic, TypeVar + + T1 = TypeVar('T1') + T2 = TypeVar('T2') + T3 = TypeVar('T3') + + class Grandparent(Generic[T1, T2]): + ... + class Parent(Grandparent[T1, T2]): + ... + class Child(Parent[T1, T2], Grandparent[T2, T1]): # INVALID + ... Abstract generic types ---------------------- @@ -474,12 +533,12 @@ classes without a metaclass conflict. Type variables with an upper bound ---------------------------------- -A type variable may specify an upper bound using ``bound=`` (when -using the ``TypeVar`` constructor) or using ``: `` (when using the native -syntax for generics). The bound itself cannot be parameterized by type variables. -This means that an -actual type substituted (explicitly or implicitly) for the type variable must -be a subtype of the boundary type. Example:: +A type variable may specify an upper bound using ``bound=`` (when using +the ``TypeVar`` constructor) or using ``: `` (when using the native +syntax for generics). The bound itself cannot be parameterized by type +variables. This means that an actual type substituted (explicitly or +implicitly) for the type variable must be :term:`assignable` to the bound. +Example:: from typing import TypeVar from collections.abc import Sized @@ -496,11 +555,10 @@ be a subtype of the boundary type. Example:: longer({1}, {1, 2}) # ok, return type set[int] longer([1], {1, 2}) # ok, return type a supertype of list[int] and set[int] -An upper bound cannot be combined with type constraints (as used in -``AnyStr``, see the example earlier); type constraints cause the -inferred type to be *exactly* one of the constraint types, while an -upper bound just requires that the actual type is a subtype of the -boundary type. +An upper bound cannot be combined with type constraints (as used in ``AnyStr``, +see the example earlier); type constraints cause the inferred type to be +*exactly* one of the constraint types, while an upper bound just requires that +the actual type is :term:`assignable` to the bound. .. _`variance`: @@ -523,13 +581,12 @@ introduction to these concepts can be found on `Wikipedia `_ and in :pep:`483`; here we just show how to control a type checker's behavior. -By default generic types declared using the old ``TypeVar`` syntax -are considered *invariant* in all type variables, -which means that values for variables annotated with types like -``list[Employee]`` must exactly match the type annotation -- no subclasses or -superclasses of the type parameter (in this example ``Employee``) are -allowed. See below for the behavior when using the built-in generic syntax -in Python 3.12 and higher. +By default generic types declared using the old ``TypeVar`` syntax are +considered *invariant* in all type variables, which means that e.g. +``list[Manager]`` is neither a supertype nor a subtype of ``list[Employee]``. + +See below for the behavior when using the built-in generic syntax in Python +3.12 and higher. To facilitate the declaration of container types where covariant or contravariant type checking is acceptable, type variables accept keyword @@ -600,8 +657,18 @@ ParamSpec Declaration """""""""""" -A parameter specification variable is defined in a similar manner to how a -normal type variable is defined with ``typing.TypeVar``. +In Python 3.12 and newer, a parameter specification variable can be introduced +inline by prefixing its name with ``**`` inside a type parameter list +(for a function, class, or type alias). + +.. code-block:: + + def decorator[**P](func: Callable[P, int]) -> Callable[P, str]: ... + + class CallbackWrapper[T, **P]: + callback: Callable[P, T] + +Prior to 3.12, the ``ParamSpec`` constructor can be used. .. code-block:: @@ -610,8 +677,9 @@ normal type variable is defined with ``typing.TypeVar``. P = ParamSpec("WrongName") # Rejected because P =/= WrongName The runtime should accept ``bound``\ s and ``covariant`` and ``contravariant`` -arguments in the declaration just as ``typing.TypeVar`` does, but for now we -will defer the standardization of the semantics of those options to a later PEP. +arguments in the declaration just as ``typing.TypeVar`` does. + +We defer the standardization of the semantics of the ``bound`` option to a later PEP. .. _`paramspec_valid_use_locations`: @@ -637,62 +705,54 @@ parameter specification variable (``Callable[Concatenate[int, P], int]``\ ). parameter_specification_variable "]" -where ``parameter_specification_variable`` is a ``typing.ParamSpec`` variable, -declared in the manner as defined above, and ``concatenate`` is -``typing.Concatenate``. +where ``parameter_specification_variable`` is introduced either inline (using +``**`` in a type parameter list) or via ``typing.ParamSpec`` as shown above, +and ``concatenate`` is ``typing.Concatenate``. As before, ``parameters_expression``\ s by themselves are not acceptable in places where a type is expected .. code-block:: - def foo(x: P) -> P: ... # Rejected - def foo(x: Concatenate[int, P]) -> int: ... # Rejected - def foo(x: list[P]) -> None: ... # Rejected - def foo(x: Callable[[int, str], P]) -> None: ... # Rejected + def foo[**P](x: P) -> P: ... # Rejected + def foo[**P](x: Concatenate[int, P]) -> int: ... # Rejected + def foo[**P](x: list[P]) -> None: ... # Rejected + def foo[**P](x: Callable[[int, str], P]) -> None: ... # Rejected User-Defined Generic Classes """""""""""""""""""""""""""" -Just as defining a class as inheriting from ``Generic[T]`` makes a class generic -for a single parameter (when ``T`` is a ``TypeVar``\ ), defining a class as -inheriting from ``Generic[P]`` makes a class generic on -``parameters_expression``\ s (when ``P`` is a ``ParamSpec``). +Just as defining a class with ``class C[T]: ...`` makes that class generic over +the type parameter ``T``, adding ``**P`` makes it generic over a parameter +specification. .. code-block:: - T = TypeVar("T") - P_2 = ParamSpec("P_2") - - class X(Generic[T, P]): - f: Callable[P, int] - x: T - - def f(x: X[int, P_2]) -> str: ... # Accepted - def f(x: X[int, Concatenate[int, P_2]]) -> str: ... # Accepted - def f(x: X[int, [int, bool]]) -> str: ... # Accepted - def f(x: X[int, ...]) -> str: ... # Accepted - def f(x: X[int, int]) -> str: ... # Rejected + from collections.abc import Callable + from typing import Concatenate -Or, equivalently, using the built-in syntax for generics in Python 3.12 -and higher:: + class X[T, **P]: + f: Callable[P, int] + x: T - class X[T, **P]: - f: Callable[P, int] - x: T + def accept_params[**P](x: X[int, P]) -> str: ... # Accepted + def accept_concatenate[**P](x: X[int, Concatenate[int, P]]) -> str: ... # Accepted + def accept_concrete(x: X[int, [int, bool]]) -> str: ... # Accepted + def accept_unspecified(x: X[int, ...]) -> str: ... # Accepted + def reject_bad(x: X[int, int]) -> str: ... # Rejected By the rules defined above, spelling a concrete instance of a class generic with respect to only a single ``ParamSpec`` would require unsightly double -brackets. For aesthetic purposes we allow these to be omitted. +brackets. For aesthetic purposes we allow these to be omitted. .. code-block:: - class Z(Generic[P]): - f: Callable[P, int] + class Z[**P]: + f: Callable[P, int] - def f(x: Z[[int, str, bool]]) -> str: ... # Accepted - def f(x: Z[int, str, bool]) -> str: ... # Equivalent + def accept_list(x: Z[[int, str, bool]]) -> str: ... # Accepted + def accept_flat(x: Z[int, str, bool]) -> str: ... # Equivalent # Both Z[[int, str, bool]] and Z[int, str, bool] express this: class Z_instantiated: @@ -707,7 +767,7 @@ evaluating ones with ``TypeVar``\ s. .. code-block:: - def changes_return_type_to_str(x: Callable[P, int]) -> Callable[P, str]: ... + def changes_return_type_to_str[**P](x: Callable[P, int]) -> Callable[P, str]: ... def returns_int(a: str, b: bool) -> int: ... @@ -730,9 +790,7 @@ but is not obligated to do so. .. code-block:: - P = ParamSpec("P") - - def foo(x: Callable[P, int], y: Callable[P, int]) -> Callable[P, bool]: ... + def foo[**P](x: Callable[P, int], y: Callable[P, int]) -> Callable[P, bool]: ... def x_y(x: int, y: str) -> int: ... def y_x(y: int, x: str) -> int: ... @@ -755,9 +813,7 @@ evaluated in the same way. .. code-block:: - U = TypeVar("U") - - class Y(Generic[U, P]): + class Y[U, **P]: f: Callable[P, str] prop: U @@ -779,15 +835,15 @@ transform a finite number of parameters of a callable. def bar(x: int, *args: bool) -> int: ... - def add(x: Callable[P, int]) -> Callable[Concatenate[str, P], bool]: ... + def add[**P](x: Callable[P, int]) -> Callable[Concatenate[str, P], bool]: ... add(bar) # Should return (a: str, /, x: int, *args: bool) -> bool - def remove(x: Callable[Concatenate[int, P], int]) -> Callable[P, bool]: ... + def remove[**P](x: Callable[Concatenate[int, P], int]) -> Callable[P, bool]: ... remove(bar) # Should return (*args: bool) -> bool - def transform( + def transform[**P]( x: Callable[Concatenate[int, P], int] ) -> Callable[Concatenate[str, P], bool]: ... @@ -800,7 +856,7 @@ their first position with a ``X`` can satisfy .. code-block:: - def expects_int_first(x: Callable[Concatenate[int, P], int]) -> None: ... + def expects_int_first[**P](x: Callable[Concatenate[int, P], int]) -> None: ... @expects_int_first # Rejected def one(x: str) -> int: ... @@ -842,7 +898,7 @@ These "properties" can only be used as the annotated types for .. code-block:: - def puts_p_into_scope(f: Callable[P, int]) -> None: + def p_in_scope[**P](f: Callable[P, int]) -> None: def inner(*args: P.args, **kwargs: P.kwargs) -> None: # Accepted pass @@ -853,7 +909,7 @@ These "properties" can only be used as the annotated types for def misplaced(x: P.args) -> None: # Rejected pass - def out_of_scope(*args: P.args, **kwargs: P.kwargs) -> None: # Rejected + def p_not_in_scope(*args: P.args, **kwargs: P.kwargs) -> None: # Rejected pass @@ -866,7 +922,7 @@ together, so that our usage is valid for all possible partitions. .. code-block:: - def puts_p_into_scope(f: Callable[P, int]) -> None: + def p_in_scope[**P](f: Callable[P, int]) -> None: stored_args: P.args # Rejected @@ -906,7 +962,7 @@ parameter preserving decorators. .. code-block:: - def decorator(f: Callable[P, int]) -> Callable[P, None]: + def decorator[**P](f: Callable[P, int]) -> Callable[P, None]: def foo(*args: P.args, **kwargs: P.kwargs) -> None: @@ -931,7 +987,7 @@ To extend this to include ``Concatenate``, we declare the following properties: .. code-block:: - def add(f: Callable[P, int]) -> Callable[Concatenate[str, P], None]: + def add[**P](f: Callable[P, int]) -> Callable[Concatenate[str, P], None]: def foo(s: str, *args: P.args, **kwargs: P.kwargs) -> None: # Accepted pass @@ -942,7 +998,7 @@ To extend this to include ``Concatenate``, we declare the following properties: return foo # Accepted - def remove(f: Callable[Concatenate[int, P], int]) -> Callable[P, None]: + def remove[**P](f: Callable[Concatenate[int, P], int]) -> Callable[P, None]: def foo(*args: P.args, **kwargs: P.kwargs) -> None: f(1, *args, **kwargs) # Accepted @@ -959,7 +1015,7 @@ these parameters can not be addressed via a named argument: .. code-block:: - def outer(f: Callable[P, None]) -> Callable[P, None]: + def outer[**P](f: Callable[P, None]) -> Callable[P, None]: def foo(x: int, *args: P.args, **kwargs: P.kwargs) -> None: f(*args, **kwargs) @@ -996,7 +1052,7 @@ of that ``ParamSpec``. That allows us to spell things like this: .. code-block:: - def twice(f: Callable[P, int], *args: P.args, **kwargs: P.kwargs) -> int: + def twice[**P](f: Callable[P, int], *args: P.args, **kwargs: P.kwargs) -> int: return f(*args, **kwargs) + f(*args, **kwargs) The type of ``twice`` in the above example is @@ -1006,7 +1062,7 @@ outer ``Callable``. This has the following semantics: .. code-block:: def a_int_b_str(a: int, b: str) -> int: - pass + return a twice(a_int_b_str, 1, "A") # Accepted @@ -1036,27 +1092,27 @@ In the same way that a normal type variable is a stand-in for a single type such as ``int``, a type variable *tuple* is a stand-in for a *tuple* type such as ``tuple[int, str]``. -Type variable tuples are created and used with: +In Python 3.12 and newer, type variable tuples can be introduced inline by prefixing +their name with ``*`` inside a type parameter list. :: - from typing import TypeVarTuple + class Array[*Ts]: + ... - Ts = TypeVarTuple('Ts') + def pack[*Ts](*values: *Ts) -> tuple[*Ts]: + ... - class Array(Generic[*Ts]): - ... +Prior to 3.12, the ``TypeVarTuple`` constructor can be used. - def foo(*args: *Ts): - ... +:: -Or when using the built-in syntax for generics in Python 3.12 and higher:: + from typing import TypeVarTuple - class Array[*Ts]: - ... + Ts = TypeVarTuple('Ts') - def foo[*Ts](*args: *Ts): - ... + class Array(Generic[*Ts]): + ... Using Type Variable Tuples in Generic Classes """"""""""""""""""""""""""""""""""""""""""""" @@ -1066,9 +1122,9 @@ Type variable tuples behave like a number of individual type variables packed in :: - Shape = TypeVarTuple('Shape') + from typing import NewType - class Array(Generic[*Shape]): ... + class Array[*Shape]: ... Height = NewType('Height', int) Width = NewType('Width', int) @@ -1078,9 +1134,9 @@ The ``Shape`` type variable tuple here behaves like ``tuple[T1, T2]``, where ``T1`` and ``T2`` are type variables. To use these type variables as type parameters of ``Array``, we must *unpack* the type variable tuple using the star operator: ``*Shape``. The signature of ``Array`` then behaves -as if we had simply written ``class Array(Generic[T1, T2]): ...``. +as if we had simply written ``class Array[T1, T2]: ...``. -In contrast to ``Generic[T1, T2]``, however, ``Generic[*Shape]`` allows +In contrast to ``class Array[T1, T2]``, however, ``class Array[*Shape]`` allows us to parameterize the class with an *arbitrary* number of type parameters. That is, in addition to being able to define rank-2 arrays such as ``Array[Height, Width]``, we could also define rank-3 arrays, rank-4 arrays, @@ -1102,7 +1158,7 @@ signatures and variable annotations: :: - class Array(Generic[*Shape]): + class Array[*Shape]: def __init__(self, shape: tuple[*Shape]): self._shape: tuple[*Shape] = shape @@ -1133,51 +1189,35 @@ for two reasons: * To improve readability: the star also functions as an explicit visual indicator that the type variable tuple is not a normal type variable. -Variance, Type Constraints and Type Bounds: Not (Yet) Supported -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - -``TypeVarTuple`` does not yet support specification of: +Type Constraints and Type Bounds +"""""""""""""""""""""""""""""""" -* Variance (e.g. ``TypeVar('T', covariant=True)``) -* Type constraints (``TypeVar('T', int, float)``) -* Type bounds (``TypeVar('T', bound=ParentClass)``) +``TypeVarTuple`` does not support type constraints such as +``TypeVar('T', int, float)``. -We leave the decision of how these arguments should behave to a future PEP, when variadic generics have been tested in the field. As of PEP 646, type variable tuples are -invariant. +The ``TypeVarTuple`` constructor accepts a ``bound`` argument beginning in +Python 3.15 and in ``typing_extensions`` 4.16 and newer. As with ``ParamSpec``, +the typing semantics of this argument are not yet specified. Type Variable Tuple Equality """""""""""""""""""""""""""" If the same ``TypeVarTuple`` instance is used in multiple places in a signature -or class, a valid type inference might be to bind the ``TypeVarTuple`` to -a ``tuple`` of a union of types: +or class, type checkers may use the same rules for solving the variables as they +would for normal ``TypeVar``\ s. The exact inference behavior is not specified. :: - def foo(arg1: tuple[*Ts], arg2: tuple[*Ts]): ... + def foo(arg1: tuple[*Ts], arg2: tuple[*Ts]) -> tuple[*Ts]: ... a = (0,) b = ('0',) - foo(a, b) # Can Ts be bound to tuple[int | str]? - -We do *not* allow this; type unions may *not* appear within the ``tuple``. -If a type variable tuple appears in multiple places in a signature, -the types must match exactly (the list of type parameters must be the same -length, and the type parameters themselves must be identical): + reveal_type(foo(a, b)) # May be e.g. tuple[object], tuple[int | str], tuple[Literal[0, "0"]] -:: +All usages of the ``TypeVarTuple`` must match in length, however:: - def pointwise_multiply( - x: Array[*Shape], - y: Array[*Shape] - ) -> Array[*Shape]: ... + foo((1,), (2, 3)) # Error: Expected a tuple of length 1 for arg2, but got a tuple of length 2. - x: Array[Height] - y: Array[Width] - z: Array[Height, Width] - pointwise_multiply(x, x) # Valid - pointwise_multiply(x, y) # Error - pointwise_multiply(x, z) # Error Multiple Type Variable Tuples: Not Allowed """""""""""""""""""""""""""""""""""""""""" @@ -1186,7 +1226,7 @@ Only a single type variable tuple may appear in a type parameter list: :: - class Array(Generic[*Ts1, *Ts2]): ... # Error + class Array[*Ts1, *Ts2]: ... # Error The reason is that multiple type variable tuples make it ambiguous which parameters get bound to which type variable tuple: :: @@ -1201,13 +1241,12 @@ prefixed and/or suffixed: :: - Shape = TypeVarTuple('Shape') Batch = NewType('Batch', int) Channels = NewType('Channels', int) - def add_batch_axis(x: Array[*Shape]) -> Array[Batch, *Shape]: ... - def del_batch_axis(x: Array[Batch, *Shape]) -> Array[*Shape]: ... - def add_batch_channels( + def add_batch_axis[*Shape](x: Array[*Shape]) -> Array[Batch, *Shape]: ... + def del_batch_axis[*Shape](x: Array[Batch, *Shape]) -> Array[*Shape]: ... + def add_batch_channels[*Shape]( x: Array[*Shape] ) -> Array[Batch, *Shape, Channels]: ... @@ -1221,10 +1260,7 @@ Normal ``TypeVar`` instances can also be prefixed and/or suffixed: :: - T = TypeVar('T') - Ts = TypeVarTuple('Ts') - - def prefix_tuple( + def prefix_tuple[T, *Ts]( x: T, y: tuple[*Ts] ) -> tuple[T, *Ts]: ... @@ -1264,7 +1300,7 @@ unnecessary ``TypeVarTuple``: process_batch_channels(z) # Error: Expected Channels. -We can also pass a ``*tuple[int, ...]`` wherever a ``*Ts`` is +We can also pass a ``*tuple[Any, ...]`` wherever a ``*Ts`` is expected. This is useful when we have particularly dynamic code and cannot state the precise number of dimensions or the precise types for each of the dimensions. In those cases, we can smoothly fall back to @@ -1495,8 +1531,8 @@ a similar way to regular type variables: :: - IntTuple = tuple[int, *Ts] - NamedArray = tuple[str, Array[*Ts]] + type IntTuple[*Ts] = tuple[int, *Ts] + type NamedArray[*Ts] = tuple[str, Array[*Ts]] IntTuple[float, bool] # Equivalent to tuple[int, float, bool] NamedArray[Height] # Equivalent to tuple[str, Array[Height]] @@ -1509,15 +1545,14 @@ or datatype: :: - Shape = TypeVarTuple('Shape') - DType = TypeVar('DType') - class Array(Generic[DType, *Shape]): + class Array[DType, *Shape]: + ... # E.g. Float32Array[Height, Width, Channels] - Float32Array = Array[np.float32, *Shape] + type Float32Array[*Shape] = Array[np.float32, *Shape] # E.g. Array1D[np.uint8] - Array1D = Array[DType, Any] + type Array1D[DType] = Array[DType, Any] If an explicitly empty type parameter list is given, the type variable tuple in the alias is set empty: @@ -1547,8 +1582,7 @@ Normal ``TypeVar`` instances can also be used in such aliases: :: - T = TypeVar('T') - Foo = tuple[T, *Ts] + type Foo[T, *Ts] = tuple[T, *Ts] # T bound to str, Ts to tuple[int] Foo[str, int] @@ -1574,11 +1608,8 @@ First, type arguments to generic aliases can be variadic. For example, a :: - Ts1 = TypeVar('Ts1') - Ts2 = TypeVar('Ts2') - - IntTuple = tuple[int, *Ts1] - IntFloatTuple = IntTuple[float, *Ts2] # Valid + type IntTuple[*Ts1] = tuple[int, *Ts1] + type IntFloatTuple[*Ts2] = IntTuple[float, *Ts2] # Valid Here, ``*Ts1`` in the ``IntTuple`` alias is bound to ``tuple[float, *Ts2]``, resulting in an alias ``IntFloatTuple`` equivalent to @@ -1604,9 +1635,7 @@ themselves variadic. For example: :: - T = TypeVar('T') - - IntTuple = tuple[int, T] + type IntTuple[T] = tuple[int, T] IntTuple[str] # Valid IntTuple[*Ts] # NOT valid @@ -1727,11 +1756,9 @@ true of ``TypeVarTuple``\s in the argument list: :: - Ts1 = TypeVarTuple('Ts1') - Ts2 = TypeVarTuple('Ts2') - - Camelot = tuple[T, *Ts1] - Camelot[*Ts2] # NOT valid + type Camelot[T, *Ts] = tuple[T, *Ts] + Camelot[int, *tuple[str, ...]] # Valid + Camelot[*tuple[str, ...]] # NOT valid This is not possible because, unlike in the case of an unpacked arbitrary-length tuple, there is no way to 'peer inside' the ``TypeVarTuple`` to see what its @@ -1746,12 +1773,11 @@ overloads can be used with individual ``TypeVar`` instances in place of the type :: - Shape = TypeVarTuple('Shape') Axis1 = TypeVar('Axis1') Axis2 = TypeVar('Axis2') Axis3 = TypeVar('Axis3') - class Array(Generic[*Shape]): + class Array[*Shape]: @overload def transpose( @@ -1842,28 +1868,24 @@ literal "``...``" or another in-scope ``ParamSpec`` (see `Scoping Rules`_). :: - DefaultP = ParamSpec("DefaultP", default=[str, int]) - - class Foo(Generic[DefaultP]): ... + class Foo[**P = [str, int]]: ... - reveal_type(Foo) # type is type[Foo[DefaultP = [str, int]]] - reveal_type(Foo()) # type is Foo[[str, int]] - reveal_type(Foo[[bool, bool]]()) # type is Foo[[bool, bool]] + reveal_type(Foo) # type is type[Foo[str, int]] + reveal_type(Foo()) # type is Foo[str, int] + reveal_type(Foo[[bool, bool]]()) # type is Foo[bool, bool] ``TypeVarTuple`` Defaults ^^^^^^^^^^^^^^^^^^^^^^^^^ ``TypeVarTuple`` defaults are defined using the same syntax as -``TypeVar`` \ s but use an unpacked tuple of types instead of a single type -or another in-scope ``TypeVarTuple`` (see `Scoping Rules`_). +``TypeVar`` \ s, but instead of a single type, they use an unpacked tuple of +types or an unpacked, in-scope ``TypeVarTuple`` (see `Scoping Rules`_). :: - DefaultTs = TypeVarTuple("DefaultTs", default=Unpack[tuple[str, int]]) + class Foo[*Ts = *tuple[str, int]]: ... - class Foo(Generic[*DefaultTs]): ... - - reveal_type(Foo) # type is type[Foo[DefaultTs = *tuple[str, int]]] + reveal_type(Foo) # type is type[Foo[str, int]] reveal_type(Foo()) # type is Foo[str, int] reveal_type(Foo[int, bool]()) # type is Foo[int, bool] @@ -1920,20 +1942,22 @@ Scoping Rules Using a type parameter from an outer scope as a default is not supported. +:: + class Foo(Generic[T1]): class Bar(Generic[T2]): ... # Type Error Bound Rules ^^^^^^^^^^^ -``T1``'s bound must be a subtype of ``T2``'s bound. +``T1``'s bound must be :term:`assignable` to ``T2``'s bound. :: T1 = TypeVar("T1", bound=int) TypeVar("Ok", default=T1, bound=float) # Valid TypeVar("AlsoOk", default=T1, bound=int) # Valid - TypeVar("Invalid", default=T1, bound=str) # Invalid: int is not a subtype of str + TypeVar("Invalid", default=T1, bound=str) # Invalid: int is not assignable to str Constraint Rules ^^^^^^^^^^^^^^^^ @@ -2022,8 +2046,8 @@ normal subscription rules, non-overridden defaults should be substituted. Using ``bound`` and ``default`` """"""""""""""""""""""""""""""" -If both ``bound`` and ``default`` are passed, ``default`` must be a -subtype of ``bound``. If not, the type checker should generate an +If both ``bound`` and ``default`` are passed, ``default`` must be +:term:`assignable` to ``bound``. If not, the type checker should generate an error. :: @@ -2068,10 +2092,7 @@ should be bound to the ``TypeVarTuple`` or the defaulted ``TypeVar``. :: - Ts = TypeVarTuple("Ts") - T = TypeVar("T", default=bool) - - class Foo(Generic[*Ts, T]): ... # Type checker error + class Foo[*Ts, T = bool]: ... # Type checker error # Could be reasonably interpreted as either Ts = (int, str, float), T = bool # or Ts = (int, str), T = float @@ -2083,13 +2104,10 @@ for the ``ParamSpec`` and one for the ``TypeVarTuple``. :: - Ts = TypeVarTuple("Ts") - P = ParamSpec("P", default=[float, bool]) - - class Foo(Generic[*Ts, P]): ... # Valid + class Foo[*Ts = *tuple[int, str], **P = [float, bool]]: ... # Valid - Foo[int, str] # Ts = (int, str), P = [float, bool] - Foo[int, str, [bytes]] # Ts = (int, str), P = [bytes] + Foo[int, str] # Ts = (int, str), P = [float, bool] + Foo[int, str, [bytes]] # Ts = (int, str), P = [bytes] Binding rules """"""""""""" @@ -2268,7 +2286,8 @@ Use in Attribute Annotations ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Another use for ``Self`` is to annotate attributes. One example is where we -have a ``LinkedList`` whose elements must be subclasses of the current class. +have a ``LinkedList`` whose elements must be :term:`assignable` to the current +class. :: @@ -2298,8 +2317,8 @@ constructions with subclasses: def ordinal_value(self) -> str: return as_ordinal(self.value) - # Should not be OK because LinkedList[int] is not a subclass of - # OrdinalLinkedList, # but the type checker allows it. + # Should not be OK because LinkedList[int] is not assignable to + # OrdinalLinkedList, but the type checker allows it. xs = OrdinalLinkedList(value=1, next=LinkedList[int](value=2)) if xs.next: @@ -2469,11 +2488,11 @@ See :pep:`PEP 544 <544#self-types-in-protocols>` for details on the behavior of TypeVars bound to protocols. -Checking a class for compatibility with a protocol: If a protocol uses -``Self`` in methods or attribute annotations, then a class ``Foo`` is -considered compatible with the protocol if its corresponding methods and -attribute annotations use either ``Self`` or ``Foo`` or any of ``Foo``’s -subclasses. See the examples below: +Checking a class for assignability to a protocol: If a protocol uses ``Self`` +in methods or attribute annotations, then a class ``Foo`` is :term:`assignable` +to the protocol if its corresponding methods and attribute annotations use +either ``Self`` or ``Foo`` or any of ``Foo``’s subclasses. See the examples +below: :: @@ -2694,27 +2713,39 @@ The algorithm for computing the variance of a type parameter is as follows. For each type parameter in a generic class: -1. If the type parameter is variadic (``TypeVarTuple``) or a parameter -specification (``ParamSpec``), it is always considered invariant. No further -inference is needed. - -2. If the type parameter comes from a traditional ``TypeVar`` declaration and -is not specified as ``infer_variance`` (see below), its variance is specified -by the ``TypeVar`` constructor call. No further inference is needed. +1. If the type parameter comes from a traditional +``TypeVar``/``TypeVarTuple``/``ParamSpec`` declaration and is not constructed +with ``infer_variance=True`` (see below), its variance is specified by the +constructor call. No further inference is needed. -3. Create two specialized versions of the class. We'll refer to these as +2. Create two specialized versions of the class. We'll refer to these as ``upper`` and ``lower`` specializations. In both of these specializations, -replace all type parameters other than the one being inferred by a dummy type -instance (a concrete anonymous class that is type compatible with itself and -assumed to meet the bounds or constraints of the type parameter). In -the ``upper`` specialized class, specialize the target type parameter with -an ``object`` instance. This specialization ignores the type parameter's -upper bound or constraints. In the ``lower`` specialized class, specialize -the target type parameter with itself (i.e. the corresponding type argument -is the type parameter itself). - -4. Determine whether ``lower`` can be assigned to ``upper`` using normal type -compatibility rules. If so, the target type parameter is covariant. If not, +replace all type parameters other than the one being inferred by a dummy +argument of the appropriate kind: + +- for a type variable, a dummy type instance (a concrete anonymous class that + is assumed to meet the bounds or constraints of the type parameter) +- for a type variable tuple, a fixed-length pack containing a single dummy type + instance +- for a parameter specification, a signature taking a single positional-only + parameter of a dummy type + +Any dummy argument will do, as long as it is fixed across both specializations; +its only purpose is to make the class fully specialized so that the target type +parameter can be varied on its own. In the ``upper`` specialized class, +specialize the target type parameter with: + +- an ``object`` instance for a type variable +- a ``*tuple[object, ...]`` value for a type variable tuple +- a "top signature" value for a parameter specification, i.e. a type that + represents the super type of every possible signature. + +This specialization ignores the type parameter's upper bound or constraints. +In the ``lower`` specialized class, specialize the target type parameter with +itself (i.e. the corresponding type argument is the type parameter itself). + +3. Determine whether ``lower`` can be assigned to ``upper`` using normal +assignability rules. If so, the target type parameter is covariant. If not, determine whether ``upper`` can be assigned to ``lower``. If so, the target type parameter is contravariant. If neither of these combinations are assignable, the target type parameter is invariant. @@ -2737,9 +2768,8 @@ To determine the variance of ``T1``, we specialize ``ClassA`` as follows: upper = ClassA[object, Dummy, Dummy] lower = ClassA[T1, Dummy, Dummy] -We find that ``upper`` is not assignable to ``lower`` using normal type -compatibility rules defined in :pep:`484`. Likewise, ``lower`` is not assignable -to ``upper``, so we conclude that ``T1`` is invariant. +We find that ``upper`` is not assignable to ``lower``. Likewise, ``lower`` is +not assignable to ``upper``, so we conclude that ``T1`` is invariant. To determine the variance of ``T2``, we specialize ``ClassA`` as follows: @@ -2760,18 +2790,21 @@ To determine the variance of ``T3``, we specialize ``ClassA`` as follows: Since ``lower`` is assignable to ``upper``, ``T3`` is covariant. -Auto Variance For TypeVar -^^^^^^^^^^^^^^^^^^^^^^^^^ +Auto Variance For Traditional Type Variables +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The ``TypeVar``, ``TypeVarTuple``, and ``ParamSpec`` constructors accept the +keyword parameters ``covariant``, ``contravariant``, and ``infer_variance``. +At most one of these parameters may be ``True``. If all three are ``False``, +the type variable is invariant. If ``infer_variance`` is ``True``, a type +checker should infer whether the type variable is invariant, covariant, or +contravariant. -The existing ``TypeVar`` class constructor accepts keyword parameters named -``covariant`` and ``contravariant``. If both of these are ``False``, the -type variable is assumed to be invariant. PEP 695 adds another keyword -parameter named ``infer_variance`` indicating that a type checker should use -inference to determine whether the type variable is invariant, covariant or -contravariant. A corresponding instance variable ``__infer_variance__`` can be -accessed at runtime to determine whether the variance is inferred. Type -variables that are implicitly allocated using the new syntax will always -have ``__infer_variance__`` set to ``True``. +:pep:`695` introduced ``infer_variance`` for ``TypeVar``. The ``TypeVarTuple`` +constructor accepts these variance parameters beginning in Python 3.15; +``typing_extensions`` provides a backport starting with version 4.16. Type +parameters implicitly allocated using the new syntax always have inferred +variance. A generic class that uses the traditional syntax may include combinations of type variables with explicit and inferred variance. diff --git a/docs/spec/glossary.rst b/docs/spec/glossary.rst index 39973ab6c..3c8a32cfd 100644 --- a/docs/spec/glossary.rst +++ b/docs/spec/glossary.rst @@ -12,24 +12,172 @@ This section defines a few terms that may be used elsewhere in the specification :term:`type expression`, sometimes with additional :term:`type qualifiers `. See :ref:`"Type and annotation expression" ` for details. + assignable + If a type ``B`` is "assignable to" a type ``A``, a type checker should + not error on the assignment ``x: A = b``, where ``b`` is some expression + whose type is ``B``. Similarly for function calls and returns: ``f(b)`` + where ``def f(x: A): ...`` and ``return b`` inside ``def f(...) -> A: + ...`` are both valid (not type errors) if and only if ``B`` is assignable + to ``A``. In this case ``A`` is "assignable from" ``B``. For :term:`fully + static types `, "assignable to" is equivalent to + ":term:`subtype` of" and "assignable from" is equivalent to + ":term:`supertype` of". For :term:`gradual types `, a type + ``B`` is assignable to a type ``A`` if there exist fully static + :term:`materializations ` ``A'`` and ``B'`` of ``A`` and + ``B``, respectively, such that ``B'`` is a subtype of ``A'``. See + :ref:`type-system-concepts`. + + bare ``Final`` + A :ref:`Final ` :term:`type qualifier` without an + explicit type, e.g. ``x: Final``. + + closed + A :ref:`TypedDict ` type is closed if it may not contain any + additional :term:`items ` beyond those specified in the TypedDict definition. + A closed TypedDict can be created using the ``closed=True`` argument to + :py:func:`typing.TypedDict`, or equivalently by setting ``extra_items=Never``. + Compare :term:`extra items` and :term:`open`. + + consistent + Two :term:`fully static types ` are "consistent with" + each other if they are :term:`equivalent`. Two gradual types are + "consistent with" each other if they could :term:`materialize` to the + same type. See :ref:`type-system-concepts`. If two types are consistent, + they are both :term:`assignable` to and from each other. + + consistent subtype + "Consistent subtype" is synonymous with ":term:`assignable` to" (and + "consistent supertype" is synonymous with "assignable from"). See + :ref:`type-system-concepts`. + distribution The packaged file which is used to publish and distribute a release. (:pep:`426`) + equivalent + Two :term:`fully static types ` ``A`` and ``B`` are + equivalent if ``A`` is a :term:`subtype` of ``B`` and ``B`` is a + :term:`subtype` of ``A``. This implies that ``A`` and ``B`` represent the + same set of possible runtime objects. Two gradual types ``A`` and ``B`` + are equivalent if all :term:`materializations ` of ``A`` are + also materializations of ``B``, and all materializations of ``B`` are + also materializations of ``A``. + + explicitly typed ``Final`` + A :ref:`Final ` :term:`type qualifier` with an explicit + type, e.g. ``x: Final[int]``. + + extra items + A :ref:`TypedDict ` type with extra items may contain arbitrary + additional key-value pairs beyond those specified in the TypedDict definition, but those + values must be of the type specified by the ``extra_items=`` argument to the definition. + A TypedDict with extra items can be created using the ``extra_items=`` + argument to :py:func:`typing.TypedDict`. Extra items may or may not be + :term:`read-only`. Compare :term:`closed` and :term:`open`. + + fully static type + A type is "fully static" if it does not contain any :term:`gradual form`. + A fully static type represents a set of possible runtime values. Fully + static types participate in the :term:`subtype` relation. See + :ref:`type-system-concepts`. + + gradual form + A gradual form is an element of a :term:`type expression` which makes the type it is + part of not a :term:`fully static type`, but rather a representation of a + set of possible static types. See :ref:`type-system-concepts`. The + primary gradual form is :ref:`Any`. The ellipsis (``...``) is a gradual + form in some, but not all, contexts. It is a gradual form when used in a + :ref:`Callable` type, and when used in ``tuple[Any, ...]`` (but not in + other :ref:`tuple ` types). + + gradual type + All types in the Python type system are "gradual". A gradual type may be + a :term:`fully static type`, or it may be :ref:`Any`, or a type that + contains ``Any`` or another :term:`gradual form`. A gradual type does not + necessarily represent a single set of possible runtime values; instead it + can represent a set of possible static types (a set of possible sets of + possible runtime values). Gradual types which are not fully static do not + participate in the :term:`subtype` relation, but they do participate in + :term:`consistency ` and :term:`assignability `. + They can be :term:`materialized ` to a more static, or fully static, + type. See :ref:`type-system-concepts`. + + inhabit + A value is said to inhabit a type if it is a member of the set of values + represented by that type. For example, the value ``42`` inhabits the type + ``int``, and the value ``"hello"`` inhabits the type ``str``. + inline Inline type annotations are annotations that are included in the runtime code using :pep:`526` and :pep:`3107` syntax (the filename ends in ``.py``). + item + In the context of a :ref:`TypedDict `, an item consists of a name + (the dictionary key) and a type (representing the type that values corresponding to the key must have). + Items may be :term:`required` or :term:`non-required`, and may be :term:`read-only` or writable. + + materialize + A :term:`gradual type` can be materialized to a more static type + (possibly a :term:`fully static type`) by replacing :ref:`Any` with any + other type, or by replacing the `...` in a :ref:`Callable` type with a + list of types, or by replacing ``tuple[Any, ...]`` with a specific-length + tuple type. This materialization relation is key to defining + :term:`assignability ` for gradual types. See + :ref:`type-system-concepts`. + module A file containing Python runtime code or stubbed type information. + narrow + A :term:`fully static type` ``B`` is narrower than a fully static type + ``A`` if ``B`` is a :term:`subtype` of ``A`` and ``B`` is not + :term:`equivalent` to ``A``. This means that ``B`` represents a proper + subset of the possible objects represented by ``A``. "Type narrowing" is + when a type checker infers that a name or expression must have a narrower + type at some locations in control flow, due to an assignment or a runtime + check of its value. + + nominal + A nominal type (e.g. a class name) represents the set of values whose + ``__class__`` is that type, or any of its subclasses, transitively. In + contrast, see :term:`structural` types. + + non-required + If an :term:`item` in a :ref:`TypedDict ` is non-required, it may or + may not be present on an object of that TypedDict type, but if it is present + it must be of the type specified by the TypedDict definition. + Items can be marked as non-required using the :py:data:`typing.NotRequired` qualifier + or the ``total=False`` argument to :py:func:`typing.TypedDict`. Compare :term:`required`. + + open + A :ref:`TypedDict ` type is open if it may contain arbitrary + additional :term:`items ` beyond those specified in the TypedDict definition. + This is the default behavior for TypedDicts that do not use the ``closed=True`` + or ``extra_items=`` arguments to :py:func:`typing.TypedDict`. + Open TypedDicts behave similarly to TypedDicts with :term:`extra items` of type + ``ReadOnly[object]``, but differ in some behaviors; see the TypedDict specification + chapter for details. + Compare :term:`extra items` and :term:`closed`. + package A directory or directories that namespace Python modules. (Note the distinction between packages and :term:`distributions `. While most distributions are named after the one package they install, some distributions install multiple packages.) + read-only + A read-only :term:`item` in a :ref:`TypedDict ` may not be modified. + Attempts to delete or assign to that item + should be reported as type errors by a type checker. Read-only items are created + using the :py:data:`typing.ReadOnly` qualifier. + + required + If an :term:`item` in a :ref:`TypedDict ` is required, it must be present + in any object of that TypedDict type. Items are + required by default, but items can also be explicitly marked as required using + the :py:data:`typing.Required` qualifier. Compare :term:`non-required`. + special form A special form is an object that has a special meaning within the type system, comparable to a keyword in the language grammar. Examples include ``Any``, @@ -38,10 +186,37 @@ This section defines a few terms that may be used elsewhere in the specification be imported from the :py:mod:`typing` module or equivalently from ``typing_extensions``, but some special forms are placed in other modules. + structural + A structural type (see e.g. :ref:`Protocols`, :ref:`TypedDict`) defines a + set of values not by their ``__class__``, but by their properties (e.g. + attributes, methods, dictionary key/value types). :ref:`Callable` types + are also structural; a callable type is a subtype of another callable + type based on their signatures, not a subclass relationship. In contrast, + see :term:`nominal` types. + stub A file containing only type information, empty of runtime code (the filename ends in ``.pyi``). See :ref:`stub-files`. + subtype + A :term:`fully static type` ``B`` is a subtype of a fully static type + ``A`` if and only if the set of possible runtime values represented by + ``B`` is a subset of the set of possible runtime values represented by + ``A``. For :term:`nominal` types (classes), subtyping is defined by + inheritance. For :term:`structural` types, subtyping is defined by a + shared set of attributes/methods or keys. Subtype is the inverse of + :term:`supertype`. A type that is not fully static is not a subtype or + supertype of any other type, but via :term:`materialization + ` can be :term:`assignable` to another type. See + :ref:`type-system-concepts`. + + supertype + A :term:`fully static type` ``A`` is a supertype of a fully static type + ``B`` if and only if the set of possible runtime values represented by + ``A`` is a superset of the set of possible runtime values represented by + ``B``. Supertype is the inverse of :term:`subtype`. See + :ref:`type-system-concepts`. + type expression An expression that represents a type. The type system requires the use of type expressions within :term:`annotation expression` and also in several other contexts. @@ -52,4 +227,11 @@ This section defines a few terms that may be used elsewhere in the specification form an :term:`annotation expression`. For example, the type qualifier :ref:`Final ` can be used around a type to indicate that the annotated value may not be overridden or modified. This term is also used for other special forms that modify a type, but using a different - syntactic context, such as the `@final ` decorator. + syntactic context, such as the :ref:`@final ` decorator. + + wide + A :term:`fully static type` ``A`` is wider than a fully static type ``B`` + if and only if ``B`` is a :term:`subtype` of ``A`` and ``B`` is not + :term:`equivalent` to ``A``. This means that ``A`` represents a proper + superset of the possible values represented by ``B``. See also + ":term:`narrow`". diff --git a/docs/spec/index.rst b/docs/spec/index.rst index 6e5e5c00b..47d491766 100644 --- a/docs/spec/index.rst +++ b/docs/spec/index.rst @@ -9,6 +9,7 @@ Specification for the Python type system meta concepts annotations + type-forms special-types generics qualifiers @@ -24,6 +25,7 @@ Specification for the Python type system typeddict tuples namedtuples + enums narrowing directives distributing diff --git a/docs/spec/literal.rst b/docs/spec/literal.rst index d0ca618c6..7254632b2 100644 --- a/docs/spec/literal.rst +++ b/docs/spec/literal.rst @@ -24,9 +24,8 @@ concrete value. For example, if we define some variable ``foo`` to have type ``Literal[3]``, we are declaring that ``foo`` must be exactly equal to ``3`` and no other value. -Given some value ``v`` that is a member of type ``T``, the type -``Literal[v]`` shall be treated as a subtype of ``T``. For example, -``Literal[3]`` is a subtype of ``int``. +Given some value ``v`` that is a member of type ``T``, the type ``Literal[v]`` +is a subtype of ``T``. For example, ``Literal[3]`` is a subtype of ``int``. All methods from the parent type will be directly inherited by the literal type. So, if we have some variable ``foo`` of type ``Literal[3]`` @@ -94,22 +93,28 @@ what values may and may not be used as parameters. In short, a ``Literal[...]`` type may be parameterized by one or more literal expressions, and nothing else. +.. _literal-legal-parameters: Legal parameters for ``Literal`` at type check time """"""""""""""""""""""""""""""""""""""""""""""""""" -``Literal`` may be parameterized with literal ints, byte and unicode strings, -bools, Enum values and ``None``. So for example, all of +``Literal`` may be parameterized with literal ``int``, ``str``, ``bytes``, +and ``bool`` objects, instances of ``enum.Enum`` subclasses, and ``None``. So for example, all of the following would be legal:: Literal[26] - Literal[0x1A] # Exactly equivalent to Literal[26] + Literal[0x1A] # Equivalent to Literal[26] Literal[-4] Literal["hello world"] + Literal[u"hello world"] # Equivalent to Literal["hello world"] Literal[b"hello world"] - Literal[u"hello world"] Literal[True] - Literal[Color.RED] # Assuming Color is some enum + + class Color(enum.Enum): + RED = 1 + GREEN = 2 + + Literal[Color.RED] Literal[None] **Note:** Since the type ``None`` is inhabited by just a single @@ -143,17 +148,6 @@ This should be exactly equivalent to the following type:: Literal[1, 2, 3, "foo", 5] | None -**Note:** String literal types like ``Literal["foo"]`` should subtype either -bytes or unicode in the same way regular string literals do at runtime. - -For example, in Python 3, the type ``Literal["foo"]`` is equivalent to -``Literal[u"foo"]``, since ``"foo"`` is equivalent to ``u"foo"`` in Python 3. - -Similarly, in Python 2, the type ``Literal["foo"]`` is equivalent to -``Literal[b"foo"]`` -- unless the file includes a -``from __future__ import unicode_literals`` import, in which case it would be -equivalent to ``Literal[u"foo"]``. - Illegal parameters for ``Literal`` at type check time """"""""""""""""""""""""""""""""""""""""""""""""""""" @@ -304,18 +298,18 @@ special-casing. For example, programs like the following are type safe:: # Legal: Literal["foo"] is a subtype of str expects_str(var) -This also means non-Literal expressions in general should not automatically -be cast to Literal. For example:: +This also means non-Literal types in general are not :term:`assignable` to +Literal types. For example:: def expects_literal(x: Literal["foo"]) -> None: ... def runner(my_str: str) -> None: - # ILLEGAL: str is not a subclass of Literal["foo"] + # ILLEGAL: str is not assignable to Literal["foo"] expects_literal(my_str) **Note:** If the user wants their API to support accepting both literals *and* the original type -- perhaps for legacy purposes -- they should -implement a fallback overload. See :ref:`literalstring-overloads`. +implement a fallback overload. Interactions with other types and features ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -329,7 +323,7 @@ Literals can be used to "intelligently index" into structured types like tuples, NamedTuple, and classes. (Note: this is not an exhaustive list). For example, type checkers should infer the correct value type when -indexing into a tuple using an int key that corresponds a valid index:: +indexing into a tuple using an int key that corresponds to a valid index:: a: Literal[0] = 0 b: Literal[5] = 5 @@ -398,21 +392,15 @@ maintain backwards-compatibility. Interactions with generics """""""""""""""""""""""""" -Types like ``Literal[3]`` are meant to be just plain old subclasses of -``int``. This means you can use types like ``Literal[3]`` anywhere -you could use normal types, such as with generics. +Literal types are types, and can be used anywhere a type is expected. -This means that it is legal to parameterize generic functions or +For example, it is legal to parameterize generic functions or classes using Literal types:: - A = TypeVar('A', bound=int) - B = TypeVar('B', bound=int) - C = TypeVar('C', bound=int) - # A simplified definition for Matrix[row, column] - class Matrix(Generic[A, B]): + class Matrix[A: int, B: int]: def __add__(self, other: Matrix[A, B]) -> Matrix[A, B]: ... - def __matmul__(self, other: Matrix[B, C]) -> Matrix[A, C]: ... + def __matmul__[C: int](self, other: Matrix[B, C]) -> Matrix[A, C]: ... def transpose(self) -> Matrix[B, A]: ... foo: Matrix[Literal[2], Literal[3]] = Matrix(...) @@ -421,11 +409,14 @@ classes using Literal types:: baz = foo @ bar reveal_type(baz) # Revealed type is 'Matrix[Literal[2], Literal[7]]' -Similarly, it is legal to construct TypeVars with value restrictions +Similarly, it is legal to use type variables with value restrictions or bounds involving Literal types:: - T = TypeVar('T', Literal["a"], Literal["b"], Literal["c"]) - S = TypeVar('S', bound=Literal["foo"]) + def takes_letter[T: (Literal["a"], Literal["b"], Literal["c"])](value: T) -> T: + return value + + def takes_foo[S: Literal["foo"]](value: S) -> S: + return value ...although it is unclear when it would ever be useful to construct a TypeVar with a Literal upper bound. For example, the ``S`` TypeVar in @@ -508,11 +499,13 @@ involving Literal bools. For example, we can combine ``Literal[True]``, else: scalar += "foo" # Type checks: type of 'scalar' is narrowed to 'str' +.. _literal-final-interactions: + Interactions with Final """"""""""""""""""""""" -The ``Final`` qualifier can be used to declare that some variable or -attribute cannot be reassigned:: +A :term:`bare Final` type qualifier can be used to declare that some variable +or attribute cannot be reassigned:: foo: Final = 3 foo = 4 # Error: 'foo' is declared to be Final @@ -525,8 +518,8 @@ is valid to use in any context that expects a ``Literal[3]``:: expects_three(foo) # Type checks, since 'foo' is Final and equal to 3 -The ``Final`` qualifier serves as a shorthand for declaring that a variable -is *effectively Literal*. +A :term:`bare Final` type qualifier serves as a shorthand for declaring that a +variable is *effectively Literal*. Type checkers are expected to support this shortcut. Specifically, given a variable or attribute assignment @@ -537,7 +530,7 @@ any context that expects a ``Literal[value]``. Type checkers are not obligated to understand any other uses of Final. For example, whether or not the following program type checks is left unspecified:: - # Note: The assignment does not exactly match the form 'var: Final = value'. + # Note: Literal inference is unspecified for explicitly typed Final. bar1: Final[int] = 3 expects_three(bar1) # May or may not be accepted by type checkers @@ -568,7 +561,8 @@ Valid locations for ``LiteralString`` type_argument: List[LiteralString] - T = TypeVar("T", bound=LiteralString) + def enforce_literal[T: LiteralString](value: T) -> T: + return value It cannot be nested within unions of ``Literal`` types: @@ -584,28 +578,28 @@ Type inference Inferring ``LiteralString`` """"""""""""""""""""""""""" -Any literal string type is compatible with ``LiteralString``. For +Any literal string type is assignable to ``LiteralString``. For example, ``x: LiteralString = "foo"`` is valid because ``"foo"`` is inferred to be of type ``Literal["foo"]``. We also infer ``LiteralString`` in the following cases: -+ Addition: ``x + y`` is of type ``LiteralString`` if both ``x`` and - ``y`` are compatible with ``LiteralString``. ++ Addition: ``x + y`` is of type ``LiteralString`` if the types of both ``x`` + and ``y`` are assignable to ``LiteralString``. + Joining: ``sep.join(xs)`` is of type ``LiteralString`` if ``sep``'s - type is compatible with ``LiteralString`` and ``xs``'s type is - compatible with ``Iterable[LiteralString]``. + type is assignable to ``LiteralString`` and ``xs``'s type is + assignable to ``Iterable[LiteralString]``. -+ In-place addition: If ``s`` has type ``LiteralString`` and ``x`` has - type compatible with ``LiteralString``, then ``s += x`` preserves - ``s``'s type as ``LiteralString``. ++ In-place addition: If ``s`` has type ``LiteralString`` and ``x`` has a type + assignable to ``LiteralString``, then ``s += x`` preserves ``s``'s type as + ``LiteralString``. -+ String formatting: An f-string has type ``LiteralString`` if and only - if its constituent expressions are literal strings. ``s.format(...)`` - has type ``LiteralString`` if and only if ``s`` and the arguments have - types compatible with ``LiteralString``. ++ String formatting: An f-string has type ``LiteralString`` if and only if its + constituent expressions are literal strings. ``s.format(...)`` is assignable + to ``LiteralString`` if and only if ``s`` and the arguments have types + assignable to ``LiteralString``. In all other cases, if one or more of the composed values has a non-literal type ``str``, the composition of types will have type @@ -613,7 +607,7 @@ non-literal type ``str``, the composition of types will have type has type ``str``. This matches the pre-existing behavior of type checkers. -``LiteralString`` is compatible with the type ``str``. It inherits all +``LiteralString`` is assignable to the type ``str``. It inherits all methods from ``str``. So, if we have a variable ``s`` of type ``LiteralString``, it is safe to write ``s.startswith("hello")``. @@ -626,7 +620,7 @@ check: if s == "bar": reveal_type(s) # => Literal["bar"] -Such a refined type in the if-block is also compatible with +Such a refined type in the if-block is also assignable to ``LiteralString`` because its type is ``Literal["bar"]``. @@ -699,7 +693,7 @@ Format strings using literal strings: expect_literal_string("hello {}".format(username)) # Not OK -Other literal types, such as literal integers, are not compatible with ``LiteralString``: +Other literal types, such as literal integers, are not assignable to ``LiteralString``: :: @@ -739,18 +733,16 @@ Conditional statements and expressions work as expected: return result # OK -Interaction with TypeVars and Generics -"""""""""""""""""""""""""""""""""""""" +Interaction with Type Variables and Generics +"""""""""""""""""""""""""""""""""""""""""""" -TypeVars can be bound to ``LiteralString``: +Type variables can use ``LiteralString`` as an upper bound: :: - from typing import Literal, LiteralString, TypeVar - - TLiteral = TypeVar("TLiteral", bound=LiteralString) + from typing import Literal, LiteralString - def literal_identity(s: TLiteral) -> TLiteral: + def literal_identity[T: LiteralString](s: T) -> T: return s hello: Literal["hello"] = "hello" @@ -763,14 +755,14 @@ TypeVars can be bound to ``LiteralString``: s_error: str literal_identity(s_error) - # Error: Expected TLiteral (bound to LiteralString), got str. + # Error: Expected T (bound to LiteralString), got str. ``LiteralString`` can be used as a type argument for generic classes: :: - class Container(Generic[T]): + class Container[T]: def __init__(self, value: T) -> None: self.value = value @@ -785,28 +777,3 @@ Standard containers like ``List`` work as expected: :: xs: List[LiteralString] = ["foo", "bar", "baz"] - - -.. _literalstring-overloads: - -Interactions with Overloads -""""""""""""""""""""""""""" - -Literal strings and overloads do not need to interact in a special -way: the existing rules work fine. ``LiteralString`` can be used as a -fallback overload where a specific ``Literal["foo"]`` type does not -match: - -:: - - @overload - def foo(x: Literal["foo"]) -> int: ... - @overload - def foo(x: LiteralString) -> bool: ... - @overload - def foo(x: str) -> str: ... - - x1: int = foo("foo") # First overload. - x2: bool = foo("bar") # Second overload. - s: str - x3: str = foo(s) # Third overload. diff --git a/docs/spec/namedtuples.rst b/docs/spec/namedtuples.rst index 835d196f4..87a6e4332 100644 --- a/docs/spec/namedtuples.rst +++ b/docs/spec/namedtuples.rst @@ -20,6 +20,14 @@ Type checkers should support the class syntax:: y: int units: str = "meters" +Fields must be annotated attributes - methods and un-annotated attributes are not +considered fields. Field names may not start with an underscore:: + + class MyTuple(NamedTuple): + x1 = 1 # Not a field + def x2() -> None: pass # Not a field + _x3: int # Type error: illegal field name + Regardless of whether the class syntax or factory function call is used to define a named tuple, type checkers should synthesize a ``__new__`` method based on the named tuple fields. This mirrors the runtime behavior. In the example @@ -46,6 +54,15 @@ in the base class:: name: str # OK x: int # Type error (invalid override of named tuple field) +Namedtuple fields may be conditional, via checks of the same +:ref:`statically-known conditions` +that a type-checker understands elsewhere, such as Python version:: + + class ConditionalField(NamedTuple): + x: int + if sys.version_info >= (3, 14): + y: str + In Python 3.11 and newer, the class syntax supports generic named tuple classes. Type checkers should support this:: @@ -79,17 +96,21 @@ A type checker may support the factory function call in its various forms:: Point5 = NamedTuple('Point5', [('x', int), ('y', int)]) Point6 = NamedTuple('Point6', (('x', int), ('y', int))) -At runtime, the ``namedtuple`` function disallows field names that are -illegal Python identifiers and either raises an exception or replaces these -fields with a parameter name of the form ``_N``. The behavior depends on -the value of the ``rename`` argument. Type checkers may replicate this -behavior statically:: +At runtime, the ``namedtuple`` function disallows field names that begin with +an underscore or are illegal Python identifiers, and either raises an exception +or replaces these fields with a parameter name of the form ``_N``. The behavior +depends on the value of the ``rename`` argument. Type checkers may replicate +this behavior statically:: NT1 = namedtuple("NT1", ["a", "a"]) # Type error (duplicate field name) NT2 = namedtuple("NT2", ["abc", "def"], rename=False) # Type error (illegal field name) + NT3 = namedtuple("NT3", ["abc", "_d"], rename=False) # Type error (illegal field name) + + NT4 = namedtuple("NT4", ["abc", "def"], rename=True) # OK + NT4(abc="", _1="") # OK - NT3 = namedtuple("NT3", ["abc", "def"], rename=True) # OK - NT3(abc="", _1="") # OK + NT5 = namedtuple("NT5", ["abc", "_d"], rename=True) # OK + NT5(abc="", _1="") # OK The ``namedtuple`` function also supports a ``defaults`` keyword argument that specifies default values for the fields. Type checkers may support this:: @@ -133,11 +154,12 @@ this:: x, y = p # Type error (too few values to unpack) -Type Compatibility Rules ------------------------- +Assignability +------------- -A named tuple is a subtype of a ``tuple`` with a known length and parameterized -by types corresponding to the named tuple's individual field types:: +A named tuple is :term:`assignable` to a ``tuple`` with a known length and +parameterized by types corresponding to the named tuple's individual field +types:: p = Point(x=1, y=2, units="inches") v1: tuple[int, int, str] = p # OK diff --git a/docs/spec/narrowing.rst b/docs/spec/narrowing.rst index cbab74f09..6199aa092 100644 --- a/docs/spec/narrowing.rst +++ b/docs/spec/narrowing.rst @@ -34,9 +34,7 @@ User-defined type guards can be generic functions, as shown in this example: :: - _T = TypeVar("_T") - - def is_two_element_tuple(val: Tuple[_T, ...]) -> TypeGuard[tuple[_T, _T]]: + def is_two_element_tuple[T](val: tuple[T, ...]) -> TypeGuard[tuple[T, T]]: return len(val) == 2 def func(names: tuple[str, ...]): @@ -65,9 +63,7 @@ than one argument: return allow_empty return all(isinstance(x, str) for x in val) - _T = TypeVar("_T") - - def is_set_of(val: set[Any], type: type[_T]) -> TypeGuard[Set[_T]]: + def is_set_of[T](val: set[Any], type: type[T]) -> TypeGuard[set[T]]: return all(isinstance(x, type) for x in val) @@ -110,6 +106,8 @@ is not narrowed in the negative case. reveal_type(val) # tuple[str, str] ... +.. _`typeis`: + TypeIs ------ @@ -149,8 +147,8 @@ To specify the behavior of ``TypeIs``, we use the following terminology: else: assert_type(val, NN) -The return type ``R`` must be consistent with ``I``. The type checker should -emit an error if this condition is not met. +The return type ``R`` must be :term:`assignable` to ``I``. The type checker +should emit an error if this condition is not met. Formally, type *NP* should be narrowed to :math:`A \land R`, the intersection of *A* and *R*, and type *NN* should be narrowed to @@ -193,7 +191,8 @@ argument's previously-known type:: else: assert_type(x, int) -It is an error to narrow to a type that is not consistent with the input type:: +It is an error to narrow to a type that is not :term:`assignable` to the input +type:: from typing import TypeIs diff --git a/docs/spec/overload.rst b/docs/spec/overload.rst index 3b534046d..85e8acb62 100644 --- a/docs/spec/overload.rst +++ b/docs/spec/overload.rst @@ -1,11 +1,21 @@ .. _`overload`: -``@overload`` +``Overloads`` ============= +In Python, it is common for callable objects to be polymorphic, meaning +they accept different types of arguments. It is also common for such +callables to return different types depending on the arguments passed to +them. Overloads provide a way to describe the accepted input signatures +and corresponding return types. + + +Overload definitions +^^^^^^^^^^^^^^^^^^^^ + The ``@overload`` decorator allows describing functions and methods -that support multiple different combinations of argument types. This -pattern is used frequently in builtin modules and types. For example, +that support multiple different combinations of argument types. This +pattern is used frequently in builtin modules and types. For example, the ``__getitem__()`` method of the ``bytes`` type can be described as follows:: @@ -18,9 +28,9 @@ follows:: @overload def __getitem__(self, s: slice) -> bytes: ... -This description is more precise than would be possible using unions -(which cannot express the relationship between the argument and return -types):: +This description is more precise than would be possible using unions, +which cannot express the relationship between the argument and return +types:: class bytes: ... @@ -30,39 +40,40 @@ Another example where ``@overload`` comes in handy is the type of the builtin ``map()`` function, which takes a different number of arguments depending on the type of the callable:: - from typing import TypeVar, overload + from typing import overload from collections.abc import Callable, Iterable, Iterator - T1 = TypeVar('T1') - T2 = TypeVar('T2') - S = TypeVar('S') - @overload - def map(func: Callable[[T1], S], iter1: Iterable[T1]) -> Iterator[S]: ... + def map[T1, S](func: Callable[[T1], S], iter1: Iterable[T1]) -> Iterator[S]: ... @overload - def map(func: Callable[[T1, T2], S], - iter1: Iterable[T1], iter2: Iterable[T2]) -> Iterator[S]: ... + def map[T1, T2, S]( + func: Callable[[T1, T2], S], + iter1: Iterable[T1], + iter2: Iterable[T2], + ) -> Iterator[S]: ... # ... and we could add more items to support more than two iterables Note that we could also easily add items to support ``map(None, ...)``:: @overload - def map(func: None, iter1: Iterable[T1]) -> Iterable[T1]: ... + def map[T1](func: None, iter1: Iterable[T1]) -> Iterable[T1]: ... @overload - def map(func: None, - iter1: Iterable[T1], - iter2: Iterable[T2]) -> Iterable[tuple[T1, T2]]: ... + def map[T1, T2]( + func: None, + iter1: Iterable[T1], + iter2: Iterable[T2], + ) -> Iterable[tuple[T1, T2]]: ... Uses of the ``@overload`` decorator as shown above are suitable for -stub files. In regular modules, a series of ``@overload``-decorated +stub files. In regular modules, a series of ``@overload``-decorated definitions must be followed by exactly one non-``@overload``-decorated definition (for the same function/method). The ``@overload``-decorated definitions are for the benefit of the type checker only, since they will be overwritten by the non-``@overload``-decorated definition, while the latter is used at -runtime but should be ignored by a type checker. At runtime, calling -a ``@overload``-decorated function directly will raise -``NotImplementedError``. Here's an example of a non-stub overload +runtime but should be ignored by a type checker. At runtime, calling +an ``@overload``-decorated function directly will raise +``NotImplementedError``. Here's an example of a non-stub overload that can't easily be expressed using a union or a type variable:: @overload @@ -77,15 +88,11 @@ that can't easily be expressed using a union or a type variable:: def utf8(value): -A constrained ``TypeVar`` type can often be used instead of using the -``@overload`` decorator. For example, the definitions of ``concat1`` -and ``concat2`` in this stub file are equivalent:: - - from typing import TypeVar - - AnyStr = TypeVar('AnyStr', str, bytes) +A constrained ``TypeVar`` type can sometimes be used instead of +using the ``@overload`` decorator. For example, the definitions +of ``concat1`` and ``concat2`` in this stub file are equivalent:: - def concat1(x: AnyStr, y: AnyStr) -> AnyStr: ... + def concat1[S: (str, bytes)](x: S, y: S) -> S: ... @overload def concat2(x: str, y: str) -> str: ... @@ -97,10 +104,334 @@ be represented precisely using type variables. We recommend that ``@overload`` is only used in cases where a type variable is not sufficient. -Another important difference between type variables such as ``AnyStr`` -and using ``@overload`` is that the prior can also be used to define -constraints for generic class type parameters. For example, the type -parameter of the generic class ``typing.IO`` is constrained (only -``IO[str]``, ``IO[bytes]`` and ``IO[Any]`` are valid):: +Another important difference between type variables and an ``@overload`` +is that the former can also be used to define constraints for generic +class type parameters. For example, the type parameter of the generic +class ``typing.IO`` is constrained (only ``IO[str]``, ``IO[bytes]`` +and ``IO[Any]`` are valid):: + + class IO[S: (str, bytes)]: ... + + +Invalid overload definitions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Type checkers should enforce the following rules for overload definitions. + +At least two ``@overload``-decorated definitions must be present. If only +one is present, an error should be reported. + +The ``@overload``-decorated definitions must be followed by an overload +implementation, which does not include an ``@overload`` decorator. Type +checkers should report an error or warning if an implementation is missing. +Overload definitions within stub files, protocols, and on abstract methods +within abstract base classes are exempt from this check. + +If one overload signature is decorated with ``@staticmethod`` or +``@classmethod``, all overload signatures must be similarly decorated. The +implementation, if present, must also have a consistent decorator. Type +checkers should report an error if these conditions are not met. + +If a ``@final`` or ``@override`` decorator is supplied for a function with +overloads, the decorator should be applied only to the overload implementation +if it is present. If an overload implementation isn't present (for example, in +a stub file), the ``@final`` or ``@override`` decorator should be applied only +to the first overload. Type checkers should enforce these rules and generate +an error when they are violated. If a ``@final`` or ``@override`` decorator +follows these rules, a type checker should treat the decorator as if it is +present on all overloads. + +Overloads are allowed to use a mixture of ``async def`` and ``def`` statements +within the same overload definition. Type checkers should convert +``async def`` statements to a non-async signature (wrapping the return +type in a ``Coroutine``) before testing for implementation consistency. + + +Implementation consistency +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +If an overload implementation is defined, type checkers should validate +that it is consistent with all of its associated overload signatures. +The implementation should accept all potential sets of arguments +that are accepted by the overloads and should produce all potential return +types produced by the overloads. In typing terms, this means the input +signature of the implementation should be :term:`assignable` to the input +signatures of all overloads, and the return type of all overloads should be +assignable to the return type of the implementation. + +If the implementation is inconsistent with its overloads, a type checker +should report an error:: + + @overload + def func(x: str, /) -> str: ... + @overload + def func(x: int) -> int: ... + + # This implementation is inconsistent with the second overload + # because it does not accept a keyword argument ``x`` and the + # the overload's return type ``int`` is not assignable to the + # implementation's return type ``str``. + def func(x: int | str, /) -> str: + return str(x) + +When a type checker checks the implementation for consistency with overloads, +it should first apply any transforms that change the effective type of the +implementation including the presence of a ``yield`` statement in the +implementation body, the use of ``async def``, and the presence of additional +decorators. + + +Overload call evaluation +^^^^^^^^^^^^^^^^^^^^^^^^ + +When a type checker evaluates the call of an overloaded function, it +attempts to "match" the supplied arguments with one or more overloads. +This section describes the algorithm that type checkers should use +for overload matching. + +Only the overloads (the ``@overload``-decorated signatures) should be +considered for matching purposes. The implementation, if provided, +should be ignored for purposes of overload matching. + +Step 1 +~~~~~~ + +Examine the argument list to determine the number of +positional and keyword arguments. Use this information to eliminate any +overload candidates that are not plausible based on their +input signatures. + +- If no candidate overloads remain, generate an error and stop. +- If only one candidate overload remains, it is the winning match. Evaluate + it as if it were a non-overloaded function call and stop. +- If two or more candidate overloads remain, proceed to step 2. + +Step 2 +~~~~~~ + +Evaluate each remaining overload as a regular (non-overloaded) +call to determine whether it is compatible with the supplied +argument list. Unlike step 1, this step considers the types of the parameters +and arguments. During this step, do not generate any user-visible errors. +Simply record which of the overloads result in evaluation errors. + +- If all overloads result in errors, proceed to step 3. +- If only one overload evaluates without error, it is the winning match. + Evaluate it as if it were a non-overloaded function call and stop. +- If two or more candidate overloads remain, proceed to step 4. + +Step 3 +~~~~~~ + +If step 2 produces errors for all overloads, perform +"argument type expansion". Union types can be expanded +into their constituent subtypes. For example, the type ``int | str`` can +be expanded into ``int`` and ``str``. + +Type expansion should be performed one argument at a time from left to +right. Each expansion results in sets of effective argument types. +For example, if there are two arguments whose types evaluate to +``int | str`` and ``int | bytes``, expanding the first argument type +results in two sets of argument types: ``(int, int | bytes)`` and +``(str, int | bytes)``. If type expansion for the second argument is required, +four sets of argument types are produced: ``(int, int)``, ``(int, bytes)``, +``(str, int)``, and ``(str, bytes)``. + +After each argument's expansion, return to step 2 and evaluate all +expanded argument lists. + +- If all argument lists evaluate successfully, combine their + respective return types by union to determine the final return type + for the call, and stop. +- If argument expansion has been applied to all arguments and one or + more of the expanded argument lists cannot be evaluated successfully, + generate an error and stop. + + +For additional details about argument type expansion, see +`argument-type-expansion`_ below. + +Step 4 +~~~~~~ + +If the argument list is compatible with two or more overloads, +determine whether one or more of the overloads has a variadic parameter +(either ``*args`` or ``**kwargs``) that maps to a corresponding argument +that supplies an indeterminate number of positional or keyword arguments. +If so, eliminate overloads that do not have a variadic parameter. + +- If this results in only one remaining candidate overload, it is + the winning match. Evaluate it as if it were a non-overloaded function + call and stop. +- If two or more candidate overloads remain, proceed to step 5. + +Step 5 +~~~~~~ + +For all arguments, determine whether all possible +:term:`materializations ` of the argument's type are assignable to +the corresponding parameter type for each of the remaining overloads. If so, +eliminate all of the subsequent remaining overloads. + +Consider the following example:: + + @overload + def example(x: list[int]) -> int: ... + @overload + def example(x: list[Any]) -> str: ... + @overload + def example(x: Any) -> Any: ... + + def test(a: list[Any]): + # All materializations of list[Any] will match either the first or + # second overload, so the third overload can be eliminated. + example(a) + +This rule eliminates overloads that will never be chosen even if the +caller eliminates types that include ``Any``. + +If the call involves more than one argument, all possible materializations of +every argument type must be assignable to its corresponding parameter type. +If this condition exists, all subsequent remaining overloads should be eliminated. + +Once this filtering process is applied for all arguments, examine the return +types of the remaining overloads. If these return types include type variables, +they should be replaced with their solved types. If the resulting return types +for all remaining overloads are :term:`equivalent`, proceed to step 6. + +If the return types are not equivalent, overload matching is ambiguous. In +this case, infer a return type that is :term:`assignable` to each of the +remaining return types and permits operations supported by any of them without +errors, then stop. A type checker may infer ``Any`` or a more precise gradual +type that satisfies these requirements. + +For example, if the remaining return types are ``int`` and ``str``, the result +should be assignable to both ``int`` and ``str``, and both ``result + 1`` and +``result.upper()`` should be accepted. Inferring the ordinary union ``int | str`` +would not satisfy these requirements. + +Step 6 +~~~~~~ + +Choose the first remaining candidate overload as the winning +match. Evaluate it as if it were a non-overloaded function call and stop. + +Examples +~~~~~~~~ + +Example 1:: + + @overload + def example1(x: int, y: str) -> int: ... + @overload + def example1(x: str) -> str: ... + + example1() # Error in step 1: no plausible overloads + example1(1, "") # Step 1 eliminates second overload + example1("") # Step 1 eliminates first overload + + example1("", "") # Error in step 2: no compatible overloads + example1(1) # Error in step 2: no compatible overloads + + +Example 2:: + + @overload + def example2(x: int, y: str, z: int) -> str: ... + @overload + def example2(x: int, y: int, z: int) -> int: ... + + def test(values: list[str | int]): + # In this example, argument type expansion is + # performed on the first two arguments. Expansion + # of the third is unnecessary. + r1 = example2(1, values[0], 1) + reveal_type(r1) # Should reveal str | int + + # Here, the types of all three arguments are expanded + # without success. + example2(values[0], values[1], values[2]) # Error in step 3 + + +Example 3:: + + @overload + def example3(x: int, /) -> tuple[int]: ... + @overload + def example3(x: int, y: int, /) -> tuple[int, int]: ... + @overload + def example3(*args: int) -> tuple[int, ...]: ... + + def test(val: list[int]): + # Step 1 eliminates second overload. Step 4 and + # step 5 do not apply. Step 6 picks the first + # overload. + r1 = example3(1) + reveal_type(r1) # Should reveal tuple[int] + + # Step 1 eliminates first overload. Step 4 and + # step 5 do not apply. Step 6 picks the second + # overload. + r2 = example3(1, 2) + reveal_type(r2) # Should reveal tuple[int, int] + + # Step 1 doesn't eliminate any overloads. Step 4 + # picks the third overload. + r3 = example3(*val) + reveal_type(r3) # Should reveal tuple[int, ...] + + +Example 4:: + + @overload + def example4(x: list[int], y: int) -> int: ... + @overload + def example4(x: list[str], y: str) -> int: ... + @overload + def example4(x: int, y: int) -> list[int]: ... + + def test(v1: list[Any], v2: Any): + # Step 2 eliminates the third overload. Step 5 + # determines that first and second overloads + # both apply and are ambiguous due to Any, but + # return types are consistent. + r1 = example4(v1, v2) + reveal_type(r1) # Reveals int + + # Step 2 eliminates the second overload. Step 5 + # determines that first and third overloads + # both apply and are ambiguous due to Any, and + # the return types are inconsistent. + r2 = example4(v2, 1) + int_result: int = r2 # OK + list_result: list[int] = r2 # OK + + +.. _argument-type-expansion: + +Argument type expansion +^^^^^^^^^^^^^^^^^^^^^^^ + +When performing argument type expansion, a type that is equivalent to +a union of a finite set of subtypes should be expanded into its constituent +subtypes. This includes the following cases. + +1. Explicit unions: Each subtype of the union should be considered as a + separate argument type. For example, the type ``int | str`` should be expanded + into ``int`` and ``str``. + +2. ``bool`` should be expanded into ``Literal[True]`` and ``Literal[False]``. + +3. ``Enum`` types (other than those that derive from ``enum.Flag``) should + be expanded into their literal members. + +4. ``type[A | B]`` should be expanded into ``type[A]`` and ``type[B]``. + +5. Tuples of known length that contain expandable types should be expanded + into all possible combinations of their element types. For example, the type + ``tuple[int | str, bool]`` should be expanded into ``(int, Literal[True])``, + ``(int, Literal[False])``, ``(str, Literal[True])``, and + ``(str, Literal[False])``. - class IO(Generic[AnyStr]): ... +The above list may not be exhaustive, and additional cases may be added in +the future as the type system evolves. diff --git a/docs/spec/protocol.rst b/docs/spec/protocol.rst index 5532276f0..bfa352aa2 100644 --- a/docs/spec/protocol.rst +++ b/docs/spec/protocol.rst @@ -8,7 +8,7 @@ Protocols Terminology ^^^^^^^^^^^ -The term *protocols* is used for types supporting structural +The term *protocols* is used for some types supporting :term:`structural` subtyping. The reason is that the term *iterator protocol*, for example, is widely understood in the community, and coming up with a new term for this concept in a statically typed context would just create @@ -22,19 +22,19 @@ The distinction is not important most of the time, and in other cases we can just add a qualifier such as *protocol classes* when referring to the static type concept. -If a class includes a protocol in its MRO, the class is called -an *explicit* subclass of the protocol. If a class is a structural subtype -of a protocol, it is said to implement the protocol and to be compatible -with a protocol. If a class is compatible with a protocol but the protocol -is not included in the MRO, the class is an *implicit* subtype -of the protocol. (Note that one can explicitly subclass a protocol and -still not implement it if a protocol attribute is set to ``None`` -in the subclass, see Python :py:ref:`data model ` -for details.) +If a class includes a protocol in its MRO, the class is called an *explicit* +subclass of the protocol. If a class defines all attributes and methods of a +protocol with types that are :term:`assignable` to the types of the protocol's +attributes and methods, it is said to implement the protocol and to be +assignable to the protocol. If a class is assignable to a protocol but the +protocol is not included in the MRO, the class is *implicitly* assignable to +the protocol. (Note that one can explicitly subclass a protocol and still not +implement it if a protocol attribute is set to ``None`` in the subclass. See +Python :py:ref:`data model ` for details.) -The attributes (variables and methods) of a protocol that are mandatory -for another class in order to be considered a structural subtype are called -protocol members. +The attributes (variables and methods) of a protocol that are mandatory for +another class for it to be assignable to the protocol are called "protocol +members". .. _protocol-definition: @@ -51,10 +51,10 @@ at the end of the list. Here is a simple example:: def close(self) -> None: ... -Now if one defines a class ``Resource`` with a ``close()`` method that has -a compatible signature, it would implicitly be a subtype of -``SupportsClose``, since the structural subtyping is used for -protocol types:: +Now if one defines a class ``Resource`` with a ``close()`` method whose type +signature is :term:`assignable` to ``SupportsClose.close``, it would implicitly +be assignable to ``SupportsClose``, since :term:`structural` assignability is +used for protocol types:: class Resource: ... @@ -74,10 +74,9 @@ be used in every context where normal types can:: close_all([f, r]) # OK! close_all([1]) # Error: 'int' has no 'close' method -Note that both the user-defined class ``Resource`` and the built-in -``IO`` type (the return type of ``open()``) are considered subtypes of -``SupportsClose``, because they provide a ``close()`` method with -a compatible type signature. +Note that both the user-defined class ``Resource`` and the built-in ``IO`` type +(the return type of ``open()``) are assignable to ``SupportsClose``, because +each provides a ``close()`` method with an assignable type signature. Protocol members @@ -147,9 +146,9 @@ expected to automatically detect that a class implements a given protocol. So while it's possible to subclass a protocol explicitly, it's *not necessary* to do so for the sake of type-checking. -The default implementations cannot be used if -the subtype relationship is implicit and only via structural -subtyping -- the semantics of inheritance is not changed. Examples:: +The default implementations cannot be used if the assignable-to relationship is +implicit and only :term:`structural` -- the semantics of inheritance is not +changed. Examples:: class PColor(Protocol): @abstractmethod @@ -181,10 +180,10 @@ subtyping -- the semantics of inheritance is not changed. Examples:: represent(nice) # OK represent(another) # Also OK -Note that there is little difference between explicit and implicit -subtypes; the main benefit of explicit subclassing is to get some protocol -methods "for free". In addition, type checkers can statically verify that -the class actually implements the protocol correctly:: +Note that there is little difference between explicitly subclassing and +implicitly implementing the protocol; the main benefit of explicit subclassing +is to get some protocol methods "for free". In addition, type checkers can +statically verify that the class actually implements the protocol correctly:: class RGB(Protocol): rgb: tuple[int, int, int] @@ -201,22 +200,22 @@ the class actually implements the protocol correctly:: A class can explicitly inherit from multiple protocols and also from normal classes. In this case methods are resolved using normal MRO and a type checker -verifies that all subtyping are correct. The semantics of ``@abstractmethod`` -is not changed; all of them must be implemented by an explicit subclass -before it can be instantiated. +verifies that all member assignability is correct. The semantics of +``@abstractmethod`` is not changed; all of them must be implemented by an +explicit subclass before it can be instantiated. Merging and extending protocols ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The general philosophy is that protocols are mostly like regular ABCs, -but a static type checker will handle them specially. Subclassing a protocol -class would not turn the subclass into a protocol unless it also has -``typing.Protocol`` as an explicit base class. Without this base, the class -is "downgraded" to a regular ABC that cannot be used with structural +The general philosophy is that protocols are mostly like regular ABCs, but a +static type checker will handle them specially. Subclassing a protocol class +would not turn the subclass into a protocol unless it also has +``typing.Protocol`` as an explicit base class. Without this base, the class is +"downgraded" to a regular ABC that cannot be used with :term:`structural` subtyping. The rationale for this rule is that we don't want to accidentally -have some class act as a protocol just because one of its base classes -happens to be one. We still slightly prefer nominal subtyping over structural +have some class act as a protocol just because one of its base classes happens +to be one. We still slightly prefer :term:`nominal` subtyping over structural subtyping in the static typing world. A subprotocol can be defined by having *both* one or more protocols as @@ -246,9 +245,9 @@ with ``typing.Sized``:: class SizedAndClosable(Sized, SupportsClose, Protocol): pass -The two definitions of ``SizedAndClosable`` are equivalent. -Subclass relationships between protocols are not meaningful when -considering subtyping, since structural compatibility is +The two definitions of ``SizedAndClosable`` are equivalent. Subclass +relationships between protocols are not meaningful when considering +assignability, since :term:`structural` :term:`assignability ` is the criterion, not the MRO. If ``Protocol`` is included in the base class list, all the other base classes @@ -258,6 +257,7 @@ from regular ABCs, where abstractness is simply defined by having at least one abstract method being unimplemented. Protocol classes must be marked *explicitly*. +.. _`generic-protocols`: Generic protocols ^^^^^^^^^^^^^^^^^ @@ -266,17 +266,26 @@ Generic protocols are important. For example, ``SupportsAbs``, ``Iterable`` and ``Iterator`` are generic protocols. They are defined similar to normal non-protocol generic types:: - class Iterable(Protocol[T]): + class Iterable[T](Protocol): @abstractmethod def __iter__(self) -> Iterator[T]: ... -``Protocol[T, S, ...]`` is allowed as a shorthand for -``Protocol, Generic[T, S, ...]``. +The older (pre-3.12) syntax ``Protocol[T, S, ...]`` remains available as a +shorthand for ``Protocol, Generic[T, S, ...]``. It is an error to combine the +shorthand with ``Generic[T, S, ...]`` or to mix it with the new +``class Iterable[T]`` form:: -User-defined generic protocols support explicitly declared variance. -Type checkers will warn if the inferred variance is different from -the declared variance. Examples:: + class Iterable(Protocol[T], Generic[T]): # INVALID + ... + + class Iterable[T](Protocol[T]): # INVALID + ... + +When using the generics syntax introduced in Python 3.12, the variance of +type variables is inferred. When using the pre-3.12 generics syntax, variance +must be specified (unless ``infer_variance=True`` is used). Type checkers will +warn if the declared variance does not match the protocol definition. Examples:: T = TypeVar('T') T_co = TypeVar('T_co', covariant=True) @@ -303,7 +312,7 @@ the declared variance. Examples:: var: Proto[float] another_var: Proto[int] - var = another_var # Error! 'Proto[float]' is incompatible with 'Proto[int]'. + var = another_var # Error! 'Proto[float]' is not assignable to 'Proto[int]'. Note that unlike nominal classes, de facto covariant protocols cannot be declared as invariant, since this can break transitivity of subtyping. @@ -328,7 +337,7 @@ like trees in an abstract fashion:: def leaves(self) -> Iterable['Traversable']: ... -Note that for recursive protocols, a class is considered a subtype of +Note that for recursive protocols, a class is considered assignable to the protocol in situations where the decision depends on itself. Continuing the previous example:: @@ -345,7 +354,7 @@ Continuing the previous example:: def walk(graph: Traversable) -> None: ... tree: Tree[float] = Tree() - walk(tree) # OK, 'Tree[float]' is a subtype of 'Traversable' + walk(tree) # OK, 'Tree[float]' is assignable to 'Traversable' Self-types in protocols @@ -354,43 +363,42 @@ Self-types in protocols The self-types in protocols follow the :ref:`rules for other methods `. For example:: - C = TypeVar('C', bound='Copyable') class Copyable(Protocol): - def copy(self: C) -> C: + def copy[C: Copyable](self: C) -> C: + ... class One: def copy(self) -> 'One': ... - T = TypeVar('T', bound='Other') class Other: - def copy(self: T) -> T: + def copy[T: Other](self: T) -> T: ... c: Copyable c = One() # OK c = Other() # Also OK -Subtyping relationships with other types -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Assignability relationships with other types +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Protocols cannot be instantiated, so there are no values whose runtime type is a protocol. For variables and parameters with protocol types, -subtyping relationships are subject to the following rules: +assignability relationships are subject to the following rules: -* A protocol is never a subtype of a concrete type. -* A concrete type ``X`` is a subtype of protocol ``P`` - if and only if ``X`` implements all protocol members of ``P`` with - compatible types. In other words, subtyping with respect to a protocol is - always structural. -* A protocol ``P1`` is a subtype of another protocol ``P2`` if ``P1`` defines - all protocol members of ``P2`` with compatible types. +* A protocol is never assignable to a concrete type. +* A concrete type ``X`` is assignable to a protocol ``P`` if and only if ``X`` + implements all protocol members of ``P`` with assignable types. In other + words, :term:`assignability ` with respect to a protocol is + always :term:`structural`. +* A protocol ``P1`` is assignable to another protocol ``P2`` if ``P1`` defines + all protocol members of ``P2`` with assignable types. Generic protocol types follow the same rules of variance as non-protocol types. Protocol types can be used in all contexts where any other types can be used, such as in unions, ``ClassVar``, type variables bounds, etc. Generic protocols follow the rules for generic abstract classes, except for -using structural compatibility instead of compatibility defined by +using structural assignability instead of assignability defined by inheritance relationships. Static type checkers will recognize protocol implementations, even if the @@ -399,8 +407,7 @@ corresponding protocols are *not imported*:: # file lib.py from collections.abc import Sized - T = TypeVar('T', contravariant=True) - class ListLike(Sized, Protocol[T]): + class ListLike[T](Sized, Protocol): def append(self, x: T) -> None: pass @@ -460,8 +467,9 @@ Example:: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Variables and parameters annotated with ``type[Proto]`` accept only concrete -(non-protocol) subtypes of ``Proto``. The main reason for this is to allow -instantiation of parameters with such types. For example:: +(non-protocol) :term:`consistent subtypes ` of ``Proto``. +The main reason for this is to allow instantiation of parameters with such +types. For example:: class Proto(Protocol): @abstractmethod @@ -489,7 +497,7 @@ For normal (non-abstract) classes, the behavior of ``type[]`` is not changed. A class object is considered an implementation of a protocol if accessing -all members on it results in types compatible with the protocol members. +all members on it results in types assignable to the types of the protocol members. For example:: from typing import Any, Protocol @@ -505,6 +513,7 @@ For example:: a: ProtoA = C # Type check error, signatures don't match! b: ProtoB = C # OK +.. _`protocol-newtype-aliases`: ``NewType()`` and type aliases ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -525,20 +534,19 @@ illusion that a distinct type is provided:: In contrast, type aliases are fully supported, including generic type aliases:: - from typing import TypeVar from collections.abc import Reversible, Iterable, Sized - T = TypeVar('T') - class SizedIterable(Iterable[T], Sized, Protocol): + class SizedIterable[T](Iterable[T], Sized, Protocol): pass - CompatReversible = Reversible[T] | SizedIterable[T] + + type CompatReversible[T] = Reversible[T] | SizedIterable[T] Modules as implementations of protocols ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ A module object is accepted where a protocol is expected if the public -interface of the given module is compatible with the expected protocol. +interface of the given module is assignable to the expected protocol. For example:: # file default_config.py @@ -560,7 +568,7 @@ For example:: setup(default_config) # OK -To determine compatibility of module level functions, the ``self`` argument +To determine assignability of module level functions, the ``self`` argument of the corresponding protocol methods is dropped. For example:: # callbacks.py @@ -622,11 +630,11 @@ the risks for this feature, the following rules are applied. if it only contains methods as members (for example ``Sized``, ``Iterator``, etc). A protocol that contains at least one non-method member (like ``x: int``) is called a data protocol. -* *Unsafe overlap*: A type ``X`` is called unsafely overlapping with - a protocol ``P``, if ``X`` is not a subtype of ``P``, but it is a subtype - of the type erased version of ``P`` where all members have type ``Any``. - In addition, if at least one element of a union unsafely overlaps with - a protocol ``P``, then the whole union is unsafely overlapping with ``P``. +* *Unsafe overlap*: A type ``X`` is called unsafely overlapping with a protocol + ``P``, if ``X`` is not assignable to ``P``, but it is assignable to the + type-erased version of ``P`` where all members have type ``Any``. In + addition, if at least one element of a union unsafely overlaps with a + protocol ``P``, then the whole union is unsafely overlapping with ``P``. **Specification**: diff --git a/docs/spec/qualifiers.rst b/docs/spec/qualifiers.rst index 49ec63f2d..b05202125 100644 --- a/docs/spec/qualifiers.rst +++ b/docs/spec/qualifiers.rst @@ -81,30 +81,27 @@ variable or attribute should not be reassigned, redefined, or overridden. Syntax ^^^^^^ -``Final`` may be used in one of several forms: +``Final`` may be used in one of two forms: -* With an explicit type, using the syntax ``Final[]``. Example:: +* As an :term:`explicitly typed Final`, using the syntax ``Final[]``. + Example:: ID: Final[float] = 1 -* With no type annotation. Example:: + In class bodies and stub files the right hand side can be omitted:: + + ID: Final[float] + +* As a :term:`bare Final`, without a type argument. Example:: ID: Final = 1 + Bare ``Final`` annotations must have an assigned value. + The typechecker should apply its usual type inference mechanisms to determine the type of ``ID`` (here, likely, ``int``). Note that unlike for generic classes this is *not* the same as ``Final[Any]``. -* In class bodies and stub files you can omit the right hand side and just write - ``ID: Final[float]``. If the right hand side is omitted, there must - be an explicit type argument to ``Final``. - -* Finally, as ``self.id: Final = 1`` (also optionally with a type in - square brackets). This is allowed *only* in ``__init__`` methods, so - that the final instance attribute is assigned only once when an - instance is created. - - Semantics and examples ^^^^^^^^^^^^^^^^^^^^^^ @@ -156,8 +153,8 @@ be initialized in the ``__init__`` method (except in stub files):: self.x = 1 # Good The generated ``__init__`` method of :doc:`dataclasses` qualifies for this -requirement: a bare ``x: Final[int]`` is permitted in a dataclass body, because -the generated ``__init__`` will initialize ``x``. +requirement: an ``x: Final[int]`` without an initializer is permitted in a +dataclass body, because the generated ``__init__`` will initialize ``x``. Type checkers should infer a final attribute that is initialized in a class body as being a class variable, except in the case of :doc:`dataclasses`, where @@ -167,6 +164,15 @@ necessary to create a final class variable with value ``3``. In non-dataclasses, combining ``ClassVar`` and ``Final`` is redundant, and type checkers may choose to warn or error on the redundancy. +``Final`` attributes can also be declared in ``__init__`` methods, as +annotations on an assignment to an attribute on ``self``. This is allowed +*only* in ``__init__``, not in any other method:: + + class ImmutableAttributes: + def __init__(self) -> None: + self.x: Final = 3 + self.y: Final[str] = "knight" + ``Final`` may only be used in assignments or variable annotations. Using it in any other position is an error. In particular, ``Final`` can't be used in annotations for function arguments:: @@ -177,7 +183,7 @@ annotations for function arguments:: ... ``Final`` may be wrapped only by other type qualifiers (e.g. ``ClassVar`` or -``Annotation``). It cannot be used in a type parameter (e.g. +``Annotated``). It cannot be used in a type parameter (e.g. ``list[Final[int]]`` is not permitted.) Note that declaring a name as final only guarantees that the name will @@ -193,9 +199,9 @@ with ``Final`` to prevent mutating such values:: z: Final = ('a', 'b') # Also works -Type checkers should treat uses of a final name that was initialized -with a literal as if it was replaced by the literal. For example, the -following should be allowed:: +Type checkers should treat uses of names declared with a :term:`bare Final` +that was initialized with a literal as if it was replaced by the literal. For +example, the following should be allowed:: from typing import NamedTuple, Final @@ -203,6 +209,38 @@ following should be allowed:: Y: Final = "y" N = NamedTuple("N", [(X, int), (Y, int)]) +``Final`` cannot be used as a qualifier for a :ref:`TypedDict ` +item or a :ref:`NamedTuple ` field. Such usage also generates +an error at runtime. + + +Importing ``Final`` Variables +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +If a module declares a ``Final`` variable and another module imports that +variable in an import statement by name or wildcard, the imported symbol +inherits the ``Final`` type qualifier. Any attempt to assign a different value +to this symbol should be flagged as an error by a type checker:: + + # lib/submodule.py + from typing import Final + PI: Final = 3.14 + + # lib/__init__.py + from .submodule import PI # PI is Final + + # test1.py + from lib import PI + PI = 0 # Error: Can't assign to Final value + + from lib import PI as PI2 + PI2 = 0 # Error: Can't assign to Final value + + # test2.py + from lib import * + PI = 0 # Error: Can't assign to Final value + + .. _`annotated`: ``Annotated`` @@ -213,21 +251,31 @@ following should be allowed:: Syntax ^^^^^^ -``Annotated`` is parameterized with a type and an arbitrary list of -Python values that represent the annotations. Here are the specific -details of the syntax: +``Annotated`` is parameterized with a *base expression* and at least one +Python value representing associated *metadata*:: + + from typing import Annotated + + Annotated[BaseExpr, Metadata1, Metadata2, ...] -* The first argument to ``Annotated`` must be a valid type +Here are the specific details of the syntax: -* Multiple type annotations are supported (``Annotated`` supports variadic +* The base expression (the first argument to ``Annotated``) must be valid + in the context where it is being used: + + * If ``Annotated`` is used in a place where arbitrary + :term:`annotation expressions ` are allowed, + the base expression may be an annotation expression. + * Otherwise, the base expression must be a valid :term:`type expression`. + +* Multiple metadata elements are supported (``Annotated`` supports variadic arguments):: Annotated[int, ValueRange(3, 10), ctype("char")] -* ``Annotated`` must be called with at least two arguments ( - ``Annotated[int]`` is not valid) +* There must be at least one metadata element (``Annotated[int]`` is not valid) -* The order of the annotations is preserved and matters for equality +* The order of the metadata is preserved and matters for equality checks:: Annotated[int, ValueRange(3, 10), ctype("char")] != Annotated[ @@ -235,27 +283,25 @@ details of the syntax: ] * Nested ``Annotated`` types are flattened, with metadata ordered - starting with the innermost annotation:: + starting with the innermost ``Annotated`` expression:: Annotated[Annotated[int, ValueRange(3, 10)], ctype("char")] == Annotated[ int, ValueRange(3, 10), ctype("char") ] -* Duplicated annotations are not removed:: +* Duplicated metadata elements are not removed:: Annotated[int, ValueRange(3, 10)] != Annotated[ int, ValueRange(3, 10), ValueRange(3, 10) ] -* ``Annotated`` can be used with nested and generic aliases:: - - T = TypeVar("T") - Vec = Annotated[list[tuple[T, T]], MaxLen(10)] - V = Vec[int] +* ``Annotated`` can be used in definition of nested and generic aliases, + but only if it wraps a :term:`type expression`:: - V == Annotated[list[tuple[int, int]], MaxLen(10)] + type Vec[T] = Annotated[list[tuple[T, T]], MaxLen(10)] + type V = Vec[int] # Annotated[list[tuple[int, int]], MaxLen(10)] -* As with most :term:`special forms `, ``Annotated`` is not type compatible with +* As with most :term:`special forms `, ``Annotated`` is not assignable to ``type`` or ``type[T]``:: v1: type[int] = Annotated[int, ""] # Type error @@ -272,33 +318,51 @@ details of the syntax: SmallInt = Annotated[int, ValueRange(0, 100)] SmallInt(1) # Type error +:pep:`593` and an earlier version of this specification used the term +"annotations" instead of "metadata" for the extra arguments to +``Annotated``. The term "annotations" is deprecated to avoid confusion +with the parameter, return, and variable annotations that are part of +the Python syntax. + +Meaning +^^^^^^^ + +The metadata provided by ``Annotated`` can be used for either static +or runtime analysis. If a library (or tool) encounters an instance of +``Annotated[T, x]`` and has no special logic for metadata element ``x``, it +should ignore it and treat the expression as equivalent to ``T``. Thus, in general, +any :term:`type expression` or :term:`annotation expression` may be +wrapped in ``Annotated`` without changing the meaning of the +wrapped expression. However, type +checkers may additionally choose to recognize particular metadata elements and use +them to implement extensions to the standard type system. + +``Annotated`` metadata may apply either to the base expression or to the symbol +being annotated, or even to some other aspect of the program. -Consuming annotations -^^^^^^^^^^^^^^^^^^^^^ +Consuming metadata +^^^^^^^^^^^^^^^^^^ -Ultimately, the responsibility of how to interpret the annotations (if +Ultimately, deciding how to interpret the metadata (if at all) is the responsibility of the tool or library encountering the ``Annotated`` type. A tool or library encountering an ``Annotated`` type -can scan through the annotations to determine if they are of interest +can scan through the metadata to determine if they are of interest (e.g., using ``isinstance()``). -**Unknown annotations:** When a tool or a library does not support -annotations or encounters an unknown annotation it should just ignore it -and treat annotated type as the underlying type. For example, when encountering -an annotation that is not an instance of ``struct2.ctype`` to the annotations -for name (e.g., ``Annotated[str, 'foo', struct2.ctype("<10s")]``), the unpack -method should ignore it. +**Unknown metadata:** When a tool or a library does not support +metadata or encounters an unknown metadata element, it should ignore it +and treat the annotation as the base expression. -**Namespacing annotations:** Namespaces are not needed for annotations since -the class used by the annotations acts as a namespace. +**Namespacing metadata:** Namespaces are not needed for metadata since +the class of the metadata object acts as a namespace. -**Multiple annotations:** It's up to the tool consuming the annotations -to decide whether the client is allowed to have several annotations on -one type and how to merge those annotations. +**Multiple metadata elements:** It's up to the tool consuming the metadata +to decide whether the client is allowed to have several metadata elements on +one annotation and how to merge those elements. -Since the ``Annotated`` type allows you to put several annotations of -the same (or different) type(s) on any node, the tools or libraries -consuming those annotations are in charge of dealing with potential +Since the ``Annotated`` type allows you to put several metadata elements of +the same (or different) type(s) on any annotation, the tools or libraries +consuming the metadata are in charge of dealing with potential duplicates. For example, if you are doing value range analysis you might allow this:: @@ -313,12 +377,11 @@ Aliases & Concerns over verbosity ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Writing ``typing.Annotated`` everywhere can be quite verbose; -fortunately, the ability to alias annotations means that in practice we +fortunately, the ability to alias types means that in practice we don't expect clients to have to write lots of boilerplate code:: - T = TypeVar('T') - Const = Annotated[T, my_annotations.CONST] + type Const[T] = Annotated[T, my_annotations.CONST] class C: - def const_method(self: Const[List[int]]) -> int: + def const_method(self, x: Const[list[int]]) -> int: ... diff --git a/docs/spec/special-types.rst b/docs/spec/special-types.rst index b94222e60..56e61daa2 100644 --- a/docs/spec/special-types.rst +++ b/docs/spec/special-types.rst @@ -8,16 +8,12 @@ Special types in annotations ``Any`` ------- -A special kind of type is ``Any``. Every type is consistent with -``Any``. It can be considered a type that has all values and all methods. -Note that ``Any`` and builtin type ``object`` are completely different. +``Any`` represents an unknown static type. -When the type of a value is ``object``, the type checker will reject -almost all operations on it, and assigning it to a variable (or using -it as a return value) of a more specialized type is a type error. On -the other hand, when a value has type ``Any``, the type checker will -allow all operations on it, and a value of type ``Any`` can be assigned -to a variable (or used as a return value) of a more constrained type. +Every type is :term:`assignable` to ``Any``, and ``Any`` is assignable to every +type. + +See :ref:`type-system-concepts` for more discussion of ``Any``. A function parameter without an annotation is assumed to be annotated with ``Any``. If a generic type is used without specifying type parameters, @@ -57,6 +53,46 @@ are highly dynamic. When used in a type hint, the expression ``None`` is considered equivalent to ``type(None)``. +.. _ `sentinels`: + +Sentinels +--------- + +Sentinel objects may be used in type annotations to represent themselves:: + + MISSING = sentinel('MISSING') + OTHER = sentinel('OTHER') + + def f(x: int | MISSING = MISSING) -> int: + if x is MISSING: + return 0 + return x + + f(OTHER) # Error, OTHER is not an int or MISSING + f(MISSING) # OK, MISSING is a valid argument + +Sentinels may be created using the ``sentinel()`` built-in in Python 3.15 +and higher. ``typing_extensions`` provides a backport of this function. For +historical reasons the object was first introduced under the name +``typing_extensions.Sentinel``, and later ``typing_extensions.sentinel`` was +added as an alias; type checkers should support both. + +Sentinel objects may be used in type annotations if they are defined using +a simple assignment of the form ``NAME = sentinel('NAME')`` in the +global scope or in a class body that is not within a function. The name of the +variable need not match the string argument passed to ``sentinel()`` but it is +conventional to do so for names in the global scope. + +Type checkers must support narrowing union types involving sentinels using the +``is`` and ``is not`` operators:: + + def g(x: int | MISSING) -> None: + if x is MISSING: + assert_type(x, MISSING) + else: + assert_type(x, int) + + .. _`noreturn`: ``NoReturn`` @@ -98,8 +134,9 @@ is unreachable and will behave accordingly:: ``Never`` --------- -Since Python 3.11, the ``typing`` module contains a :term:`special form` ``Never``. It -represents the bottom type, a type that has no members. +Since Python 3.11, the ``typing`` module contains a :term:`special form` +``Never``. It represents the bottom type, a type that represents the empty set +of Python objects. The ``Never`` type is equivalent to ``NoReturn``, which is discussed above. The ``NoReturn`` type is conventionally used in return annotations of @@ -155,8 +192,7 @@ would be:: However using ``type[]`` and a type variable with an upper bound we can do much better:: - U = TypeVar('U', bound=User) - def new_user(user_class: type[U]) -> U: + def new_user[U: User](user_class: type[U]) -> U: ... Now when we call ``new_user()`` with a specific subclass of ``User`` a @@ -178,7 +214,10 @@ Note that it is legal to use a union of classes as the parameter for user = new_user(user_class) ... -However the actual argument passed in at runtime must still be a +``type[]`` distributes over unions: +``type[A | B]`` is :term:`equivalent` to ``type[A] | type[B]``. + +However, the actual argument passed in at runtime must still be a concrete class object, e.g. in the above example:: new_non_team_user(ProUser) # OK @@ -189,8 +228,8 @@ concrete class object, e.g. in the above example:: ``type[T]`` where ``T`` is a type variable is allowed when annotating the first argument of a class method (see the relevant section). -Any other special constructs like ``tuple`` or ``Callable`` are not allowed -as an argument to ``type``. +Any other :term:`special forms ` like ``Callable`` are not +allowed as an argument to ``type``. There are some concerns with this feature: for example when ``new_user()`` calls ``user_class()`` this implies that all subclasses diff --git a/docs/spec/tuples.rst b/docs/spec/tuples.rst index 4f04b914a..40afc732b 100644 --- a/docs/spec/tuples.rst +++ b/docs/spec/tuples.rst @@ -29,10 +29,10 @@ Arbitrary-length homogeneous tuples are sometimes referred to as "unbounded tuples". Both of these terms appear within the typing spec, and they refer to the same concept. -The type ``tuple[Any, ...]`` is special in that it is bidirectionally -compatible with any tuple of any length. This is useful for gradual typing. -The type ``tuple`` (with no type arguments provided) is equivalent to -``tuple[Any, ...]``. +The type ``tuple[Any, ...]`` is special in that it is :term:`consistent` with +all tuple types, and :term:`assignable` to a tuple of any length. This is +useful for gradual typing. The type ``tuple`` (with no type arguments provided) +is equivalent to ``tuple[Any, ...]``. Arbitrary-length tuples have exactly two type arguments -- the type and an ellipsis. Any other tuple form that uses an ellipsis is invalid:: @@ -61,8 +61,7 @@ more elements of type ``str``. The type ``tuple[*tuple[int, ...]]`` is equivalent to ``tuple[int, ...]``. If an unpacked ``*tuple[Any, ...]`` is embedded within another tuple, that -portion of the tuple is bidirectionally type compatible with any tuple of -any length. +portion of the tuple is :term:`consistent` with any tuple of any length. Only one unbounded tuple can be used within another tuple:: @@ -92,7 +91,7 @@ Type Compatibility Rules ------------------------ Because tuple contents are immutable, the element types of a tuple are covariant. -For example, ``tuple[int, int]`` is a subtype of ``tuple[float, complex]``. +For example, ``tuple[bool, int]`` is a subtype of ``tuple[int, object]``. As discussed above, a homogeneous tuple of arbitrary length is equivalent to a union of tuples of different lengths. That means ``tuple[()]``, @@ -100,7 +99,7 @@ to a union of tuples of different lengths. That means ``tuple[()]``, ``tuple[int, ...]``. The converse is not true; ``tuple[int, ...]`` is not a subtype of ``tuple[int]``. -The type ``tuple[Any, ...]`` is bidirectionally compatible with any tuple:: +The type ``tuple[Any, ...]`` is :term:`consistent` with any tuple:: def func(t1: tuple[int], t2: tuple[int, ...], t3: tuple[Any, ...]): v1: tuple[int, ...] = t1 # OK diff --git a/docs/spec/type-forms.rst b/docs/spec/type-forms.rst new file mode 100644 index 000000000..4dc7c9e35 --- /dev/null +++ b/docs/spec/type-forms.rst @@ -0,0 +1,191 @@ +.. _`type-forms`: + +Type forms +========== + +.. _`typeform`: + +TypeForm +-------- + +(Originally specified in :pep:`747`.) + +When a type expression is evaluated at runtime, the resulting value is a +*type form* object. This value encodes the information supplied in the type +expression, and it represents the type described by that type expression. + +``TypeForm`` is a :term:`special form` that, when used in a type expression, +describes a set of type form objects. It accepts a single type argument, which +must be a :ref:`valid type expression `. +``TypeForm[T]`` describes the set of all type form objects that represent +the type ``T`` or types that are :term:`assignable` to ``T``. For example, +``TypeForm[str | None]`` describes the set of all type form objects that +represent a type assignable to ``str | None``:: + + from typing import Any, Literal, Optional + from typing_extensions import TypeForm + + ok1: TypeForm[str | None] = str | None # OK + ok2: TypeForm[str | None] = str # OK + ok3: TypeForm[str | None] = None # OK + ok4: TypeForm[str | None] = Literal[None] # OK + ok5: TypeForm[str | None] = Optional[str] # OK + ok6: TypeForm[str | None] = "str | None" # OK + ok7: TypeForm[str | None] = Any # OK + + err1: TypeForm[str | None] = str | int # Error + err2: TypeForm[str | None] = list[str | None] # Error + +By this same definition, ``TypeForm[object]`` describes a type form object +that represents the type ``object`` or any type that is assignable to +``object``. Since all types in the Python type system are assignable to +``object``, ``TypeForm[object]`` describes the set of all type form objects +evaluated from all valid type expressions. + +``TypeForm[Any]`` describes a ``TypeForm`` type whose type argument is not +statically known but is a valid type form object. It is assignable both +to and from any other ``TypeForm`` type (because ``Any`` is assignable both +to and from any type). + +The type expression ``TypeForm``, with no type argument provided, is +equivalent to ``TypeForm[Any]``. + +.. _`implicit-typeform-evaluation`: + +Implicit ``TypeForm`` evaluation +-------------------------------- + +When a static type checker encounters a valid type expression, the evaluated +type of this expression should be assignable to ``TypeForm[T]`` if the type it +describes is assignable to ``T``. + +For example, if a static type checker encounters the expression +``str | None``, it may normally evaluate its type as ``UnionType`` because it +produces a runtime value that is an instance of ``types.UnionType``. However, +because this expression is a valid type expression, it is also assignable to +the type ``TypeForm[str | None]``:: + + from types import GenericAlias, UnionType + from typing_extensions import TypeForm + + v1_actual: UnionType = str | None # OK + v1_type_form: TypeForm[str | None] = str | None # OK + + v2_actual: GenericAlias = list[int] # OK + v2_type_form: TypeForm = list[int] # OK + +The ``Annotated`` special form is allowed in type expressions, so it can +also appear in an expression that is assignable to ``TypeForm``. Consistent +with the general rules for ``Annotated``, a static type checker may +choose to ignore any ``Annotated`` metadata that it does not understand:: + + from typing import Annotated + from typing_extensions import TypeForm + + v3: TypeForm[int | str] = Annotated[int | str, "metadata"] # OK + +A string literal expression containing a valid type expression should likewise +be assignable to ``TypeForm``:: + + from typing_extensions import TypeForm + + v4: TypeForm[set[str]] = "set[str]" # OK + +.. _`valid-type-expressions`: + +Valid type expressions +---------------------- + +This specification defines syntactic rules for type expressions in the form of a +:ref:`formal grammar `. Semantic rules are specified as +comments along with the grammar definition. Contextual requirements are +detailed throughout the text in sections that discuss concepts that +appear within type expressions. For example, the special form ``Self`` can be +used in a type expression only within a class, and a type variable can be used +within a type expression only when it is associated with a valid scope. + +A valid type expression is an expression that follows all of the syntactic, +semantic, and contextual rules for a type expression. + +Expressions that are not valid type expressions should not evaluate to a +``TypeForm`` type:: + + from typing import ClassVar, Final, Literal, Optional, Self, TypeVarTuple, Unpack + from typing_extensions import TypeForm + + Ts = TypeVarTuple("Ts") + var = 1 + + bad1: TypeForm = tuple() # Error: call expression not allowed in type expression + bad2: TypeForm = (1, 2) # Error: tuple expression not allowed in type expression + bad3: TypeForm = 1 # Error: non-class object not allowed in type expression + bad4: TypeForm = Self # Error: Self not allowed outside of a class + bad5: TypeForm = Literal[var] # Error: variable not allowed in type expression + bad6: TypeForm = Literal[f""] # Error: f-strings not allowed in type expression + bad7: TypeForm = ClassVar[int] # Error: ClassVar not allowed in type expression + bad8: TypeForm = Final[int] # Error: Final not allowed in type expression + bad9: TypeForm = Unpack[Ts] # Error: Unpack not allowed in this context + bad10: TypeForm = Optional # Error: invalid use of Optional special form + bad11: TypeForm = "int + str" # Error: invalid quoted type expression + +.. _`explicit-typeform-evaluation`: + +Explicit ``TypeForm`` evaluation +-------------------------------- + +``TypeForm`` also acts as a function that can be called with a single +argument. Type checkers should validate that this argument is a valid type +expression:: + + from typing import assert_type + from typing_extensions import TypeForm + + x1 = TypeForm(str | None) + assert_type(x1, TypeForm[str | None]) + + x2 = TypeForm("list[int]") + assert_type(x2, TypeForm[list[int]]) + + x3 = TypeForm("type(1)") # Error: invalid type expression + +The static type of a ``TypeForm(T)`` expression is ``TypeForm[T]``. + +At runtime the ``TypeForm(...)`` callable simply returns the value passed to +it. + +This explicit syntax serves two purposes. First, it documents the developer's +intent to use the value as a type form object. Second, static type checkers +validate that all rules for type expressions are followed:: + + x4 = type(1) # No error, evaluates to "type[int]" + + x5 = TypeForm(type(1)) # Error: call not allowed in type expression + +.. _`typeform-assignability`: + +Assignability +------------- + +``TypeForm`` has a single type parameter, which is covariant. That means +``TypeForm[B]`` is assignable to ``TypeForm[A]`` if ``B`` is assignable to +``A``:: + + from typing_extensions import TypeForm + + def get_type_form() -> TypeForm[int]: ... + + t1: TypeForm[int | str] = get_type_form() # OK + t2: TypeForm[str] = get_type_form() # Error + +``type[T]`` is a subtype of ``TypeForm[T]``, which means that ``type[B]`` is +assignable to ``TypeForm[A]`` if ``B`` is assignable to ``A``:: + + from typing_extensions import TypeForm + + def get_type() -> type[int]: ... + + t3: TypeForm[int | str] = get_type() # OK + t4: TypeForm[str] = get_type() # Error + +``TypeForm`` is a subtype of ``object`` and is assumed to have all of the +attributes and methods of ``object``. diff --git a/docs/spec/typeddict.rst b/docs/spec/typeddict.rst index 6d6326553..bbbc1fd03 100644 --- a/docs/spec/typeddict.rst +++ b/docs/spec/typeddict.rst @@ -1,46 +1,62 @@ +.. _`typeddict`: .. _`typed-dictionaries`: Typed dictionaries ================== -.. _`typeddict`: - -TypedDict ---------- - -(Originally specified in :pep:`589`.) - -A TypedDict type represents dictionary objects with a specific set of -string keys, and with specific value types for each valid key. Each -string key can be either required (it must be present) or -non-required (it doesn't need to exist). - -There are two ways of defining TypedDict types. The first uses -a class-based syntax. The second is an alternative -assignment-based syntax that is provided for backwards compatibility, -to allow the feature to be backported to older Python versions. The -rationale is similar to why :pep:`484` supports a comment-based -annotation syntax for Python 2.7: type hinting is particularly useful -for large existing codebases, and these often need to run on older -Python versions. The two syntax options parallel the syntax variants -supported by ``typing.NamedTuple``. Other features include -TypedDict inheritance and totality (specifying whether keys are -required or not). - -This section also provides a sketch of how a type checker is expected -to support type checking operations involving TypedDict objects. -Similar to :pep:`484`, this discussion is left somewhat vague on purpose, -to allow experimentation with a wide variety of different type -checking approaches. In particular, type compatibility should be -based on structural compatibility: a more specific TypedDict type can -be compatible with a smaller (more general) TypedDict type. - +(Originally specified in :pep:`589`, with later additions: ``Required`` +and ``NotRequired`` in :pep:`655`, use with ``Unpack`` in :pep:`692`, +``ReadOnly`` in :pep:`705`, and ``closed=True`` and ``extra_items=`` in :pep:`728`.) + +A TypedDict type represents ``dict`` objects that contain only keys of +type ``str``. There are restrictions on which string keys are valid, and +which values can be associated with each key. Values that :term:`inhabit` a +TypedDict type must be instances of ``dict`` itself, not a subclass. + +TypedDict types can define any number of :term:`items `, which are string +keys associated with values of a specified type. For example, +a TypedDict may contain the item ``a: str``, indicating that the key ``a`` +must map to a value of type ``str``. Items may be either :term:`required`, +meaning they must be present in every instance of the TypedDict type, or +:term:`non-required`, meaning they may be omitted, but if they are present, +they must be of the type specified in the TypedDict definition. By default, +all items in a TypedDict are mutable, but items +may also be marked as :term:`read-only`, indicating that they may not be +modified. + +In addition to explicitly specified items, TypedDicts may allow additional +items. By default, TypedDicts are :term:`open`, meaning they may contain an +unknown set of additional items. They may also be marked as :term:`closed`, +in which case they may not contain any keys beyond those explicitly specified. +As a third option, they may be defined with :term:`extra items` of a specific type. +In this case, there may be any number of additional items present at runtime, but +their values must be of the specified type. Extra items may or may not be +:term:`read-only`. Thus, a TypedDict may be open, closed, or have extra items; +we refer to this property as the *openness* of the TypedDict. For many purposes, +an open TypedDict is equivalent to a TypedDict with read-only extra items of +type ``object``, but certain behaviors differ; for example, the +:ref:`TypedDict constructor ` of open TypedDicts does not +allow unrecognized keys. + +A TypedDict is a :term:`structural` type: independent TypedDict types may be +:term:`assignable` to each other based on their structure, even if they do not +share a common base class. For example, two TypedDict types that contain the same +items are :term:`equivalent`. Nevertheless, TypedDict types may inherit from other +TypedDict types to share common items. TypedDict types may also be generic. + +Syntax +------ + +This section outlines the syntax for creating TypedDict types. There are two +syntaxes: the class-based syntax and the functional syntax. + +.. _typeddict-class-based-syntax: Class-based Syntax ^^^^^^^^^^^^^^^^^^ A TypedDict type can be defined using the class definition syntax with -``typing.TypedDict`` as the sole base class:: +``typing.TypedDict`` as a direct or indirect base class:: from typing import TypedDict @@ -51,41 +67,149 @@ A TypedDict type can be defined using the class definition syntax with ``Movie`` is a TypedDict type with two items: ``'name'`` (with type ``str``) and ``'year'`` (with type ``int``). -A type checker should validate that the body of a class-based -TypedDict definition conforms to the following rules: +A TypedDict can also be created through inheritance from one or more +other TypedDict types:: -* The class body should only contain lines with item definitions of the - form ``key: value_type``, optionally preceded by a docstring. The - syntax for item definitions is identical to attribute annotations, - but there must be no initializer, and the key name actually refers - to the string value of the key instead of an attribute name. + class BookBasedMovie(Movie): + based_on: str -* Type comments cannot be used with the class-based syntax, for - consistency with the class-based ``NamedTuple`` syntax. Instead, - `Alternative Syntax`_ provides an - alternative, assignment-based syntax for backwards compatibility. +This creates a TypedDict type ``BookBasedMovie`` with three items: +``'name'`` (type ``str``), ``'year'`` (type ``int``), and ``'based_on'`` (type ``str``). +See :ref:`Inheritance ` for more details. -* String literal forward references are valid in the value types. +A generic TypedDict can be created by inheriting from ``Generic`` with a list +of type parameters:: -* Methods are not allowed, since the runtime type of a TypedDict - object will always be just ``dict`` (it is never a subclass of - ``dict``). + from typing import Generic, TypeVar -* Specifying a metaclass is not allowed. + T = TypeVar('T') -* TypedDicts may be made generic by adding ``Generic[T]`` among the - bases (or, in Python 3.12 and higher, by using the new - syntax for generic classes). + class Response(TypedDict, Generic[T]): + status: int + payload: T -An empty TypedDict can be created by only including ``pass`` in the -body (if there is a docstring, ``pass`` can be omitted):: +Or, in Python 3.12 and newer, by using the native syntax for generic classes:: - class EmptyDict(TypedDict): - pass + from typing import TypedDict + + class Response[T](TypedDict): + status: int + payload: T + +It is invalid to specify a base class other than ``TypedDict``, ``Generic``, +or another TypedDict type in a class-based TypedDict definition. +It is also invalid to specify a custom metaclass. + +A TypedDict definition may also contain the following keyword arguments +in the class definition: + +* ``total``: a boolean literal (``True`` or ``False``) indicating whether + all items are :term:`required` (``True``, the default) or :term:`non-required` + (``False``). This affects only items defined in this class, not in any + base classes, and it does not affect any items that use an explicit + ``Required[]`` or ``NotRequired[]`` qualifier. The value must be exactly + ``True`` or ``False``; other expressions are not allowed. +* ``closed``: a boolean literal (``True`` or ``False``) indicating whether + the TypedDict is :term:`closed` (``True``) or :term:`open` (``False``). + The latter is the default, except when inheriting from another TypedDict that + is not open (see :ref:`typeddict-inheritance`), or when the ``extra_items`` + argument is also used. + As with ``total``, the value must be exactly ``True`` or ``False``. It is an error + to use this argument together with ``extra_items=``. +* ``extra_items``: indicates that the TypedDict has :term:`extra items`. The argument + must be a :term:`annotation expression` specifying the type of the extra items. + The :term:`type qualifier` ``ReadOnly[]`` may be used to indicate that the extra items are + :term:`read-only`. Other type qualifiers are not allowed. If the extra items type + is ``Never``, no extra items are allowed, so this is equivalent to ``closed=True``. + +The body of the class definition defines the :term:`items ` of the +TypedDict type. It may also contain a docstring or ``pass`` statements +(primarily to allow the creation of an empty TypedDict). `if` conditions that +the type checker is able to +:ref:`statically evaluate` are also permitted (e.g. +`if sys.version_info > (3, 14)`), in order to specify items that exist only under +the given conditions. No other statements are allowed, and type checkers should +report an error if any are present. Type comments are not supported for +creating TypedDict items. + +.. _`required-notrequired`: +.. _`required`: +.. _`notrequired`: + +An item definition takes the form of an attribute annotation, ``key: T``. ``key`` is +an identifier and corresponds to the string key of the item, and ``T`` is an +:term:`annotation expression` specifying the type of the item value. This annotation +expression contains a :term:`type expression`, optionally qualified with one of the +:term:`type qualifiers ` ``Required``, ``NotRequired``, or ``ReadOnly``. +These type qualifiers may be nested arbitrarily or wrapped in ``Annotated[]``. It is +an error to use both ``Required`` and ``NotRequired`` in the same item definition. +It is also an error to nest a qualifier within itself (e.g., ``Required[Required[T]]``). +An item is :term:`read-only` if and only if the ``ReadOnly`` qualifier is used. + +To determine whether an item is :term:`required` or :term:`non-required`, the following +procedure is used: + +* If the ``Required`` qualifier is present, the item is required. +* If the ``NotRequired`` qualifier is present, the item is non-required. +* If the ``total`` argument of the TypedDict definition is ``False``, the item is non-required. +* Else, the item is required. + +It is valid to use ``Required[]`` and ``NotRequired[]`` even for +items where it is redundant, to enable additional explicitness if desired. +Note that the value of ``total`` only affects items defined in the current class body, +not in any base classes. Thus, inheritance can be used to create a TypedDict that mixes +required and non-required items without using ``Required[]`` or ``NotRequired[]``. + +The following example demonstrates some of these rules:: + + from typing import TypedDict, NotRequired, Required, ReadOnly, Annotated + + class Movie(TypedDict): + name: str # required, not read-only + year: int # required, not read-only + director: NotRequired[str] # non-required, not read-only + rating: NotRequired[ReadOnly[float]] # non-required, read-only + invalid: Required[NotRequired[int]] # type checker error: both Required and NotRequired used + + class PartialMovie(TypedDict, total=False): + name: str # non-required, not read-only + year: Required[int] # required, not read-only + score: ReadOnly[float] # non-required, read-only + +.. _typeddict-functional-syntax: + +Functional syntax +^^^^^^^^^^^^^^^^^ + +In addition to the class-based syntax, TypedDict types can be created +using an alternative functional syntax. This syntax allows defining +items with keys that are not valid Python identifiers, and it is compatible +with older Python versions such as 3.5 and 2.7 that don't support the +variable definition syntax introduced in :pep:`526`. On the other hand, this syntax +does not support inheritance. + +The functional syntax resembles the traditional syntax for defining named tuples:: + + from typing import TypedDict + + Movie = TypedDict('Movie', {'name': str, 'year': int}) +The syntax comprises a call to ``TypedDict()``, the result of which must be immediately +assigned to a variable with the same name as the first argument to ``TypedDict()``. + +The call to ``TypedDict()`` must have two positional arguments. The first is a string +literal specifying the name of the TypedDict type. The second is a dictionary specifying +the :term:`items ` of the TypedDict. It must be a dictionary display expression, +not a variable or other expression that evaluates to a dictionary at runtime. +The keys of the dictionary must be string literals and the values must be +:term:`annotation expressions ` following the same rules as +the class-based syntax (i.e., the qualifiers ``Required``, ``NotRequired``, and +``ReadOnly`` are allowed). In addition to the two positional arguments, ``total``, +``closed``, and ``extra_items`` keyword arguments are also supported, with the same +semantics as in the class-based syntax. Using TypedDict Types -^^^^^^^^^^^^^^^^^^^^^ +--------------------- Here is an example of how the type ``Movie`` can be used:: @@ -127,534 +251,448 @@ key, and the ``'name'`` key is missing:: The created TypedDict type object is not a real class object. Here are the only uses of the type a type checker is expected to allow: -* It can be used in type annotations and in any context where an - arbitrary type hint is valid, such as in type aliases and as the - target type of a cast. +* It can be used in :term:`type expressions ` to + represent the TypedDict type. * It can be used as a callable object with keyword arguments - corresponding to the TypedDict items. Non-keyword arguments are not - allowed. Example:: - - m = Movie(name='Blade Runner', year=1982) - - When called, the TypedDict type object returns an ordinary - dictionary object at runtime:: - - print(type(m)) # + corresponding to the TypedDict items; see :ref:`typeddict-constructor`. * It can be used as a base class, but only when defining a derived - TypedDict. This is discussed in more detail below. + TypedDict (see :ref:`above `). In particular, TypedDict type objects cannot be used in -``isinstance()`` tests such as ``isinstance(d, Movie)``. The reason is -that there is no existing support for checking types of dictionary -item values, since ``isinstance()`` does not work with many -types, including common ones like ``list[str]``. This would be needed -for cases like this:: +``isinstance()`` tests such as ``isinstance(d, Movie)``. This is +consistent with how ``isinstance()`` is not supported for +other type forms such as ``list[str]``. - class Strings(TypedDict): - items: list[str] +.. _typeddict-constructor: - print(isinstance({'items': [1]}, Strings)) # Should be False - print(isinstance({'items': ['x']}, Strings)) # Should be True +The TypedDict constructor +^^^^^^^^^^^^^^^^^^^^^^^^^ -The above use case is not supported. This is consistent with how -``isinstance()`` is not supported for ``list[str]``. +TypedDict types are callable at runtime and can be used as a constructor +to create values that conform to the TypedDict type. The constructor +takes only keyword arguments, corresponding to the items of the TypedDict. +Example:: + m = Movie(name='Blade Runner', year=1982) -Inheritance -^^^^^^^^^^^ +When called, the TypedDict type object returns an ordinary +dictionary object at runtime:: -It is possible for a TypedDict type to inherit from one or more -TypedDict types using the class-based syntax. In this case the -``TypedDict`` base class should not be included. Example:: + print(type(m)) # - class BookBasedMovie(Movie): - based_on: str +Every :term:`required` item must be provided as a keyword argument. :term:`Non-required` +items may be omitted. Whether an item is read-only has no effect on the +constructor. -Now ``BookBasedMovie`` has keys ``name``, ``year``, and ``based_on``. -It is equivalent to this definition, since TypedDict types use -structural compatibility:: +Closed and open TypedDicts allow no additional items beyond those explicitly +defined, but TypedDicts with extra items allow arbitrary keyword arguments, +which must be of the specified type. Example:: - class BookBasedMovie(TypedDict): + from typing import TypedDict, ReadOnly + + class MovieWithExtras(TypedDict, extra_items=ReadOnly[int | str]): name: str year: int - based_on: str - -Here is an example of multiple inheritance:: - - class X(TypedDict): - x: int - - class Y(TypedDict): - y: str - class XYZ(X, Y): - z: bool + m1 = MovieWithExtras(name='Blade Runner', year=1982) # OK + m2 = MovieWithExtras(name='The Godfather', year=1972, director='Francis Ford Coppola', rating=9) # OK + m3 = MovieWithExtras(name='Inception', year=2010, budget=160.0) # Type check error: budget must be int or str -The TypedDict ``XYZ`` has three items: ``x`` (type ``int``), ``y`` -(type ``str``), and ``z`` (type ``bool``). +Initialization from dictionary literals +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -A TypedDict cannot inherit from both a TypedDict type and a -non-TypedDict base class other than ``Generic``. +Type checkers should also allow initializing a value of TypedDict type from +a dictionary literal:: -Additional notes on TypedDict class inheritance: + m: Movie = {'name': 'Blade Runner', 'year': 1982} # OK -* Changing a field type of a parent TypedDict class in a subclass is not allowed. - Example:: +Or from a call to ``dict()`` with keyword arguments:: - class X(TypedDict): - x: str + m: Movie = dict(name='Blade Runner', year=1982) # OK - class Y(X): - x: int # Type check error: cannot overwrite TypedDict field "x" +In these cases, extra keys should not be allowed unless the TypedDict +is defined to allow :term:`extra items`. In this example, the ``director`` key is not defined in +``Movie`` and is expected to generate an error from a type checker:: - In the example outlined above TypedDict class annotations returns - type ``str`` for key ``x``:: + m: Movie = dict( + name='Alien', + year=1979, + director='Ridley Scott') # error: Unexpected key 'director' - print(Y.__annotations__) # {'x': } +If a TypedDict has extra items, extra keys are allowed, provided their value +matches the extra items type:: + class ExtraMovie(TypedDict, extra_items=bool): + name: str -* Multiple inheritance does not allow conflict types for the same name field:: + a: ExtraMovie = {"name": "Blade Runner", "novel_adaptation": True} # OK + b: ExtraMovie = { + "name": "Blade Runner", + "year": 1982, # Not OK. 'int' is not assignable to 'bool' + } - class X(TypedDict): - x: int +Here, ``extra_items=bool`` specifies that items other than ``'name'`` +have a value type of ``bool`` and are non-required. - class Y(TypedDict): - x: str +.. _typeddict-inheritance: - class XYZ(X, Y): # Type check error: cannot overwrite TypedDict field "x" while merging - xyz: bool +Inheritance +----------- +As discussed under :ref:`typeddict-class-based-syntax`, TypedDict types +can inherit from one or more other TypedDict types. In this case the +``TypedDict`` base class should not be included. Example:: -Totality -^^^^^^^^ + class BookBasedMovie(Movie): + based_on: str -By default, all keys must be present in a TypedDict. It is possible -to override this by specifying *totality*. Here is how to do this -using the class-based syntax:: +Now ``BookBasedMovie`` has keys ``name``, ``year``, and ``based_on``. It is +equivalent to this definition, since TypedDict types are :term:`structural` types:: - class Movie(TypedDict, total=False): + class BookBasedMovie(TypedDict): name: str year: int + based_on: str -This means that a ``Movie`` TypedDict can have any of the keys omitted. Thus -these are valid:: - - m: Movie = {} - m2: Movie = {'year': 2015} - -A type checker is only expected to support a literal ``False`` or -``True`` as the value of the ``total`` argument. ``True`` is the -default, and makes all items defined in the class body be required. - -The totality flag only applies to items defined in the body of the -TypedDict definition. Inherited items won't be affected, and instead -use totality of the TypedDict type where they were defined. This makes -it possible to have a combination of required and non-required keys in -a single TypedDict type. Alternatively, ``Required`` and ``NotRequired`` -(see below) can be used to mark individual items as required or non-required. - -.. _typeddict-functional-syntax: - -Alternative Syntax -^^^^^^^^^^^^^^^^^^ - -This section provides an alternative syntax that can be backported to -older Python versions such as 3.5 and 2.7 that don't support the -variable definition syntax introduced in :pep:`526`. It -resembles the traditional syntax for defining named tuples:: - - Movie = TypedDict('Movie', {'name': str, 'year': int}) - -It is also possible to specify totality using the alternative syntax:: - - Movie = TypedDict('Movie', - {'name': str, 'year': int}, - total=False) - -The semantics are equivalent to the class-based syntax. This syntax -doesn't support inheritance, however. The -motivation for this is keeping the backwards compatible syntax as -simple as possible while covering the most common use cases. - -A type checker is only expected to accept a dictionary display expression -as the second argument to ``TypedDict``. In particular, a variable that -refers to a dictionary object does not need to be supported, to simplify -implementation. - - -Type Consistency +Overriding items ^^^^^^^^^^^^^^^^ -Informally speaking, *type consistency* is a generalization of the -is-subtype-of relation to support the ``Any`` type. It is defined -more formally in :pep:`483`. This section introduces the -new, non-trivial rules needed to support type consistency for -TypedDict types. +Under limited circumstances, subclasses may redeclare items defined in a superclass with +a different type or different qualifiers. Redeclaring an item with the same type and qualifiers +is always allowed, although it is redundant. -First, any TypedDict type is consistent with ``Mapping[str, object]``. -Second, a TypedDict type ``A`` is consistent with TypedDict ``B`` if -``A`` is structurally compatible with ``B``. This is true if and only -if both of these conditions are satisfied: +If an item is mutable in a superclass, it must remain mutable in the subclass. Similarly, +mutable items that are :term:`required` in a superclass must remain required in the subclass, +and mutable :term:`non-required` items in the superclass must remain non-required in the subclass. +However, if the superclass item is :term:`read-only`, a superclass item that is non-required +may be overridden with a required item in the subclass. A read-only item in a superclass +may be redeclared as mutable (that is, without the ``ReadOnly`` qualifier) in a subclass. +These rules are necessary for type safety. -* For each key in ``B``, ``A`` has the corresponding key and the - corresponding value type in ``A`` is consistent with the value type - in ``B``. For each key in ``B``, the value type in ``B`` is also - consistent with the corresponding value type in ``A``. +If an item is read-only in the superclass, the subclass may redeclare it with a different type +that is :term:`assignable` to the superclass type. Otherwise, changing the type of an item is not allowed. +Example:: -* For each required key in ``B``, the corresponding key is required - in ``A``. For each non-required key in ``B``, the corresponding key - is not required in ``A``. - -Discussion: + class X(TypedDict): + x: str + y: ReadOnly[int] + z: int -* Value types behave invariantly, since TypedDict objects are mutable. - This is similar to mutable container types such as ``List`` and - ``Dict``. Example where this is relevant:: + class Y(X): + x: int # Type check error: cannot overwrite TypedDict field "x" + y: bool # OK: bool is assignable to int, and a mutable item can override a read-only one + z: bool # Type check error: key is mutable, so subclass type must be consistent with superclass - class A(TypedDict): - x: int | None +Openness +^^^^^^^^ - class B(TypedDict): - x: int +The openness of a TypedDict (whether it is :term:`open`, :term:`closed`, or has :term:`extra items`) +is inherited from its superclass by default:: - def f(a: A) -> None: - a['x'] = None + class ClosedBase(TypedDict, closed=True): + name: str - b: B = {'x': 0} - f(b) # Type check error: 'B' not compatible with 'A' - b['x'] + 1 # Runtime error: None + 1 + class ClosedChild(ClosedBase): # also closed + pass -* A TypedDict type with a required key is not consistent with a - TypedDict type where the same key is a non-required key, since the - latter allows keys to be deleted. Example where this is relevant:: + class ExtraItemsBase(TypedDict, extra_items=int | None): + name: str - class A(TypedDict, total=False): - x: int + class ExtraItemsChild(ExtraItemsBase): # also has extra_items=int | None + pass - class B(TypedDict): - x: int +However, subclasses may also explicitly use the ``closed`` and ``extra_items`` arguments +to change the openness of the TypedDict, but in some cases this yields a type checker error: - def f(a: A) -> None: - del a['x'] +- If the base class is open, all possible states are allowed in the subclass: it may remain open, + it may be closed (with ``closed=True``), or it may have extra items (with ``extra_items=...``). - b: B = {'x': 0} - f(b) # Type check error: 'B' not compatible with 'A' - b['x'] + 1 # Runtime KeyError: 'x' +- If the base class is closed, any child classes must also be closed. -* A TypedDict type ``A`` with no key ``'x'`` is not consistent with a - TypedDict type with a non-required key ``'x'``, since at runtime - the key ``'x'`` could be present and have an incompatible type - (which may not be visible through ``A`` due to structural subtyping). - Example:: +- If the base class has extra items, but they are not read-only, the child class must also allow + the same extra items. - class A(TypedDict, total=False): - x: int - y: int +- If the base class has read-only extra items, the child class may be closed, + or it may redeclare its extra items with a type that is :term:`assignable` to the base class type. + Child classes may also have mutable extra items if the base class has read-only extra items. - class B(TypedDict, total=False): - x: int +For example:: - class C(TypedDict, total=False): - x: int - y: str + class ExtraItemsRO(TypedDict, extra_items=ReadOnly[int | str]): + name: str - def f(a: A) -> None: - a['y'] = 1 + class ClosedChild(ExtraItemsRO, closed=True): # OK + pass - def g(b: B) -> None: - f(b) # Type check error: 'B' incompatible with 'A' + # OK, str is assignable to int | str, and mutable extra items can override read-only ones + class NarrowerChild(ExtraItemsRO, extra_items=str): + pass - c: C = {'x': 0, 'y': 'foo'} - g(c) - c['y'] + 'bar' # Runtime error: int + str +When a TypedDict has extra items, this effectively defines the value type of any unnamed +items accepted to the TypedDict and marks them as non-required. Thus, there are some +restrictions on the items that can be added in subclasses. For each item +added in a subclass of a class with extra items of type ``T``, the following rules must be followed: -* A TypedDict isn't consistent with any ``Dict[...]`` type, since - dictionary types allow destructive operations, including - ``clear()``. They also allow arbitrary keys to be set, which - would compromise type safety. Example:: +- If ``extra_items`` is read-only - class A(TypedDict): - x: int + - The item can be either required or non-required + - The item's value type must be :term:`assignable` to ``T`` - class B(A): - y: str +- If ``extra_items`` is not read-only - def f(d: Dict[str, int]) -> None: - d['y'] = 0 + - The item must be non-required + - The item's value type must be :term:`consistent` with ``T`` - def g(a: A) -> None: - f(a) # Type check error: 'A' incompatible with Dict[str, int] +For example:: - b: B = {'x': 0, 'y': 'foo'} - g(b) - b['y'] + 'bar' # Runtime error: int + str + class MovieBase(TypedDict, extra_items=int | None): + name: str -* A TypedDict with all ``int`` values is not consistent with - ``Mapping[str, int]``, since there may be additional non-``int`` - values not visible through the type, due to structural subtyping. - These can be accessed using the ``values()`` and ``items()`` - methods in ``Mapping``, for example. Example:: + class MovieRequiredYear(MovieBase): # Not OK. Required key 'year' is not known to 'MovieBase' + year: int | None - class A(TypedDict): - x: int + class MovieNotRequiredYear(MovieBase): # Not OK. 'int | None' is not consistent with 'int' + year: NotRequired[int] - class B(TypedDict): - x: int - y: str + class MovieWithYear(MovieBase): # OK + year: NotRequired[int | None] - def sum_values(m: Mapping[str, int]) -> int: - n = 0 - for v in m.values(): - n += v # Runtime error - return n + class BookBase(TypedDict, extra_items=ReadOnly[int | str]): + title: str - def f(a: A) -> None: - sum_values(a) # Error: 'A' incompatible with Mapping[str, int] + class Book(BookBase, extra_items=str): # OK + year: int # OK, since extra_items is read-only - b: B = {'x': 0, 'y': 'foo'} - f(b) +Multiple inheritance +^^^^^^^^^^^^^^^^^^^^ +TypedDict types may use multiple inheritance to inherit items from multiple +base classes. Here is an example:: -Supported and Unsupported Operations -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + class X(TypedDict): + x: int -Type checkers should support restricted forms of most ``dict`` -operations on TypedDict objects. The guiding principle is that -operations not involving ``Any`` types should be rejected by type -checkers if they may violate runtime type safety. Here are some of -the most important type safety violations to prevent: + class Y(TypedDict): + y: str -1. A required key is missing. + class XYZ(X, Y): + z: bool -2. A value has an invalid type. +The TypedDict ``XYZ`` has three items: ``x`` (type ``int``), ``y`` +(type ``str``), and ``z`` (type ``bool``). -3. A key that is not defined in the TypedDict type is added. +Multiple inheritance does not allow conflicting types for the same item:: -A key that is not a literal should generally be rejected, since its -value is unknown during type checking, and thus can cause some of the -above violations. (`Use of Final Values and Literal Types`_ -generalizes this to cover final names and literal types.) - -The use of a key that is not known to exist should be reported as an -error, even if this wouldn't necessarily generate a runtime type -error. These are often mistakes, and these may insert values with an -invalid type if structural subtyping hides the types of certain items. -For example, ``d['x'] = 1`` should generate a type check error if -``'x'`` is not a valid key for ``d`` (which is assumed to be a -TypedDict type). - -Extra keys included in TypedDict object construction should also be -caught. In this example, the ``director`` key is not defined in -``Movie`` and is expected to generate an error from a type checker:: + class X(TypedDict): + x: int - m: Movie = dict( - name='Alien', - year=1979, - director='Ridley Scott') # error: Unexpected key 'director' + class Y(TypedDict): + x: str -Type checkers should reject the following operations on TypedDict -objects as unsafe, even though they are valid for normal dictionaries: + class XYZ(X, Y): # Type check error: cannot overwrite TypedDict field "x" while merging + xyz: bool -* Operations with arbitrary ``str`` keys (instead of string literals - or other expressions with known string values) should generally be - rejected. This involves both destructive operations such as setting - an item and read-only operations such as subscription expressions. - As an exception to the above rule, ``d.get(e)`` and ``e in d`` - should be allowed for TypedDict objects, for an arbitrary expression - ``e`` with type ``str``. The motivation is that these are safe and - can be useful for introspecting TypedDict objects. The static type - of ``d.get(e)`` should be ``object`` if the string value of ``e`` - cannot be determined statically. +.. _typeddict-assignability: -* ``clear()`` is not safe since it could remove required keys, some of - which may not be directly visible because of structural - subtyping. ``popitem()`` is similarly unsafe, even if all known - keys are not required (``total=False``). +Subtyping and assignability +--------------------------- -* ``del obj['key']`` should be rejected unless ``'key'`` is a - non-required key. +Because TypedDict types are :term:`structural` types, a TypedDict ``T1`` is :term:`assignable` to another +TypedDict type ``T2`` if the two are structurally compatible, meaning that all operations that +are allowed on ``T2`` are also allowed on ``T1``. For similar reasons, TypedDict types are +generally not assignable to any specialization of ``dict`` or ``Mapping``, other than ``Mapping[str, object]``, +though certain :term:`closed` TypedDicts and TypedDicts with :term:`extra items` may be assignable +to these types. -Type checkers may allow reading an item using ``d['x']`` even if -the key ``'x'`` is not required, instead of requiring the use of -``d.get('x')`` or an explicit ``'x' in d`` check. The rationale is -that tracking the existence of keys is difficult to implement in full -generality, and that disallowing this could require many changes to -existing code. +The rest of this section discusses the :term:`subtyping ` rules for TypedDict in more detail. +As with any type, the rules for :term:`assignability ` can be derived from the subtyping +rules using the :term:`materialization ` procedure. Generally, this means that where +":term:`equivalent`" is mentioned below, the :term:`consistency ` relation can be used instead +when implementing assignability, and where ":term:`subtyping `" between elements of a +TypedDict is mentioned, assignability can be used instead when implementing assignability between TypedDicts. -The exact type checking rules are up to each type checker to decide. -In some cases potentially unsafe operations may be accepted if the -alternative is to generate false positive errors for idiomatic code. +Subtyping between TypedDict types +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +A TypedDict type ``B`` is a :term:`subtype` of a TypedDict type ``A`` if +and only if all of the conditions below are satisfied. For the purposes of these conditions, +an :term:`open` TypedDict is treated as if it had read-only :term:`extra items` of type ``object``. -Use of Final Values and Literal Types -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +The conditions are as follows: -Type checkers should allow :ref:`final names ` with -string values to be used instead of string literals in operations on -TypedDict objects. For example, this is valid:: +- For each item in ``A``: - YEAR: Final = 'year' + - If it is required in ``A``: - m: Movie = {'name': 'Alien', 'year': 1979} - years_since_epoch = m[YEAR] - 1970 + - It must also be required in ``B``. + - If it is read-only in ``A``, the item type in ``B`` must be a subtype of the item type in ``A``. + (For :term:`assignability ` between two TypedDicts, the first item must instead + be assignable to the second.) -Similarly, an expression with a suitable :ref:`literal type ` -can be used instead of a literal value:: + - If it is mutable in ``A``, it must also be mutable in ``B``, and the item type in ``B`` must be + :term:`equivalent` to the item type in ``A``. (It follows that for assignability, the two item types + must be :term:`consistent`.) - def get_value(movie: Movie, - key: Literal['year', 'name']) -> int | str: - return movie[key] + - If it is non-required in ``A``: -Type checkers are only expected to support actual string literals, not -final names or literal types, for specifying keys in a TypedDict type -definition. Also, only a boolean literal can be used to specify -totality in a TypedDict definition. The motivation for this is to -make type declarations self-contained, and to simplify the -implementation of type checkers. + - If it is read-only in ``A``: + - If ``B`` has an item with the same key, its item type must be a subtype of the item type in ``A``. + - Else: -Backwards Compatibility -^^^^^^^^^^^^^^^^^^^^^^^ + - If ``B`` is closed, the check succeeds. + - If ``B`` has extra items, the extra items type must be a subtype of the item type in ``A``. -To retain backwards compatibility, type checkers should not infer a -TypedDict type unless it is sufficiently clear that this is desired by -the programmer. When unsure, an ordinary dictionary type should be -inferred. Otherwise existing code that type checks without errors may -start generating errors once TypedDict support is added to the type -checker, since TypedDict types are more restrictive than dictionary -types. In particular, they aren't subtypes of dictionary types. + - If it is mutable in ``A``: -.. _`required-notrequired`: + - If ``B`` has an item with the same key, it must also be mutable and non-required, and its item type must be + :term:`equivalent` to the item type in ``A``. -``Required`` and ``NotRequired`` --------------------------------- + - Else: -(Originally specified in :pep:`655`.) + - If ``B`` is closed, the check fails. + - If ``B`` has extra items, the extra items type must not be read-only and must + be :term:`equivalent` to the item type in ``A``. -.. _`required`: +- If ``A`` is closed, ``B`` must also be closed, and it must not contain any items that are not present in ``A``. +- If ``A`` has read-only extra items, ``B`` must either be closed or also have extra items, and the extra items type in ``B`` + must be a subtype of the extra items type in ``A``. Additionally, for any items in ``B`` that are not present in ``A``, + the item type must be a subtype of the extra items type in ``A``. +- If ``A`` has mutable extra items, ``B`` must also have mutable extra items, and the extra items type in ``B`` + must be :term:`equivalent` to the extra items type in ``A``. Additionally, for any items in ``B`` that are not present in ``A``, + the item type must be :term:`equivalent` to the extra items type in ``A``. -The ``typing.Required`` :term:`type qualifier` is used to indicate that a -variable declared in a TypedDict definition is a required key: +The intuition behind these rules is that any operation that is valid on ``A`` must also be valid and safe on ``B``. +For example, any key access on ``A`` that is guaranteed to succeed (because the item is required) must also succeed on ``B``, +and any mutating operation (such as setting or deleting a key) that is allowed on ``A`` must also be allowed on ``B``. -:: +An example where mutability is relevant:: - class Movie(TypedDict, total=False): - title: Required[str] - year: int + class A(TypedDict): + x: int | None -.. _`notrequired`: + class B(TypedDict): + x: int -Additionally the ``typing.NotRequired`` :term:`type qualifier` is used to -indicate that a variable declared in a TypedDict definition is a -potentially-missing key: + def f(a: A) -> None: + a['x'] = None -:: + b: B = {'x': 0} + f(b) # Type check error: 'B' not assignable to 'A' + b['x'] + 1 # Runtime error: None + 1 - class Movie(TypedDict): # implicitly total=True - title: str - year: NotRequired[int] +.. _typeddict-mapping: -It is an error to use ``Required[]`` or ``NotRequired[]`` in any -location that is not an item of a TypedDict. -Type checkers must enforce this restriction. +Subtyping with ``Mapping`` +^^^^^^^^^^^^^^^^^^^^^^^^^^ -It is valid to use ``Required[]`` and ``NotRequired[]`` even for -items where it is redundant, to enable additional explicitness if desired: +A TypedDict type is a :term:`subtype` of a type of the form ``Mapping[str, VT]`` +when all value types of the items in the TypedDict +are subtypes of ``VT``. For the purpose of this rule, an :term:`open` TypedDict is considered +to have read-only :term:`extra items` of type ``object``. -:: +For example:: - class Movie(TypedDict): - title: Required[str] # redundant - year: NotRequired[int] + class MovieExtraStr(TypedDict, extra_items=str): + name: str -It is an error to use both ``Required[]`` and ``NotRequired[]`` at the -same time: + extra_str: MovieExtraStr = {"name": "Blade Runner", "summary": ""} + str_mapping: Mapping[str, str] = extra_str # OK -:: + class MovieExtraInt(TypedDict, extra_items=int): + name: str - class Movie(TypedDict): - title: str - year: NotRequired[Required[int]] # ERROR + extra_int: MovieExtraInt = {"name": "Blade Runner", "year": 1982} + int_mapping: Mapping[str, int] = extra_int # Not OK. 'int | str' is not assignable with 'int' + int_str_mapping: Mapping[str, int | str] = extra_int # OK -Type checkers must enforce this restriction. -The runtime implementations of ``Required[]`` and ``NotRequired[]`` -may also enforce this restriction. +As a consequence, every TypedDict type is :term:`assignable` to ``Mapping[str, object]``. -The :ref:`alternative functional syntax ` -for TypedDict also supports -``Required[]``, ``NotRequired[]``, and ``ReadOnly[]``: +.. _typeddict-dict: -:: +Subtyping with ``dict`` +^^^^^^^^^^^^^^^^^^^^^^^ - Movie = TypedDict('Movie', {'name': str, 'year': NotRequired[int]}) +Generally, TypedDict types are not subtypes of any specialization of ``dict[...]`` type, since +dictionary types allow destructive operations, including ``clear()``. They +also allow arbitrary keys to be set, which would compromise type safety. +However, a TypedDict with :term:`extra items` may be a subtype of ``dict[str, VT]``, +provided certain conditions are met, because it introduces sufficient restrictions +for this subtyping relation to be safe. +A TypedDict type is a subtype of ``dict[str, VT]`` if the following conditions are met: -Interaction with ``total=False`` -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- The TypedDict type has mutable :term:`extra items` of a type that is :term:`equivalent` to ``VT``. +- All items on the TypedDict satisfy the following conditions: -Any TypedDict declared with ``total=False`` is equivalent -to a TypedDict with an implicit ``total=True`` definition with all of its -keys marked as ``NotRequired[]``. + - The value type of the item is :term:`equivalent` to ``VT``. + - The item is not read-only. + - The item is not required. -Therefore: +For example:: -:: + class IntDict(TypedDict, extra_items=int): + pass - class _MovieBase(TypedDict): # implicitly total=True - title: str + class IntDictWithNum(IntDict): + num: NotRequired[int] - class Movie(_MovieBase, total=False): - year: int + def f(x: IntDict) -> None: + v: dict[str, int] = x # OK + v.clear() # OK + not_required_num_dict: IntDictWithNum = {"num": 1, "bar": 2} + regular_dict: dict[str, int] = not_required_num_dict # OK + f(not_required_num_dict) # OK -is equivalent to: +In this case, some methods that are otherwise unavailable on a TypedDict are allowed, +with signatures matching ``dict[str, VT]`` +(e.g.: ``__setitem__(self, key: str, value: VT) -> None``):: -:: + not_required_num_dict.clear() # OK - class _MovieBase(TypedDict): - title: str + reveal_type(not_required_num_dict.popitem()) # OK. Revealed type is 'tuple[str, int]' - class Movie(_MovieBase): - year: NotRequired[int] + def f(not_required_num_dict: IntDictWithNum, key: str): + not_required_num_dict[key] = 42 # OK + del not_required_num_dict[key] # OK +On the other hand, ``dict[str, VT]`` is not assignable to any TypedDict type, +because such a type includes instances of subclasses of ``dict``:: -Interaction with ``Annotated[]`` -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + class CustomDict(dict[str, int]): + pass -``Required[]`` and ``NotRequired[]`` can be used with ``Annotated[]``, -in any nesting order: + def f(might_not_be_a_builtin_dict: dict[str, int]): + int_dict: IntDict = might_not_be_a_builtin_dict # Not OK -:: + not_a_builtin_dict = CustomDict({"num": 1}) + f(not_a_builtin_dict) - class Movie(TypedDict): - title: str - year: NotRequired[Annotated[int, ValueRange(-9999, 9999)]] # ok +.. _typeddict-operations: -:: +Supported and Unsupported Operations +------------------------------------ - class Movie(TypedDict): - title: str - year: Annotated[NotRequired[int], ValueRange(-9999, 9999)] # ok +Type checkers should support restricted forms of most ``dict`` +operations on TypedDict objects. The guiding principle is that +operations not involving ``Any`` types should be rejected by type +checkers if they may violate runtime type safety. Here are some of +the most important type safety violations to prevent: -In particular allowing ``Annotated[]`` to be the outermost annotation -for an item allows better interoperability with non-typing uses of -annotations, which may always want ``Annotated[]`` as the outermost annotation -(`discussion `__). +1. A required key is missing. +2. A value has an invalid type. -Read-only Items ---------------- +3. A key that is not defined in the TypedDict type is added. -(Originally specified in :pep:`705`.) +4. Read-only items are modified or deleted. .. _`readonly`: -``typing.ReadOnly`` type qualifier -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The ``typing.ReadOnly`` :term:`type qualifier` is used to indicate that an item declared in a ``TypedDict`` definition may not be mutated (added, modified, or removed):: +Items that are :term:`read-only` may not be mutated (added, modified, or removed):: from typing import ReadOnly @@ -667,135 +705,117 @@ The ``typing.ReadOnly`` :term:`type qualifier` is used to indicate that an item blur["members"] = ["Damon Albarn"] # Type check error: "members" is read-only blur["members"].append("Damon Albarn") # OK: list is mutable +The exact type checking rules are up to each type checker to decide. +In some cases potentially unsafe operations may be accepted if the +alternative is to generate false positive errors for idiomatic code. +Sometimes, operations on :term:`closed` TypedDicts or TypedDicts with +:term:`extra items` are safe even if they would be unsafe on +:term:`open` TypedDicts, so type checker behavior may depend on the +openness of the TypedDict. -Interaction with other special types -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -``ReadOnly[]`` can be used with ``Required[]``, ``NotRequired[]`` and ``Annotated[]``, in any nesting order: - -:: - - class Movie(TypedDict): - title: ReadOnly[Required[str]] # OK - year: ReadOnly[NotRequired[Annotated[int, ValueRange(-9999, 9999)]]] # OK +Allowed keys +^^^^^^^^^^^^ -:: +Many operations on TypedDict objects involve specifying a dictionary key. +Examples include accessing an item with ``d['key']`` or setting an item with +``d['key'] = value``. - class Movie(TypedDict): - title: Required[ReadOnly[str]] # OK - year: Annotated[NotRequired[ReadOnly[int]], ValueRange(-9999, 9999)] # OK +A key that is not a literal should generally be rejected, since its +value is unknown during type checking, and thus can cause some of the +above violations. This involves both destructive operations such as setting +an item and read-only operations such as subscription expressions. + +The use of a key that is not known to exist should be reported as an error, +even if this wouldn't necessarily generate a runtime type error. These are +often mistakes, and these may insert values with an invalid type if +:term:`structural` :term:`assignability ` hides the types of +certain items. For example, ``d['x'] = 1`` should generate a type check error +if ``'x'`` is not a valid key for ``d`` (which is assumed to be a TypedDict +type), unless ``d`` has mutable :term:`extra items` of a compatible type. + +Type checkers should allow names declared with a :term:`bare Final` and a +string value to be used instead of string literals in operations on +TypedDict objects. For example, this is valid:: + YEAR: Final = 'year' -Inheritance -^^^^^^^^^^^ + m: Movie = {'name': 'Alien', 'year': 1979} + years_since_epoch = m[YEAR] - 1970 -Subclasses can redeclare read-only items as non-read-only, allowing them to be mutated:: +Similarly, an expression with a suitable :ref:`literal type ` +can be used instead of a literal value:: - class NamedDict(TypedDict): - name: ReadOnly[str] + def get_value(movie: Movie, + key: Literal['year', 'name']) -> int | str: + return movie[key] - class Album(NamedDict): - name: str - year: int +Specific operations +^^^^^^^^^^^^^^^^^^^ - album: Album = { "name": "Flood", "year": 1990 } - album["year"] = 1973 - album["name"] = "Dark Side Of The Moon" # OK: "name" is not read-only in Album +This section discusses some specific operations in more detail. -If a read-only item is not redeclared, it remains read-only:: +* As an exception to the general rule around non-literal keys, ``d.get(e)`` and ``e in d`` + should be allowed for TypedDict objects, for an arbitrary expression + ``e`` with type ``str``. The motivation is that these are safe and + can be useful for introspecting TypedDict objects. The static type + of ``d.get(e)`` should be the union of all possible item types in ``d`` + if the string value of ``e`` cannot be determined statically. + (This simplifies to ``object`` if ``d`` is :term:`open`.) - class Album(NamedDict): - year: int +* ``clear()`` is not safe on :term:`open` TypedDicts since it could remove required items, some of which + may not be directly visible because of :term:`structural` + :term:`assignability `. However, this method is safe on + :term:`closed` TypedDicts and TypedDicts with :term:`extra items` if + there are no required or read-only items and there cannot be any subclasses with required + or read-only items. - album: Album = { "name": "Flood", "year": 1990 } - album["name"] = "Dark Side Of The Moon" # Type check error: "name" is read-only in Album +* ``popitem()`` is similarly unsafe on many TypedDicts, even + if all known items are :term:`non-required`. -Subclasses can narrow value types of read-only items:: +* ``del obj['key']`` should be rejected unless ``'key'`` is a + non-required, mutable key. + +* Type checkers may allow reading an item using ``d['x']`` even if + the key ``'x'`` is not required, instead of requiring the use of + ``d.get('x')`` or an explicit ``'x' in d`` check. The rationale is + that tracking the existence of keys is difficult to implement in full + generality, and that disallowing this could require many changes to + existing code. + Similarly, type checkers may allow indexed accesses + with arbitrary str keys when a TypedDict is :term:`closed` or has :term:`extra items`. + For example:: + + def bar(movie: MovieExtraInt, key: str) -> None: + reveal_type(movie[key]) # Revealed type is 'str | int' + +* The return types of the ``items()`` and ``values()`` methods can be determined + from the union of all item types in the TypedDict (which would include ``object`` + for :term:`open` TypedDicts). Therefore, type checkers should infer more precise + types for TypedDicts that are not open:: - class AlbumCollection(TypedDict): - albums: ReadOnly[Collection[Album]] + from typing import TypedDict - class RecordShop(AlbumCollection): + class MovieExtraInt(TypedDict, extra_items=int): name: str - albums: ReadOnly[list[Album]] # OK: "albums" is read-only in AlbumCollection - -Subclasses can require items that are read-only but not required in the superclass:: - - class OptionalName(TypedDict): - name: ReadOnly[NotRequired[str]] - - class RequiredName(OptionalName): - name: ReadOnly[Required[str]] - - d: RequiredName = {} # Type check error: "name" required - -Subclasses can combine these rules:: - - class OptionalIdent(TypedDict): - ident: ReadOnly[NotRequired[str | int]] - - class User(OptionalIdent): - ident: str # Required, mutable, and not an int - -Note that these are just consequences of structural typing, but they are highlighted here as the behavior now differs from the rules specified in :pep:`589`. - -Type consistency -^^^^^^^^^^^^^^^^ - -*This section updates the type consistency rules described above that were created prior to the introduction of ReadOnly* - -A TypedDict type ``A`` is consistent with TypedDict ``B`` if ``A`` is structurally compatible with ``B``. This is true if and only if all of the following are satisfied: - -* For each item in ``B``, ``A`` has the corresponding key, unless the item in ``B`` is read-only, not required, and of top value type (``ReadOnly[NotRequired[object]]``). -* For each item in ``B``, if ``A`` has the corresponding key, the corresponding value type in ``A`` is consistent with the value type in ``B``. -* For each non-read-only item in ``B``, its value type is consistent with the corresponding value type in ``A``. -* For each required key in ``B``, the corresponding key is required in ``A``. -* For each non-required key in ``B``, if the item is not read-only in ``B``, the corresponding key is not required in ``A``. - -Discussion: -* All non-specified items in a TypedDict implicitly have value type ``ReadOnly[NotRequired[object]]``. + def foo(movie: MovieExtraInt) -> None: + reveal_type(movie.items()) # Revealed type is 'dict_items[str, str | int]' + reveal_type(movie.values()) # Revealed type is 'dict_values[str, str | int]' -* Read-only items behave covariantly, as they cannot be mutated. This is similar to container types such as ``Sequence``, and different from non-read-only items, which behave invariantly. Example:: - - class A(TypedDict): - x: ReadOnly[int | None] - - class B(TypedDict): - x: int - - def f(a: A) -> None: - print(a["x"] or 0) - - b: B = {"x": 1} - f(b) # Accepted by type checker - -* A TypedDict type ``A`` with no explicit key ``'x'`` is not consistent with a TypedDict type ``B`` with a non-required key ``'x'``, since at runtime the key ``'x'`` could be present and have an incompatible type (which may not be visible through ``A`` due to structural subtyping). The only exception to this rule is if the item in ``B`` is read-only, and the value type is of top type (``object``). For example:: - - class A(TypedDict): - x: int - - class B(TypedDict): - x: int - y: ReadOnly[NotRequired[object]] - - a: A = { "x": 1 } - b: B = a # Accepted by type checker - -Update method -^^^^^^^^^^^^^ - -In addition to existing type checking rules, type checkers should error if a TypedDict with a read-only item is updated with another TypedDict that declares that key:: +* The ``update()`` method should not allow mutating a read-only item. + Therefore, type checkers should error if a + TypedDict with a read-only item is updated with another TypedDict that declares + that item:: class A(TypedDict): x: ReadOnly[int] y: int - a1: A = { "x": 1, "y": 2 } - a2: A = { "x": 3, "y": 4 } + a1: A = {"x": 1, "y": 2} + a2: A = {"x": 3, "y": 4} a1.update(a2) # Type check error: "x" is read-only in A -Unless the declared value is of bottom type (:data:`~typing.Never`):: + Unless the declared value is of bottom type (:data:`~typing.Never`):: class B(TypedDict): x: NotRequired[typing.Never] @@ -804,25 +824,15 @@ Unless the declared value is of bottom type (:data:`~typing.Never`):: def update_a(a: A, b: B) -> None: a.update(b) # Accepted by type checker: "x" cannot be set on b -Note: Nothing will ever match the ``Never`` type, so an item annotated with it must be absent. - -Keyword argument typing -^^^^^^^^^^^^^^^^^^^^^^^ - -As discussed in the section :ref:`unpack-kwargs`, an unpacked ``TypedDict`` can be used to annotate ``**kwargs``. Marking one or more of the items of a ``TypedDict`` used in this way as read-only will have no effect on the type signature of the method. However, it *will* prevent the item from being modified in the body of the function:: - - class Args(TypedDict): - key1: int - key2: str - - class ReadOnlyArgs(TypedDict): - key1: ReadOnly[int] - key2: ReadOnly[str] - - class Function(Protocol): - def __call__(self, **kwargs: Unpack[Args]) -> None: ... + Note: Nothing will ever match the ``Never`` type, so an item annotated with it must be absent. - def impl(**kwargs: Unpack[ReadOnlyArgs]) -> None: - kwargs["key1"] = 3 # Type check error: key1 is readonly +Backwards Compatibility +----------------------- - fn: Function = impl # Accepted by type checker: function signatures are identical +To retain backwards compatibility, type checkers should not infer a +TypedDict type unless it is sufficiently clear that this is desired by +the programmer. When unsure, an ordinary dictionary type should be +inferred. Otherwise existing code that type checks without errors may +start generating errors once TypedDict support is added to the type +checker, since TypedDict types are more restrictive than dictionary +types. In particular, they aren't subtypes of dictionary types. diff --git a/docs/tutorials/external_libraries.rst b/docs/tutorials/external_libraries.rst new file mode 100644 index 000000000..66a1d5452 --- /dev/null +++ b/docs/tutorials/external_libraries.rst @@ -0,0 +1,42 @@ +.. _external_libraries: + +************************ +Using External Libraries +************************ + +.. seealso:: + If you are looking for information on how to write type hints for + external libraries, see the :ref:`writing_stubs` guide. + +Many external libraries -- whether installed from the +`Python Package Index `_ (PyPI) or from other sources -- +provide their own type hints. This is indicated by the presence of a +``py.typed`` file in the library's root directory. If you install such a +library, you can use it with any type checker without any additional +configuration. + +Type hints can either be included in the library's source code the same way +as in your own code, or they can be provided in separate so-called +*stub files*. Stub files are named ``.pyi`` and contain only type +hints, without any implementation. + +For libraries that don't include their own type hints, a separate +*stub package* may provide them. These stub packages are often written by the +library authors themselves, by the contributors to the +`typeshed `_ project, or by third-party +contributors. These packages are usually named ``types-`` +or ``-stubs``. These packages can be installed from PyPI as usual, and +they will be automatically discovered by type checkers:: + + pip install requests types-requests + +.. warning:: + + The usual security considerations apply when installing third-party + packages. Only install packages from sources you trust. Stub packages + have the same security implications as any other package. + +.. + TODO: Once development dependencies are supported by pyproject.toml, + and described in https://packaging.python.org/en/latest/guides/writing-pyproject-toml/ + we should recommend installing type stubs as a development dependency. diff --git a/docs/tutorials/index.rst b/docs/tutorials/index.rst new file mode 100644 index 000000000..f84673dad --- /dev/null +++ b/docs/tutorials/index.rst @@ -0,0 +1,15 @@ +:orphan: + +********************* +Type System Tutorials +********************* + +.. + Keep in sync with docs/index.rst. + + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + external_libraries diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..5eca7c54e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,21 @@ +[project] +name = "typing" +version = "1" # dummy +requires-python = ">= 3.12" # for building the documentation etc. + +[dependency-groups] +test = [ + "flake8", + "flake8-bugbear", + "flake8-pyi", +] +docs = [ + # Sphinx version is pinned so that new versions that introduce new warnings + # won't suddenly cause build failures. Updating the version is fine as long + # as no warnings are raised by doing so. + "sphinx==9.1.0", + + # The theme used by the documentation is stored separately, so we need + # to install that as well. + "python-docs-theme", +] diff --git a/test-requirements.txt b/test-requirements.txt deleted file mode 100644 index 658ae0a52..000000000 --- a/test-requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -flake8 -flake8-bugbear -flake8-pyi