Python
Java
PHP
IOS
Android
Nodejs
JavaScript
Html5
Windows
Ubuntu
Linux
isinstance 如何用于 List?
我试图了解 Python 的类型注释是如何工作的 例如List and Dict not list or dict 具体来说 我感兴趣的是如何isinstance list List 有效 这样我就可以创建自己的自定义注释 我看到List定
python
python3x
metaclass
typehinting
isinstance
mypy 错误:赋值中的类型不兼容(表达式的类型为“Dict[
,
]”,目标的类型为“List[str]”)
我尝试过了实例化一个空字典在现有字典的第二层上 然后为其分配一个键值对 但 MyPy 会抛出错误 这是一个最小的示例 当激活 MyPy 检查时它将重现它 result Test something result key result key
python
typehinting
mypy
pythontyping
如何获取类变量和类型提示?
假设我定义一个类 其中包含带有类型提示的类级别变量 例如新的 python 3 7dataclasses class Person name str age int def parse me self what do I do here 我
python
typehinting
mypy 在参数化泛型中 isinstance 和 issubclass 从 python 3.5 到 3.6 的差异
在我从 python 3 5 升级到 python 3 6 之前 这是有效的 import typing issubclass list typing List int returns True isinstance 1 2 3 typin
python
python3x
typehinting
typing
mypy
类型提示闭包参数
通过 PHP 中的类型提示 是否可以对闭包的参数进行类型提示 例如 function some function Closure
php
closures
typehinting
什么类型提示同时包含列表和元组?
我有一个函数可以接受任何可以索引的变量作为输入 例如列表或元组 如何在函数的类型提示中指出这一点 你的方法正在接受sequence https docs python org 3 glossary html term sequence 所以
python
python3x
typehinting
支持 __getitem__ 的类的 Python 类型提示
我想向一个函数添加类型提示 该函数将接受带有 getitem 方法 例如 在 def my function hasitems locator hasitems locator 我不想限制hasitems成为特定类型 例如list or d
python
typehinting
pythontyping
一种出于类型检查目的而对 NamedTuple 进行子类化的方法
我有一些namedtuple共享一些字段 我有一个接受这些元组的函数 并保证只与共享字段交互 我想在 mypy txt 中对此类代码进行类型检查 代码示例如下 from typing import NamedTuple class Base
python
typehinting
mypy
pythontyping
namedtuple
python3.8中的最终注释和装饰器
由于 Python 3 8 即将发布 我只是想知道两者之间的区别最终装饰器和最终注释 在 Python 3 8 中 Python 类型提示功能 体现为typing module https docs python org 3 library
python3x
typehinting
python38
是否可以“提示”字典键?
In PyCharm 代码完成 https www jetbrains com help pycharm auto completing code html gt 基本完成 gt 调用基本完成 gt 字典 我发现 如果您将字典硬编码为某些值
python
pycharm
typehinting
mypy,类型提示:Union[float, int] -> 是否有 Number 类型?
mypy 确实很方便并且捕获了很多错误 但是当我编写 科学 应用程序时 我经常最终会这样做 def my func number Union float int Do something number是 float 或 int 具体取决于用
python
typehinting
mypy
pythontyping
uniontypes
PHP7 中类型声明之前的问号(?string 或?int)的用途是什么?
你能告诉我这个怎么称呼吗 string and string 使用示例 public function string parameter1 string parameter2 我想了解一些关于它们的知识 但我在 PHP 文档和 google
php
php7
typehinting
为什么 Final 字典不能用作 TypedDict 中的文字?
我正在尝试完成以下任务 请参阅 from typing import TypedDict Final account schema Final name str email str Account TypedDict Account acc
python
Dictionary
typehinting
mypy
pythontyping
使用类型提示时无法传递 null 参数
以下代码 class Type function foo Type t foo null 运行时失败 PHP 致命错误 传递给 foo 的参数 1 不能为 null 为什么不允许像其他语言一样传递null PHP 7 1 或更高版本 201
php
typehinting
关闭“Python 版本 3.5 不支持变量注释”错误消息
我刚刚将 PyCharm 更新到最新版本 但一直遇到此错误消息的问题 基本上 我无法关闭 Python 版本 3 5 不支持变量注释 的错误消息 我的默认和项目解释器是 Python 3 6 我什至没有在 PyCharm 中添加 Pytho
python
types
pycharm
python36
typehinting
使用描述符进行类型提示
In 这个拉取请求 https github com python mypy pull 2266看起来添加了对描述符的类型提示支持 然而 似乎没有发布最终的 正确 用法示例 也没有添加任何文档到typing module https doc
python
python3x
typehinting
mypy
pythondescriptors
在类定义中使用类自己的类型[重复]
这个问题在这里已经有答案了 以下代码无法按预期工作 显然 我不能在类定义中使用类自己的类型 class Foo def init self key str gt None self key key def eq self other Foo
python
typehinting
mypy
PHP 7 - 不支持声明“strict_types”
我在一个小项目中使用 PHP 7 也在我的本地和生产服务器中使用相同的配置 一切都在我的本地服务器上工作 但在完成 LAMP 设置后在生产服务器上我无法在 etc php 7 0 apache 下找到 apache 文件夹 所以我遇到了内部
php
apache
typehinting
为什么我会收到 mypy no overrides of "zip" matches argument 错误?
我有一个带有方法的类 class TimeUtilitiesTestCase def test date and delta self gt None Tests date and delta utility method now date
python
python3x
typehinting
mypy
具有两个或多个返回参数的函数注释
当我为返回一个参数的函数编写注释时 没有任何问题 def func gt str return ok 但是 当我编写带有两个或更多参数的注释时 我的 PyCharm 给了我SyntaxError invalid syntax def fun
python
python3x
typehinting
1
2
3
4
5
6
»