Python
Java
PHP
IOS
Android
Nodejs
JavaScript
Html5
Windows
Ubuntu
Linux
从 Python 中的类元信息对 __init__ 函数进行类型提示
我想做的是复制什么SQLAlchemy确实 以其DeclarativeMeta班级 有了这段代码 from sqlalchemy import Column Integer String from sqlalchemy ext declar
python
sqlalchemy
pycharm
typehinting
Python 类型提示:typing.Mapping 与typing.Dict
我正在开发一个 python 项目 我们使用typing整个模块类型提示 看来我们用的是typing Dict and typing Mapping几乎可以互换 有理由选择其中一种而不是另一种吗 我自己设法回答了这个问题 typing Di
python
python3x
typehinting
如何在类型提示中定义元组或列表的大小
有没有办法在参数的类型提示中定义元组或列表的大小 目前我正在使用这样的东西 from typing import List Optional Tuple def function name self list1 List Class1 if
python
python3x
tuples
parameterpassing
typehinting
有没有办法完全忽略特定项目包中的所有 MyPy 错误?
有没有办法忽略我的项目中某些包中的所有错误 我的项目中的一些代码是编译的 Protocol Buffers 代码 但未通过 MyPy 检查 它全部位于目录 myproj generated proto 中 这是我的 mypy 配置文件中的内
python
typehinting
mypy
PHP 7 上可以指定多个返回类型吗?
我有一些可以返回的方法两种返回类型之一 我正在使用利用 MCV 的框架 因此重构这几个函数尤其没有吸引力 是否可以声明返回类型返回其中之一而在其他情况下失败 function test if this gt condition false
php
php7
typehinting
“char”/“character”类型的类型提示
char 或 character 没有内置的原始类型 因此显然必须使用长度为 1 的字符串 但是为了暗示这一点并暗示它应该被视为一个字符 如何通过类型提示来实现这一点 grade chr A 一种方法可能是使用内置的 chr 函数来表示这一
python
python3x
typehinting
定义 types.Dict 和 dict 之间的区别?
我正在练习使用 Python 3 5 中的类型提示 我的一位同事使用typing Dict import typing def change bandwidths new bandwidths typing Dict user id int
python
Dictionary
typehinting
pythontyping
具有类型提示的 const 方法的 python 等效项
我正在尝试找到 c 的 python 等价物const方法 那是 方法是禁止的改变any他们班级的数据成员 from typing import Final age Final 2 age 3 lt warn about this work
python
constants
typehinting
mypy
为什么 PHP 中不允许“传统”类型提示?
刚刚发现类型提示 http php net manual en language oop5 typehinting phpPHP 中允许 但不适用于整数 字符串 布尔值或浮点数 为什么 PHP 不允许对整数 字符串等类型进行类型提示 从 P
php
typehinting
类型提示:解决循环依赖
以下产生NameError name Client is not defined 我该如何解决 class Server def register client self client Client pass class Client de
python
typehinting
pythontyping
为什么类型提示“float”接受“int”,而它甚至不是子类?
一方面 我了解到数字可以int or float应将类型注释为float 来源 PEP 484 类型提示 https www python org dev peps pep 0484 the numeric tower and 这个计算器问
python
unions
typehinting
Pylance:“property”与“int”不兼容
from typing extensions import Protocol class IFoo Protocol value int class Foo IFoo property def value self gt int retur
python
interface
gettersetter
typehinting
pylance
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
1
2
3
4
5
6
7
»