Skip to content

Migrate messages.py to ErrorMessage class #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: base
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 24 additions & 22 deletions mypy/errorcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ def __str__(self) -> str:
CALL_ARG: Final[ErrorCode] = ErrorCode(
"call-arg", "Check number, names and kinds of arguments in calls", "General"
)
ARG_TYPE: Final = ErrorCode("arg-type", "Check argument types in calls", "General")
ARG_TYPE: Final[ErrorCode] = ErrorCode("arg-type", "Check argument types in calls", "General")
CALL_OVERLOAD: Final = ErrorCode(
"call-overload", "Check that an overload variant matches arguments", "General"
)
VALID_TYPE: Final[ErrorCode] = ErrorCode(
"valid-type", "Check that type (annotation) is valid", "General"
)
VAR_ANNOTATED: Final = ErrorCode(
VAR_ANNOTATED: Final[ErrorCode] = ErrorCode(
"var-annotated", "Require variable annotation if type can't be inferred", "General"
)
OVERRIDE: Final = ErrorCode(
OVERRIDE: Final[ErrorCode] = ErrorCode(
"override", "Check that method override is compatible with base class", "General"
)
RETURN: Final[ErrorCode] = ErrorCode(
Expand All @@ -54,28 +54,30 @@ def __str__(self) -> str:
RETURN_VALUE: Final[ErrorCode] = ErrorCode(
"return-value", "Check that return value is compatible with signature", "General"
)
ASSIGNMENT: Final = ErrorCode(
ASSIGNMENT: Final[ErrorCode] = ErrorCode(
"assignment", "Check that assigned value is compatible with target", "General"
)
TYPE_ARG: Final[ErrorCode] = ErrorCode(
"type-arg", "Check that generic type arguments are present", "General"
)
TYPE_VAR: Final = ErrorCode("type-var", "Check that type variable values are valid", "General")
UNION_ATTR: Final = ErrorCode(
UNION_ATTR: Final[ErrorCode] = ErrorCode(
"union-attr", "Check that attribute exists in each item of a union", "General"
)
INDEX: Final = ErrorCode("index", "Check indexing operations", "General")
OPERATOR: Final = ErrorCode("operator", "Check that operator is valid for operands", "General")
LIST_ITEM: Final = ErrorCode(
INDEX: Final[ErrorCode] = ErrorCode("index", "Check indexing operations", "General")
OPERATOR: Final[ErrorCode] = ErrorCode(
"operator", "Check that operator is valid for operands", "General"
)
LIST_ITEM: Final[ErrorCode] = ErrorCode(
"list-item", "Check list items in a list expression [item, ...]", "General"
)
DICT_ITEM: Final = ErrorCode(
DICT_ITEM: Final[ErrorCode] = ErrorCode(
"dict-item", "Check dict items in a dict expression {key: value, ...}", "General"
)
TYPEDDICT_ITEM: Final = ErrorCode(
TYPEDDICT_ITEM: Final[ErrorCode] = ErrorCode(
"typeddict-item", "Check items when constructing TypedDict", "General"
)
HAS_TYPE: Final = ErrorCode(
HAS_TYPE: Final[ErrorCode] = ErrorCode(
"has-type", "Check that type of reference can be determined", "General"
)
IMPORT: Final = ErrorCode(
Expand All @@ -84,22 +86,22 @@ def __str__(self) -> str:
NO_REDEF: Final[ErrorCode] = ErrorCode(
"no-redef", "Check that each name is defined once", "General"
)
FUNC_RETURNS_VALUE: Final = ErrorCode(
FUNC_RETURNS_VALUE: Final[ErrorCode] = ErrorCode(
"func-returns-value", "Check that called function returns a value in value context", "General"
)
ABSTRACT: Final = ErrorCode(
ABSTRACT: Final[ErrorCode] = ErrorCode(
"abstract", "Prevent instantiation of classes with abstract attributes", "General"
)
VALID_NEWTYPE: Final[ErrorCode] = ErrorCode(
"valid-newtype", "Check that argument 2 to NewType is valid", "General"
)
STRING_FORMATTING: Final = ErrorCode(
STRING_FORMATTING: Final[ErrorCode] = ErrorCode(
"str-format", "Check that string formatting/interpolation is type-safe", "General"
)
STR_BYTES_PY3: Final = ErrorCode(
"str-bytes-safe", "Warn about dangerous coercions related to bytes and string types", "General"
)
EXIT_RETURN: Final = ErrorCode(
EXIT_RETURN: Final[ErrorCode] = ErrorCode(
"exit-return", "Warn about too general return type for '__exit__'", "General"
)
LITERAL_REQ: Final = ErrorCode(
Expand All @@ -110,29 +112,29 @@ def __str__(self) -> str:
NO_UNTYPED_DEF: Final[ErrorCode] = ErrorCode(
"no-untyped-def", "Check that every function has an annotation", "General"
)
NO_UNTYPED_CALL: Final = ErrorCode(
NO_UNTYPED_CALL: Final[ErrorCode] = ErrorCode(
"no-untyped-call",
"Disallow calling functions without type annotations from annotated functions",
"General",
)
REDUNDANT_CAST: Final = ErrorCode(
REDUNDANT_CAST: Final[ErrorCode] = ErrorCode(
"redundant-cast", "Check that cast changes type of expression", "General"
)
COMPARISON_OVERLAP: Final = ErrorCode(
COMPARISON_OVERLAP: Final[ErrorCode] = ErrorCode(
"comparison-overlap", "Check that types in comparisons and 'in' expressions overlap", "General"
)
NO_ANY_UNIMPORTED: Final = ErrorCode(
NO_ANY_UNIMPORTED: Final[ErrorCode] = ErrorCode(
"no-any-unimported", 'Reject "Any" types from unfollowed imports', "General"
)
NO_ANY_RETURN: Final = ErrorCode(
NO_ANY_RETURN: Final[ErrorCode] = ErrorCode(
"no-any-return",
'Reject returning value with "Any" type if return type is not "Any"',
"General",
)
UNREACHABLE: Final = ErrorCode(
UNREACHABLE: Final[ErrorCode] = ErrorCode(
"unreachable", "Warn about unreachable statements or expressions", "General"
)
REDUNDANT_EXPR: Final = ErrorCode(
REDUNDANT_EXPR: Final[ErrorCode] = ErrorCode(
"redundant-expr", "Warn about redundant expressions", "General", default_enabled=False
)
TRUTHY_BOOL: Final[ErrorCode] = ErrorCode(
Expand Down
Loading