├── conformance ├── src │ ├── __init__.py │ └── options.py ├── results │ ├── mypy │ │ ├── version.toml │ │ ├── protocols_self.toml │ │ ├── enums_definition.toml │ │ ├── protocols_recursive.toml │ │ ├── typeddicts_final.toml │ │ ├── annotations_coroutines.toml │ │ ├── directives_type_checking.toml │ │ ├── directives_type_ignore_file1.toml │ │ ├── exceptions_context_managers.toml │ │ ├── generics_typevartuple_concat.toml │ │ ├── generics_typevartuple_overloads.toml │ │ ├── dataclasses_order.toml │ │ ├── specialtypes_promotions.toml │ │ ├── dataclasses_match_args.toml │ │ ├── constructors_consistency.toml │ │ ├── typeddicts_readonly_kwargs.toml │ │ ├── directives_type_ignore_file2.toml │ │ ├── dataclasses_hash.toml │ │ ├── generics_typevartuple_callable.toml │ │ ├── generics_typevartuple_unpack.toml │ │ ├── annotations_methods.toml │ │ ├── generics_syntax_compatibility.toml │ │ ├── dataclasses_kwonly.toml │ │ ├── overloads_consistency.toml │ │ ├── dataclasses_inheritance.toml │ │ ├── specialtypes_any.toml │ │ ├── enums_behaviors.toml │ │ ├── typeddicts_inheritance.toml │ │ ├── generics_self_basic.toml │ │ ├── namedtuples_type_compat.toml │ │ ├── directives_no_type_check.toml │ │ ├── generics_self_attributes.toml │ │ ├── enums_member_names.toml │ │ ├── overloads_basic.toml │ │ ├── enums_expansion.toml │ │ ├── dataclasses_frozen.toml │ │ ├── specialtypes_none.toml │ │ ├── typeddicts_required.toml │ │ ├── generics_upper_bound.toml │ │ ├── tuples_unpacked.toml │ │ ├── dataclasses_slots.toml │ │ ├── aliases_variance.toml │ │ ├── dataclasses_descriptors.toml │ │ ├── generics_defaults_specialization.toml │ │ ├── typeddicts_readonly_update.toml │ │ ├── specialtypes_never.toml │ │ ├── literals_semantics.toml │ │ ├── dataclasses_transform_meta.toml │ │ ├── dataclasses_transform_class.toml │ │ ├── enums_member_values.toml │ │ ├── generics_paramspec_specialization.toml │ │ ├── typeddicts_class_syntax.toml │ │ ├── classes_override.toml │ │ ├── directives_reveal_type.toml │ │ ├── narrowing_typeguard.toml │ │ ├── dataclasses_transform_field.toml │ │ ├── typeddicts_usage.toml │ │ ├── typeddicts_readonly.toml │ │ ├── directives_version_platform.toml │ │ ├── namedtuples_usage.toml │ │ ├── dataclasses_postinit.toml │ │ ├── constructors_call_type.toml │ │ ├── protocols_runtime_checkable.toml │ │ ├── typeddicts_alt_syntax.toml │ │ ├── directives_assert_type.toml │ │ └── constructors_call_init.toml │ ├── zuban │ │ ├── version.toml │ │ ├── protocols_self.toml │ │ ├── specialtypes_any.toml │ │ ├── typeddicts_final.toml │ │ ├── annotations_coroutines.toml │ │ ├── protocols_recursive.toml │ │ ├── constructors_consistency.toml │ │ ├── dataclasses_descriptors.toml │ │ ├── directives_type_checking.toml │ │ ├── exceptions_context_managers.toml │ │ ├── directives_type_ignore_file1.toml │ │ ├── generics_typevartuple_concat.toml │ │ ├── generics_typevartuple_overloads.toml │ │ ├── enums_definition.toml │ │ ├── annotations_methods.toml │ │ ├── dataclasses_order.toml │ │ ├── specialtypes_promotions.toml │ │ ├── enums_member_names.toml │ │ ├── dataclasses_match_args.toml │ │ ├── typeddicts_readonly_kwargs.toml │ │ ├── typeddicts_readonly_update.toml │ │ ├── directives_type_ignore_file2.toml │ │ ├── generics_typevartuple_callable.toml │ │ ├── dataclasses_hash.toml │ │ ├── generics_typevartuple_unpack.toml │ │ ├── constructors_call_metaclass.toml │ │ ├── dataclasses_transform_field.toml │ │ ├── directives_cast.toml │ │ ├── generics_syntax_compatibility.toml │ │ ├── generics_defaults_specialization.toml │ │ ├── directives_no_type_check.toml │ │ ├── dataclasses_kwonly.toml │ │ ├── overloads_consistency.toml │ │ ├── enums_behaviors.toml │ │ ├── dataclasses_inheritance.toml │ │ ├── typeddicts_inheritance.toml │ │ ├── generics_self_basic.toml │ │ ├── namedtuples_type_compat.toml │ │ ├── generics_self_attributes.toml │ │ ├── overloads_basic.toml │ │ ├── specialtypes_none.toml │ │ ├── typeddicts_required.toml │ │ ├── dataclasses_frozen.toml │ │ ├── enums_expansion.toml │ │ ├── tuples_unpacked.toml │ │ ├── generics_upper_bound.toml │ │ ├── aliases_variance.toml │ │ ├── directives_reveal_type.toml │ │ ├── typeddicts_usage.toml │ │ ├── narrowing_typeguard.toml │ │ ├── dataclasses_slots.toml │ │ ├── enums_member_values.toml │ │ ├── directives_version_platform.toml │ │ ├── specialtypes_never.toml │ │ ├── typeddicts_class_syntax.toml │ │ ├── generics_self_advanced.toml │ │ ├── literals_semantics.toml │ │ ├── dataclasses_transform_meta.toml │ │ ├── generics_paramspec_specialization.toml │ │ ├── dataclasses_transform_class.toml │ │ ├── constructors_call_init.toml │ │ ├── classes_override.toml │ │ ├── typeddicts_alt_syntax.toml │ │ ├── namedtuples_usage.toml │ │ ├── dataclasses_transform_func.toml │ │ ├── typeddicts_readonly.toml │ │ ├── historical_positional.toml │ │ ├── dataclasses_postinit.toml │ │ ├── directives_assert_type.toml │ │ ├── generics_typevartuple_specialization.toml │ │ ├── constructors_call_type.toml │ │ ├── protocols_runtime_checkable.toml │ │ ├── protocols_explicit.toml │ │ ├── directives_type_ignore.toml │ │ ├── generics_defaults_referential.toml │ │ └── specialtypes_type.toml │ ├── pyrefly │ │ ├── version.toml │ │ ├── protocols_self.toml │ │ ├── enums_definition.toml │ │ ├── specialtypes_any.toml │ │ ├── typeddicts_final.toml │ │ ├── protocols_recursive.toml │ │ ├── annotations_coroutines.toml │ │ ├── constructors_consistency.toml │ │ ├── dataclasses_descriptors.toml │ │ ├── directives_type_checking.toml │ │ ├── directives_type_ignore.toml │ │ ├── directives_type_ignore_file1.toml │ │ ├── generics_typevartuple_concat.toml │ │ ├── generics_typevartuple_overloads.toml │ │ ├── overloads_basic.toml │ │ ├── annotations_methods.toml │ │ ├── dataclasses_order.toml │ │ ├── generics_self_advanced.toml │ │ ├── enums_expansion.toml │ │ ├── enums_member_names.toml │ │ ├── dataclasses_match_args.toml │ │ ├── directives_type_ignore_file2.toml │ │ ├── typeddicts_readonly_kwargs.toml │ │ ├── specialtypes_promotions.toml │ │ ├── aliases_variance.toml │ │ ├── typeddicts_readonly_update.toml │ │ ├── dataclasses_hash.toml │ │ ├── directives_version_platform.toml │ │ ├── generics_typevartuple_callable.toml │ │ ├── directives_reveal_type.toml │ │ ├── generics_typevartuple_unpack.toml │ │ ├── namedtuples_type_compat.toml │ │ ├── protocols_variance.toml │ │ ├── constructors_call_metaclass.toml │ │ ├── generics_defaults_specialization.toml │ │ ├── enums_behaviors.toml │ │ ├── dataclasses_inheritance.toml │ │ ├── generics_self_basic.toml │ │ ├── dataclasses_transform_field.toml │ │ ├── generics_self_attributes.toml │ │ ├── overloads_consistency.toml │ │ ├── generics_self_protocols.toml │ │ ├── constructors_call_new.toml │ │ ├── dataclasses_kwonly.toml │ │ ├── dataclasses_frozen.toml │ │ ├── dataclasses_final.toml │ │ ├── directives_cast.toml │ │ ├── specialtypes_none.toml │ │ ├── generics_syntax_compatibility.toml │ │ ├── typeddicts_inheritance.toml │ │ ├── exceptions_context_managers.toml │ │ ├── literals_semantics.toml │ │ ├── dataclasses_slots.toml │ │ ├── generics_self_usage.toml │ │ ├── tuples_unpacked.toml │ │ ├── historical_positional.toml │ │ ├── typeddicts_required.toml │ │ ├── aliases_recursive.toml │ │ ├── generics_upper_bound.toml │ │ ├── typeddicts_readonly.toml │ │ ├── generics_scoping.toml │ │ ├── generics_variance.toml │ │ ├── overloads_evaluation.toml │ │ ├── directives_no_type_check.toml │ │ ├── protocols_modules.toml │ │ ├── narrowing_typeguard.toml │ │ ├── typeddicts_usage.toml │ │ ├── directives_assert_type.toml │ │ ├── typeddicts_class_syntax.toml │ │ ├── dataclasses_postinit.toml │ │ ├── protocols_merging.toml │ │ ├── generics_paramspec_specialization.toml │ │ ├── namedtuples_usage.toml │ │ ├── typeddicts_readonly_consistency.toml │ │ ├── specialtypes_never.toml │ │ ├── protocols_class_objects.toml │ │ ├── classes_override.toml │ │ ├── constructors_call_init.toml │ │ ├── protocols_subtyping.toml │ │ ├── enums_member_values.toml │ │ ├── generics_base_class.toml │ │ └── generics_syntax_scoping.toml │ └── pyright │ │ ├── version.toml │ │ ├── enums_definition.toml │ │ ├── protocols_self.toml │ │ ├── specialtypes_any.toml │ │ ├── typeddicts_final.toml │ │ ├── enums_member_names.toml │ │ ├── protocols_recursive.toml │ │ ├── annotations_coroutines.toml │ │ ├── dataclasses_descriptors.toml │ │ ├── directives_type_checking.toml │ │ ├── directives_type_ignore.toml │ │ ├── generics_self_advanced.toml │ │ ├── directives_type_ignore_file1.toml │ │ ├── directives_version_platform.toml │ │ ├── exceptions_context_managers.toml │ │ ├── generics_typevartuple_concat.toml │ │ ├── generics_typevartuple_overloads.toml │ │ ├── dataclasses_order.toml │ │ ├── enums_expansion.toml │ │ ├── dataclasses_match_args.toml │ │ ├── specialtypes_promotions.toml │ │ ├── typeddicts_readonly_kwargs.toml │ │ ├── directives_type_ignore_file2.toml │ │ ├── dataclasses_transform_field.toml │ │ ├── constructors_call_metaclass.toml │ │ ├── constructors_consistency.toml │ │ ├── dataclasses_kwonly.toml │ │ ├── generics_defaults_specialization.toml │ │ ├── dataclasses_inheritance.toml │ │ ├── generics_typevartuple_callable.toml │ │ ├── annotations_methods.toml │ │ ├── directives_no_type_check.toml │ │ ├── overloads_basic.toml │ │ ├── typeddicts_readonly_update.toml │ │ ├── enums_behaviors.toml │ │ ├── directives_cast.toml │ │ ├── typeddicts_required.toml │ │ ├── generics_typevartuple_unpack.toml │ │ ├── generics_syntax_compatibility.toml │ │ ├── generics_self_basic.toml │ │ ├── historical_positional.toml │ │ ├── literals_interactions.toml │ │ ├── namedtuples_type_compat.toml │ │ ├── dataclasses_hash.toml │ │ ├── dataclasses_frozen.toml │ │ ├── directives_reveal_type.toml │ │ ├── typeddicts_inheritance.toml │ │ ├── overloads_consistency.toml │ │ ├── constructors_call_new.toml │ │ ├── dataclasses_postinit.toml │ │ ├── dataclasses_slots.toml │ │ ├── typeddicts_class_syntax.toml │ │ ├── specialtypes_none.toml │ │ ├── typeddicts_alt_syntax.toml │ │ ├── tuples_unpacked.toml │ │ ├── classes_override.toml │ │ ├── specialtypes_never.toml │ │ ├── typeddicts_usage.toml │ │ ├── dataclasses_transform_meta.toml │ │ ├── dataclasses_transform_class.toml │ │ ├── dataclasses_transform_func.toml │ │ ├── enums_member_values.toml │ │ ├── protocols_modules.toml │ │ ├── aliases_variance.toml │ │ ├── generics_self_attributes.toml │ │ ├── generics_upper_bound.toml │ │ ├── generics_defaults.toml │ │ └── constructors_call_type.toml ├── requirements.txt ├── tests │ ├── _enums_member_values.py │ ├── _enums_members.py │ ├── pyrefly.toml │ ├── _protocols_modules1.py │ ├── _qualifiers_final_annotation_2.py │ ├── _qualifiers_final_annotation_1.py │ ├── _protocols_modules2.py │ ├── _enums_member_values.pyi │ ├── _enums_members.pyi │ ├── specialtypes_promotions.py │ ├── directives_type_checking.py │ ├── directives_cast.py │ ├── directives_type_ignore_file1.py │ ├── directives_type_ignore_file2.py │ ├── _qualifiers_final_decorator.pyi │ ├── generics_syntax_compatibility.py │ ├── directives_type_ignore.py │ ├── directives_reveal_type.py │ ├── constructors_consistency.py │ ├── typeddicts_final.py │ ├── namedtuples_type_compat.py │ ├── dataclasses_order.py │ ├── annotations_coroutines.py │ ├── generics_self_attributes.py │ ├── typeddicts_readonly_update.py │ ├── enums_member_names.py │ ├── generics_typevartuple_overloads.py │ ├── specialtypes_none.py │ ├── generics_paramspec_basic.py │ └── dataclasses_frozen.py └── .gitignore ├── test-requirements.txt ├── docs ├── reference │ ├── stubs.rst │ └── index.rst ├── tutorials │ └── index.rst ├── guides │ └── index.rst ├── requirements.txt ├── spec │ └── index.rst └── make.bat ├── .gitignore ├── .github ├── ISSUE_TEMPLATE │ ├── other-issue.md │ ├── new-typing-feature.md │ └── documentation-issue.md ├── dependabot.yml └── workflows │ ├── build-docs.yml │ └── ci.yml ├── .flake8 ├── .editorconfig ├── .readthedocs.yaml └── .pre-commit-config.yaml /conformance/src/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /conformance/results/mypy/version.toml: -------------------------------------------------------------------------------- 1 | version = "mypy 1.19.0" 2 | -------------------------------------------------------------------------------- /conformance/results/zuban/version.toml: -------------------------------------------------------------------------------- 1 | version = "zuban 0.3.0" 2 | -------------------------------------------------------------------------------- /test-requirements.txt: -------------------------------------------------------------------------------- 1 | flake8 2 | flake8-bugbear 3 | flake8-pyi 4 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/version.toml: -------------------------------------------------------------------------------- 1 | version = "pyrefly 0.45.2" 2 | -------------------------------------------------------------------------------- /conformance/results/pyright/version.toml: -------------------------------------------------------------------------------- 1 | version = "pyright 1.1.407" 2 | -------------------------------------------------------------------------------- /conformance/requirements.txt: -------------------------------------------------------------------------------- 1 | tomli 2 | tomlkit 3 | pyright 4 | mypy 5 | pip 6 | zuban 7 | pyrefly 8 | -------------------------------------------------------------------------------- /conformance/tests/_enums_member_values.py: -------------------------------------------------------------------------------- 1 | """ 2 | Dummy implementation _enums_member_values stub. 3 | """ 4 | -------------------------------------------------------------------------------- /conformance/tests/_enums_members.py: -------------------------------------------------------------------------------- 1 | """ 2 | Dummy implementation for stub file for enums_members test. 3 | """ 4 | -------------------------------------------------------------------------------- /conformance/tests/pyrefly.toml: -------------------------------------------------------------------------------- 1 | # Empty configuration file to make sure pyrefly treats this directory as the project root. 2 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/protocols_self.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | """ 6 | -------------------------------------------------------------------------------- /conformance/results/zuban/protocols_self.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | """ 6 | -------------------------------------------------------------------------------- /conformance/results/zuban/specialtypes_any.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | """ 6 | -------------------------------------------------------------------------------- /conformance/results/zuban/typeddicts_final.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | """ 6 | -------------------------------------------------------------------------------- /conformance/results/zuban/annotations_coroutines.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | """ 6 | -------------------------------------------------------------------------------- /conformance/results/zuban/protocols_recursive.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | """ 6 | -------------------------------------------------------------------------------- /conformance/results/zuban/constructors_consistency.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | """ 6 | -------------------------------------------------------------------------------- /conformance/results/zuban/dataclasses_descriptors.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | """ 6 | -------------------------------------------------------------------------------- /conformance/results/zuban/directives_type_checking.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | """ 6 | -------------------------------------------------------------------------------- /conformance/results/zuban/exceptions_context_managers.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | """ 6 | -------------------------------------------------------------------------------- /conformance/results/zuban/directives_type_ignore_file1.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | """ 6 | -------------------------------------------------------------------------------- /conformance/results/zuban/generics_typevartuple_concat.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | """ 6 | -------------------------------------------------------------------------------- /conformance/results/zuban/generics_typevartuple_overloads.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | """ 6 | -------------------------------------------------------------------------------- /conformance/results/mypy/protocols_self.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | """ 4 | conformance_automated = "Pass" 5 | errors_diff = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/mypy/enums_definition.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | """ 6 | conformance_automated = "Pass" 7 | -------------------------------------------------------------------------------- /conformance/results/mypy/protocols_recursive.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | """ 4 | conformance_automated = "Pass" 5 | errors_diff = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/mypy/typeddicts_final.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | """ 4 | conformance_automated = "Pass" 5 | errors_diff = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/enums_definition.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/specialtypes_any.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/typeddicts_final.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyright/enums_definition.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | """ 6 | conformance_automated = "Pass" 7 | -------------------------------------------------------------------------------- /conformance/results/pyright/protocols_self.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | """ 4 | conformance_automated = "Pass" 5 | errors_diff = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyright/specialtypes_any.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | """ 4 | conformance_automated = "Pass" 5 | errors_diff = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyright/typeddicts_final.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | """ 4 | conformance_automated = "Pass" 5 | errors_diff = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/mypy/annotations_coroutines.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | """ 4 | conformance_automated = "Pass" 5 | errors_diff = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/mypy/directives_type_checking.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | """ 4 | conformance_automated = "Pass" 5 | errors_diff = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/protocols_recursive.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyright/enums_member_names.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyright/protocols_recursive.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | """ 4 | conformance_automated = "Pass" 5 | errors_diff = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/mypy/directives_type_ignore_file1.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | """ 4 | conformance_automated = "Pass" 5 | errors_diff = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/mypy/exceptions_context_managers.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | """ 6 | conformance_automated = "Pass" 7 | -------------------------------------------------------------------------------- /conformance/results/mypy/generics_typevartuple_concat.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | """ 4 | conformance_automated = "Pass" 5 | errors_diff = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/annotations_coroutines.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/constructors_consistency.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/dataclasses_descriptors.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/directives_type_checking.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/directives_type_ignore.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyright/annotations_coroutines.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | """ 4 | conformance_automated = "Pass" 5 | errors_diff = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyright/dataclasses_descriptors.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | """ 4 | conformance_automated = "Pass" 5 | errors_diff = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyright/directives_type_checking.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | """ 4 | conformance_automated = "Pass" 5 | errors_diff = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyright/directives_type_ignore.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | """ 4 | conformance_automated = "Pass" 5 | errors_diff = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyright/generics_self_advanced.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | """ 4 | conformance_automated = "Pass" 5 | errors_diff = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/tests/_protocols_modules1.py: -------------------------------------------------------------------------------- 1 | """ 2 | Support file for protocols_modules.py test. 3 | """ 4 | 5 | timeout = 100 6 | one_flag = True 7 | other_flag = False 8 | -------------------------------------------------------------------------------- /conformance/results/mypy/generics_typevartuple_overloads.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | """ 4 | conformance_automated = "Pass" 5 | errors_diff = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/directives_type_ignore_file1.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/generics_typevartuple_concat.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/generics_typevartuple_overloads.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyright/directives_type_ignore_file1.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | """ 4 | conformance_automated = "Pass" 5 | errors_diff = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyright/directives_version_platform.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | """ 4 | conformance_automated = "Pass" 5 | errors_diff = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyright/exceptions_context_managers.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | """ 6 | conformance_automated = "Pass" 7 | -------------------------------------------------------------------------------- /conformance/results/pyright/generics_typevartuple_concat.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | """ 4 | conformance_automated = "Pass" 5 | errors_diff = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyright/generics_typevartuple_overloads.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | """ 4 | conformance_automated = "Pass" 5 | errors_diff = """ 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/tests/_qualifiers_final_annotation_2.py: -------------------------------------------------------------------------------- 1 | """ 2 | Used as part of the test for the typing.Final special form. 3 | """ 4 | 5 | from typing import Final 6 | 7 | PI: Final = 3.14 8 | -------------------------------------------------------------------------------- /docs/reference/stubs.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | ********** 4 | Type Stubs 5 | ********** 6 | 7 | The contents of this document have been moved to :ref:`stub-files` and 8 | :ref:`writing_stubs`. 9 | -------------------------------------------------------------------------------- /conformance/tests/_qualifiers_final_annotation_1.py: -------------------------------------------------------------------------------- 1 | """ 2 | Used as part of the test for the typing.Final special form. 3 | """ 4 | 5 | from typing import Final 6 | 7 | TEN: Final[int] = 10 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | MANIFEST 2 | 3 | __pycache__/ 4 | build/ 5 | dist/ 6 | tmp/ 7 | venv*/ 8 | 9 | .cache/ 10 | .idea/ 11 | .tox/ 12 | .venv*/ 13 | .vscode/ 14 | 15 | *.swp 16 | *.pyc 17 | *.egg-info/ 18 | -------------------------------------------------------------------------------- /conformance/results/zuban/enums_definition.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | enums_definition.py:24: error: Too many arguments for Enum() [call-arg] 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/zuban/annotations_methods.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | annotations_methods.py:42: error: Expression is of type "B", not "A" [misc] 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/tests/_protocols_modules2.py: -------------------------------------------------------------------------------- 1 | """ 2 | Support file for protocols_modules.py test. 3 | """ 4 | 5 | 6 | def on_error(x: int) -> None: 7 | ... 8 | 9 | 10 | def on_success() -> None: 11 | ... 12 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/other-issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Other issue 3 | about: Report any other issue 4 | title: '' 5 | labels: 'topic: other' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/overloads_basic.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR overloads_basic.py:39:1-6: Cannot index into `Bytes` [bad-index] 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/zuban/dataclasses_order.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | dataclasses_order.py:50: error: Unsupported operand types for < ("DC1" and "DC2") [operator] 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/zuban/specialtypes_promotions.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | specialtypes_promotions.py:13: error: "float" has no attribute "numerator" [attr-defined] 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/annotations_methods.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR annotations_methods.py:42:12-28: assert_type(B, A) failed [assert-type] 7 | """ 8 | -------------------------------------------------------------------------------- /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | 3 | max-line-length = 90 4 | exclude = conformance 5 | ignore = 6 | # irrelevant plugins 7 | B3, 8 | DW12, 9 | # code is sometimes better without this 10 | E129, 11 | # consistency with mypy 12 | W504 13 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: monthly 7 | groups: 8 | actions: 9 | patterns: 10 | - "*" 11 | -------------------------------------------------------------------------------- /conformance/results/zuban/enums_member_names.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | enums_member_names.py:30: error: Expression is of type "str", not "Literal['RED', 'BLUE', 'GREEN']" [misc] 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/mypy/dataclasses_order.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | dataclasses_order.py:50: error: Unsupported operand types for < ("DC1" and "DC2") [operator] 4 | """ 5 | conformance_automated = "Pass" 6 | errors_diff = """ 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/mypy/specialtypes_promotions.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | specialtypes_promotions.py:13: error: "float" has no attribute "numerator" [attr-defined] 4 | """ 5 | conformance_automated = "Pass" 6 | errors_diff = """ 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/mypy/dataclasses_match_args.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | dataclasses_match_args.py:42: error: "type[DC4]" has no attribute "__match_args__" [attr-defined] 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/dataclasses_order.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR dataclasses_order.py:50:4-17: `<` is not supported between `DC1` and `DC2` [unsupported-operation] 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/generics_self_advanced.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | notes = """ 3 | Treats attributes not initialized on the class as instance-only 4 | """ 5 | conformance_automated = "Pass" 6 | errors_diff = """ 7 | """ 8 | output = """ 9 | """ 10 | -------------------------------------------------------------------------------- /conformance/results/zuban/dataclasses_match_args.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | dataclasses_match_args.py:42: error: "type[DC4]" has no attribute "__match_args__" [attr-defined] 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/zuban/typeddicts_readonly_kwargs.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | typeddicts_readonly_kwargs.py:33: error: ReadOnly TypedDict key "key1" TypedDict is mutated [typeddict-readonly-mutated] 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/mypy/constructors_consistency.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | notes = """ 3 | Does not report inconsistency between __new__ and __init__ (optional). 4 | """ 5 | conformance_automated = "Pass" 6 | errors_diff = """ 7 | """ 8 | output = """ 9 | """ 10 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/enums_expansion.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR enums_expansion.py:53:20-51: assert_type(CustomFlags, Literal[CustomFlags.FLAG3]) failed [assert-type] 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/enums_member_names.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR enums_member_names.py:30:16-65: assert_type(str, Literal['BLUE', 'GREEN', 'RED']) failed [assert-type] 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/pyright/dataclasses_order.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | dataclasses_order.py:50:4 - error: Operator "<" not supported for types "DC1" and "DC2" (reportOperatorIssue) 4 | """ 5 | conformance_automated = "Pass" 6 | errors_diff = """ 7 | """ 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*.{py,pyi,rst,md,yml,yaml,toml,json}] 4 | trim_trailing_whitespace = true 5 | insert_final_newline = true 6 | indent_style = space 7 | 8 | [*.{py,pyi,toml,json}] 9 | indent_size = 4 10 | 11 | [*.{yml,yaml}] 12 | indent_size = 2 13 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/dataclasses_match_args.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR dataclasses_match_args.py:42:1-19: Class `DC4` has no class attribute `__match_args__` [missing-attribute] 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/directives_type_ignore_file2.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR directives_type_ignore_file2.py:14:10-12: `Literal['']` is not assignable to `int` [bad-assignment] 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/typeddicts_readonly_kwargs.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR typeddicts_readonly_kwargs.py:33:12-18: Key `key1` in TypedDict `ReadOnlyArgs` is read-only [read-only] 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/zuban/typeddicts_readonly_update.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Incorrectly allows update of ReadOnly item. 4 | """ 5 | conformance_automated = "Fail" 6 | errors_diff = """ 7 | Line 23: Expected 1 errors 8 | """ 9 | output = """ 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/specialtypes_promotions.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR specialtypes_promotions.py:13:5-16: Object of class `float` has no attribute `numerator` [missing-attribute] 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/mypy/typeddicts_readonly_kwargs.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | typeddicts_readonly_kwargs.py:33: error: ReadOnly TypedDict key "key1" TypedDict is mutated [typeddict-readonly-mutated] 4 | """ 5 | conformance_automated = "Pass" 6 | errors_diff = """ 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/zuban/directives_type_ignore_file2.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | directives_type_ignore_file2.py:14: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] 6 | """ 7 | -------------------------------------------------------------------------------- /docs/tutorials/index.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | ********************* 4 | Type System Tutorials 5 | ********************* 6 | 7 | .. 8 | Keep in sync with docs/index.rst. 9 | 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | :caption: Contents: 14 | 15 | external_libraries 16 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/aliases_variance.toml: -------------------------------------------------------------------------------- 1 | conformant = "Unsupported" 2 | conformance_automated = "Fail" 3 | errors_diff = """ 4 | Line 24: Expected 1 errors 5 | Line 28: Expected 1 errors 6 | Line 32: Expected 1 errors 7 | Line 44: Expected 1 errors 8 | """ 9 | output = """ 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/zuban/generics_typevartuple_callable.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | generics_typevartuple_callable.py:26: error: Argument "args" to "Process" has incompatible type "tuple[str, int]"; expected "tuple[int, str]" [arg-type] 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyright/enums_expansion.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | enums_expansion.py:53:21 - error: "assert_type" mismatch: expected "Literal[CustomFlags.FLAG3]" but received "CustomFlags" (reportAssertTypeFailure) 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/mypy/directives_type_ignore_file2.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | directives_type_ignore_file2.py:14: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] 4 | """ 5 | conformance_automated = "Pass" 6 | errors_diff = """ 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/typeddicts_readonly_update.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR typeddicts_readonly_update.py:23:10-14: No matching overload found for function `A.update` called with arguments: (A) [no-matching-overload] 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/pyright/dataclasses_match_args.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | dataclasses_match_args.py:42:5 - error: Cannot access attribute "__match_args__" for class "type[DC4]" 6 |   Attribute "__match_args__" is unknown (reportAttributeAccessIssue) 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/mypy/dataclasses_hash.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not report when dataclass is not compatible with Hashable protocol. 4 | """ 5 | output = """ 6 | """ 7 | conformance_automated = "Fail" 8 | errors_diff = """ 9 | Line 15: Expected 1 errors 10 | Line 32: Expected 1 errors 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/results/pyright/specialtypes_promotions.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | specialtypes_promotions.py:13:7 - error: Cannot access attribute "numerator" for class "float" 4 |   Attribute "numerator" is unknown (reportAttributeAccessIssue) 5 | """ 6 | conformance_automated = "Pass" 7 | errors_diff = """ 8 | """ 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/new-typing-feature.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: New typing feature 3 | about: Suggest a new feature for Python's typing system 4 | title: '' 5 | labels: 'topic: feature' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /conformance/results/pyright/typeddicts_readonly_kwargs.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | typeddicts_readonly_kwargs.py:33:5 - error: Could not assign item in TypedDict 4 |   "key1" is a read-only key in "ReadOnlyArgs" (reportTypedDictNotRequiredAccess) 5 | """ 6 | conformance_automated = "Pass" 7 | errors_diff = """ 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/zuban/dataclasses_hash.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not report when dataclass is not compatible with Hashable protocol. 4 | """ 5 | conformance_automated = "Fail" 6 | errors_diff = """ 7 | Line 15: Expected 1 errors 8 | Line 32: Expected 1 errors 9 | """ 10 | output = """ 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/results/zuban/generics_typevartuple_unpack.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | 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] 6 | """ 7 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/dataclasses_hash.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR dataclasses_hash.py:15:16-22: `DC1` is not assignable to `Hashable` [bad-assignment] 7 | ERROR dataclasses_hash.py:32:16-22: `DC3` is not assignable to `Hashable` [bad-assignment] 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/mypy/generics_typevartuple_callable.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | generics_typevartuple_callable.py:26: error: Argument "target" to "Process" has incompatible type "Callable[[int, str], None]"; expected "Callable[[str, int], None]" [arg-type] 4 | """ 5 | conformance_automated = "Pass" 6 | errors_diff = """ 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/pyright/directives_type_ignore_file2.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | directives_type_ignore_file2.py:14:10 - error: Type "Literal['']" is not assignable to declared type "int" 4 |   "Literal['']" is not assignable to "int" (reportAssignmentType) 5 | """ 6 | conformance_automated = "Pass" 7 | errors_diff = """ 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/mypy/generics_typevartuple_unpack.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | generics_typevartuple_unpack.py:30: error: Argument 1 to "process_batch_channels" has incompatible type "Array[Batch]"; expected "Array[Batch, *tuple[Any, ...], Channels]" [arg-type] 4 | """ 5 | conformance_automated = "Pass" 6 | errors_diff = """ 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/pyright/dataclasses_transform_field.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | dataclasses_transform_field.py:64:16 - error: No parameter named "id" (reportCallIssue) 4 | dataclasses_transform_field.py:75:16 - error: Expected 0 positional arguments (reportCallIssue) 5 | """ 6 | conformance_automated = "Pass" 7 | errors_diff = """ 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/zuban/constructors_call_metaclass.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | constructors_call_metaclass.py:54: error: Missing positional argument "x" in call to "Class3" [call-arg] 6 | constructors_call_metaclass.py:68: error: Missing positional argument "x" in call to "Class4" [call-arg] 7 | """ 8 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # Read the Docs configuration file 2 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 3 | 4 | version: 2 5 | 6 | build: 7 | os: ubuntu-22.04 8 | tools: 9 | python: "3" 10 | 11 | sphinx: 12 | configuration: docs/conf.py 13 | 14 | python: 15 | install: 16 | - requirements: docs/requirements.txt 17 | -------------------------------------------------------------------------------- /conformance/results/zuban/dataclasses_transform_field.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | dataclasses_transform_field.py:64: error: Unexpected keyword argument "id" for "CustomerModel1" [call-arg] 6 | dataclasses_transform_field.py:75: error: Too many positional arguments for "CustomerModel2" [call-arg] 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/pyright/constructors_call_metaclass.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | constructors_call_metaclass.py:54:1 - error: Argument missing for parameter "x" (reportCallIssue) 6 | constructors_call_metaclass.py:68:1 - error: Argument missing for parameter "x" (reportCallIssue) 7 | """ 8 | conformance_automated = "Pass" 9 | -------------------------------------------------------------------------------- /conformance/results/zuban/directives_cast.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | directives_cast.py:15: error: "cast" expects 2 arguments [call-arg] 6 | directives_cast.py:16: error: Invalid type: try using Literal[1] instead? [valid-type] 7 | directives_cast.py:17: error: "cast" expects 2 arguments [call-arg] 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/zuban/generics_syntax_compatibility.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | generics_syntax_compatibility.py:14: error: All type parameters should be declared ("K" not declared) [misc] 6 | generics_syntax_compatibility.py:26: error: All type parameters should be declared ("K" not declared) [misc] 7 | """ 8 | -------------------------------------------------------------------------------- /docs/guides/index.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | ****************** 4 | Type System Guides 5 | ****************** 6 | 7 | .. 8 | Keep in sync with docs/index.rst. 9 | 10 | .. toctree:: 11 | :maxdepth: 1 12 | :caption: Contents: 13 | 14 | libraries 15 | writing_stubs 16 | modernizing 17 | unreachable 18 | type_narrowing 19 | typing_anti_pitch 20 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/directives_version_platform.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR directives_version_platform.py:40:17-19: `Literal['']` is not assignable to `int` [bad-assignment] 7 | ERROR directives_version_platform.py:45:17-19: `Literal['']` is not assignable to `int` [bad-assignment] 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/generics_typevartuple_callable.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | 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] 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/directives_reveal_type.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR directives_reveal_type.py:19:16-18: reveal_type needs 1 positional argument, got 0 [bad-argument-count] 7 | ERROR directives_reveal_type.py:20:16-22: reveal_type needs 1 positional argument, got 2 [bad-argument-count] 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/generics_typevartuple_unpack.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | 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] 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/namedtuples_type_compat.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR namedtuples_type_compat.py:22:23-24: `Point` is not assignable to `tuple[int, int]` [bad-assignment] 7 | ERROR namedtuples_type_compat.py:23:28-29: `Point` is not assignable to `tuple[int, str, str]` [bad-assignment] 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/zuban/generics_defaults_specialization.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | generics_defaults_specialization.py:30: error: Bad number of arguments for type alias, expected between 0 and 1, given 2 [misc] 6 | generics_defaults_specialization.py:55: error: "Foo" expects no type arguments, but 1 given [type-arg] 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/mypy/annotations_methods.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | notes = """ 3 | Type evaluation differs from other type checkers because of ambiguity in the spec related to method bindings. 4 | """ 5 | output = """ 6 | annotations_methods.py:42: error: Expression is of type "B", not "A" [assert-type] 7 | """ 8 | conformance_automated = "Pass" 9 | errors_diff = """ 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/zuban/directives_no_type_check.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | directives_no_type_check.py:15: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] 6 | directives_no_type_check.py:32: error: Missing positional arguments "a", "b" in call to "func1" [call-arg] 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/protocols_variance.toml: -------------------------------------------------------------------------------- 1 | conformant = "Unsupported" 2 | conformance_automated = "Fail" 3 | errors_diff = """ 4 | Line 21: Expected 1 errors 5 | Line 40: Expected 1 errors 6 | Line 56: Expected 1 errors 7 | Line 61: Expected 1 errors 8 | Line 66: Expected 1 errors 9 | Line 71: Expected 1 errors 10 | Line 104: Expected 1 errors 11 | """ 12 | output = """ 13 | """ 14 | -------------------------------------------------------------------------------- /conformance/results/zuban/dataclasses_kwonly.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | dataclasses_kwonly.py:23: error: Too many positional arguments for "DC1" [call-arg] 6 | dataclasses_kwonly.py:38: error: Too many positional arguments for "DC2" [call-arg] 7 | dataclasses_kwonly.py:53: error: Too many positional arguments for "DC3" [call-arg] 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/zuban/overloads_consistency.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | overloads_consistency.py:28: error: Overloaded function implementation cannot produce return type of signature 2 [misc] 6 | overloads_consistency.py:44: error: Overloaded function implementation does not accept all possible arguments of signature 2 [misc] 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/mypy/generics_syntax_compatibility.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | generics_syntax_compatibility.py:14: error: All type parameters should be declared ("K" not declared) [valid-type] 4 | generics_syntax_compatibility.py:26: error: All type parameters should be declared ("K" not declared) [valid-type] 5 | """ 6 | conformance_automated = "Pass" 7 | errors_diff = """ 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/constructors_call_metaclass.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR constructors_call_metaclass.py:54:7-9: Missing argument `x` in function `Class3.__new__` [missing-argument] 7 | ERROR constructors_call_metaclass.py:68:7-9: Missing argument `x` in function `Class4.__new__` [missing-argument] 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/generics_defaults_specialization.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR generics_defaults_specialization.py:30:1-19: Expected 1 type argument for `MyAlias`, got 2 [bad-specialization] 7 | ERROR generics_defaults_specialization.py:55:1-9: Expected 0 type arguments for `Foo`, got 1 [bad-specialization] 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/pyright/constructors_consistency.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | constructors_consistency.py:25:9 - error: Mismatch between signature of __new__ and __init__ in class "Class1" 6 |   Signature of __init__ is "(x: str) -> None" 7 |   Signature of __new__ is "() -> Class1" (reportInconsistentConstructor) 8 | """ 9 | conformance_automated = "Pass" 10 | -------------------------------------------------------------------------------- /docs/reference/index.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | ********************* 4 | Type System Reference 5 | ********************* 6 | 7 | .. 8 | Keep in sync with docs/index.rst. 9 | 10 | .. toctree:: 11 | :maxdepth: 2 12 | :caption: Contents: 13 | 14 | generics 15 | protocols 16 | best_practices 17 | quality 18 | typing Module Documentation 19 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/documentation-issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Documentation issue 3 | about: Report a problem or suggest changes for the documentation at https://typing.python.org/ 4 | title: '' 5 | labels: 'topic: documentation' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /conformance/results/mypy/dataclasses_kwonly.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | dataclasses_kwonly.py:23: error: Too many positional arguments for "DC1" [misc] 4 | dataclasses_kwonly.py:38: error: Too many positional arguments for "DC2" [misc] 5 | dataclasses_kwonly.py:53: error: Too many positional arguments for "DC3" [misc] 6 | """ 7 | conformance_automated = "Pass" 8 | errors_diff = """ 9 | """ 10 | -------------------------------------------------------------------------------- /conformance/results/mypy/overloads_consistency.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | overloads_consistency.py:28: error: Overloaded function implementation cannot produce return type of signature 2 [misc] 7 | overloads_consistency.py:44: error: Overloaded function implementation does not accept all possible arguments of signature 2 [misc] 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/zuban/enums_behaviors.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | enums_behaviors.py:28: error: Expression is of type "Color", not "Literal[Color.RED]" [misc] 6 | enums_behaviors.py:32: error: Expression is of type "Color", not "Literal[Color.BLUE]" [misc] 7 | enums_behaviors.py:44: error: Cannot extend enum with existing members: "Shape" [misc] 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/enums_behaviors.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | ERROR enums_behaviors.py:27:12-33: assert_type(Literal[Color.RED], Color) failed [assert-type] 6 | ERROR enums_behaviors.py:32:12-43: assert_type(Color, Literal[Color.BLUE]) failed [assert-type] 7 | ERROR enums_behaviors.py:44:21-26: Cannot extend final class `Shape` [invalid-inheritance] 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/zuban/dataclasses_inheritance.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | dataclasses_inheritance.py:62: error: Cannot override instance variable (previously declared on base class "DC6") with class variable [misc] 6 | dataclasses_inheritance.py:66: error: Cannot override class variable (previously declared on base class "DC6") with instance variable [misc] 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/zuban/typeddicts_inheritance.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | typeddicts_inheritance.py:44: error: All bases of a new TypedDict must be TypedDict types [misc] 6 | typeddicts_inheritance.py:55: error: Overwriting TypedDict field "x" while extending [misc] 7 | typeddicts_inheritance.py:65: error: Overwriting TypedDict field "x" while merging [misc] 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/pyright/dataclasses_kwonly.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | dataclasses_kwonly.py:23:11 - error: Expected 1 positional argument (reportCallIssue) 4 | dataclasses_kwonly.py:38:11 - error: Expected 1 positional argument (reportCallIssue) 5 | dataclasses_kwonly.py:53:11 - error: Expected 1 positional argument (reportCallIssue) 6 | """ 7 | conformance_automated = "Pass" 8 | errors_diff = """ 9 | """ 10 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | # Requirements to build the Python documentation 2 | 3 | # Sphinx version is pinned so that new versions that introduce new warnings 4 | # won't suddenly cause build failures. Updating the version is fine as long 5 | # as no warnings are raised by doing so. 6 | sphinx==7.2.6 7 | 8 | # The theme used by the documentation is stored separately, so we need 9 | # to install that as well. 10 | python-docs-theme 11 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/dataclasses_inheritance.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR dataclasses_inheritance.py:62:5-6: ClassVar `DC7.x` overrides instance variable of the same name in parent class `DC6` [bad-override] 7 | ERROR dataclasses_inheritance.py:66:5-6: Instance variable `DC7.y` overrides ClassVar of the same name in parent class `DC6` [bad-override] 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/mypy/dataclasses_inheritance.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | dataclasses_inheritance.py:62: error: Cannot override instance variable (previously declared on base class "DC6") with class variable [misc] 4 | dataclasses_inheritance.py:66: error: Cannot override class variable (previously declared on base class "DC6") with instance variable [misc] 5 | """ 6 | conformance_automated = "Pass" 7 | errors_diff = """ 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/zuban/generics_self_basic.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | generics_self_basic.py:20: error: Incompatible return value type (got "Shape", expected "Self") [return-value] 6 | generics_self_basic.py:33: error: Incompatible return value type (got "Shape", expected "Self") [return-value] 7 | generics_self_basic.py:68: error: Self type cannot have type arguments [valid-type] 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/zuban/namedtuples_type_compat.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | namedtuples_type_compat.py:22: error: Incompatible types in assignment (expression has type "Point", variable has type "tuple[int, int]") [assignment] 6 | namedtuples_type_compat.py:23: error: Incompatible types in assignment (expression has type "Point", variable has type "tuple[int, str, str]") [assignment] 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/mypy/specialtypes_any.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | specialtypes_any.py:37: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] 4 | specialtypes_any.py:38: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] 5 | """ 6 | conformance_automated = "Pass" 7 | errors_diff = """ 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/mypy/enums_behaviors.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | enums_behaviors.py:28: error: Expression is of type "Color", not "Literal[Color.RED]" [assert-type] 6 | enums_behaviors.py:32: error: Expression is of type "Color", not "Literal[Color.BLUE]" [assert-type] 7 | enums_behaviors.py:44: error: Cannot extend enum with existing members: "Shape" [misc] 8 | """ 9 | conformance_automated = "Pass" 10 | -------------------------------------------------------------------------------- /conformance/results/mypy/typeddicts_inheritance.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | typeddicts_inheritance.py:44: error: All bases of a new TypedDict must be TypedDict types [misc] 4 | typeddicts_inheritance.py:55: error: Overwriting TypedDict field "x" while extending [misc] 5 | typeddicts_inheritance.py:65: error: Overwriting TypedDict field "x" while merging [misc] 6 | """ 7 | conformance_automated = "Pass" 8 | errors_diff = """ 9 | """ 10 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/generics_self_basic.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Return annotation of Self allows returning the concrete instance of the current class. 4 | """ 5 | conformance_automated = "Fail" 6 | errors_diff = """ 7 | Line 20: Expected 1 errors 8 | Line 33: Expected 1 errors 9 | """ 10 | output = """ 11 | ERROR generics_self_basic.py:68:26-35: `type[Self@Container]` is not subscriptable [unsupported-operation] 12 | """ 13 | -------------------------------------------------------------------------------- /conformance/tests/_enums_member_values.pyi: -------------------------------------------------------------------------------- 1 | """ 2 | Support stub file for enums_member_values test. 3 | """ 4 | 5 | from enum import Enum 6 | 7 | # > If the literal values for enum members are not supplied, as they sometimes 8 | # > are not within a type stub file, a type checker can use the type of the 9 | # > _value_ attribute. 10 | 11 | class ColumnType(Enum): 12 | _value_: int 13 | DORIC = ... 14 | IONIC = ... 15 | CORINTHIAN = ... 16 | -------------------------------------------------------------------------------- /conformance/tests/_enums_members.pyi: -------------------------------------------------------------------------------- 1 | """ 2 | Support stub file for enums_members test. 3 | """ 4 | 5 | from enum import Enum 6 | 7 | # > Within a type stub, members can be defined using the actual runtime values, 8 | # > or a placeholder of ... can be used 9 | 10 | class Pet2(Enum): 11 | genus: str # Non-member attribute 12 | species: str # Non-member attribute 13 | 14 | CAT = ... # Member attribute 15 | DOG = ... # Member attribute 16 | -------------------------------------------------------------------------------- /conformance/tests/specialtypes_promotions.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests "type promotions" for float and complex when they appear in annotations. 3 | """ 4 | 5 | # Specification: https://typing.readthedocs.io/en/latest/spec/special-types.html#special-cases-for-float-and-complex 6 | 7 | v1: float = 1 8 | v2: complex = 1.2 9 | v2 = 1 10 | 11 | 12 | def func1(f: float): 13 | f.numerator # E 14 | 15 | if not isinstance(f, float): 16 | f.numerator # OK 17 | -------------------------------------------------------------------------------- /conformance/results/pyright/generics_defaults_specialization.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | generics_defaults_specialization.py:30:15 - error: Too many type arguments provided for "MyAlias[DefaultStrT@MyAlias]"; expected 1 but received 2 (reportInvalidTypeForm) 4 | generics_defaults_specialization.py:55:5 - error: Expected no type arguments for class "Foo" (reportInvalidTypeArguments) 5 | """ 6 | conformance_automated = "Pass" 7 | errors_diff = """ 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/mypy/generics_self_basic.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | generics_self_basic.py:20: error: Incompatible return value type (got "Shape", expected "Self") [return-value] 4 | generics_self_basic.py:33: error: Incompatible return value type (got "Shape", expected "Self") [return-value] 5 | generics_self_basic.py:68: error: Self type cannot have type arguments [misc] 6 | """ 7 | conformance_automated = "Pass" 8 | errors_diff = """ 9 | """ 10 | -------------------------------------------------------------------------------- /conformance/results/mypy/namedtuples_type_compat.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | namedtuples_type_compat.py:22: error: Incompatible types in assignment (expression has type "Point", variable has type "tuple[int, int]") [assignment] 4 | namedtuples_type_compat.py:23: error: Incompatible types in assignment (expression has type "Point", variable has type "tuple[int, str, str]") [assignment] 5 | """ 6 | conformance_automated = "Pass" 7 | errors_diff = """ 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/dataclasses_transform_field.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR dataclasses_transform_field.py:64:16-18: Unexpected keyword argument `id` in function `CustomerModel1.__init__` [unexpected-keyword] 7 | ERROR dataclasses_transform_field.py:75:16-17: Expected argument `name` to be passed by name in function `CustomerModel2.__init__` [unexpected-positional-argument] 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/pyright/dataclasses_inheritance.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | dataclasses_inheritance.py:62:5 - error: Class variable "x" overrides instance variable of same name in class "DC6" (reportIncompatibleVariableOverride) 4 | dataclasses_inheritance.py:66:5 - error: Instance variable "y" overrides class variable of same name in class "DC6" (reportIncompatibleVariableOverride) 5 | """ 6 | conformance_automated = "Pass" 7 | errors_diff = """ 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/zuban/generics_self_attributes.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | generics_self_attributes.py:26: error: Argument "next" to "OrdinalLinkedList" has incompatible type "LinkedList[int]"; expected "OrdinalLinkedList | None" [arg-type] 6 | generics_self_attributes.py:32: error: Incompatible types in assignment (expression has type "LinkedList[int]", variable has type "OrdinalLinkedList | None") [assignment] 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/pyright/generics_typevartuple_callable.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | 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__" 4 |   "Literal['']" is not assignable to "int" 5 |   "Literal[0]" is not assignable to "str" (reportArgumentType) 6 | """ 7 | conformance_automated = "Pass" 8 | errors_diff = """ 9 | """ 10 | -------------------------------------------------------------------------------- /conformance/results/zuban/overloads_basic.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | overloads_basic.py:39: error: No overload variant of "__getitem__" of "Bytes" matches argument type "str" [call-overload] 6 | overloads_basic.py:39: note: Possible overload variants: 7 | overloads_basic.py:39: note: def __getitem__(self, int, /) -> int 8 | overloads_basic.py:39: note: def __getitem__(self, slice[Any, Any, Any], /) -> bytes 9 | """ 10 | -------------------------------------------------------------------------------- /conformance/results/mypy/directives_no_type_check.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not honor `@no_type_check` class decorator (allowed). 4 | Does not reject invalid call of `@no_type_check` function. 5 | """ 6 | output = """ 7 | directives_no_type_check.py:15: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] 8 | """ 9 | conformance_automated = "Fail" 10 | errors_diff = """ 11 | Line 32: Expected 1 errors 12 | """ 13 | -------------------------------------------------------------------------------- /conformance/results/pyright/annotations_methods.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | notes = """ 3 | Type evaluation differs from other type checkers because of ambiguity in the spec related to method bindings. 4 | """ 5 | output = """ 6 | annotations_methods.py:46:8 - error: Argument of type "A" cannot be assigned to parameter "self" of type "B" in function "copy" 7 |   "A" is not assignable to "B" (reportArgumentType) 8 | """ 9 | conformance_automated = "Pass" 10 | errors_diff = """ 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/results/mypy/generics_self_attributes.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | generics_self_attributes.py:26: error: Argument "next" to "OrdinalLinkedList" has incompatible type "LinkedList[int]"; expected "OrdinalLinkedList | None" [arg-type] 4 | generics_self_attributes.py:32: error: Incompatible types in assignment (expression has type "LinkedList[int]", variable has type "OrdinalLinkedList | None") [assignment] 5 | """ 6 | conformance_automated = "Pass" 7 | errors_diff = """ 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/generics_self_attributes.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | 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] 6 | ERROR generics_self_attributes.py:32:15-50: `LinkedList[int]` is not assignable to attribute `next` with type `OrdinalLinkedList | None` [bad-assignment] 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/overloads_consistency.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR overloads_consistency.py:25:5-16: Overload return type `str` is not assignable to implementation return type `int` [inconsistent-overload] 7 | 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] 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/tests/directives_type_checking.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests the typing.TYPE_CHECKING constant. 3 | """ 4 | 5 | # Specification: https://typing.readthedocs.io/en/latest/spec/directives.html#type-checking 6 | 7 | from typing import TYPE_CHECKING, assert_type 8 | 9 | 10 | if not TYPE_CHECKING: 11 | a: int = "" # This should not generate an error 12 | 13 | if TYPE_CHECKING: 14 | b: list[int] = [1, 2, 3] 15 | else: 16 | b: list[str] = ["a", "b", "c"] 17 | 18 | assert_type(b, list[int]) 19 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/generics_self_protocols.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | 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] 6 | 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] 7 | """ 8 | -------------------------------------------------------------------------------- /conformance/results/mypy/enums_member_names.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | notes = """ 3 | Does not support special-cased handling of member name literal types in some cases (optional). 4 | """ 5 | conformance_automated = "Pass" 6 | errors_diff = """ 7 | """ 8 | output = """ 9 | enums_member_names.py:26: error: Expression is of type "str", not "Literal['RED', 'BLUE']" [assert-type] 10 | enums_member_names.py:30: error: Expression is of type "str", not "Literal['RED', 'BLUE', 'GREEN']" [assert-type] 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/results/mypy/overloads_basic.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | overloads_basic.py:39: error: No overload variant of "__getitem__" of "Bytes" matches argument type "str" [call-overload] 4 | overloads_basic.py:39: note: Possible overload variants: 5 | overloads_basic.py:39: note: def __getitem__(self, int, /) -> int 6 | overloads_basic.py:39: note: def __getitem__(self, slice[Any, Any, Any], /) -> bytes 7 | """ 8 | conformance_automated = "Pass" 9 | errors_diff = """ 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/constructors_call_new.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | 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] 7 | 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] 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/zuban/specialtypes_none.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | specialtypes_none.py:21: error: Argument 1 to "func1" has incompatible type "type[None]"; expected "None" [arg-type] 6 | specialtypes_none.py:27: error: Incompatible types in assignment (expression has type "None", variable has type "Iterable[Any]") [assignment] 7 | specialtypes_none.py:41: error: Argument 1 to "func2" has incompatible type "None"; expected "type[None]" [arg-type] 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/results/zuban/typeddicts_required.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | typeddicts_required.py:12: error: Required[] can be only used in a TypedDict definition [valid-type] 6 | typeddicts_required.py:16: error: NotRequired[] can be only used in a TypedDict definition [valid-type] 7 | typeddicts_required.py:59: error: "Required[]" type cannot be nested [misc] 8 | typeddicts_required.py:60: error: "NotRequired[]" type cannot be nested [misc] 9 | """ 10 | -------------------------------------------------------------------------------- /conformance/results/zuban/dataclasses_frozen.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | dataclasses_frozen.py:16: error: Property "a" defined in "DC1" is read-only [misc] 6 | dataclasses_frozen.py:17: error: Property "b" defined in "DC1" is read-only [misc] 7 | dataclasses_frozen.py:23: error: Non-frozen dataclass cannot inherit from a frozen dataclass [misc] 8 | dataclasses_frozen.py:33: error: Frozen dataclass cannot inherit from a non-frozen dataclass [misc] 9 | """ 10 | -------------------------------------------------------------------------------- /conformance/results/zuban/enums_expansion.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Improperly applies narrowing to Flag subclass. 4 | """ 5 | conformance_automated = "Fail" 6 | errors_diff = """ 7 | Line 53: Expected 1 errors 8 | Line 52: Unexpected errors ['enums_expansion.py:52: error: Expression is of type "Literal[CustomFlags.FLAG3]", not "CustomFlags" [misc]'] 9 | """ 10 | output = """ 11 | enums_expansion.py:52: error: Expression is of type "Literal[CustomFlags.FLAG3]", not "CustomFlags" [misc] 12 | """ 13 | -------------------------------------------------------------------------------- /conformance/results/mypy/enums_expansion.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Improperly applies narrowing to Flag subclass. 4 | """ 5 | conformance_automated = "Fail" 6 | errors_diff = """ 7 | Line 53: Expected 1 errors 8 | Line 52: Unexpected errors ['enums_expansion.py:52: error: Expression is of type "Literal[CustomFlags.FLAG3]", not "CustomFlags" [assert-type]'] 9 | """ 10 | output = """ 11 | enums_expansion.py:52: error: Expression is of type "Literal[CustomFlags.FLAG3]", not "CustomFlags" [assert-type] 12 | """ 13 | -------------------------------------------------------------------------------- /conformance/results/pyright/directives_no_type_check.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | notes = """ 3 | Does not honor `@no_type_check` class decorator (allowed). 4 | """ 5 | output = """ 6 | directives_no_type_check.py:15:14 - error: Type "Literal['']" is not assignable to declared type "int" 7 |   "Literal['']" is not assignable to "int" (reportAssignmentType) 8 | directives_no_type_check.py:32:1 - error: Arguments missing for parameters "a", "b" (reportCallIssue) 9 | """ 10 | conformance_automated = "Pass" 11 | errors_diff = """ 12 | """ 13 | -------------------------------------------------------------------------------- /conformance/results/mypy/dataclasses_frozen.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | dataclasses_frozen.py:16: error: Property "a" defined in "DC1" is read-only [misc] 4 | dataclasses_frozen.py:17: error: Property "b" defined in "DC1" is read-only [misc] 5 | dataclasses_frozen.py:23: error: Non-frozen dataclass cannot inherit from a frozen dataclass [misc] 6 | dataclasses_frozen.py:33: error: Frozen dataclass cannot inherit from a non-frozen dataclass [misc] 7 | """ 8 | conformance_automated = "Pass" 9 | errors_diff = """ 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/mypy/specialtypes_none.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | specialtypes_none.py:21: error: Argument 1 to "func1" has incompatible type "type[None]"; expected "None" [arg-type] 4 | specialtypes_none.py:27: error: Incompatible types in assignment (expression has type "None", variable has type "Iterable[Any]") [assignment] 5 | specialtypes_none.py:41: error: Argument 1 to "func2" has incompatible type "None"; expected "type[None]" [arg-type] 6 | """ 7 | conformance_automated = "Pass" 8 | errors_diff = """ 9 | """ 10 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/dataclasses_kwonly.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR dataclasses_kwonly.py:23:11-12: Expected 1 positional argument, got 2 in function `DC1.__init__` [bad-argument-count] 7 | ERROR dataclasses_kwonly.py:38:11-12: Expected 1 positional argument, got 2 in function `DC2.__init__` [bad-argument-count] 8 | ERROR dataclasses_kwonly.py:53:11-12: Expected 1 positional argument, got 2 in function `DC3.__init__` [bad-argument-count] 9 | """ 10 | -------------------------------------------------------------------------------- /conformance/results/pyright/overloads_basic.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | notes = """ 3 | """ 4 | output = """ 5 | overloads_basic.py:39:1 - error: No overloads for "__getitem__" match the provided arguments (reportCallIssue) 6 | 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__" 7 |   "Literal['']" is not assignable to "slice[Any, Any, Any]" (reportArgumentType) 8 | """ 9 | conformance_automated = "Pass" 10 | errors_diff = """ 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/results/pyright/typeddicts_readonly_update.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | typeddicts_readonly_update.py:23:1 - error: No overloads for "update" match the provided arguments (reportCallIssue) 4 | typeddicts_readonly_update.py:23:11 - error: Argument of type "A" cannot be assigned to parameter "__m" of type "Partial[A]" in function "update" 5 |   "x" is an incompatible type 6 |     Type "int" is not assignable to type "Never" (reportArgumentType) 7 | """ 8 | conformance_automated = "Pass" 9 | errors_diff = """ 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/mypy/typeddicts_required.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | typeddicts_required.py:12: error: Required[] can be only used in a TypedDict definition [valid-type] 4 | typeddicts_required.py:16: error: NotRequired[] can be only used in a TypedDict definition [valid-type] 5 | typeddicts_required.py:59: error: "Required[]" type cannot be nested [valid-type] 6 | typeddicts_required.py:60: error: "NotRequired[]" type cannot be nested [valid-type] 7 | """ 8 | conformance_automated = "Pass" 9 | errors_diff = """ 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/pyright/enums_behaviors.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | enums_behaviors.py:28:13 - error: "assert_type" mismatch: expected "Literal[Color.RED]" but received "Color" (reportAssertTypeFailure) 6 | enums_behaviors.py:32:13 - error: "assert_type" mismatch: expected "Literal[Color.BLUE]" but received "Color" (reportAssertTypeFailure) 7 | enums_behaviors.py:44:21 - error: Enum class "Shape" is final and cannot be subclassed (reportGeneralTypeIssues) 8 | """ 9 | conformance_automated = "Pass" 10 | -------------------------------------------------------------------------------- /conformance/results/pyright/directives_cast.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | directives_cast.py:15:8 - error: No overloads for "cast" match the provided arguments 4 |   Argument types: () (reportCallIssue) 5 | directives_cast.py:16:13 - error: Expected class but received "Literal[1]" (reportGeneralTypeIssues) 6 | directives_cast.py:17:8 - error: No overloads for "cast" match the provided arguments 7 |   Argument types: (type[int], Literal[''], Literal['']) (reportCallIssue) 8 | """ 9 | conformance_automated = "Pass" 10 | errors_diff = """ 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/dataclasses_frozen.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR dataclasses_frozen.py:16:1-6: Cannot set field `a` [read-only] 7 | ERROR dataclasses_frozen.py:17:1-6: Cannot set field `b` [read-only] 8 | ERROR dataclasses_frozen.py:23:7-10: Cannot inherit non-frozen dataclass `DC2` from frozen dataclass `DC1` [invalid-inheritance] 9 | ERROR dataclasses_frozen.py:33:7-10: Cannot inherit frozen dataclass `DC4` from non-frozen dataclass `DC3` [invalid-inheritance] 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/zuban/tuples_unpacked.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | tuples_unpacked.py:40: error: More than one Unpack in a type is not allowed [misc] 6 | tuples_unpacked.py:41: error: More than one Unpack in a type is not allowed [misc] 7 | tuples_unpacked.py:51: error: More than one Unpack in a type is not allowed [misc] 8 | tuples_unpacked.py:59: error: More than one Unpack in a type is not allowed [misc] 9 | tuples_unpacked.py:61: error: More than one Unpack in a type is not allowed [misc] 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/dataclasses_final.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | ERROR dataclasses_final.py:27:1-17: Cannot set field `final_classvar` [read-only] 6 | ERROR dataclasses_final.py:35:1-19: Cannot set field `final_no_default` [read-only] 7 | ERROR dataclasses_final.py:36:1-21: Cannot set field `final_with_default` [read-only] 8 | ERROR dataclasses_final.py:37:1-19: Cannot set field `final_no_default` [read-only] 9 | ERROR dataclasses_final.py:38:1-21: Cannot set field `final_with_default` [read-only] 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/directives_cast.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR directives_cast.py:15:12-14: `typing.cast` missing required argument `typ` [missing-argument] 7 | ERROR directives_cast.py:15:12-14: `typing.cast` missing required argument `val` [missing-argument] 8 | ERROR directives_cast.py:16:12-19: First argument to `typing.cast` must be a type [bad-argument-type] 9 | ERROR directives_cast.py:17:12-25: `typing.cast` expected 2 arguments, got 3 [bad-argument-count] 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/specialtypes_none.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | 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] 7 | ERROR specialtypes_none.py:27:19-23: `None` is not assignable to `Iterable[Unknown]` [bad-assignment] 8 | 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] 9 | """ 10 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/generics_syntax_compatibility.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR generics_syntax_compatibility.py:14:7-13: Class `ClassA` uses type variables not specified in `Generic` or `Protocol` base [invalid-type-var] 7 | ERROR generics_syntax_compatibility.py:14:22-23: Type parameter K is not included in the type parameter list [invalid-type-var] 8 | ERROR generics_syntax_compatibility.py:26:35-36: Type parameter K is not included in the type parameter list [invalid-type-var] 9 | """ 10 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/typeddicts_inheritance.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | ERROR typeddicts_inheritance.py:44:7-19: `NonTypedDict` is not a typed dictionary. Typed dictionary definitions may only extend other typed dictionaries. [invalid-inheritance] 6 | ERROR typeddicts_inheritance.py:55:4-5: Class member `Y1.x` overrides parent class `X1` in an inconsistent manner [bad-override] 7 | ERROR typeddicts_inheritance.py:65:7-11: Field `x` has inconsistent types inherited from multiple base classes [inconsistent-inheritance] 8 | """ 9 | -------------------------------------------------------------------------------- /conformance/tests/directives_cast.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests the typing.cast call. 3 | """ 4 | 5 | # Specification: https://typing.readthedocs.io/en/latest/spec/directives.html#cast 6 | 7 | from typing import cast 8 | 9 | def find_first_str(a: list[object]) -> str: 10 | index = next(i for i, x in enumerate(a) if isinstance(x, str)) 11 | return cast(str, a[index]) 12 | 13 | x: int = cast(int, "not an int") # No type error 14 | 15 | bad1 = cast() # E: Too few arguments 16 | bad2 = cast(1, "") # E: Bad first argument type 17 | bad3 = cast(int, "", "") # E: Too many arguments 18 | -------------------------------------------------------------------------------- /conformance/results/pyright/typeddicts_required.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | typeddicts_required.py:12:8 - error: "Required" is not allowed in this context (reportInvalidTypeForm) 4 | typeddicts_required.py:16:8 - error: "NotRequired" is not allowed in this context (reportInvalidTypeForm) 5 | typeddicts_required.py:59:8 - error: "Required" is not allowed in this context (reportInvalidTypeForm) 6 | typeddicts_required.py:60:8 - error: "Required" is not allowed in this context (reportInvalidTypeForm) 7 | """ 8 | conformance_automated = "Pass" 9 | errors_diff = """ 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/zuban/generics_upper_bound.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not reject use of type variable within an upper bound. 4 | """ 5 | conformance_automated = "Fail" 6 | errors_diff = """ 7 | Line 24: Expected 1 errors 8 | """ 9 | output = """ 10 | generics_upper_bound.py:51: error: Value of type variable "ST" of "longer" cannot be "int" [type-var] 11 | generics_upper_bound.py:51: error: Value of type variable "ST" of "longer" cannot be "int" [type-var] 12 | generics_upper_bound.py:56: error: TypeVar cannot have both values and an upper bound [misc] 13 | """ 14 | -------------------------------------------------------------------------------- /conformance/results/zuban/aliases_variance.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | aliases_variance.py:24: error: Variance of TypeVar "T_co" incompatible with variance in parent type [type-var] 6 | aliases_variance.py:28: error: Variance of TypeVar "T_co" incompatible with variance in parent type [type-var] 7 | aliases_variance.py:32: error: Variance of TypeVar "T_co" incompatible with variance in parent type [type-var] 8 | aliases_variance.py:44: error: Variance of TypeVar "T_contra" incompatible with variance in parent type [type-var] 9 | """ 10 | -------------------------------------------------------------------------------- /conformance/results/mypy/generics_upper_bound.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not reject use of type variable within an upper bound. 4 | """ 5 | output = """ 6 | generics_upper_bound.py:43: error: Expression is of type "Collection[int]", not "list[int] | set[int]" [assert-type] 7 | generics_upper_bound.py:51: error: Value of type variable "ST" of "longer" cannot be "int" [type-var] 8 | generics_upper_bound.py:56: error: TypeVar cannot have both values and an upper bound [misc] 9 | """ 10 | conformance_automated = "Fail" 11 | errors_diff = """ 12 | Line 24: Expected 1 errors 13 | """ 14 | -------------------------------------------------------------------------------- /conformance/results/mypy/tuples_unpacked.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | "More than one unpack" error is missing in some cases. 4 | """ 5 | output = """ 6 | tuples_unpacked.py:40: error: More than one variadic Unpack in a type is not allowed [misc] 7 | tuples_unpacked.py:51: error: More than one variadic Unpack in a type is not allowed [misc] 8 | tuples_unpacked.py:59: error: More than one variadic Unpack in a type is not allowed [misc] 9 | """ 10 | conformance_automated = "Fail" 11 | errors_diff = """ 12 | Line 41: Expected 1 errors 13 | Lines 60, 61: Expected error (tag 't14') 14 | """ 15 | -------------------------------------------------------------------------------- /conformance/results/mypy/dataclasses_slots.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not reject write to instance variable that is not defined in __slots__. 4 | """ 5 | output = """ 6 | dataclasses_slots.py:11: error: "DC1" both defines "__slots__" and is used with "slots=True" [misc] 7 | dataclasses_slots.py:66: error: "type[DC6]" has no attribute "__slots__" [attr-defined] 8 | dataclasses_slots.py:69: error: "DC6" has no attribute "__slots__" [attr-defined] 9 | """ 10 | conformance_automated = "Fail" 11 | errors_diff = """ 12 | Line 25: Expected 1 errors 13 | Line 38: Expected 1 errors 14 | """ 15 | -------------------------------------------------------------------------------- /conformance/results/pyright/generics_typevartuple_unpack.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | 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" 4 |   "Array[Batch]" is not assignable to "Array[Batch, *tuple[Any, ...], Channels]" 5 |     Type parameter "Ts@Array" is invariant, but "*tuple[Batch]" is not the same as "*tuple[Batch, *tuple[Any, ...], Channels]" (reportArgumentType) 6 | """ 7 | conformance_automated = "Pass" 8 | errors_diff = """ 9 | """ 10 | -------------------------------------------------------------------------------- /conformance/results/mypy/aliases_variance.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | aliases_variance.py:24: error: Variance of TypeVar "T_co" incompatible with variance in parent type [type-var] 4 | aliases_variance.py:28: error: Variance of TypeVar "T_co" incompatible with variance in parent type [type-var] 5 | aliases_variance.py:32: error: Variance of TypeVar "T_co" incompatible with variance in parent type [type-var] 6 | aliases_variance.py:44: error: Variance of TypeVar "T_contra" incompatible with variance in parent type [type-var] 7 | """ 8 | conformance_automated = "Pass" 9 | errors_diff = """ 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/exceptions_context_managers.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Some error suppressing context managers are not detected 4 | """ 5 | conformance_automated = "Fail" 6 | errors_diff = """ 7 | Line 50: Unexpected errors ['assert_type(str, int | str) failed [assert-type]'] 8 | Line 57: Unexpected errors ['assert_type(str, int | str) failed [assert-type]'] 9 | """ 10 | output = """ 11 | ERROR exceptions_context_managers.py:50:16-30: assert_type(str, int | str) failed [assert-type] 12 | ERROR exceptions_context_managers.py:57:16-30: assert_type(str, int | str) failed [assert-type] 13 | """ 14 | -------------------------------------------------------------------------------- /conformance/results/pyright/generics_syntax_compatibility.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | generics_syntax_compatibility.py:14:22 - error: Type parameter "K" is not included in the type parameter list for "ClassA" (reportGeneralTypeIssues) 4 | generics_syntax_compatibility.py:26:35 - error: Type parameter "K" is not included in the type parameter list for "method2" (reportGeneralTypeIssues) 5 | generics_syntax_compatibility.py:26:45 - error: Type parameter "K" is not included in the type parameter list for "method2" (reportGeneralTypeIssues) 6 | """ 7 | conformance_automated = "Pass" 8 | errors_diff = """ 9 | """ 10 | -------------------------------------------------------------------------------- /docs/spec/index.rst: -------------------------------------------------------------------------------- 1 | Specification for the Python type system 2 | ======================================== 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | :caption: Contents: 7 | 8 | type-system 9 | meta 10 | concepts 11 | annotations 12 | special-types 13 | generics 14 | qualifiers 15 | class-compat 16 | aliases 17 | literal 18 | protocol 19 | callables 20 | constructors 21 | overload 22 | exceptions 23 | dataclasses 24 | typeddict 25 | tuples 26 | namedtuples 27 | enums 28 | narrowing 29 | directives 30 | distributing 31 | historical 32 | glossary 33 | -------------------------------------------------------------------------------- /conformance/results/pyright/generics_self_basic.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | generics_self_basic.py:20:16 - error: Type "Shape" is not assignable to return type "Self@Shape" 4 |   Type "Shape" is not assignable to type "Self@Shape" (reportReturnType) 5 | generics_self_basic.py:33:16 - error: Type "Shape" is not assignable to return type "Self@Shape" 6 |   Type "Shape" is not assignable to type "Self@Shape" (reportReturnType) 7 | generics_self_basic.py:68:31 - error: Expected no type arguments for class "Self" (reportInvalidTypeArguments) 8 | """ 9 | conformance_automated = "Pass" 10 | errors_diff = """ 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/tests/directives_type_ignore_file1.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # type: ignore 4 | 5 | """ 6 | Tests a file-level type ignore comment. 7 | """ 8 | 9 | # Specification: https://typing.readthedocs.io/en/latest/spec/directives.html#type-ignore-comments 10 | 11 | # > A # type: ignore comment on a line by itself at the top of a file, before any 12 | # > docstrings, imports, or other executable code, silences all errors in the file. 13 | # > Blank lines and other comments, such as shebang lines and coding cookies, may 14 | # > precede the # type: ignore comment. 15 | 16 | x: int = "" # No error should be reported 17 | -------------------------------------------------------------------------------- /conformance/tests/directives_type_ignore_file2.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests a file-level type ignore comment. 3 | """ 4 | 5 | # Specification: https://typing.readthedocs.io/en/latest/spec/directives.html#type-ignore-comments 6 | 7 | # type: ignore 8 | 9 | # > A # type: ignore comment on a line by itself at the top of a file, before any 10 | # > docstrings, imports, or other executable code, silences all errors in the file. 11 | # > Blank lines and other comments, such as shebang lines and coding cookies, may 12 | # > precede the # type: ignore comment. 13 | 14 | x: int = "" # E: should still error because comment is not at top of file. 15 | -------------------------------------------------------------------------------- /.github/workflows/build-docs.yml: -------------------------------------------------------------------------------- 1 | name: Build the documentation 2 | 3 | on: 4 | pull_request: 5 | 6 | permissions: 7 | contents: read 8 | 9 | jobs: 10 | build: 11 | 12 | name: Build documentation 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v6 17 | - name: Set up Python 18 | uses: actions/setup-python@v6 19 | with: 20 | python-version: 3.9 21 | - name: Install dependencies 22 | run: | 23 | pip install --upgrade pip 24 | pip install -r docs/requirements.txt 25 | - name: Build the documentation 26 | run: make -C docs html 27 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/literals_semantics.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR literals_semantics.py:10:18-19: `Literal[4]` is not assignable to `Literal[3]` [bad-assignment] 7 | ERROR literals_semantics.py:24:26-27: `Literal[0]` is not assignable to `Literal[False]` [bad-assignment] 8 | ERROR literals_semantics.py:25:22-23: `Literal[False]` is not assignable to `Literal[0]` [bad-assignment] 9 | ERROR literals_semantics.py:33:5-11: Augmented assignment produces a value of type `int`, which is not assignable to `Literal[3, 4, 5]` [bad-assignment] 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/dataclasses_slots.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | __slots__ is generated but not checked during attribute assignment 4 | """ 5 | conformance_automated = "Fail" 6 | errors_diff = """ 7 | Line 25: Expected 1 errors 8 | Line 38: Expected 1 errors 9 | """ 10 | output = """ 11 | ERROR dataclasses_slots.py:11:7-10: Cannot specify both `slots=True` and `__slots__` [bad-class-definition] 12 | ERROR dataclasses_slots.py:66:1-14: Class `DC6` has no class attribute `__slots__` [missing-attribute] 13 | ERROR dataclasses_slots.py:69:1-17: Object of class `DC6` has no attribute `__slots__` [missing-attribute] 14 | """ 15 | -------------------------------------------------------------------------------- /conformance/results/pyright/historical_positional.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | historical_positional.py:18:8 - error: Expected 1 more positional argument (reportCallIssue) 4 | historical_positional.py:26:16 - error: Position-only parameter not allowed after parameter that is not position-only (reportGeneralTypeIssues) 5 | historical_positional.py:38:26 - error: Position-only parameter not allowed after parameter that is not position-only (reportGeneralTypeIssues) 6 | historical_positional.py:43:10 - error: Expected 1 more positional argument (reportCallIssue) 7 | """ 8 | conformance_automated = "Pass" 9 | errors_diff = """ 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/zuban/directives_reveal_type.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | directives_reveal_type.py:14: note: Revealed type is "builtins.int | builtins.str" 6 | directives_reveal_type.py:15: note: Revealed type is "builtins.list[builtins.int]" 7 | directives_reveal_type.py:16: note: Revealed type is "Any" 8 | directives_reveal_type.py:17: note: Revealed type is "directives_reveal_type.ForwardReference" 9 | directives_reveal_type.py:19: error: Too few arguments for "reveal_type" [call-arg] 10 | directives_reveal_type.py:20: error: Too many arguments for "reveal_type" [call-arg] 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # Environments 30 | .env 31 | .venv 32 | 33 | # Tools 34 | .mypy_cache 35 | .coverage 36 | htmlcov 37 | 38 | # General 39 | .DS_Store 40 | 41 | # Editor temp files 42 | .*.swp 43 | 44 | # Workspace configurations 45 | .vscode 46 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/generics_self_usage.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not implement some restrictions on where Self can be used 4 | """ 5 | conformance_automated = "Fail" 6 | errors_diff = """ 7 | Line 73: Expected 1 errors 8 | Line 76: Expected 1 errors 9 | Line 82: Expected 1 errors 10 | Line 87: Expected 1 errors 11 | Line 103: Expected 1 errors 12 | Line 108: Expected 1 errors 13 | Line 113: Expected 1 errors 14 | Line 118: Expected 1 errors 15 | Line 123: Expected 1 errors 16 | Line 127: Expected 1 errors 17 | """ 18 | output = """ 19 | ERROR generics_self_usage.py:105:12-16: Invalid base class: `Self` [invalid-inheritance] 20 | """ 21 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/tuples_unpacked.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR tuples_unpacked.py:40:29-45: Only one unbounded type is allowed to be unpacked [bad-unpacking] 7 | ERROR tuples_unpacked.py:41:42-58: Only one unbounded type is allowed to be unpacked [bad-unpacking] 8 | ERROR tuples_unpacked.py:51:33-36: Only one unbounded type is allowed to be unpacked [bad-unpacking] 9 | ERROR tuples_unpacked.py:59:37-60: Only one unbounded type is allowed to be unpacked [bad-unpacking] 10 | ERROR tuples_unpacked.py:61:50-73: Only one unbounded type is allowed to be unpacked [bad-unpacking] 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/results/pyright/literals_interactions.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | literals_interactions.py:15:5 - error: Index 5 is out of range for type tuple[int, str, list[bool]] (reportGeneralTypeIssues) 4 | literals_interactions.py:16:5 - error: Index -5 is out of range for type tuple[int, str, list[bool]] (reportGeneralTypeIssues) 5 | literals_interactions.py:17:5 - error: Index 4 is out of range for type tuple[int, str, list[bool]] (reportGeneralTypeIssues) 6 | literals_interactions.py:18:5 - error: Index -4 is out of range for type tuple[int, str, list[bool]] (reportGeneralTypeIssues) 7 | """ 8 | conformance_automated = "Pass" 9 | errors_diff = """ 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/pyright/namedtuples_type_compat.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | namedtuples_type_compat.py:22:23 - error: Type "Point" is not assignable to declared type "tuple[int, int]" 4 |   "Point" is not assignable to "tuple[int, int]" 5 |     Tuple size mismatch; expected 2 but received 3 (reportAssignmentType) 6 | namedtuples_type_compat.py:23:28 - error: Type "Point" is not assignable to declared type "tuple[int, str, str]" 7 |   "Point" is not assignable to "tuple[int, str, str]" 8 |     Tuple entry 2 is incorrect type 9 |       "int" is not assignable to "str" (reportAssignmentType) 10 | """ 11 | conformance_automated = "Pass" 12 | errors_diff = """ 13 | """ 14 | -------------------------------------------------------------------------------- /conformance/results/zuban/typeddicts_usage.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | typeddicts_usage.py:23: error: TypedDict "Movie" has no key "director" [typeddict-unknown-key] 6 | typeddicts_usage.py:24: error: Value of "year" has incompatible type "str"; expected "int" [typeddict-item] 7 | typeddicts_usage.py:28: error: Extra key "title" for TypedDict "Movie" [typeddict-unknown-key] 8 | typeddicts_usage.py:28: error: Missing key "name" for TypedDict "Movie" [typeddict-item] 9 | typeddicts_usage.py:35: error: Cannot use isinstance() with TypedDict type [misc] 10 | typeddicts_usage.py:40: error: Invalid type [valid-type] 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/historical_positional.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR historical_positional.py:18:4-7: Expected argument `__x` to be positional in function `f1` [unexpected-keyword] 7 | ERROR historical_positional.py:26:16-19: Positional-only parameter `__y` cannot appear after keyword parameters [bad-function-definition] 8 | ERROR historical_positional.py:38:26-29: Positional-only parameter `__y` cannot appear after keyword parameters [bad-function-definition] 9 | ERROR historical_positional.py:43:6-9: Expected argument `__x` to be positional in function `A.m1` [unexpected-keyword] 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/typeddicts_required.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | ERROR typeddicts_required.py:12:5-6: `Required` may only be used for TypedDict members [invalid-annotation] 6 | ERROR typeddicts_required.py:16:8-19: `NotRequired` is only allowed inside a class body [invalid-annotation] 7 | ERROR typeddicts_required.py:16:8-24: `NotRequired` is not allowed in this context [invalid-annotation] 8 | ERROR typeddicts_required.py:59:8-31: Duplicate qualifier `Required` [invalid-annotation] 9 | ERROR typeddicts_required.py:60:8-34: Cannot combine `Required` and `NotRequired` for a TypedDict field [invalid-annotation] 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/zuban/narrowing_typeguard.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | narrowing_typeguard.py:102: error: TypeGuard functions must have a positional argument [misc] 6 | narrowing_typeguard.py:107: error: TypeGuard functions must have a positional argument [misc] 7 | narrowing_typeguard.py:128: error: Argument 1 to "takes_callable_str" has incompatible type "Callable[[object], TypeGuard[int]]"; expected "Callable[[object], str]" [arg-type] 8 | narrowing_typeguard.py:148: error: Argument 1 to "takes_callable_str_proto" has incompatible type "Callable[[object], TypeGuard[int]]"; expected "CallableStrProto" [arg-type] 9 | """ 10 | -------------------------------------------------------------------------------- /conformance/results/pyright/dataclasses_hash.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | dataclasses_hash.py:15:16 - error: Type "DC1" is not assignable to declared type "Hashable" 4 |   "DC1" is incompatible with protocol "Hashable" 5 |     "__hash__" is an incompatible type 6 |       Type "None" is not assignable to type "() -> int" (reportAssignmentType) 7 | dataclasses_hash.py:32:16 - error: Type "DC3" is not assignable to declared type "Hashable" 8 |   "DC3" is incompatible with protocol "Hashable" 9 |     "__hash__" is an incompatible type 10 |       Type "None" is not assignable to type "() -> int" (reportAssignmentType) 11 | """ 12 | conformance_automated = "Pass" 13 | errors_diff = """ 14 | """ 15 | -------------------------------------------------------------------------------- /conformance/results/pyright/dataclasses_frozen.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | dataclasses_frozen.py:16:5 - error: Cannot assign to attribute "a" for class "DC1" 4 |   Attribute "a" is read-only (reportAttributeAccessIssue) 5 | dataclasses_frozen.py:17:5 - error: Cannot assign to attribute "b" for class "DC1" 6 |   Attribute "b" is read-only (reportAttributeAccessIssue) 7 | dataclasses_frozen.py:22:1 - error: A non-frozen class cannot inherit from a class that is frozen (reportGeneralTypeIssues) 8 | dataclasses_frozen.py:32:12 - error: A frozen class cannot inherit from a class that is not frozen (reportGeneralTypeIssues) 9 | """ 10 | conformance_automated = "Pass" 11 | errors_diff = """ 12 | """ 13 | -------------------------------------------------------------------------------- /conformance/results/zuban/dataclasses_slots.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not reject write to instance variable that is not defined in __slots__. 4 | """ 5 | conformance_automated = "Fail" 6 | errors_diff = """ 7 | Line 25: Expected 1 errors 8 | """ 9 | output = """ 10 | dataclasses_slots.py:11: error: "DC1" both defines "__slots__" and is used with "slots=True" [misc] 11 | dataclasses_slots.py:38: error: Trying to assign name "y" that is not in "__slots__" of type "dataclasses_slots.DC3" [misc] 12 | dataclasses_slots.py:66: error: "type[DC6]" has no attribute "__slots__" [attr-defined] 13 | dataclasses_slots.py:69: error: "DC6" has no attribute "__slots__" [attr-defined] 14 | """ 15 | -------------------------------------------------------------------------------- /conformance/results/zuban/enums_member_values.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not enforce declared type of `_value_`. 4 | """ 5 | conformance_automated = "Fail" 6 | errors_diff = """ 7 | Line 78: Expected 1 errors 8 | """ 9 | output = """ 10 | enums_member_values.py:54: error: Expression is of type "tuple[Literal[1], float, float]", not "Literal[1]" [misc] 11 | enums_member_values.py:68: error: Expression is of type "int", not "Literal[1]" [misc] 12 | enums_member_values.py:85: error: Incompatible types in assignment (expression has type "int", variable has type "str") [assignment] 13 | enums_member_values.py:96: error: Expression is of type "EllipsisType", not "int" [misc] 14 | """ 15 | -------------------------------------------------------------------------------- /conformance/results/mypy/dataclasses_descriptors.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not correctly evaluate type of descriptor access. 4 | """ 5 | output = """ 6 | dataclasses_descriptors.py:66: error: Expression is of type "Desc2[int]", not "int" [assert-type] 7 | dataclasses_descriptors.py:67: error: Expression is of type "Desc2[str]", not "str" [assert-type] 8 | """ 9 | conformance_automated = "Fail" 10 | errors_diff = """ 11 | Line 66: Unexpected errors ['dataclasses_descriptors.py:66: error: Expression is of type "Desc2[int]", not "int" [assert-type]'] 12 | Line 67: Unexpected errors ['dataclasses_descriptors.py:67: error: Expression is of type "Desc2[str]", not "str" [assert-type]'] 13 | """ 14 | -------------------------------------------------------------------------------- /conformance/results/mypy/generics_defaults_specialization.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | output = """ 3 | generics_defaults_specialization.py:30: error: Bad number of arguments for type alias, expected between 0 and 1, given 2 [type-arg] 4 | generics_defaults_specialization.py:45: error: Expression is of type "type[Bar[DefaultStrT]]", not "type[Bar[str]]" [assert-type] 5 | generics_defaults_specialization.py:55: error: The type "type[Foo]" is not generic and not indexable [misc] 6 | """ 7 | conformance_automated = "Fail" 8 | errors_diff = """ 9 | Line 45: Unexpected errors ['generics_defaults_specialization.py:45: error: Expression is of type "type[Bar[DefaultStrT]]", not "type[Bar[str]]" [assert-type]'] 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/mypy/typeddicts_readonly_update.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Incorrectly allows update of ReadOnly item. 4 | Incorrectly rejects update involving an item with Never type. 5 | """ 6 | output = """ 7 | typeddicts_readonly_update.py:34: error: Argument 1 to "update" of "TypedDict" has incompatible type "B"; expected "TypedDict({'x'?=: int, 'y': int})" [typeddict-item] 8 | """ 9 | conformance_automated = "Fail" 10 | errors_diff = """ 11 | Line 23: Expected 1 errors 12 | 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]'] 13 | """ 14 | -------------------------------------------------------------------------------- /conformance/results/pyright/directives_reveal_type.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | directives_reveal_type.py:14:17 - information: Type of "a" is "int | str" 4 | directives_reveal_type.py:15:17 - information: Type of "b" is "list[int]" 5 | directives_reveal_type.py:16:17 - information: Type of "c" is "Any" 6 | directives_reveal_type.py:17:17 - information: Type of "d" is "ForwardReference" 7 | directives_reveal_type.py:19:5 - error: Expected a single positional argument for "reveal_type" call (reportCallIssue) 8 | directives_reveal_type.py:20:5 - error: Expected a single positional argument for "reveal_type" call (reportCallIssue) 9 | """ 10 | conformance_automated = "Pass" 11 | errors_diff = """ 12 | """ 13 | -------------------------------------------------------------------------------- /conformance/results/zuban/directives_version_platform.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | directives_version_platform.py:19: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] 6 | directives_version_platform.py:27: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] 7 | directives_version_platform.py:40: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] 8 | directives_version_platform.py:45: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] 9 | """ 10 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Test and lint 2 | 3 | on: 4 | push: 5 | pull_request: 6 | 7 | permissions: 8 | contents: read 9 | 10 | jobs: 11 | linting: 12 | name: Lint 13 | 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v6 18 | - name: Set up Python 3 19 | uses: actions/setup-python@v6 20 | with: 21 | python-version: 3 22 | cache: "pip" 23 | cache-dependency-path: "test-requirements.txt" 24 | 25 | - name: Install dependencies 26 | run: | 27 | pip install --upgrade pip 28 | pip install -r test-requirements.txt 29 | 30 | - name: Lint implementation 31 | run: flake8 32 | -------------------------------------------------------------------------------- /conformance/results/zuban/specialtypes_never.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | specialtypes_never.py:19: error: Implicit return in function which does not return [misc] 6 | specialtypes_never.py:86: error: Incompatible types in assignment (expression has type "list[Never]", variable has type "list[int]") [assignment] 7 | specialtypes_never.py:86: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance 8 | specialtypes_never.py:86: note: Consider using "Sequence" instead, which is covariant 9 | specialtypes_never.py:105: error: Incompatible return value type (got "ClassC[Never]", expected "ClassC[U]") [return-value] 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/zuban/typeddicts_class_syntax.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | typeddicts_class_syntax.py:29: error: Invalid statement in TypedDict definition; expected "field_name: field_type" [misc] 6 | typeddicts_class_syntax.py:33: error: Invalid statement in TypedDict definition; expected "field_name: field_type" [misc] 7 | typeddicts_class_syntax.py:38: error: Invalid statement in TypedDict definition; expected "field_name: field_type" [misc] 8 | typeddicts_class_syntax.py:44: error: Unexpected keyword argument "metaclass" for "TypedDict" [call-arg] 9 | typeddicts_class_syntax.py:49: error: Unexpected keyword argument "other" for "TypedDict" [call-arg] 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/zuban/generics_self_advanced.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Doesn't allow accessing `Self` in a classmethod 4 | """ 5 | conformance_automated = "Fail" 6 | errors_diff = """ 7 | Line 43: Unexpected errors ['generics_self_advanced.py:43: error: Access to generic instance variables via class is ambiguous [misc]'] 8 | Line 44: Unexpected errors ['generics_self_advanced.py:44: error: Access to generic instance variables via class is ambiguous [misc]'] 9 | """ 10 | output = """ 11 | generics_self_advanced.py:43: error: Access to generic instance variables via class is ambiguous [misc] 12 | generics_self_advanced.py:44: error: Access to generic instance variables via class is ambiguous [misc] 13 | """ 14 | -------------------------------------------------------------------------------- /conformance/results/pyright/typeddicts_inheritance.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | typeddicts_inheritance.py:44:7 - error: All base classes for TypedDict classes must also be TypedDict classes 4 |   Class "NonTypedDict" is not a TypedDict (reportGeneralTypeIssues) 5 | typeddicts_inheritance.py:55:4 - error: "x" overrides symbol of same name in class "X1" 6 |   Variable is mutable so its type is invariant 7 |     Override type "int" is not the same as base type "str" (reportIncompatibleVariableOverride) 8 | typeddicts_inheritance.py:65:7 - error: Base classes for class "XYZ2" define variable "x" in incompatible way (reportIncompatibleVariableOverride) 9 | """ 10 | conformance_automated = "Pass" 11 | errors_diff = """ 12 | """ 13 | -------------------------------------------------------------------------------- /conformance/tests/_qualifiers_final_decorator.pyi: -------------------------------------------------------------------------------- 1 | """ 2 | Support stub file for @final tests. 3 | """ 4 | 5 | from typing import final, overload 6 | 7 | 8 | class Base3: 9 | # > For overloaded methods, @final should be placed on the implementation 10 | # > (or on the first overload, for stubs): 11 | @final 12 | @overload 13 | def method(self, x: int) -> int: 14 | ... 15 | 16 | @overload 17 | def method(self, x: str) -> str: 18 | ... 19 | 20 | class Base4: 21 | # (Swap the order of overload and final decorators.) 22 | @overload 23 | @final 24 | def method(self, x: int) -> int: 25 | ... 26 | 27 | @overload 28 | def method(self, x: str) -> str: 29 | ... 30 | -------------------------------------------------------------------------------- /conformance/tests/generics_syntax_compatibility.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests the compatibility rules between type parameter syntax (introduced in PEP 695) 3 | and traditional TypeVars. 4 | """ 5 | 6 | # Specification: https://peps.python.org/pep-0695/#compatibility-with-traditional-typevars 7 | 8 | from typing import TypeVar 9 | 10 | 11 | K = TypeVar("K") 12 | 13 | 14 | class ClassA[V](dict[K, V]): # E: traditional TypeVar not allowed here 15 | ... 16 | 17 | 18 | class ClassB[K, V](dict[K, V]): # OK 19 | ... 20 | 21 | 22 | class ClassC[V]: 23 | def method1(self, a: V, b: K) -> V | K: # OK 24 | raise NotImplementedError 25 | 26 | def method2[M](self, a: M, b: K) -> M | K: # E 27 | raise NotImplementedError 28 | -------------------------------------------------------------------------------- /conformance/results/mypy/specialtypes_never.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | specialtypes_never.py:19: error: Implicit return in function which does not return [misc] 4 | specialtypes_never.py:86: error: Incompatible types in assignment (expression has type "list[Never]", variable has type "list[int]") [assignment] 5 | specialtypes_never.py:86: note: "list" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance 6 | specialtypes_never.py:86: note: Consider using "Sequence" instead, which is covariant 7 | specialtypes_never.py:105: error: Incompatible return value type (got "ClassC[Never]", expected "ClassC[U]") [return-value] 8 | """ 9 | conformance_automated = "Pass" 10 | errors_diff = """ 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/results/pyright/overloads_consistency.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | overloads_consistency.py:28:5 - error: Overloaded implementation is not consistent with signature of overload 2 7 |   Function return type "str" is incompatible with type "int" 8 |     "str" is not assignable to "int" (reportInconsistentOverload) 9 | overloads_consistency.py:44:5 - error: Overloaded implementation is not consistent with signature of overload 2 10 |   Type "(x: int) -> (int | str)" is not assignable to type "(x: str) -> str" 11 |     Parameter 1: type "str" is incompatible with type "int" 12 |       "str" is not assignable to "int" (reportInconsistentOverload) 13 | """ 14 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/aliases_recursive.toml: -------------------------------------------------------------------------------- 1 | conformant = "Unsupported" 2 | conformance_automated = "Fail" 3 | errors_diff = """ 4 | Line 19: Expected 1 errors 5 | Line 20: Expected 1 errors 6 | Line 38: Expected 1 errors 7 | Line 39: Expected 1 errors 8 | Line 50: Expected 1 errors 9 | Line 51: Expected 1 errors 10 | Line 52: Expected 1 errors 11 | Line 63: Expected 1 errors 12 | Line 69: Expected 1 errors 13 | Line 72: Expected 1 errors 14 | Line 75: Expected 1 errors 15 | Line 42: Unexpected errors ["Expected a type form, got instance of `Literal['RecursiveMapping']` [not-a-type]"] 16 | """ 17 | output = """ 18 | ERROR aliases_recursive.py:42:45-63: Expected a type form, got instance of `Literal['RecursiveMapping']` [not-a-type] 19 | """ 20 | -------------------------------------------------------------------------------- /conformance/results/zuban/literals_semantics.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | literals_semantics.py:10: error: Incompatible types in assignment (expression has type "Literal[4]", variable has type "Literal[3]") [assignment] 6 | literals_semantics.py:24: error: Incompatible types in assignment (expression has type "Literal[0]", variable has type "Literal[False]") [assignment] 7 | literals_semantics.py:25: error: Incompatible types in assignment (expression has type "Literal[False]", variable has type "Literal[0]") [assignment] 8 | literals_semantics.py:33: error: Incompatible types in assignment (expression has type "Literal[6, 7, 8]", variable has type "Literal[3, 4, 5]") [assignment] 9 | """ 10 | -------------------------------------------------------------------------------- /conformance/results/mypy/literals_semantics.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | literals_semantics.py:10: error: Incompatible types in assignment (expression has type "Literal[4]", variable has type "Literal[3]") [assignment] 4 | literals_semantics.py:24: error: Incompatible types in assignment (expression has type "Literal[0]", variable has type "Literal[False]") [assignment] 5 | literals_semantics.py:25: error: Incompatible types in assignment (expression has type "Literal[False]", variable has type "Literal[0]") [assignment] 6 | literals_semantics.py:33: error: Incompatible types in assignment (expression has type "int", variable has type "Literal[3, 4, 5]") [assignment] 7 | """ 8 | conformance_automated = "Pass" 9 | errors_diff = """ 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/generics_upper_bound.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | ERROR generics_upper_bound.py:24:38-45: Type variable bounds and constraints must be concrete [invalid-annotation] 6 | ERROR generics_upper_bound.py:43:12-55: assert_type(list[int], list[int] | set[int]) failed [assert-type] 7 | ERROR generics_upper_bound.py:43:25-31: Argument `set[int]` is not assignable to parameter `y` with type `list[int]` in function `longer` [bad-argument-type] 8 | ERROR generics_upper_bound.py:51:7-13: `int` is not assignable to upper bound `Sized` of type variable `ST` [bad-specialization] 9 | ERROR generics_upper_bound.py:56:38-49: TypeVar cannot have both constraints and bound [invalid-type-var] 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/typeddicts_readonly.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR typeddicts_readonly.py:24:4-13: Key `members` in TypedDict `Band` is read-only [read-only] 7 | ERROR typeddicts_readonly.py:36:4-13: Key `members` in TypedDict `Band2` is read-only [read-only] 8 | ERROR typeddicts_readonly.py:50:4-11: Key `title` in TypedDict `Movie1` is read-only [read-only] 9 | ERROR typeddicts_readonly.py:51:4-10: Key `year` in TypedDict `Movie1` is read-only [read-only] 10 | ERROR typeddicts_readonly.py:60:4-11: Key `title` in TypedDict `Movie2` is read-only [read-only] 11 | ERROR typeddicts_readonly.py:61:4-10: Key `year` in TypedDict `Movie2` is read-only [read-only] 12 | """ 13 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/generics_scoping.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not implement several scoping checks/restrictions for generics 4 | """ 5 | conformance_automated = "Fail" 6 | errors_diff = """ 7 | Line 50: Expected 1 errors 8 | Line 54: Expected 1 errors 9 | Line 75: Expected 1 errors 10 | Line 78: Expected 1 errors 11 | Line 87: Expected 1 errors 12 | Line 94: Expected 1 errors 13 | Line 95: Expected 1 errors 14 | Line 96: Expected 1 errors 15 | """ 16 | output = """ 17 | ERROR generics_scoping.py:29:10-13: Argument `Literal['a']` is not assignable to parameter `x` with type `int` in function `MyClass.meth_2` [bad-argument-type] 18 | ERROR generics_scoping.py:65:11-20: Redundant type parameter declaration [invalid-type-var] 19 | """ 20 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/generics_variance.toml: -------------------------------------------------------------------------------- 1 | conformant = "Unsupported" 2 | conformance_automated = "Fail" 3 | errors_diff = """ 4 | Line 77: Expected 1 errors 5 | Line 81: Expected 1 errors 6 | Line 93: Expected 1 errors 7 | Line 105: Expected 1 errors 8 | Line 113: Expected 1 errors 9 | Line 163: Expected 1 errors 10 | Line 167: Expected 1 errors 11 | Line 191: Expected 1 errors 12 | Lines 125, 126: Expected error (tag 'CoContra_Child2') 13 | Lines 131, 132: Expected error (tag 'CoContra_Child3') 14 | Lines 141, 142: Expected error (tag 'CoContra_Child5') 15 | Lines 195, 196: Expected error (tag 'ContraToContraToContra_WithTA') 16 | """ 17 | output = """ 18 | ERROR generics_variance.py:14:36-54: Contradictory variance specifications [invalid-type-var] 19 | """ 20 | -------------------------------------------------------------------------------- /conformance/results/zuban/dataclasses_transform_meta.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | dataclasses_transform_meta.py:51: error: Non-frozen dataclass cannot inherit from a frozen dataclass [misc] 6 | dataclasses_transform_meta.py:63: error: Property "id" defined in "Customer1" is read-only [misc] 7 | dataclasses_transform_meta.py:66: error: Too many positional arguments for "Customer1" [call-arg] 8 | dataclasses_transform_meta.py:73: error: Unsupported left operand type for < ("Customer1") [operator] 9 | dataclasses_transform_meta.py:83: error: Too many positional arguments for "Customer2" [call-arg] 10 | dataclasses_transform_meta.py:103: error: Property "id" defined in "Customer3" is read-only [misc] 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/results/zuban/generics_paramspec_specialization.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | generics_paramspec_specialization.py:44: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "int" [misc] 6 | generics_paramspec_specialization.py:54: error: Argument 1 has incompatible type "str"; expected "int" [arg-type] 7 | generics_paramspec_specialization.py:55: error: Argument 3 has incompatible type "str"; expected "bool" [arg-type] 8 | generics_paramspec_specialization.py:60: error: Argument 1 has incompatible type "str"; expected "int" [arg-type] 9 | generics_paramspec_specialization.py:61: error: Argument 3 has incompatible type "str"; expected "bool" [arg-type] 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/pyright/constructors_call_new.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | constructors_call_new.py:21:13 - error: Argument of type "float" cannot be assigned to parameter "x" of type "int" in function "__new__" 6 |   "float" is not assignable to "int" (reportArgumentType) 7 | constructors_call_new.py:148:1 - error: 8 |   Could not bind method "__new__" because "type[Class11[str]]" is not assignable to parameter "cls" 9 |     "type[Class11[str]]" is not assignable to "type[Class11[int]]" 10 |     Type "type[Class11[str]]" is not assignable to type "type[Class11[int]]" 11 |       Type parameter "T@Class11" is invariant, but "str" is not the same as "int" (reportGeneralTypeIssues) 12 | """ 13 | conformance_automated = "Pass" 14 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/overloads_evaluation.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | ERROR overloads_evaluation.py:38:11-13: No matching overload found for function `example1_1` called with arguments: () [no-matching-overload] 6 | ERROR overloads_evaluation.py:46:11-17: No matching overload found for function `example1_1` called with arguments: (Literal[1], Literal[1]) [no-matching-overload] 7 | ERROR overloads_evaluation.py:51:11-14: No matching overload found for function `example1_1` called with arguments: (Literal[1]) [no-matching-overload] 8 | 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] 9 | """ 10 | -------------------------------------------------------------------------------- /conformance/results/pyright/dataclasses_postinit.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | dataclasses_postinit.py:19:40 - error: Dataclass __post_init__ method parameter type mismatch for field "y" 4 |   "str" is not assignable to "int" (reportGeneralTypeIssues) 5 | dataclasses_postinit.py:28:11 - error: Cannot access attribute "x" for class "DC1" 6 |   "x" is an init-only field (reportAttributeAccessIssue) 7 | dataclasses_postinit.py:29:11 - error: Cannot access attribute "y" for class "DC1" 8 |   "y" is an init-only field (reportAttributeAccessIssue) 9 | dataclasses_postinit.py:36:9 - error: Dataclass __post_init__ incorrect parameter count; number of InitVar fields is 2 (reportGeneralTypeIssues) 10 | """ 11 | conformance_automated = "Pass" 12 | errors_diff = """ 13 | """ 14 | -------------------------------------------------------------------------------- /conformance/results/zuban/dataclasses_transform_class.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | dataclasses_transform_class.py:51: error: Non-frozen dataclass cannot inherit from a frozen dataclass [misc] 6 | dataclasses_transform_class.py:63: error: Property "id" defined in "Customer1" is read-only [misc] 7 | dataclasses_transform_class.py:66: error: Too many positional arguments for "Customer1" [call-arg] 8 | dataclasses_transform_class.py:72: error: Unsupported left operand type for < ("Customer1") [operator] 9 | dataclasses_transform_class.py:82: error: Too many positional arguments for "Customer2" [call-arg] 10 | dataclasses_transform_class.py:122: error: Property "id" defined in "Customer3" is read-only [misc] 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/results/mypy/dataclasses_transform_meta.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | dataclasses_transform_meta.py:51: error: Non-frozen dataclass cannot inherit from a frozen dataclass [misc] 4 | dataclasses_transform_meta.py:63: error: Property "id" defined in "Customer1" is read-only [misc] 5 | dataclasses_transform_meta.py:66: error: Too many positional arguments for "Customer1" [misc] 6 | dataclasses_transform_meta.py:73: error: Unsupported left operand type for < ("Customer1") [operator] 7 | dataclasses_transform_meta.py:83: error: Too many positional arguments for "Customer2" [misc] 8 | dataclasses_transform_meta.py:103: error: Property "id" defined in "Customer3" is read-only [misc] 9 | """ 10 | conformance_automated = "Pass" 11 | errors_diff = """ 12 | """ 13 | -------------------------------------------------------------------------------- /conformance/results/pyright/dataclasses_slots.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | dataclasses_slots.py:10:12 - error: __slots__ is already defined in class (reportGeneralTypeIssues) 4 | dataclasses_slots.py:25:14 - error: "y" is not specified in __slots__ (reportGeneralTypeIssues) 5 | dataclasses_slots.py:38:14 - error: "y" is not specified in __slots__ (reportGeneralTypeIssues) 6 | dataclasses_slots.py:66:5 - error: Cannot access attribute "__slots__" for class "type[DC6]" 7 |   Attribute "__slots__" is unknown (reportAttributeAccessIssue) 8 | dataclasses_slots.py:69:8 - error: Cannot access attribute "__slots__" for class "DC6" 9 |   Attribute "__slots__" is unknown (reportAttributeAccessIssue) 10 | """ 11 | conformance_automated = "Pass" 12 | errors_diff = """ 13 | """ 14 | -------------------------------------------------------------------------------- /conformance/results/zuban/constructors_call_init.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not report errors during binding to self parameter of __init__ method. 4 | Does not reject use of class-scoped type variables in annotation of self parameter in __init__ method. 5 | """ 6 | conformance_automated = "Fail" 7 | errors_diff = """ 8 | Line 56: Expected 1 errors 9 | Line 107: Expected 1 errors 10 | """ 11 | output = """ 12 | constructors_call_init.py:21: error: Argument 1 to "Class1" has incompatible type "float"; expected "int" [arg-type] 13 | constructors_call_init.py:42: error: Argument 1 to "Class3" has incompatible type "Class2[Never]"; expected "Self | None" [arg-type] 14 | constructors_call_init.py:130: error: Too many arguments for "Class11" [call-arg] 15 | """ 16 | -------------------------------------------------------------------------------- /conformance/results/zuban/classes_override.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | classes_override.py:53: error: Method "method3" is marked as an override, but no base method was found with this name [misc] 6 | classes_override.py:56: error: Method "method4" is marked as an override, but no base method was found with this name [misc] 7 | classes_override.py:79: error: Method "static_method1" is marked as an override, but no base method was found with this name [misc] 8 | classes_override.py:84: error: Method "class_method1" is marked as an override, but no base method was found with this name [misc] 9 | classes_override.py:89: error: Method "property1" is marked as an override, but no base method was found with this name [misc] 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/tests/directives_type_ignore.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests "# type: ignore" comments. 3 | """ 4 | 5 | # Specification: https://typing.readthedocs.io/en/latest/spec/directives.html#type-ignore-comments 6 | 7 | # The following type violation should be suppressed. 8 | x: int = "" # type: ignore 9 | 10 | # The following type violation should be suppressed. 11 | y: int = "" # type: ignore - additional stuff 12 | 13 | # The following type violation should be suppressed. 14 | z: int = "" # type: ignore[additional_stuff] 15 | 16 | # > In some cases, linting tools or other comments may be needed on the same 17 | # > line as a type comment. In these cases, the type comment should be before 18 | # > other comments and linting markers. 19 | 20 | a: int = "" # type: ignore # other comment 21 | -------------------------------------------------------------------------------- /conformance/results/mypy/dataclasses_transform_class.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | dataclasses_transform_class.py:51: error: Non-frozen dataclass cannot inherit from a frozen dataclass [misc] 4 | dataclasses_transform_class.py:63: error: Property "id" defined in "Customer1" is read-only [misc] 5 | dataclasses_transform_class.py:66: error: Too many positional arguments for "Customer1" [misc] 6 | dataclasses_transform_class.py:72: error: Unsupported left operand type for < ("Customer1") [operator] 7 | dataclasses_transform_class.py:82: error: Too many positional arguments for "Customer2" [misc] 8 | dataclasses_transform_class.py:122: error: Property "id" defined in "Customer3" is read-only [misc] 9 | """ 10 | conformance_automated = "Pass" 11 | errors_diff = """ 12 | """ 13 | -------------------------------------------------------------------------------- /conformance/results/mypy/enums_member_values.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not enforce declared type of `_value_`. 4 | Does not enforce assigned tuple types for enum members (optional). 5 | """ 6 | conformance_automated = "Fail" 7 | errors_diff = """ 8 | Line 78: Expected 1 errors 9 | """ 10 | output = """ 11 | enums_member_values.py:26: error: Expression is of type "Any", not "Literal[1, 3]" [assert-type] 12 | enums_member_values.py:54: error: Expression is of type "tuple[int, float, float]", not "Literal[1]" [assert-type] 13 | enums_member_values.py:68: error: Expression is of type "int", not "Literal[1]" [assert-type] 14 | enums_member_values.py:85: error: Incompatible types in assignment (expression has type "int", variable has type "str") [assignment] 15 | """ 16 | -------------------------------------------------------------------------------- /conformance/results/zuban/typeddicts_alt_syntax.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | notes = """ 3 | Does not support keyword-argument form of alternative syntax (deprecated in 3.11). 4 | """ 5 | errors_diff = """ 6 | """ 7 | output = """ 8 | typeddicts_alt_syntax.py:23: error: TypedDict() expects a dictionary literal as the second argument [misc] 9 | typeddicts_alt_syntax.py:27: error: Invalid TypedDict() field name [misc] 10 | typeddicts_alt_syntax.py:31: error: First argument "WrongName" to TypedDict() does not match variable name "BadTypedDict3" [name-match] 11 | typeddicts_alt_syntax.py:35: error: Unexpected keyword argument "other" for "TypedDict" [call-arg] 12 | typeddicts_alt_syntax.py:41: error: TypedDict() expects a dictionary literal as the second argument [misc] 13 | """ 14 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/pre-commit/pre-commit-hooks 3 | rev: v4.6.0 4 | hooks: 5 | - id: trailing-whitespace 6 | exclude: conformance/results/.*/.*\.toml 7 | - id: end-of-file-fixer 8 | - id: check-yaml 9 | - id: check-toml 10 | - id: check-merge-conflict 11 | - id: mixed-line-ending 12 | args: [--fix=lf] 13 | exclude: docs/make\.bat 14 | - id: check-case-conflict 15 | - repo: meta 16 | hooks: 17 | - id: check-hooks-apply 18 | 19 | ci: 20 | autofix_commit_msg: "[pre-commit.ci] auto fixes from pre-commit.com hooks" 21 | autofix_prs: true 22 | autoupdate_commit_msg: "[pre-commit.ci] pre-commit autoupdate" 23 | autoupdate_schedule: quarterly 24 | submodules: false 25 | -------------------------------------------------------------------------------- /conformance/results/mypy/generics_paramspec_specialization.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | generics_paramspec_specialization.py:44: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "int" [valid-type] 4 | generics_paramspec_specialization.py:54: error: Argument 1 has incompatible type "str"; expected "int" [arg-type] 5 | generics_paramspec_specialization.py:55: error: Argument 3 has incompatible type "str"; expected "bool" [arg-type] 6 | generics_paramspec_specialization.py:60: error: Argument 1 has incompatible type "str"; expected "int" [arg-type] 7 | generics_paramspec_specialization.py:61: error: Argument 3 has incompatible type "str"; expected "bool" [arg-type] 8 | """ 9 | conformance_automated = "Pass" 10 | errors_diff = """ 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/results/mypy/typeddicts_class_syntax.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | typeddicts_class_syntax.py:29: error: Invalid statement in TypedDict definition; expected "field_name: field_type" [misc] 4 | typeddicts_class_syntax.py:33: error: Invalid statement in TypedDict definition; expected "field_name: field_type" [misc] 5 | typeddicts_class_syntax.py:38: error: Invalid statement in TypedDict definition; expected "field_name: field_type" [misc] 6 | typeddicts_class_syntax.py:44: error: Unexpected keyword argument "metaclass" for "__init_subclass__" of "TypedDict" [call-arg] 7 | typeddicts_class_syntax.py:49: error: Unexpected keyword argument "other" for "__init_subclass__" of "TypedDict" [call-arg] 8 | """ 9 | conformance_automated = "Pass" 10 | errors_diff = """ 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/results/pyright/typeddicts_class_syntax.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | typeddicts_class_syntax.py:29:5 - error: TypedDict classes can contain only type annotations (reportGeneralTypeIssues) 4 | typeddicts_class_syntax.py:33:5 - error: TypedDict classes can contain only type annotations (reportGeneralTypeIssues) 5 | typeddicts_class_syntax.py:38:5 - error: TypedDict classes can contain only type annotations (reportGeneralTypeIssues) 6 | typeddicts_class_syntax.py:44:32 - error: TypedDict does not support __init_subclass__ parameter "metaclass" (reportGeneralTypeIssues) 7 | typeddicts_class_syntax.py:49:32 - error: TypedDict does not support __init_subclass__ parameter "other" (reportGeneralTypeIssues) 8 | """ 9 | conformance_automated = "Pass" 10 | errors_diff = """ 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/results/pyright/specialtypes_none.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | specialtypes_none.py:21:7 - error: Argument of type "type[None]" cannot be assigned to parameter "val1" of type "None" in function "func1" 4 |   Type is not assignable to "None" (reportArgumentType) 5 | specialtypes_none.py:27:19 - error: Type "None" is not assignable to declared type "Iterable[Unknown]" 6 |   "None" is incompatible with protocol "Iterable[Unknown]" 7 |     "__iter__" is not present (reportAssignmentType) 8 | specialtypes_none.py:41:7 - error: Argument of type "None" cannot be assigned to parameter "val1" of type "type[None]" in function "func2" 9 |   Type "None" is not assignable to type "type[None]" (reportArgumentType) 10 | """ 11 | conformance_automated = "Pass" 12 | errors_diff = """ 13 | """ 14 | -------------------------------------------------------------------------------- /conformance/results/pyright/typeddicts_alt_syntax.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | typeddicts_alt_syntax.py:23:17 - error: Expected dict or keyword parameter as second parameter (reportArgumentType) 4 | typeddicts_alt_syntax.py:27:45 - error: Expected string literal for dictionary entry name (reportGeneralTypeIssues) 5 | typeddicts_alt_syntax.py:31:1 - error: TypedDict must be assigned to a variable named "WrongName" (reportGeneralTypeIssues) 6 | typeddicts_alt_syntax.py:35:78 - error: Extra TypedDict arguments not supported (reportCallIssue) 7 | typeddicts_alt_syntax.py:45:43 - error: Type "dict[str, str]" is not assignable to declared type "Movie2" 8 |   "Literal['']" is not assignable to "int" (reportAssignmentType) 9 | """ 10 | conformance_automated = "Pass" 11 | errors_diff = """ 12 | """ 13 | -------------------------------------------------------------------------------- /conformance/results/mypy/classes_override.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | classes_override.py:53: error: Method "method3" is marked as an override, but no base method was found with this name [misc] 4 | classes_override.py:56: error: Method "method4" is marked as an override, but no base method was found with this name [misc] 5 | classes_override.py:79: error: Method "static_method1" is marked as an override, but no base method was found with this name [misc] 6 | classes_override.py:84: error: Method "class_method1" is marked as an override, but no base method was found with this name [misc] 7 | classes_override.py:89: error: Method "property1" is marked as an override, but no base method was found with this name [misc] 8 | """ 9 | conformance_automated = "Pass" 10 | errors_diff = """ 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/results/zuban/namedtuples_usage.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | namedtuples_usage.py:34: error: Tuple index out of range [misc] 6 | namedtuples_usage.py:35: error: Tuple index out of range [misc] 7 | namedtuples_usage.py:40: error: Property "x" defined in "Point" is read-only [misc] 8 | namedtuples_usage.py:41: error: Unsupported target for indexed assignment ("Point") [index] 9 | namedtuples_usage.py:42: error: NamedTuple attributes cannot be deleted [misc] 10 | namedtuples_usage.py:43: error: "Point" has no attribute "__delitem__" [attr-defined] 11 | namedtuples_usage.py:52: error: Too many values to unpack (2 expected, 3 provided) [misc] 12 | namedtuples_usage.py:53: error: Need more than 3 values to unpack (4 expected) [misc] 13 | """ 14 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/directives_no_type_check.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR directives_no_type_check.py:15:14-16: `Literal['']` is not assignable to `int` [bad-assignment] 7 | ERROR directives_no_type_check.py:29:7-17: Argument `Literal[b'invalid']` is not assignable to parameter `a` with type `int` in function `func1` [bad-argument-type] 8 | ERROR directives_no_type_check.py:29:19-31: Argument `Literal[b'arguments']` is not assignable to parameter `b` with type `str` in function `func1` [bad-argument-type] 9 | ERROR directives_no_type_check.py:32:6-8: Missing argument `a` in function `func1` [missing-argument] 10 | ERROR directives_no_type_check.py:32:6-8: Missing argument `b` in function `func1` [missing-argument] 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/results/pyright/tuples_unpacked.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | tuples_unpacked.py:40:30 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple (reportInvalidTypeForm) 4 | tuples_unpacked.py:41:43 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple (reportInvalidTypeForm) 5 | tuples_unpacked.py:51:34 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple (reportInvalidTypeForm) 6 | tuples_unpacked.py:59:37 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple (reportInvalidTypeForm) 7 | tuples_unpacked.py:61:50 - error: Type argument list can have at most one unpacked TypeVarTuple or tuple (reportInvalidTypeForm) 8 | """ 9 | conformance_automated = "Pass" 10 | errors_diff = """ 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/results/zuban/dataclasses_transform_func.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | dataclasses_transform_func.py:56: error: Incompatible types in assignment (expression has type "int", variable has type "str") [assignment] 6 | dataclasses_transform_func.py:60: error: Unsupported left operand type for < ("Customer1") [operator] 7 | dataclasses_transform_func.py:64: error: Unexpected keyword argument "salary" for "Customer1" [call-arg] 8 | dataclasses_transform_func.py:70: error: Too many positional arguments for "Customer2" [call-arg] 9 | dataclasses_transform_func.py:89: error: Non-frozen dataclass cannot inherit from a frozen dataclass [misc] 10 | dataclasses_transform_func.py:96: error: Property "id" defined in "Customer3" is read-only [misc] 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/protocols_modules.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Fails one subtyping example of protocol modules 4 | """ 5 | conformance_automated = "Fail" 6 | errors_diff = """ 7 | Line 25: Unexpected errors ['`Module[_protocols_modules1]` is not assignable to `Options1` [bad-assignment]'] 8 | """ 9 | output = """ 10 | ERROR protocols_modules.py:25:17-36: `Module[_protocols_modules1]` is not assignable to `Options1` [bad-assignment] 11 | ERROR protocols_modules.py:26:17-36: `Module[_protocols_modules1]` is not assignable to `Options2` [bad-assignment] 12 | ERROR protocols_modules.py:48:18-37: `Module[_protocols_modules2]` is not assignable to `Reporter2` [bad-assignment] 13 | ERROR protocols_modules.py:49:18-37: `Module[_protocols_modules2]` is not assignable to `Reporter3` [bad-assignment] 14 | """ 15 | -------------------------------------------------------------------------------- /conformance/results/mypy/directives_reveal_type.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | directives_reveal_type.py:14: note: Revealed type is "builtins.int | builtins.str" 4 | directives_reveal_type.py:15: note: Revealed type is "builtins.list[builtins.int]" 5 | directives_reveal_type.py:16: note: Revealed type is "Any" 6 | directives_reveal_type.py:17: note: Revealed type is "directives_reveal_type.ForwardReference" 7 | directives_reveal_type.py:19: error: "reveal_type" expects 1 argument [misc] 8 | directives_reveal_type.py:19: error: Too few arguments for "reveal_type" [call-arg] 9 | directives_reveal_type.py:20: error: "reveal_type" expects 1 argument [misc] 10 | directives_reveal_type.py:20: error: Too many arguments for "reveal_type" [call-arg] 11 | """ 12 | conformance_automated = "Pass" 13 | errors_diff = """ 14 | """ 15 | -------------------------------------------------------------------------------- /conformance/results/mypy/narrowing_typeguard.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | narrowing_typeguard.py:102: error: TypeGuard functions must have a positional argument [valid-type] 4 | narrowing_typeguard.py:107: error: TypeGuard functions must have a positional argument [valid-type] 5 | narrowing_typeguard.py:128: error: Argument 1 to "takes_callable_str" has incompatible type "Callable[[object], TypeGuard[int]]"; expected "Callable[[object], str]" [arg-type] 6 | narrowing_typeguard.py:148: error: Argument 1 to "takes_callable_str_proto" has incompatible type "Callable[[object], TypeGuard[int]]"; expected "CallableStrProto" [arg-type] 7 | narrowing_typeguard.py:148: note: "CallableStrProto.__call__" has type "def __call__(self, val: object) -> str" 8 | """ 9 | conformance_automated = "Pass" 10 | errors_diff = """ 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/narrowing_typeguard.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR narrowing_typeguard.py:102:9-13: Type guard functions must accept at least one positional argument [bad-function-definition] 7 | ERROR narrowing_typeguard.py:107:9-13: Type guard functions must accept at least one positional argument [bad-function-definition] 8 | 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] 9 | 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] 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/typeddicts_usage.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR typeddicts_usage.py:23:7-17: TypedDict `Movie` does not have key `director` [bad-typed-dict-key] 7 | ERROR typeddicts_usage.py:24:17-23: `Literal['1982']` is not assignable to TypedDict key `year` with type `int` [bad-typed-dict-key] 8 | ERROR typeddicts_usage.py:28:17-56: Missing required key `name` for TypedDict `Movie` [bad-typed-dict-key] 9 | ERROR typeddicts_usage.py:28:18-25: Key `title` is not defined in TypedDict `Movie` [bad-typed-dict-key] 10 | ERROR typeddicts_usage.py:35:22-27: TypedDict `Movie` not allowed as second argument to isinstance() [invalid-argument] 11 | ERROR typeddicts_usage.py:40:24-33: `TypedDict` is not allowed in this context [invalid-annotation] 12 | """ 13 | -------------------------------------------------------------------------------- /conformance/results/zuban/typeddicts_readonly.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | typeddicts_readonly.py:24: error: ReadOnly TypedDict key "members" TypedDict is mutated [typeddict-readonly-mutated] 6 | typeddicts_readonly.py:36: error: ReadOnly TypedDict key "members" TypedDict is mutated [typeddict-readonly-mutated] 7 | typeddicts_readonly.py:50: error: ReadOnly TypedDict key "title" TypedDict is mutated [typeddict-readonly-mutated] 8 | typeddicts_readonly.py:51: error: ReadOnly TypedDict key "year" TypedDict is mutated [typeddict-readonly-mutated] 9 | typeddicts_readonly.py:60: error: ReadOnly TypedDict key "title" TypedDict is mutated [typeddict-readonly-mutated] 10 | typeddicts_readonly.py:61: error: ReadOnly TypedDict key "year" TypedDict is mutated [typeddict-readonly-mutated] 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/tests/directives_reveal_type.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests the typing.reveal_type function. 3 | """ 4 | 5 | # Specification: https://typing.readthedocs.io/en/latest/spec/directives.html#reveal-type 6 | 7 | from typing import Any, reveal_type 8 | 9 | # > When a static type checker encounters a call to this function, it should 10 | # > emit a diagnostic with the type of the argument. 11 | 12 | 13 | def func1(a: int | str, b: list[int], c: Any, d: "ForwardReference"): 14 | reveal_type(a) # Revealed type is "int | str" 15 | reveal_type(b) # Revealed type is "list[int]" 16 | reveal_type(c) # Revealed type is "Any" 17 | reveal_type(d) # Revealed type is "ForwardReference" 18 | 19 | reveal_type() # E: not enough arguments 20 | reveal_type(a, a) # E: Too many arguments 21 | 22 | 23 | class ForwardReference: 24 | pass 25 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/directives_assert_type.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR directives_assert_type.py:27:16-24: assert_type(int | str, int) failed [assert-type] 7 | ERROR directives_assert_type.py:28:16-24: assert_type(int | str, Any) failed [assert-type] 8 | ERROR directives_assert_type.py:29:16-24: assert_type(Any, int) failed [assert-type] 9 | ERROR directives_assert_type.py:30:16-24: assert_type(Literal[4], int) failed [assert-type] 10 | ERROR directives_assert_type.py:32:16-18: assert_type needs 2 positional arguments, got 0 [bad-argument-count] 11 | ERROR directives_assert_type.py:33:16-25: assert_type(Literal[''], int) failed [assert-type] 12 | ERROR directives_assert_type.py:34:16-33: assert_type needs 2 positional arguments, got 3 [bad-argument-count] 13 | """ 14 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/typeddicts_class_syntax.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR typeddicts_class_syntax.py:29:9-16: TypedDict members must be declared in the form `field: Annotation` with no assignment [bad-class-definition] 7 | ERROR typeddicts_class_syntax.py:34:9-16: TypedDict members must be declared in the form `field: Annotation` with no assignment [bad-class-definition] 8 | ERROR typeddicts_class_syntax.py:39:9-16: TypedDict members must be declared in the form `field: Annotation` with no assignment [bad-class-definition] 9 | ERROR typeddicts_class_syntax.py:44:7-20: Typed dictionary definitions may not specify a metaclass [invalid-inheritance] 10 | ERROR typeddicts_class_syntax.py:49:7-20: TypedDict does not support keyword argument `other` [bad-typed-dict] 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/results/mypy/dataclasses_transform_field.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not properly handle field constructor that has default value for `kw_only` or `init` parameter. 4 | """ 5 | output = """ 6 | dataclasses_transform_field.py:64: error: Unexpected keyword argument "id" for "CustomerModel1" [call-arg] 7 | dataclasses_transform_field.py:75: error: Too many positional arguments for "CustomerModel2" [misc] 8 | dataclasses_transform_field.py:75: error: Missing named argument "name" for "CustomerModel2" [call-arg] 9 | dataclasses_transform_field.py:77: error: Missing named argument "id" for "CustomerModel2" [call-arg] 10 | """ 11 | conformance_automated = "Fail" 12 | errors_diff = """ 13 | Line 77: Unexpected errors ['dataclasses_transform_field.py:77: error: Missing named argument "id" for "CustomerModel2" [call-arg]'] 14 | """ 15 | -------------------------------------------------------------------------------- /conformance/results/mypy/typeddicts_usage.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | typeddicts_usage.py:23: error: TypedDict "Movie" has no key "director" [typeddict-unknown-key] 4 | typeddicts_usage.py:24: error: Value of "year" has incompatible type "str"; expected "int" [typeddict-item] 5 | typeddicts_usage.py:28: error: Missing key "name" for TypedDict "Movie" [typeddict-item] 6 | typeddicts_usage.py:28: error: Extra key "title" for TypedDict "Movie" [typeddict-unknown-key] 7 | typeddicts_usage.py:35: error: Cannot use isinstance() with TypedDict type [misc] 8 | typeddicts_usage.py:40: error: Variable "typing.TypedDict" is not valid as a type [valid-type] 9 | typeddicts_usage.py:40: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases 10 | """ 11 | conformance_automated = "Pass" 12 | errors_diff = """ 13 | """ 14 | -------------------------------------------------------------------------------- /conformance/tests/constructors_consistency.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests consistency checks between __new__ and __init__ methods. 3 | """ 4 | 5 | # pyright: reportInconsistentConstructor=true 6 | 7 | # Specification: https://typing.readthedocs.io/en/latest/spec/constructors.html#consistency-of-new-and-init 8 | 9 | # Note: This functionality is optional in the typing spec, and conformant 10 | # type checkers are not required to implement it. 11 | 12 | 13 | # > Type checkers may optionally validate that the __new__ and __init__ 14 | # > methods for a class have consistent signatures. 15 | 16 | 17 | from typing import Self 18 | 19 | 20 | class Class1: 21 | def __new__(cls) -> Self: 22 | return super().__new__(cls) 23 | 24 | # Type error: __new__ and __init__ have inconsistent signatures 25 | def __init__(self, x: str) -> None: # E? 26 | pass 27 | -------------------------------------------------------------------------------- /conformance/results/mypy/typeddicts_readonly.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | typeddicts_readonly.py:24: error: ReadOnly TypedDict key "members" TypedDict is mutated [typeddict-readonly-mutated] 4 | typeddicts_readonly.py:36: error: ReadOnly TypedDict key "members" TypedDict is mutated [typeddict-readonly-mutated] 5 | typeddicts_readonly.py:50: error: ReadOnly TypedDict key "title" TypedDict is mutated [typeddict-readonly-mutated] 6 | typeddicts_readonly.py:51: error: ReadOnly TypedDict key "year" TypedDict is mutated [typeddict-readonly-mutated] 7 | typeddicts_readonly.py:60: error: ReadOnly TypedDict key "title" TypedDict is mutated [typeddict-readonly-mutated] 8 | typeddicts_readonly.py:61: error: ReadOnly TypedDict key "year" TypedDict is mutated [typeddict-readonly-mutated] 9 | """ 10 | conformance_automated = "Pass" 11 | errors_diff = """ 12 | """ 13 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/dataclasses_postinit.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR dataclasses_postinit.py:19:9-22: `__post_init__` type `BoundMethod[DC1, (self: DC1, 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] 7 | ERROR dataclasses_postinit.py:28:7-12: Object of class `DC1` has no attribute `x` [missing-attribute] 8 | ERROR dataclasses_postinit.py:29:7-12: Object of class `DC1` has no attribute `y` [missing-attribute] 9 | ERROR dataclasses_postinit.py:36:9-22: `__post_init__` type `BoundMethod[DC2, (self: DC2, x: int) -> None]` is not assignable to expected type `(x: int, y: str) -> object` generated from the dataclass's `InitVar` fields [bad-function-definition] 10 | """ 11 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/protocols_merging.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | ERROR protocols_merging.py:52:25-38: `SCConcrete2` is not assignable to `SizedAndClosable1` [bad-assignment] 6 | ERROR protocols_merging.py:53:25-38: `SCConcrete2` is not assignable to `SizedAndClosable2` [bad-assignment] 7 | ERROR protocols_merging.py:54:25-38: `SCConcrete2` is not assignable to `SizedAndClosable3` [bad-assignment] 8 | ERROR protocols_merging.py:67:16-33: If `Protocol` is included as a base class, all other bases must be protocols [invalid-inheritance] 9 | ERROR protocols_merging.py:82:22-24: Cannot instantiate `SizedAndClosable4` because the following members are abstract: `close` [bad-instantiation] 10 | ERROR protocols_merging.py:83:24-37: `SCConcrete1` is not assignable to `SizedAndClosable4` [bad-assignment] 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/results/zuban/historical_positional.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not reject positional-only parameter after non-positional-only parameter. 4 | Treats keyword-only parameter as positional-only. 5 | Applies legacy positional-only rules when PEP 570 syntax is used. 6 | """ 7 | conformance_automated = "Fail" 8 | errors_diff = """ 9 | Line 26: Expected 1 errors 10 | Line 38: Expected 1 errors 11 | Line 53: Unexpected errors ['historical_positional.py:53: error: Unexpected keyword argument "__y" for "f4" [call-arg]'] 12 | """ 13 | output = """ 14 | historical_positional.py:18: error: Unexpected keyword argument "__x" for "f1" [call-arg] 15 | historical_positional.py:43: error: Unexpected keyword argument "__x" for "m1" of "A" [call-arg] 16 | historical_positional.py:53: error: Unexpected keyword argument "__y" for "f4" [call-arg] 17 | """ 18 | -------------------------------------------------------------------------------- /conformance/tests/typeddicts_final.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests the use of Final values when used with TypedDicts. 3 | """ 4 | 5 | # Specification: https://typing.readthedocs.io/en/latest/spec/typeddict.html#use-of-final-values-and-literal-types 6 | 7 | from typing import Final, Literal, TypedDict 8 | 9 | 10 | class Movie(TypedDict): 11 | name: str 12 | year: int 13 | 14 | 15 | # > Type checkers should allow final names (PEP 591) with string values to be 16 | # > used instead of string literals in operations on TypedDict objects. 17 | YEAR: Final = "year" 18 | 19 | m: Movie = {"name": "Alien", "year": 1979} 20 | years_since_epoch = m[YEAR] - 1970 21 | 22 | 23 | # > An expression with a suitable literal type (PEP 586) can be used instead of 24 | # > a literal value. 25 | def get_value(movie: Movie, key: Literal["year", "name"]) -> int | str: 26 | return movie[key] 27 | -------------------------------------------------------------------------------- /conformance/results/mypy/directives_version_platform.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | notes = """ 3 | Does not understand three-element form of sys.version checks. 4 | Does not understand os.name checks. 5 | """ 6 | output = """ 7 | directives_version_platform.py:19: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] 8 | directives_version_platform.py:27: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] 9 | directives_version_platform.py:40: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] 10 | directives_version_platform.py:45: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] 11 | """ 12 | conformance_automated = "Pass" 13 | errors_diff = """ 14 | """ 15 | -------------------------------------------------------------------------------- /conformance/results/mypy/namedtuples_usage.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not reject attempt to delete named tuple field by name. 4 | """ 5 | output = """ 6 | namedtuples_usage.py:34: error: Tuple index out of range [misc] 7 | namedtuples_usage.py:35: error: Tuple index out of range [misc] 8 | namedtuples_usage.py:40: error: Property "x" defined in "Point" is read-only [misc] 9 | namedtuples_usage.py:41: error: Unsupported target for indexed assignment ("Point") [index] 10 | namedtuples_usage.py:43: error: "Point" has no attribute "__delitem__" [attr-defined] 11 | namedtuples_usage.py:52: error: Too many values to unpack (2 expected, 3 provided) [misc] 12 | namedtuples_usage.py:53: error: Need more than 3 values to unpack (4 expected) [misc] 13 | """ 14 | conformance_automated = "Fail" 15 | errors_diff = """ 16 | Line 42: Expected 1 errors 17 | """ 18 | -------------------------------------------------------------------------------- /conformance/results/zuban/dataclasses_postinit.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | dataclasses_postinit.py:19: error: Argument 2 of "__post_init__" is incompatible with supertype "dataclass"; supertype defines the argument type as "str" [override] 6 | dataclasses_postinit.py:28: error: "DC1" has no attribute "x" [attr-defined] 7 | dataclasses_postinit.py:29: error: "DC1" has no attribute "y" [attr-defined] 8 | dataclasses_postinit.py:36: error: Signature of "__post_init__" incompatible with supertype "dataclass" [override] 9 | dataclasses_postinit.py:36: note: Superclass: 10 | dataclasses_postinit.py:36: note: def __post_init__(self, x: int, y: str) -> None 11 | dataclasses_postinit.py:36: note: Subclass: 12 | dataclasses_postinit.py:36: note: def __post_init__(self, x: int) -> None 13 | """ 14 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/generics_paramspec_specialization.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR generics_paramspec_specialization.py:44:15-31: Expected a valid ParamSpec expression, got `int` [invalid-param-spec] 7 | ERROR generics_paramspec_specialization.py:54:9-11: Argument `Literal['']` is not assignable to parameter with type `int` [bad-argument-type] 8 | ERROR generics_paramspec_specialization.py:55:16-18: Argument `Literal['']` is not assignable to parameter with type `bool` [bad-argument-type] 9 | ERROR generics_paramspec_specialization.py:60:9-11: Argument `Literal['']` is not assignable to parameter with type `int` [bad-argument-type] 10 | ERROR generics_paramspec_specialization.py:61:16-18: Argument `Literal['']` is not assignable to parameter with type `bool` [bad-argument-type] 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/results/zuban/directives_assert_type.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | directives_assert_type.py:27: error: Expression is of type "int | str", not "int" [misc] 6 | directives_assert_type.py:28: error: Expression is of type "int | str", not "Any" [misc] 7 | directives_assert_type.py:29: error: Expression is of type "Any", not "int" [misc] 8 | directives_assert_type.py:30: error: Expression is of type "Literal[4]", not "int" [misc] 9 | directives_assert_type.py:32: error: "assert_type" expects 2 arguments [call-arg] 10 | directives_assert_type.py:33: error: Expression is of type "Literal['']", not "int" [misc] 11 | directives_assert_type.py:34: error: "assert_type" expects 2 arguments [call-arg] 12 | directives_assert_type.py:41: error: Expression is of type "str", not "str | Literal['spam']" [misc] 13 | """ 14 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/namedtuples_usage.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR namedtuples_usage.py:34:9-10: Index 3 out of range for tuple with 3 elements [bad-index] 7 | ERROR namedtuples_usage.py:35:9-11: Index -4 out of range for tuple with 3 elements [bad-index] 8 | ERROR namedtuples_usage.py:40:1-4: Cannot set field `x` [read-only] 9 | ERROR namedtuples_usage.py:41:1-5: Cannot set item in `Point` [unsupported-operation] 10 | ERROR namedtuples_usage.py:42:5-8: Cannot delete field `x` [read-only] 11 | ERROR namedtuples_usage.py:43:5-9: Cannot delete item in `Point` [unsupported-operation] 12 | ERROR namedtuples_usage.py:52:1-7: Cannot unpack Point (of size 3) into 2 values [bad-unpacking] 13 | ERROR namedtuples_usage.py:53:1-21: Cannot unpack Point (of size 3) into 4 values [bad-unpacking] 14 | """ 15 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/typeddicts_readonly_consistency.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR typeddicts_readonly_consistency.py:37:14-15: `A1` is not assignable to `B1` [bad-assignment] 7 | ERROR typeddicts_readonly_consistency.py:38:14-15: `C1` is not assignable to `B1` [bad-assignment] 8 | ERROR typeddicts_readonly_consistency.py:40:14-15: `A1` is not assignable to `C1` [bad-assignment] 9 | ERROR typeddicts_readonly_consistency.py:81:14-15: `A2` is not assignable to `B2` [bad-assignment] 10 | ERROR typeddicts_readonly_consistency.py:82:14-15: `C2` is not assignable to `B2` [bad-assignment] 11 | ERROR typeddicts_readonly_consistency.py:84:14-15: `A2` is not assignable to `C2` [bad-assignment] 12 | ERROR typeddicts_readonly_consistency.py:85:14-15: `B2` is not assignable to `C2` [bad-assignment] 13 | """ 14 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/specialtypes_never.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not detect invalid return is unreachable 4 | """ 5 | conformance_automated = "Fail" 6 | errors_diff = """ 7 | Line 32: Unexpected errors ["Returned type `Literal['whatever works']` is not assignable to declared return type `int` [bad-return]"] 8 | """ 9 | output = """ 10 | ERROR specialtypes_never.py:19:22-30: Function declared to return `NoReturn` but is missing an explicit `return` [bad-return] 11 | ERROR specialtypes_never.py:32:12-28: Returned type `Literal['whatever works']` is not assignable to declared return type `int` [bad-return] 12 | ERROR specialtypes_never.py:86:21-22: `list[Never]` is not assignable to `list[int]` [bad-assignment] 13 | ERROR specialtypes_never.py:105:12-27: Returned type `ClassC[Never]` is not assignable to declared return type `ClassC[U]` [bad-return] 14 | """ 15 | -------------------------------------------------------------------------------- /conformance/results/pyright/classes_override.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | classes_override.py:53:9 - error: Method "method3" is marked as override, but no base method of same name is present (reportGeneralTypeIssues) 4 | classes_override.py:65:9 - error: Method "method4" is marked as override, but no base method of same name is present (reportGeneralTypeIssues) 5 | classes_override.py:79:9 - error: Method "static_method1" is marked as override, but no base method of same name is present (reportGeneralTypeIssues) 6 | classes_override.py:84:9 - error: Method "class_method1" is marked as override, but no base method of same name is present (reportGeneralTypeIssues) 7 | classes_override.py:89:9 - error: Method "property1" is marked as override, but no base method of same name is present (reportGeneralTypeIssues) 8 | """ 9 | conformance_automated = "Pass" 10 | errors_diff = """ 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/results/zuban/generics_typevartuple_specialization.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | generics_typevartuple_specialization.py:109: error: Unpack is only valid in a variadic position [misc] 6 | generics_typevartuple_specialization.py:109: error: TypeVarTuple "Ts" is unbound [misc] 7 | generics_typevartuple_specialization.py:110: error: Unpack is only valid in a variadic position [misc] 8 | generics_typevartuple_specialization.py:121: error: More than one Unpack in a type is not allowed [misc] 9 | generics_typevartuple_specialization.py:122: error: More than one Unpack in a type is not allowed [misc] 10 | generics_typevartuple_specialization.py:127: error: Bad number of arguments for type alias, expected at least 2, given 2 [misc] 11 | generics_typevartuple_specialization.py:163: error: TypeVarTuple cannot be split [misc] 12 | """ 13 | -------------------------------------------------------------------------------- /conformance/results/mypy/dataclasses_postinit.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | dataclasses_postinit.py:19: error: Argument 3 of "__post_init__" is incompatible with supertype "dataclass"; supertype defines the argument type as "str" [override] 4 | dataclasses_postinit.py:28: error: "DC1" has no attribute "x" [attr-defined] 5 | dataclasses_postinit.py:29: error: "DC1" has no attribute "y" [attr-defined] 6 | dataclasses_postinit.py:36: error: Signature of "__post_init__" incompatible with supertype "dataclass" [override] 7 | dataclasses_postinit.py:36: note: Superclass: 8 | dataclasses_postinit.py:36: note: def __post_init__(self: DC2, x: int, y: str) -> None 9 | dataclasses_postinit.py:36: note: Subclass: 10 | dataclasses_postinit.py:36: note: def __post_init__(self: DC2, x: int) -> None 11 | """ 12 | conformance_automated = "Pass" 13 | errors_diff = """ 14 | """ 15 | -------------------------------------------------------------------------------- /conformance/results/pyright/specialtypes_never.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | specialtypes_never.py:19:22 - error: Function with declared return type "NoReturn" cannot return "None" (reportReturnType) 4 | specialtypes_never.py:86:21 - error: Type "list[Never]" is not assignable to declared type "list[int]" 5 |   "list[Never]" is not assignable to "list[int]" 6 |     Type parameter "_T@list" is invariant, but "Never" is not the same as "int" 7 |     Consider switching from "list" to "Sequence" which is covariant (reportAssignmentType) 8 | specialtypes_never.py:105:12 - error: Type "ClassC[Never]" is not assignable to return type "ClassC[U@func10]" 9 |   "ClassC[Never]" is not assignable to "ClassC[U@func10]" 10 |     Type parameter "T@ClassC" is invariant, but "Never" is not the same as "U@func10" (reportReturnType) 11 | """ 12 | conformance_automated = "Pass" 13 | errors_diff = """ 14 | """ 15 | -------------------------------------------------------------------------------- /conformance/src/options.py: -------------------------------------------------------------------------------- 1 | """ 2 | Command-line options for the test tool. 3 | """ 4 | 5 | import argparse 6 | from dataclasses import dataclass 7 | 8 | from type_checker import TYPE_CHECKERS 9 | 10 | @dataclass 11 | class _Options: 12 | report_only: bool | None 13 | only_run: str | None 14 | 15 | 16 | def parse_options(argv: list[str]) -> _Options: 17 | parser = argparse.ArgumentParser() 18 | reporting_group = parser.add_argument_group("reporting") 19 | reporting_group.add_argument( 20 | "--report-only", 21 | action="store_true", 22 | help="regenerates the test suite report from past results", 23 | ) 24 | reporting_group.add_argument( 25 | "--only-run", 26 | help="Only runs the type checker", 27 | choices=[tc.name for tc in TYPE_CHECKERS] 28 | ) 29 | ret = _Options(**vars(parser.parse_args(argv))) 30 | return ret 31 | -------------------------------------------------------------------------------- /conformance/tests/namedtuples_type_compat.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests NamedTuple type compatibility rules. 3 | """ 4 | 5 | from typing import Any, NamedTuple 6 | 7 | # Specification: https://typing.readthedocs.io/en/latest/spec/namedtuples.html#type-compatibility-rules 8 | 9 | 10 | class Point(NamedTuple): 11 | x: int 12 | y: int 13 | units: str = "meters" 14 | 15 | 16 | # > A named tuple is a subtype of a ``tuple`` with a known length and parameterized 17 | # > by types corresponding to the named tuple's individual field types. 18 | 19 | p = Point(x=1, y=2, units="inches") 20 | v1: tuple[int, int, str] = p # OK 21 | v2: tuple[Any, ...] = p # OK 22 | v3: tuple[int, int] = p # E: too few elements 23 | v4: tuple[int, str, str] = p # E: incompatible element type 24 | 25 | # > As with normal tuples, named tuples are covariant in their type parameters. 26 | 27 | v5: tuple[float, float, str] = p # OK 28 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/protocols_class_objects.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not require concrete classes to be passed to type[Proto] 4 | """ 5 | conformance_automated = "Fail" 6 | errors_diff = """ 7 | Line 104: Expected 1 errors 8 | Line 106: Expected 1 errors 9 | Line 107: Expected 1 errors 10 | Line 108: Expected 1 errors 11 | """ 12 | output = """ 13 | 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] 14 | ERROR protocols_class_objects.py:34:7-12: `type[Proto]` is not assignable to variable `var` with type `type[Proto]` [bad-assignment] 15 | ERROR protocols_class_objects.py:58:16-25: `type[ConcreteA]` is not assignable to `ProtoA1` [bad-assignment] 16 | ERROR protocols_class_objects.py:74:16-25: `type[ConcreteB]` is not assignable to `ProtoB1` [bad-assignment] 17 | """ 18 | -------------------------------------------------------------------------------- /conformance/tests/dataclasses_order.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests the synthesized comparison methods for dataclasses. 3 | """ 4 | 5 | from dataclasses import dataclass 6 | 7 | @dataclass(order=True) 8 | class DC1: 9 | a: str 10 | b: int 11 | 12 | 13 | @dataclass(order=True) 14 | class DC2: 15 | a: str 16 | b: int 17 | 18 | 19 | dc1_1 = DC1("", 0) 20 | dc1_2 = DC1("", 0) 21 | 22 | if dc1_1 < dc1_2: 23 | pass 24 | 25 | if dc1_1 <= dc1_2: 26 | pass 27 | 28 | if dc1_1 > dc1_2: 29 | pass 30 | 31 | if dc1_1 >= dc1_2: 32 | pass 33 | 34 | if dc1_1 == dc1_2: 35 | pass 36 | 37 | if dc1_1 != dc1_2: 38 | pass 39 | 40 | if dc1_1 == None: 41 | pass 42 | 43 | if dc1_1 != None: 44 | pass 45 | 46 | dc2_1 = DC2("hi", 2) 47 | 48 | # This should generate an error because the types are 49 | # incompatible. 50 | if dc1_1 < dc2_1: # E: 51 | pass 52 | 53 | if dc1_1 != dc2_1: 54 | pass 55 | -------------------------------------------------------------------------------- /conformance/results/pyright/typeddicts_usage.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | typeddicts_usage.py:23:1 - error: Could not assign item in TypedDict 4 |   "director" is not a defined key in "Movie" (reportGeneralTypeIssues) 5 | typeddicts_usage.py:24:1 - error: Could not assign item in TypedDict 6 |   "Literal['1982']" is not assignable to "int" (reportGeneralTypeIssues) 7 | typeddicts_usage.py:28:18 - error: Type "dict[str, str | int]" is not assignable to declared type "Movie" 8 |   "title" is an undefined item in type "Movie" (reportAssignmentType) 9 | typeddicts_usage.py:35:22 - error: Second argument to "isinstance" must be a class or tuple of classes 10 |   TypedDict class not allowed for instance or class checks (reportArgumentType) 11 | typeddicts_usage.py:40:24 - error: "TypedDict" cannot be used in this context (reportInvalidTypeForm) 12 | """ 13 | conformance_automated = "Pass" 14 | errors_diff = """ 15 | """ 16 | -------------------------------------------------------------------------------- /conformance/tests/annotations_coroutines.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests for annotating coroutines. 3 | """ 4 | 5 | # Specification: https://typing.readthedocs.io/en/latest/spec/annotations.html#annotating-generator-functions-and-coroutines 6 | 7 | # > Coroutines introduced in PEP 492 are annotated with the same syntax as 8 | # > ordinary functions. However, the return type annotation corresponds to 9 | # > the type of await expression, not to the coroutine type. 10 | 11 | 12 | from typing import Any, Callable, Coroutine, assert_type 13 | 14 | 15 | async def func1(ignored: int, /) -> str: 16 | return "spam" 17 | 18 | 19 | # Don't use assert_type here because some type checkers infer 20 | # the narrower type types.CoroutineType rather than typing.Coroutine 21 | # in this case. 22 | v1: Callable[[int], Coroutine[Any, Any, str]] = func1 23 | 24 | 25 | async def func2() -> None: 26 | x = await func1(42) 27 | assert_type(x, str) 28 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/classes_override.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | 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] 7 | 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] 8 | 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] 9 | 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] 10 | 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] 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/tests/generics_self_attributes.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests for usage of the typing.Self type with attributes. 3 | """ 4 | 5 | # Specification: https://typing.readthedocs.io/en/latest/spec/generics.html#use-in-attribute-annotations 6 | 7 | from typing import TypeVar, Generic, Self 8 | from dataclasses import dataclass 9 | 10 | 11 | T = TypeVar("T") 12 | 13 | @dataclass 14 | class LinkedList(Generic[T]): 15 | value: T 16 | next: Self | None = None 17 | 18 | 19 | @dataclass 20 | class OrdinalLinkedList(LinkedList[int]): 21 | def ordinal_value(self) -> str: 22 | return str(self.value) 23 | 24 | 25 | # This should result in a type error. 26 | xs = OrdinalLinkedList(value=1, next=LinkedList[int](value=2)) # E 27 | 28 | if xs.next is not None: 29 | xs.next = OrdinalLinkedList(value=3, next=None) # OK 30 | 31 | # This should result in a type error. 32 | xs.next = LinkedList[int](value=3, next=None) # E 33 | -------------------------------------------------------------------------------- /conformance/results/mypy/constructors_call_type.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not validate call to custom metaclass __call__ method through type[T]. 4 | """ 5 | conformance_automated = "Fail" 6 | errors_diff = """ 7 | Line 30: Expected 1 errors 8 | Line 72: Expected 1 errors 9 | """ 10 | output = """ 11 | constructors_call_type.py:40: error: Missing positional arguments "x", "y" in call to "Class2" [call-arg] 12 | constructors_call_type.py:50: error: Missing positional arguments "x", "y" in call to "Class3" [call-arg] 13 | constructors_call_type.py:59: error: Too many arguments for "Class4" [call-arg] 14 | constructors_call_type.py:64: error: Too many arguments for "object" [call-arg] 15 | constructors_call_type.py:81: error: Missing positional argument "y" in call to "Class2" [call-arg] 16 | constructors_call_type.py:82: error: Argument 2 to "Class2" has incompatible type "int"; expected "str" [arg-type] 17 | """ 18 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/constructors_call_init.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not reject class-scoped type var in self param annotation 4 | """ 5 | conformance_automated = "Fail" 6 | errors_diff = """ 7 | Line 107: Expected 1 errors 8 | """ 9 | output = """ 10 | 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] 11 | 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] 12 | 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] 13 | ERROR constructors_call_init.py:130:9-10: Expected 0 positional arguments, got 1 in function `object.__init__` [bad-argument-count] 14 | """ 15 | -------------------------------------------------------------------------------- /conformance/results/zuban/constructors_call_type.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not validate call to custom metaclass __call__ method through type[T]. 4 | """ 5 | conformance_automated = "Fail" 6 | errors_diff = """ 7 | Line 30: Expected 1 errors 8 | Line 72: Expected 1 errors 9 | """ 10 | output = """ 11 | constructors_call_type.py:40: error: Missing positional arguments "x", "y" in call to "Class2" [call-arg] 12 | constructors_call_type.py:50: error: Missing positional arguments "x", "y" in call to "Class3" [call-arg] 13 | constructors_call_type.py:59: error: Too many arguments for "Class4" [call-arg] 14 | constructors_call_type.py:64: error: Too many arguments for "object" [call-arg] 15 | constructors_call_type.py:81: error: Missing positional argument "y" in call to "Class2" [call-arg] 16 | constructors_call_type.py:82: error: Argument 2 to "Class2" has incompatible type "int"; expected "str" [arg-type] 17 | """ 18 | -------------------------------------------------------------------------------- /conformance/results/mypy/protocols_runtime_checkable.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not report unsafe overlap for runtime_checkable protocol. 4 | """ 5 | output = """ 6 | protocols_runtime_checkable.py:23: error: Only @runtime_checkable protocols can be used with instance and class checks [misc] 7 | protocols_runtime_checkable.py:55: error: Only protocols that don't have non-method members can be used with issubclass() [misc] 8 | protocols_runtime_checkable.py:55: note: Protocol "DataProtocol" has non-method member(s): name 9 | protocols_runtime_checkable.py:61: error: Only protocols that don't have non-method members can be used with issubclass() [misc] 10 | protocols_runtime_checkable.py:61: note: Protocol "DataProtocol" has non-method member(s): name 11 | """ 12 | conformance_automated = "Fail" 13 | errors_diff = """ 14 | Line 88: Expected 1 errors 15 | Line 92: Expected 1 errors 16 | Line 96: Expected 1 errors 17 | """ 18 | -------------------------------------------------------------------------------- /conformance/results/zuban/protocols_runtime_checkable.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not report unsafe overlap for runtime_checkable protocol. 4 | """ 5 | conformance_automated = "Fail" 6 | errors_diff = """ 7 | Line 88: Expected 1 errors 8 | Line 92: Expected 1 errors 9 | Line 96: Expected 1 errors 10 | """ 11 | output = """ 12 | protocols_runtime_checkable.py:23: error: Only @runtime_checkable protocols can be used with instance and class checks [misc] 13 | protocols_runtime_checkable.py:55: error: Only protocols that don't have non-method members can be used with issubclass() [misc] 14 | protocols_runtime_checkable.py:55: note: Protocol "DataProtocol" has non-method member(s): name 15 | protocols_runtime_checkable.py:61: error: Only protocols that don't have non-method members can be used with issubclass() [misc] 16 | protocols_runtime_checkable.py:61: note: Protocol "DataProtocol" has non-method member(s): name 17 | """ 18 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/protocols_subtyping.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR protocols_subtyping.py:16:12-14: Cannot instantiate `Proto1` because it is a protocol [bad-instantiation] 7 | ERROR protocols_subtyping.py:38:21-23: `Proto2` is not assignable to `Concrete2` [bad-assignment] 8 | ERROR protocols_subtyping.py:55:18-20: `Proto2` is not assignable to `Proto3` [bad-assignment] 9 | ERROR protocols_subtyping.py:79:30-36: `Proto5[int]` is not assignable to `Proto4[int, float]` [bad-assignment] 10 | ERROR protocols_subtyping.py:80:25-31: `Proto4[int, int]` is not assignable to `Proto5[float]` [bad-assignment] 11 | ERROR protocols_subtyping.py:102:30-32: `Proto6[float, float]` is not assignable to `Proto7[int, float]` [bad-assignment] 12 | ERROR protocols_subtyping.py:103:33-35: `Proto6[float, float]` is not assignable to `Proto7[float, object]` [bad-assignment] 13 | """ 14 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.http://sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -W -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /conformance/results/pyright/dataclasses_transform_meta.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | dataclasses_transform_meta.py:51:36 - error: A non-frozen class cannot inherit from a class that is frozen (reportGeneralTypeIssues) 4 | dataclasses_transform_meta.py:63:6 - error: Cannot assign to attribute "id" for class "Customer1" 5 |   Attribute "id" is read-only (reportAttributeAccessIssue) 6 | dataclasses_transform_meta.py:66:18 - error: Expected 0 positional arguments (reportCallIssue) 7 | dataclasses_transform_meta.py:73:6 - error: Operator "<" not supported for types "Customer1" and "Customer1" (reportOperatorIssue) 8 | dataclasses_transform_meta.py:83:18 - error: Expected 0 positional arguments (reportCallIssue) 9 | dataclasses_transform_meta.py:103:6 - error: Cannot assign to attribute "id" for class "Customer3" 10 |   Attribute "id" is read-only (reportAttributeAccessIssue) 11 | """ 12 | conformance_automated = "Pass" 13 | errors_diff = """ 14 | """ 15 | -------------------------------------------------------------------------------- /conformance/results/zuban/protocols_explicit.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | protocols_explicit.py:27: error: Call to abstract method "draw" of "PColor" with trivial body via super() is unsafe [safe-super] 6 | protocols_explicit.py:56: error: Incompatible types in assignment (expression has type "tuple[int, int, str]", variable has type "tuple[int, int, int]") [assignment] 7 | protocols_explicit.py:60: error: Cannot instantiate abstract class "Point" with abstract attributes "intensity" and "transparency" [abstract] 8 | protocols_explicit.py:89: error: Cannot instantiate abstract class "Concrete1" with abstract attribute "cm1" [abstract] 9 | protocols_explicit.py:134: error: Cannot instantiate abstract class "Concrete5" with abstract attribute "method1" [abstract] 10 | protocols_explicit.py:164: error: Cannot instantiate abstract class "Concrete7A" with abstract attribute "method1" [abstract] 11 | """ 12 | -------------------------------------------------------------------------------- /conformance/results/pyright/dataclasses_transform_class.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | dataclasses_transform_class.py:51:7 - error: A non-frozen class cannot inherit from a class that is frozen (reportGeneralTypeIssues) 4 | dataclasses_transform_class.py:63:6 - error: Cannot assign to attribute "id" for class "Customer1" 5 |   Attribute "id" is read-only (reportAttributeAccessIssue) 6 | dataclasses_transform_class.py:66:18 - error: Expected 0 positional arguments (reportCallIssue) 7 | dataclasses_transform_class.py:72:6 - error: Operator "<" not supported for types "Customer1" and "Customer1" (reportOperatorIssue) 8 | dataclasses_transform_class.py:82:18 - error: Expected 0 positional arguments (reportCallIssue) 9 | dataclasses_transform_class.py:122:6 - error: Cannot assign to attribute "id" for class "Customer3" 10 |   Attribute "id" is read-only (reportAttributeAccessIssue) 11 | """ 12 | conformance_automated = "Pass" 13 | errors_diff = """ 14 | """ 15 | -------------------------------------------------------------------------------- /conformance/results/pyright/dataclasses_transform_func.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | dataclasses_transform_func.py:56:13 - error: Cannot assign to attribute "name" for class "Customer1" 4 |   "Literal[3]" is not assignable to "str" (reportAttributeAccessIssue) 5 | dataclasses_transform_func.py:60:6 - error: Operator "<" not supported for types "Customer1" and "Customer1" (reportOperatorIssue) 6 | dataclasses_transform_func.py:64:36 - error: No parameter named "salary" (reportCallIssue) 7 | dataclasses_transform_func.py:70:18 - error: Expected 0 positional arguments (reportCallIssue) 8 | dataclasses_transform_func.py:88:1 - error: A non-frozen class cannot inherit from a class that is frozen (reportGeneralTypeIssues) 9 | dataclasses_transform_func.py:96:6 - error: Cannot assign to attribute "id" for class "Customer3" 10 |   Attribute "id" is read-only (reportAttributeAccessIssue) 11 | """ 12 | conformance_automated = "Pass" 13 | errors_diff = """ 14 | """ 15 | -------------------------------------------------------------------------------- /conformance/results/pyright/enums_member_values.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | enums_member_values.py:50:12 - error: Argument missing for parameter "radius" (reportCallIssue) 7 | enums_member_values.py:51:15 - error: Arguments missing for parameters "mass", "radius" (reportCallIssue) 8 | enums_member_values.py:54:13 - error: "assert_type" mismatch: expected "Literal[1]" but received "Any" (reportAssertTypeFailure) 9 | enums_member_values.py:68:13 - error: "assert_type" mismatch: expected "Literal[1]" but received "int" (reportAssertTypeFailure) 10 | enums_member_values.py:78:13 - error: Type "Literal['green']" is not assignable to declared type "int" 11 |   "Literal['green']" is not assignable to "int" (reportAssignmentType) 12 | enums_member_values.py:85:24 - error: Cannot assign to attribute "_value_" for class "Planet2*" 13 |   "int" is not assignable to "str" (reportAttributeAccessIssue) 14 | """ 15 | -------------------------------------------------------------------------------- /conformance/tests/typeddicts_readonly_update.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests inheritance rules involving the update method for TypedDicts 3 | that contain read-only items. 4 | """ 5 | 6 | # Specification: https://typing.readthedocs.io/en/latest/spec/typeddict.html#read-only-items 7 | 8 | from typing import Never, NotRequired, TypedDict 9 | from typing_extensions import ReadOnly 10 | 11 | # > In addition to existing type checking rules, type checkers should error if 12 | # > a TypedDict with a read-only item is updated with another TypedDict that 13 | # > declares that key. 14 | 15 | 16 | class A(TypedDict): 17 | x: ReadOnly[int] 18 | y: int 19 | 20 | 21 | a1: A = {"x": 1, "y": 2} 22 | a2: A = {"x": 3, "y": 4} 23 | a1.update(a2) # E 24 | 25 | # > Unless the declared value is of bottom type (:data:`~typing.Never`). 26 | 27 | 28 | class B(TypedDict): 29 | x: NotRequired[Never] 30 | y: ReadOnly[int] 31 | 32 | 33 | def update_a(a: A, b: B) -> None: 34 | a.update(b) # OK 35 | -------------------------------------------------------------------------------- /conformance/results/zuban/directives_type_ignore.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not honor "# type: ignore" comment if comment includes additional text. 4 | """ 5 | conformance_automated = "Fail" 6 | errors_diff = """ 7 | Line 11: Unexpected errors ['directives_type_ignore.py:11: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]'] 8 | Line 14: Unexpected errors ['directives_type_ignore.py:14: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]'] 9 | """ 10 | output = """ 11 | directives_type_ignore.py:11: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] 12 | directives_type_ignore.py:14: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] 13 | directives_type_ignore.py:14: note: Error code "assignment" not covered by "type: ignore" comment 14 | """ 15 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/enums_member_values.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | conformance_automated = "Pass" 3 | errors_diff = """ 4 | """ 5 | output = """ 6 | ERROR enums_member_values.py:21:12-43: assert_type(int, Literal[1]) failed [assert-type] 7 | ERROR enums_member_values.py:22:12-41: assert_type(int, Literal[1]) failed [assert-type] 8 | ERROR enums_member_values.py:26:16-50: assert_type(int, Literal[1, 3]) failed [assert-type] 9 | ERROR enums_member_values.py:30:16-51: assert_type(int, Literal[1, 2, 3]) failed [assert-type] 10 | ERROR enums_member_values.py:54:12-46: assert_type(Any, Literal[1]) failed [assert-type] 11 | ERROR enums_member_values.py:68:12-42: assert_type(int, Literal[1]) failed [assert-type] 12 | ERROR enums_member_values.py:78:5-10: Enum member `GREEN` has type `str`, must match the `_value_` attribute annotation of `int` [bad-assignment] 13 | ERROR enums_member_values.py:85:24-29: `int` is not assignable to attribute `_value_` with type `str` [bad-assignment] 14 | """ 15 | -------------------------------------------------------------------------------- /conformance/results/mypy/typeddicts_alt_syntax.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | notes = """ 3 | Does not support keyword-argument form of alternative syntax (deprecated in 3.11). 4 | """ 5 | output = """ 6 | typeddicts_alt_syntax.py:23: error: TypedDict() expects a dictionary literal as the second argument [misc] 7 | typeddicts_alt_syntax.py:27: error: Invalid TypedDict() field name [misc] 8 | typeddicts_alt_syntax.py:31: error: First argument "WrongName" to TypedDict() does not match variable name "BadTypedDict3" [name-match] 9 | typeddicts_alt_syntax.py:35: error: Too many arguments for TypedDict() [misc] 10 | typeddicts_alt_syntax.py:41: error: Unexpected arguments to TypedDict() [misc] 11 | typeddicts_alt_syntax.py:44: error: Extra keys ("name", "year") for TypedDict "Movie2" [typeddict-unknown-key] 12 | typeddicts_alt_syntax.py:45: error: Extra keys ("name", "year") for TypedDict "Movie2" [typeddict-unknown-key] 13 | """ 14 | conformance_automated = "Pass" 15 | errors_diff = """ 16 | """ 17 | -------------------------------------------------------------------------------- /conformance/results/pyright/protocols_modules.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | protocols_modules.py:26:17 - error: Type "Module("_protocols_modules1")" is not assignable to declared type "Options2" 4 |   "timeout" is invariant because it is mutable 5 |   "timeout" is an incompatible type 6 |     "int" is not assignable to "str" (reportAssignmentType) 7 | protocols_modules.py:48:18 - error: Type "Module("_protocols_modules2")" is not assignable to declared type "Reporter2" 8 |   "on_error" is an incompatible type 9 |     Type "(x: int) -> None" is not assignable to type "(x: int) -> int" 10 |       Function return type "None" is incompatible with type "int" 11 |         "None" is not assignable to "int" (reportAssignmentType) 12 | protocols_modules.py:49:18 - error: Type "Module("_protocols_modules2")" is not assignable to declared type "Reporter3" 13 |   "not_implemented" is not present (reportAssignmentType) 14 | """ 15 | conformance_automated = "Pass" 16 | errors_diff = """ 17 | """ 18 | -------------------------------------------------------------------------------- /conformance/results/mypy/directives_assert_type.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | directives_assert_type.py:27: error: Expression is of type "int | str", not "int" [assert-type] 4 | directives_assert_type.py:28: error: Expression is of type "int | str", not "Any" [assert-type] 5 | directives_assert_type.py:29: error: Expression is of type "Any", not "int" [assert-type] 6 | directives_assert_type.py:30: error: Expression is of type "Literal[4]", not "int" [assert-type] 7 | directives_assert_type.py:32: error: "assert_type" expects 2 arguments [misc] 8 | directives_assert_type.py:32: error: Too few arguments for "assert_type" [call-arg] 9 | directives_assert_type.py:33: error: Expression is of type "Literal['']", not "int" [assert-type] 10 | directives_assert_type.py:34: error: "assert_type" expects 2 arguments [misc] 11 | directives_assert_type.py:34: error: Too many arguments for "assert_type" [call-arg] 12 | """ 13 | conformance_automated = "Pass" 14 | errors_diff = """ 15 | """ 16 | -------------------------------------------------------------------------------- /conformance/results/pyright/aliases_variance.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | aliases_variance.py:24:23 - error: Type "T_co@ClassA_1" cannot be assigned to type variable "T@ClassA" 4 |   Variance of type argument "T_co@ClassA_1" is incompatible with base class "ClassA" (reportInvalidTypeArguments) 5 | aliases_variance.py:28:26 - error: Could not specialize type "A_Alias_1[T_co@A_Alias_1]" 6 |   Variance of type argument "T_co@ClassA_2" is incompatible with "T_co@A_Alias_1" (reportInvalidTypeForm) 7 | aliases_variance.py:32:26 - error: Could not specialize type "A_Alias_2[T_co@A_Alias_2]" 8 |   Variance of type argument "T_co@ClassA_3" is incompatible with "T_co@A_Alias_2" (reportInvalidTypeForm) 9 | aliases_variance.py:44:26 - error: Could not specialize type "B_Alias_1[T_co@B_Alias_1, T_contra@B_Alias_1]" 10 |   Variance of type argument "T_contra@ClassB_1" is incompatible with "T_co@B_Alias_1" (reportInvalidTypeForm) 11 | """ 12 | conformance_automated = "Pass" 13 | errors_diff = """ 14 | """ 15 | -------------------------------------------------------------------------------- /conformance/tests/enums_member_names.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests that the type checker handles the `_name_` and `name` attributes correctly. 3 | """ 4 | 5 | # Specification: https://typing.readthedocs.io/en/latest/spec/enums.html#member-names 6 | 7 | from enum import Enum 8 | from typing import Literal, assert_type 9 | 10 | # > All enum member objects have an attribute _name_ that contains the member’s 11 | # > name. They also have a property name that returns the same name. Type 12 | # > checkers may infer a literal type for the name of a member 13 | 14 | 15 | class Color(Enum): 16 | RED = 1 17 | GREEN = 2 18 | BLUE = 3 19 | 20 | 21 | assert_type(Color.RED._name_, Literal["RED"]) # E? 22 | assert_type(Color.RED.name, Literal["RED"]) # E? 23 | 24 | 25 | def func1(red_or_blue: Literal[Color.RED, Color.BLUE]): 26 | assert_type(red_or_blue.name, Literal["RED", "BLUE"]) # E? 27 | 28 | 29 | def func2(any_color: Color): 30 | assert_type(any_color.name, Literal["RED", "BLUE", "GREEN"]) # E? 31 | -------------------------------------------------------------------------------- /conformance/tests/generics_typevartuple_overloads.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests the use of TypeVarTuple in function overloads. 3 | """ 4 | 5 | # Specification: https://typing.readthedocs.io/en/latest/spec/generics.html#overloads-for-accessing-individual-types 6 | 7 | from typing import Any, Generic, TypeVar, TypeVarTuple, assert_type, overload 8 | 9 | 10 | Shape = TypeVarTuple("Shape") 11 | Axis1 = TypeVar("Axis1") 12 | Axis2 = TypeVar("Axis2") 13 | Axis3 = TypeVar("Axis3") 14 | 15 | 16 | class Array(Generic[*Shape]): 17 | @overload 18 | def transpose(self: "Array[Axis1, Axis2]") -> "Array[Axis2, Axis1]": 19 | ... 20 | 21 | @overload 22 | def transpose(self: "Array[Axis1, Axis2, Axis3]") -> "Array[Axis3, Axis2, Axis1]": 23 | ... 24 | 25 | def transpose(self) -> Any: 26 | pass 27 | 28 | 29 | def func1(a: Array[Axis1, Axis2], b: Array[Axis1, Axis2, Axis3]): 30 | assert_type(a.transpose(), Array[Axis2, Axis1]) 31 | assert_type(b.transpose(), Array[Axis3, Axis2, Axis1]) 32 | -------------------------------------------------------------------------------- /conformance/tests/specialtypes_none.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests the handling of builtins.None in a type annotation. 3 | """ 4 | 5 | # Specification: https://typing.readthedocs.io/en/latest/spec/special-types.html#none 6 | 7 | from types import NoneType 8 | from typing import Hashable, Iterable, assert_type 9 | 10 | 11 | # > When used in a type hint, the expression None is considered equivalent to type(None). 12 | 13 | 14 | def func1(val1: None) -> None: 15 | assert_type(val1, None) 16 | t1: None = None 17 | return None # OK 18 | 19 | 20 | func1(None) # OK 21 | func1(type(None)) # E 22 | 23 | # None is hashable 24 | none1: Hashable = None # OK 25 | 26 | # None is not iterable 27 | none2: Iterable = None # E: not iterable 28 | 29 | 30 | None.__class__ # OK 31 | None.__doc__ # OK 32 | None.__eq__(0) # OK 33 | 34 | 35 | def func2(val1: type[None]): 36 | assert_type(val1, type[None]) 37 | 38 | 39 | func2(None.__class__) # OK 40 | func2(type(None)) # OK 41 | func2(None) # E: not compatible 42 | -------------------------------------------------------------------------------- /conformance/results/pyright/generics_self_attributes.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | 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__" 4 |   Type "LinkedList[int]" is not assignable to type "OrdinalLinkedList | None" 5 |     "LinkedList[int]" is not assignable to "OrdinalLinkedList" 6 |     "LinkedList[int]" is not assignable to "None" (reportArgumentType) 7 | generics_self_attributes.py:32:8 - error: Cannot assign to attribute "next" for class "OrdinalLinkedList" 8 |   Expression of type "LinkedList[int]" cannot be assigned to attribute "next" of class "OrdinalLinkedList" 9 |     Type "LinkedList[int]" is not assignable to type "OrdinalLinkedList | None" 10 |       "LinkedList[int]" is not assignable to "OrdinalLinkedList" 11 |       "LinkedList[int]" is not assignable to "None" (reportAttributeAccessIssue) 12 | """ 13 | conformance_automated = "Pass" 14 | errors_diff = """ 15 | """ 16 | -------------------------------------------------------------------------------- /conformance/results/pyright/generics_upper_bound.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | generics_upper_bound.py:24:38 - error: TypeVar bound type cannot be generic (reportGeneralTypeIssues) 4 | 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" 5 |   Type "Literal[3]" is not assignable to type "Sized" 6 |     "Literal[3]" is incompatible with protocol "Sized" 7 |       "__len__" is not present (reportArgumentType) 8 | 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" 9 |   Type "Literal[3]" is not assignable to type "Sized" 10 |     "Literal[3]" is incompatible with protocol "Sized" 11 |       "__len__" is not present (reportArgumentType) 12 | generics_upper_bound.py:56:44 - error: TypeVar cannot be both bound and constrained (reportGeneralTypeIssues) 13 | """ 14 | conformance_automated = "Pass" 15 | errors_diff = """ 16 | """ 17 | -------------------------------------------------------------------------------- /conformance/tests/generics_paramspec_basic.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests basic usage of ParamSpec. 3 | """ 4 | 5 | # Specification: https://typing.readthedocs.io/en/latest/spec/generics.html#paramspec-variables 6 | 7 | from typing import Any, Callable, Concatenate, ParamSpec, TypeAlias 8 | 9 | P = ParamSpec("P") # OK 10 | WrongName = ParamSpec("NotIt") # E: name inconsistency 11 | 12 | 13 | # > Valid use locations 14 | 15 | TA1: TypeAlias = P # E 16 | 17 | TA2: TypeAlias = Callable[P, None] # OK 18 | TA3: TypeAlias = Callable[Concatenate[int, P], None] # OK 19 | TA4: TypeAlias = Callable[..., None] # OK 20 | TA5: TypeAlias = Callable[..., None] # OK 21 | 22 | 23 | def func1(x: P) -> P: # E 24 | ... 25 | 26 | 27 | def func2(x: Concatenate[int, P]) -> int: # E 28 | raise NotImplementedError 29 | 30 | 31 | def func3(x: list[P]) -> None: # E 32 | ... 33 | 34 | 35 | def func4(x: Callable[[int, str], P]) -> None: # E 36 | ... 37 | 38 | 39 | def func5(*args: P, **kwargs: P) -> None: # E 40 | ... 41 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/generics_base_class.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not reject inconsistent ordering of type variables in different base classes. 4 | """ 5 | conformance_automated = "Fail" 6 | errors_diff = """ 7 | Line 98: Expected 1 errors 8 | """ 9 | output = """ 10 | 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] 11 | ERROR generics_base_class.py:29:14-24: `Generic` is not allowed in this context [invalid-annotation] 12 | ERROR generics_base_class.py:30:8-15: Expected a type argument for `Generic` [invalid-annotation] 13 | ERROR generics_base_class.py:49:22-42: Expected 1 type argument for `LinkedList`, got 2 [bad-specialization] 14 | ERROR generics_base_class.py:61:18-34: Expected 1 type argument for `MyDict`, got 2 [bad-specialization] 15 | ERROR generics_base_class.py:68:28-29: Duplicated type parameter declaration `T` [invalid-inheritance] 16 | """ 17 | -------------------------------------------------------------------------------- /conformance/results/zuban/generics_defaults_referential.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | generics_defaults_referential.py:36: error: Argument 2 to "Foo" has incompatible type "str"; expected "int" [arg-type] 6 | generics_defaults_referential.py:37: error: Argument 1 to "Foo" has incompatible type "str"; expected "int" [arg-type] 7 | 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] 8 | 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] 9 | generics_defaults_referential.py:68: error: TypeVar default must be a subtype of the bound type [misc] 10 | generics_defaults_referential.py:74: error: TypeVar default must be one of the constraint types [misc] 11 | generics_defaults_referential.py:78: error: TypeVar default must be one of the constraint types [misc] 12 | """ 13 | -------------------------------------------------------------------------------- /conformance/results/mypy/constructors_call_init.toml: -------------------------------------------------------------------------------- 1 | conformant = "Partial" 2 | notes = """ 3 | Does not report errors during binding to self parameter of __init__ method. 4 | Does not reject use of class-scoped type variables in annotation of self parameter in __init__ method. 5 | """ 6 | conformance_automated = "Fail" 7 | errors_diff = """ 8 | Line 56: Expected 1 errors 9 | Line 107: Expected 1 errors 10 | Line 73: Unexpected errors ['constructors_call_init.py:73: error: Expression is of type "Class5[list[int]]", not "Class5[int]" [assert-type]'] 11 | """ 12 | output = """ 13 | constructors_call_init.py:21: error: Argument 1 to "Class1" has incompatible type "float"; expected "int" [arg-type] 14 | constructors_call_init.py:42: error: Argument 1 to "Class3" has incompatible type "Class2[Never]"; expected "Class3 | None" [arg-type] 15 | constructors_call_init.py:73: error: Expression is of type "Class5[list[int]]", not "Class5[int]" [assert-type] 16 | constructors_call_init.py:130: error: Too many arguments for "Class11" [call-arg] 17 | """ 18 | -------------------------------------------------------------------------------- /conformance/results/pyright/generics_defaults.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | output = """ 3 | generics_defaults.py:24:7 - error: "T" cannot appear after "DefaultStrT" in type parameter list because it has no default type (reportGeneralTypeIssues) 4 | generics_defaults.py:50:16 - error: Too few type arguments provided for "AllTheDefaults"; expected 2 but received 1 (reportInvalidTypeArguments) 5 | generics_defaults.py:107:51 - error: TypeVar default type must be a subtype of the bound type (reportGeneralTypeIssues) 6 | generics_defaults.py:114:52 - error: TypeVar default type must be one of the constrained types (reportGeneralTypeIssues) 7 | generics_defaults.py:132:13 - error: "assert_type" mismatch: expected "Any" but received "int" (reportAssertTypeFailure) 8 | generics_defaults.py:143:7 - error: TypeVar "T5" has a default value and cannot follow TypeVarTuple "Ts" (reportGeneralTypeIssues) 9 | """ 10 | conformance_automated = "Pass" 11 | errors_diff = """ 12 | """ 13 | ignore_errors = ["Access to generic instance variable through class is ambiguous"] 14 | -------------------------------------------------------------------------------- /conformance/results/zuban/specialtypes_type.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | specialtypes_type.py:56: error: Argument 1 to "func4" has incompatible type "type[TeamUser]"; expected "type[BasicUser | ProUser]" [arg-type] 6 | specialtypes_type.py:70: error: Argument 1 to "func5" has incompatible type "_SpecialForm"; expected "type[Never]" [arg-type] 7 | specialtypes_type.py:76: error: Invalid type comment or annotation [valid-type] 8 | specialtypes_type.py:117: error: "type[object]" has no attribute "unknown" [attr-defined] 9 | specialtypes_type.py:120: error: "type[object]" has no attribute "unknown" [attr-defined] 10 | specialtypes_type.py:143: error: "_SpecialForm" has no attribute "unknown" [attr-defined] 11 | specialtypes_type.py:144: error: "_SpecialForm" has no attribute "unknown" [attr-defined] 12 | specialtypes_type.py:145: error: "_SpecialForm" has no attribute "unknown" [attr-defined] 13 | specialtypes_type.py:146: error: "_SpecialForm" has no attribute "unknown" [attr-defined] 14 | """ 15 | -------------------------------------------------------------------------------- /conformance/results/pyright/constructors_call_type.toml: -------------------------------------------------------------------------------- 1 | conformant = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | constructors_call_type.py:30:5 - error: Arguments missing for parameters "x", "y" (reportCallIssue) 6 | constructors_call_type.py:40:5 - error: Arguments missing for parameters "x", "y" (reportCallIssue) 7 | constructors_call_type.py:50:5 - error: Arguments missing for parameters "x", "y" (reportCallIssue) 8 | constructors_call_type.py:59:9 - error: Expected 0 positional arguments (reportCallIssue) 9 | constructors_call_type.py:64:9 - error: Expected 0 positional arguments (reportCallIssue) 10 | constructors_call_type.py:72:5 - error: Arguments missing for parameters "x", "y" (reportCallIssue) 11 | constructors_call_type.py:81:5 - error: Argument missing for parameter "y" (reportCallIssue) 12 | constructors_call_type.py:82:12 - error: Argument of type "Literal[2]" cannot be assigned to parameter "y" of type "str" in function "__new__" 13 |   "Literal[2]" is not assignable to "str" (reportArgumentType) 14 | """ 15 | conformance_automated = "Pass" 16 | -------------------------------------------------------------------------------- /conformance/tests/dataclasses_frozen.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests validation of frozen dataclass instances. 3 | """ 4 | 5 | # Specification: https://peps.python.org/pep-0557/#frozen-instances 6 | 7 | from dataclasses import dataclass 8 | 9 | @dataclass(frozen=True) 10 | class DC1: 11 | a: float 12 | b: str 13 | 14 | dc1 = DC1(1, "") 15 | 16 | dc1.a = 1 # E: dataclass is frozen 17 | dc1.b = "" # E: dataclass is frozen 18 | 19 | 20 | # This should generate an error because a non-frozen dataclass 21 | # cannot inherit from a frozen dataclass. 22 | @dataclass # E[DC2] 23 | class DC2(DC1): # E[DC2] 24 | pass 25 | 26 | @dataclass 27 | class DC3: 28 | a: int 29 | 30 | # This should generate an error because a frozen dataclass 31 | # cannot inherit from a non-frozen dataclass. 32 | @dataclass(frozen=True) # E[DC4] 33 | class DC4(DC3): # E[DC4] 34 | pass 35 | 36 | 37 | @dataclass(frozen=True) 38 | class DC1Child(DC1): 39 | # This should be allowed because attributes within a frozen 40 | # dataclass are covariant rather than invariant. 41 | a: int 42 | -------------------------------------------------------------------------------- /conformance/results/pyrefly/generics_syntax_scoping.toml: -------------------------------------------------------------------------------- 1 | conformance_automated = "Pass" 2 | errors_diff = """ 3 | """ 4 | output = """ 5 | ERROR generics_syntax_scoping.py:14:20-31: Type variable bounds and constraints must be concrete [invalid-annotation] 6 | ERROR generics_syntax_scoping.py:18:26-27: Expected a type form, got instance of `int` [not-a-type] 7 | ERROR generics_syntax_scoping.py:35:7-8: `T` is uninitialized [unbound-name] 8 | ERROR generics_syntax_scoping.py:44:17-18: `T` is uninitialized [unbound-name] 9 | ERROR generics_syntax_scoping.py:44:17-18: Expected a type form, got instance of `int` [not-a-type] 10 | ERROR generics_syntax_scoping.py:92:17-18: Type parameter `T` shadows a type parameter of the same name from an enclosing scope [invalid-type-var] 11 | ERROR generics_syntax_scoping.py:95:17-18: Type parameter `T` shadows a type parameter of the same name from an enclosing scope [invalid-type-var] 12 | ERROR generics_syntax_scoping.py:98:17-18: Type parameter `T` shadows a type parameter of the same name from an enclosing scope [invalid-type-var] 13 | """ 14 | --------------------------------------------------------------------------------