-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Add error codes to many additional messages #7334
Merged
+583
−91
Merged
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
c48ee62
Update error code of invalid argument messages
JukkaL 2fe6373
Change error code for invalid argument types
JukkaL 09c3570
Update error code of invalid type messages
JukkaL 836d2ae
Add error codes for missing variable annotation
JukkaL d15923a
Change error code of invalid override errors
JukkaL 08b98dd
Give error code for incompatible return value type
JukkaL 7283416
Change error code for incompatible assignments
JukkaL a0f96f2
Change error code for missing generic type argument
JukkaL 512fe64
Change error message for missing union attribute + fix self check
JukkaL f4638e9
Update test case
JukkaL bec13f3
Update error code when function annotation is missing
JukkaL a43e048
Update error code when calling an unannotated function
JukkaL 0a0f490
Fix some has no attribute error codes
JukkaL 6fb597b
Add error code for indexing operations
JukkaL 9335b28
Add error code for incompatible type variable value
JukkaL c33a5ef
Add error codes to binary and unary operations
JukkaL 0b11215
Add error codes for invalid list/dict items
JukkaL 5b464d2
Add error codes for TypedDict literals
JukkaL b036992
Add error code when cannot determine type
JukkaL 18d7730
Add error code for redundant cast
JukkaL 3b55d70
Add test cases
JukkaL 6f06f23
Add error code for non-overlapping comparisons
JukkaL 88a5cfb
Add error code for missing module/stub
JukkaL b2eb60e
Add error code for invalid callable
JukkaL 73b8b74
Improve test case
JukkaL 5efb120
Add code for syntax error in type comment
JukkaL e3c10cd
Add more error codes for syntax errors in types
JukkaL 9815a59
Add error code to errors about redefinition
JukkaL 4ac28e0
Add error code for missing return statement
JukkaL 63758e6
Fix bug
JukkaL 92e5794
Add error code for function not returning a value
JukkaL f6befe4
Add error code for instantiating a class with abstract attributes
JukkaL 6db278c
Add error code for invalid NewType base types
JukkaL c364741
Add error code for no matching overload item
JukkaL 195e58d
Add error code for Any from unfollowed import
JukkaL 8a1a399
Add error code for incorrectly returning Any
JukkaL 6efdd30
Remove debug print
JukkaL 7cef388
Try to fix mypyc
JukkaL 1bec9c0
Add feedback
JukkaL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,22 +29,77 @@ def __str__(self) -> str: | |
'call-arg', "Check number, names and kinds of arguments in calls", 'General') # type: Final | ||
ARG_TYPE = ErrorCode( | ||
'arg-type', "Check argument types in calls", 'General') # type: Final | ||
CALL_OVERLOAD = ErrorCode( | ||
'call-overload', "Check that an overload variant matches arguments", 'General') # type: Final | ||
VALID_TYPE = ErrorCode( | ||
'valid-type', "Check that type (annotation) is valid", 'General') # type: Final | ||
MISSING_ANN = ErrorCode( | ||
VAR_ANNOTATED = ErrorCode( | ||
'var-annotated', "Require variable annotation if type can't be inferred", | ||
'General') # type: Final | ||
OVERRIDE = ErrorCode( | ||
'override', "Check that method override is compatible with base class", | ||
'General') # type: Final | ||
RETURN = ErrorCode( | ||
'return', "Check that function always returns a value", 'General') # type: Final | ||
RETURN_VALUE = ErrorCode( | ||
'return-value', "Check that return value is compatible with signature", | ||
'General') # type: Final | ||
ASSIGNMENT = ErrorCode( | ||
'assignment', "Check that assigned value is compatible with target", 'General') # type: Final | ||
TYPE_ARG = ErrorCode( | ||
'type-arg', "Check that generic type arguments are present", 'General') # type: Final | ||
TYPE_VAR = ErrorCode( | ||
'type-var', "Check that type variable values are valid", 'General') # type: Final | ||
UNION_ATTR = ErrorCode( | ||
'union-attr', "Check that attribute exists in each item of a union", 'General') # type: Final | ||
INDEX = ErrorCode( | ||
'index', "Check indexing operations", 'General') # type: Final | ||
OPERATOR = ErrorCode( | ||
'operator', "Check that operator is valid for operands", 'General') # type: Final | ||
LIST_ITEM = ErrorCode( | ||
'list-item', "Check list items in a list expression [item, ...]", 'General') # type: Final | ||
DICT_ITEM = ErrorCode( | ||
'dict-item', | ||
"Check dict items in a dict expression {key: value, ...}", 'General') # type: Final | ||
TYPEDDICT_ITEM = ErrorCode( | ||
'typeddict-item', "Check items when constructing TypedDict", 'General') # type: Final | ||
HAS_TYPE = ErrorCode( | ||
'has-type', "Check that type of reference can be determined", 'General') # type: Final | ||
IMPORT = ErrorCode( | ||
'import', "Require that imported module can be found or has stubs", 'General') # type: Final | ||
NO_REDEF = ErrorCode( | ||
'no-redef', "Check that each name is defined once", 'General') # type: Final | ||
FUNC_RETURNS_VALUE = ErrorCode( | ||
'func-returns-value', "Check that called function returns a value in value context", | ||
'General') # type: Final | ||
ABSTRACT = ErrorCode( | ||
'abstract', "Prevent instantiation of classes with abstract attributes", | ||
'General') # type: Final | ||
VALID_NEWTYPE = ErrorCode( | ||
'valid-newtype', "Check that argument 2 to NewType is valid", 'General') # type: Final | ||
|
||
# These error codes aren't enable by default. | ||
NO_UNTYPED_DEF = ErrorCode( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am just curious why the below block is separated with an empty line. Maybe add a comment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. These errors aren't enabled by default. |
||
'no-untyped-def', "Check that every function has an annotation", 'General') # type: Final | ||
NO_UNTYPED_CALL = ErrorCode( | ||
'no-untyped-call', | ||
"Disallow calling functions without type annotations from annotated functions", | ||
'General') # type: Final | ||
REDUNDANT_CAST = ErrorCode( | ||
'redundant-cast', "Check that cast changes type of expression", 'General') # type: Final | ||
COMPARISON_OVERLAP = ErrorCode( | ||
'comparison-overlap', | ||
"Check that types in comparisons and 'in' expressions overlap", 'General') # type: Final | ||
NO_ANY_UNIMPORTED = ErrorCode( | ||
'no-any-unimported', 'Reject "Any" types from unfollowed imports', 'General') # type: Final | ||
NO_ANY_RETURN = ErrorCode( | ||
'no-any-return', 'Reject returning value with "Any" type if return type is not "Any"', | ||
'General') # type: Final | ||
|
||
# Syntax errors are often blocking. | ||
SYNTAX = ErrorCode( | ||
'syntax', "Report syntax errors", 'General') # type: Final | ||
|
||
# This is a catch-all for remaining uncategorized errors. | ||
MISC = ErrorCode( | ||
'misc', "Miscenallenous other checks", 'General') # type: Final |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have the same code for all ill-defined
NewType
s not just specifically second argument?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error seems to be much more common than any other
NewType
-related errors, so I think it's worth having an error code for specifically this case.