Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在不同的机器上用mypy扫描包会产生不同的结果_Python_Typing_Mypy - Fatal编程技术网

Python 在不同的机器上用mypy扫描包会产生不同的结果

Python 在不同的机器上用mypy扫描包会产生不同的结果,python,typing,mypy,Python,Typing,Mypy,我试图使用vim中的ALE插件和命令行上的mypy键入check并获得不一致的结果 更新:在下面@aaron的评论之后,我在另一台机器上签出了代码,它按预期工作:我在那里得到的错误比在我的主开发机器上更多。所以vim内部的ALE给我的结果与另一台机器上的过程相同。我不明白为什么 两者都应该给我相同的结果,但我注意到ALE给我的结果比命令行多。我想知道调用mypy的CLI有什么不对 设置和环境以重现我所经历的行为(不需要ALE): 克隆上面链接的存储库并签出修订版4fb26c4e5b 运行pyt

我试图使用vim中的ALE插件和命令行上的
mypy
键入check并获得不一致的结果

更新:在下面@aaron的评论之后,我在另一台机器上签出了代码,它按预期工作:我在那里得到的错误比在我的主开发机器上更多。所以vim内部的ALE给我的结果与另一台机器上的过程相同。我不明白为什么

两者都应该给我相同的结果,但我注意到ALE给我的结果比命令行多。我想知道调用
mypy
的CLI有什么不对

设置和环境以重现我所经历的行为(不需要ALE):

  • 克隆上面链接的存储库并签出修订版
    4fb26c4e5b
  • 运行
    python3-m-venv-env
  • 运行
    /env/bin/pip安装-e.
  • 运行
    /env/bin/pip安装mypy
现在,使用此环境,键入检查目录
puresnmp
将产生以下结果:

$ ./env/bin/mypy puresnmp
puresnmp/aio/api/raw.py:505: error: Type signature has too few arguments
puresnmp/api/pythonic.py:239: error: Type signature has too few arguments
puresnmp/api/raw.py:490: error: Type signature has too few arguments
puresnmp/test/asyncmock.py:18: error: 'yield' in async function
Found 4 errors in 4 files (checked 38 source files)
使用
/env/bin/mypy puresnmp/***.py
/env/bin/mypy-p puresnmp
生成与上述相同的报告

但是,当显式指定文件时,我会得到更多的错误(恰好与ALE错误相对应):

$。/env/bin/mypy puresnmp/api/pythonic.py
puresnmp/x690/types.pyi:58:错误:“from_bytes”的返回类型“Union[Null,UnknownType]”与超类型“type”中的返回类型“type[bytes]”不兼容
puresnmp/transport.py:83:错误:“Timeout”的参数1具有不兼容的类型“str”;应为“int”
puresnmp/pdu.py:178:错误:“Sequence”的参数2具有不兼容的类型“Union[str,bytes,int,datetime,timedelta,None];应为“类型[任何]”
puresnmp/pdu.py:217:错误:在Python 3上'%s'%b'abc'产生“b'abc';如果这是所需的行为,请使用%r
puresnmp/pdu.py:253:错误:“VarBind”的参数2具有不兼容的类型“Null”;应为“联合[str,bytes,int,datetime,timedelta,None]”
puresnmp/pdu.py:316:错误:“VarBind”的参数2具有不兼容的类型“Null”;应为“联合[str,bytes,int,datetime,timedelta,None]”
puresnmp/pdu.py:320:错误:“Sequence”的参数2具有不兼容的类型“Union[str,bytes,int,datetime,timedelta,None];应为“类型[任何]”
puresnmp/pdu.py:365:错误:在Python 3上'%s'%b'abc'产生“b'abc';如果这是所需的行为,请使用%r
puresnmp/api/raw.py:104:错误:不兼容的返回值类型(获取“列表[Union[ObjectIdentifier,Union[str,bytes,int,datetime,timedelta,None]]”,应为“列表[type[Union[str,bytes,int,datetime,timedelta,None]]”)
puresnmp/api/raw.py:160:错误:“VarBind”的参数1具有不兼容的类型“Union[ObjectIdentifier,Union[str,bytes,int,datetime,timedelta,None]”;应为“联合[ObjectIdentifier,str]”
puresnmp/api/raw.py:160:错误:“VarBind”的参数2具有不兼容的类型“Union[ObjectIdentifier,Union[str,bytes,int,datetime,timedelta,None]”;应为“联合[str,bytes,int,datetime,timedelta,None]”
puresnmp/api/raw.py:164:错误:<(“ObjectIdentifier”)的左操作数类型不受支持
puresnmp/api/raw.py:317:错误:“VarBind”的参数2具有不兼容的类型“type[Union[str,bytes,int,datetime,timedelta,None]”;应为“联合[str,bytes,int,datetime,timedelta,None]”
puresnmp/api/raw.py:336:错误:返回值类型不兼容(获取“Dict[str,Union[ObjectIdentifier,Union[str,bytes,int,datetime,timedelta,None]]”,应为“Dict[str,type[Union[str,bytes,int,datetime,timedelta,None]]”)
puresnmp/api/raw.py:460:错误:赋值中的类型不兼容(表达式的类型为“Union[ObjectIdentifier,Union[str,bytes,int,datetime,timedelta,None]”,目标的类型为“Union[str,bytes,int,datetime,timedelta,None]”)
puresnmp/api/raw.py:490:错误:类型签名的参数太少
puresnmp/api/raw.py:566:错误:“len”的参数1具有不兼容的类型“ObjectIdentifier”;预期“大小”
puresnmp/api/raw.py:570:错误:“tablify”的参数1具有不兼容的类型“List[VarBind]”;应为“Iterable[Tuple[Any,Any]]”
puresnmp/api/raw.py:587:错误:“len”的参数1具有不兼容的类型“ObjectIdentifier”;预期“大小”
puresnmp/api/pythonic.py:104:错误:“Union[ObjectIdentifier,str,bytes,int,datetime,timedelta,None,Any]”的项“str”没有属性“pythonize”
puresnmp/api/pythonic.py:104:错误:“Union[ObjectIdentifier,str,bytes,int,datetime,timedelta,None,Any]”的项“bytes”没有属性“pythonize”
puresnmp/api/pythonic.py:104:错误:“Union[ObjectIdentifier,str,bytes,int,datetime,timedelta,None,Any]”的项“int”没有属性“pythonize”
puresnmp/api/pythonic.py:104:错误:“Union[ObjectIdentifier,str,bytes,int,datetime,timedelta,None,Any]”的项目“datetime”没有属性“pythonize”
puresnmp/api/pythonic.py:104:错误:“Union[ObjectIdentifier,str,bytes,int,datetime,timedelta,None,Any]”的项“timedelta”没有属性“pythonize”
puresnmp/api/pythonic.py:104:错误:“Union[ObjectIdentifier,str,bytes,int,datetime,timedelta,None,Any]”的项“None”没有属性“pythonize”
puresnmp/api/pythonic.py:154:错误:“VarBind”的参数1具有不兼容的类型“Union[ObjectIdentifier,Union[str,bytes,int,datetime,timedelta,None]”;应为“联合[ObjectIdentifier,str]”
puresnmp/api/pythonic.py:154:错误:“Union[ObjectIdentifier,Union[str,bytes,int,datetime,timedelta,None]”的项“str”没有属性“pythonize”
puresnmp/api/pythonic.py:154:错误:“Union[ObjectIdentifier,Union[str,bytes,int,datetime,timedelta,None]”的项“bytes”没有属性“pythonize”
puresnmp/api/pythonic.py:154:错误:“Union[ObjectIdentifier,Union[str,bytes,int,datetime,timedelta,None]”的项“int”没有属性“pythonize”
puresnmp/api/pythoni
$ ./env/bin/mypy puresnmp/api/pythonic.py
puresnmp/x690/types.pyi:58: error: Return type "Union[Null, UnknownType]" of "from_bytes" incompatible with return type "Type[bytes]" in supertype "Type"
puresnmp/transport.py:83: error: Argument 1 to "Timeout" has incompatible type "str"; expected "int"
puresnmp/pdu.py:178: error: Argument 2 to "Sequence" has incompatible type "Union[str, bytes, int, datetime, timedelta, None]"; expected "Type[Any]"
puresnmp/pdu.py:217: error: On Python 3 '%s' % b'abc' produces "b'abc'"; use %r if this is a desired behavior
puresnmp/pdu.py:253: error: Argument 2 to "VarBind" has incompatible type "Null"; expected "Union[str, bytes, int, datetime, timedelta, None]"
puresnmp/pdu.py:316: error: Argument 2 to "VarBind" has incompatible type "Null"; expected "Union[str, bytes, int, datetime, timedelta, None]"
puresnmp/pdu.py:320: error: Argument 2 to "Sequence" has incompatible type "Union[str, bytes, int, datetime, timedelta, None]"; expected "Type[Any]"
puresnmp/pdu.py:365: error: On Python 3 '%s' % b'abc' produces "b'abc'"; use %r if this is a desired behavior
puresnmp/api/raw.py:104: error: Incompatible return value type (got "List[Union[ObjectIdentifier, Union[str, bytes, int, datetime, timedelta, None]]]", expected "List[Type[Union[str, bytes, int, datetime, timedelta, None]]]")
puresnmp/api/raw.py:160: error: Argument 1 to "VarBind" has incompatible type "Union[ObjectIdentifier, Union[str, bytes, int, datetime, timedelta, None]]"; expected "Union[ObjectIdentifier, str]"
puresnmp/api/raw.py:160: error: Argument 2 to "VarBind" has incompatible type "Union[ObjectIdentifier, Union[str, bytes, int, datetime, timedelta, None]]"; expected "Union[str, bytes, int, datetime, timedelta, None]"
puresnmp/api/raw.py:164: error: Unsupported left operand type for < ("ObjectIdentifier")
puresnmp/api/raw.py:317: error: Argument 2 to "VarBind" has incompatible type "Type[Union[str, bytes, int, datetime, timedelta, None]]"; expected "Union[str, bytes, int, datetime, timedelta, None]"
puresnmp/api/raw.py:336: error: Incompatible return value type (got "Dict[str, Union[ObjectIdentifier, Union[str, bytes, int, datetime, timedelta, None]]]", expected "Dict[str, Type[Union[str, bytes, int, datetime, timedelta, None]]]")
puresnmp/api/raw.py:460: error: Incompatible types in assignment (expression has type "Union[ObjectIdentifier, Union[str, bytes, int, datetime, timedelta, None]]", target has type "Type[Union[str, bytes, int, datetime, timedelta, None]]")
puresnmp/api/raw.py:490: error: Type signature has too few arguments
puresnmp/api/raw.py:566: error: Argument 1 to "len" has incompatible type "ObjectIdentifier"; expected "Sized"
puresnmp/api/raw.py:570: error: Argument 1 to "tablify" has incompatible type "List[VarBind]"; expected "Iterable[Tuple[Any, Any]]"
puresnmp/api/raw.py:587: error: Argument 1 to "len" has incompatible type "ObjectIdentifier"; expected "Sized"
puresnmp/api/pythonic.py:104: error: Item "str" of "Union[ObjectIdentifier, str, bytes, int, datetime, timedelta, None, Any]" has no attribute "pythonize"
puresnmp/api/pythonic.py:104: error: Item "bytes" of "Union[ObjectIdentifier, str, bytes, int, datetime, timedelta, None, Any]" has no attribute "pythonize"
puresnmp/api/pythonic.py:104: error: Item "int" of "Union[ObjectIdentifier, str, bytes, int, datetime, timedelta, None, Any]" has no attribute "pythonize"
puresnmp/api/pythonic.py:104: error: Item "datetime" of "Union[ObjectIdentifier, str, bytes, int, datetime, timedelta, None, Any]" has no attribute "pythonize"
puresnmp/api/pythonic.py:104: error: Item "timedelta" of "Union[ObjectIdentifier, str, bytes, int, datetime, timedelta, None, Any]" has no attribute "pythonize"
puresnmp/api/pythonic.py:104: error: Item "None" of "Union[ObjectIdentifier, str, bytes, int, datetime, timedelta, None, Any]" has no attribute "pythonize"
puresnmp/api/pythonic.py:154: error: Argument 1 to "VarBind" has incompatible type "Union[ObjectIdentifier, Union[str, bytes, int, datetime, timedelta, None]]"; expected "Union[ObjectIdentifier, str]"
puresnmp/api/pythonic.py:154: error: Item "str" of "Union[ObjectIdentifier, Union[str, bytes, int, datetime, timedelta, None]]" has no attribute "pythonize"
puresnmp/api/pythonic.py:154: error: Item "bytes" of "Union[ObjectIdentifier, Union[str, bytes, int, datetime, timedelta, None]]" has no attribute "pythonize"
puresnmp/api/pythonic.py:154: error: Item "int" of "Union[ObjectIdentifier, Union[str, bytes, int, datetime, timedelta, None]]" has no attribute "pythonize"
puresnmp/api/pythonic.py:154: error: Item "datetime" of "Union[ObjectIdentifier, Union[str, bytes, int, datetime, timedelta, None]]" has no attribute "pythonize"
puresnmp/api/pythonic.py:154: error: Item "timedelta" of "Union[ObjectIdentifier, Union[str, bytes, int, datetime, timedelta, None]]" has no attribute "pythonize"
puresnmp/api/pythonic.py:154: error: Item "object" of "Union[ObjectIdentifier, Union[str, bytes, int, datetime, timedelta, None]]" has no attribute "pythonize"
puresnmp/api/pythonic.py:169: error: Argument 1 to "VarBind" has incompatible type "Union[ObjectIdentifier, Union[str, bytes, int, datetime, timedelta, None]]"; expected "Union[ObjectIdentifier, str]"
puresnmp/api/pythonic.py:169: error: Item "str" of "Union[ObjectIdentifier, Union[str, bytes, int, datetime, timedelta, None]]" has no attribute "pythonize"
puresnmp/api/pythonic.py:169: error: Item "bytes" of "Union[ObjectIdentifier, Union[str, bytes, int, datetime, timedelta, None]]" has no attribute "pythonize"
puresnmp/api/pythonic.py:169: error: Item "int" of "Union[ObjectIdentifier, Union[str, bytes, int, datetime, timedelta, None]]" has no attribute "pythonize"
puresnmp/api/pythonic.py:169: error: Item "datetime" of "Union[ObjectIdentifier, Union[str, bytes, int, datetime, timedelta, None]]" has no attribute "pythonize"
puresnmp/api/pythonic.py:169: error: Item "timedelta" of "Union[ObjectIdentifier, Union[str, bytes, int, datetime, timedelta, None]]" has no attribute "pythonize"
puresnmp/api/pythonic.py:169: error: Item "object" of "Union[ObjectIdentifier, Union[str, bytes, int, datetime, timedelta, None]]" has no attribute "pythonize"
puresnmp/api/pythonic.py:185: error: Argument 1 to "VarBind" has incompatible type "Union[ObjectIdentifier, Union[str, bytes, int, datetime, timedelta, None]]"; expected "Union[ObjectIdentifier, str]"
puresnmp/api/pythonic.py:239: error: Type signature has too few arguments
puresnmp/api/pythonic.py:258: error: The return type of a generator function should be "Generator" or one of its supertypes
puresnmp/api/pythonic.py:272: error: Argument 1 to "len" has incompatible type "ObjectIdentifier"; expected "Sized"
puresnmp/api/pythonic.py:282: error: The return type of a generator function should be "Generator" or one of its supertypes
puresnmp/api/pythonic.py:296: error: Argument 1 to "len" has incompatible type "ObjectIdentifier"; expected "Sized"
Found 45 errors in 5 files (checked 1 source file)