Repository navigation
Document error codes - #7451
Document error codes#7451
Conversation
gvanrossum
left a comment
There was a problem hiding this comment.
This is a huge improvement! Because it's a lot of text I have a fair number of nits.
Note that I'm not sure if the lists would look better as a single list -- maybe this is actually the best way to organize them.
|
|
||
| .. code-block:: python | ||
|
|
||
| # Assume 'foo' is defined in 'foolib', even though mypy |
There was a problem hiding this comment.
I'd drop "Assume" and remove the blank line between the comment and the import statememt.
| Mypy checks that an attribute is defined in the target class or module | ||
| when using the dot operator. This applies to both getting and setting | ||
| an attribute. Attribute assignments in the class body or through the | ||
| ``self`` argument in a method define new attributes, and they don't |
There was a problem hiding this comment.
I had to re-read this three times before I found the verb in the first clause ("define"). Maybe reword so the verb comes earlier?
| an attribute. Attribute assignments in the class body or through the | ||
| ``self`` argument in a method define new attributes, and they don't | ||
| generate ``attr-defined`` errors. Mypy doesn't allow defining | ||
| attributes outside a class definition. |
There was a problem hiding this comment.
What even would it mean to define an attribute outside a class? OTOH you mention module attributes, which are defined outside class. :-) Maybe drop this sentence?
| ---------------------- | ||
|
|
||
| Error codes are not displayed by default. Use ``--show-error-codes`` | ||
| to display error codes. Error codes are shown inside square brackets: |
There was a problem hiding this comment.
This flag also ought to be listed in command_line.html#configuring-error-messages and in the corresponding section in config_file.html.
| Mypy performs numerous other, less commonly failing checks that don't | ||
| have specific error codes. These use the ``misc`` error code. Other | ||
| than being used for multiple unrelated errors, the ``misc`` error code | ||
| is not special in other ways. For example, you can ignore all errors |
| ------------------------------------------ | ||
|
|
||
| If you use ``--disallow-any-generics``, mypy requires that each generic | ||
| type has values for each type argument. For example, the types ``List`` or |
| ------------------------------------------------------------ | ||
|
|
||
| If you use ``--disallow-untyped-defs``, mypy requires that each function | ||
| has an annotation (either a Python 3 annotation or a type comment). |
There was a problem hiding this comment.
"that all functions have annotations"
|
I addressed most comments. I left comments to the remaining ones. |
gvanrossum
left a comment
There was a problem hiding this comment.
Agreed on all counts. Ship it!
There's a general page about what error pages and for, and I document each error code that is supported, often with code examples.
There's a general page about what error pages and for, and I document
each error code that is supported, often with code examples.