Another option is to fix this error rather than suppressing it.
Such errors happen when you use classes or attributes, or functions that exist in the .py
file but are not defined in the appropriate .pyi
file. In other words, such errors happen on inconsistencies between the source code and the type hint stub. In your case, the _STRUCT
class was defined in the struct_pb2.py
, but was not defined in the .pyi
file supplied by Pyre developers, i.e., /pyre_check/typeshed/third_party/2and3/google/protobuf/struct_pb2.pyi
.
In such cases, you may try to obtain the .pyi
files from the developers of the appropriate package and replace the files in the pyre typeshed
directory. However, the .pyi
files provided by the developers of packages usually do not annotate classes or methods that start with _
. According to PEP 8 -- Style Guide for Python Code | Python.org a name beginning with a single underscore is reserved for internal use
_single_leading_underscore: weak "internal use" indicator. E.g., from M import * does not import objects whose names start with an
underscore.
Modules that are designed for use via from M import * should use the
all mechanism to prevent exporting globals, or use the older convention of prefixing such globals with an underscore (which you
might want to do to indicate these globals are "module non-public").
Use one leading underscore only for non-public methods and instance
variables.
Public attributes should have no leading underscores.
internal interfaces (packages, modules, classes, functions, attributes
or other names) should still be prefixed with a single leading
underscore.
If you cannot get the update .pyi file from the developers, or it does not contain definitions for names prefixed with an underscore, you may add these names yourself to the .pyi file supplied by Pyre developers.
There also a small hint at Errors | Pyre (pyre-check.org)