cost 176 ms
使用 Python 中的类型模块为具有多个返回类型和条件的函数创建泛型类型提示的正确方法是什么? - What is the correct way to create a generic type hint for functions with multiple return types and conditions using the typing module in Python?

在使用pyright工具进行类型检查时,我遇到了以下问题。 (Python 3.11,版权 1.1.310) 我的代码:class TypeCast(str, enum.Enum): STRING = str FLOAT = float def cast_int_to_str( ...

为什么不带字段和带 NotRequired 字段的 TypedDict 类型不兼容? - Why are TypedDict types without field and with NotRequired field incompatible?

我正在尝试创建一些函数,这些函数将返回不同 TypedDict 类型的值。 它们中的大多数字段都是相同的,所以我想在所有情况下生成具有相同 function 的基本字典。 但是我被正确输入这个问题难住了。 我的想法是创建基本类型Parent并从中继承,只添加NotRequired字段。 然而,这失 ...

Python PyDash 'find' function 返回 Any 而不是传递的数据类型 - Python PyDash 'find' function returns Any instead of passed data type

在我的案例中,逻辑要复杂得多,但归结起来就是这样。 我有一个数据类实例列表。 根据该列表,我正在进行搜索。 当我直接访问实例时,属性建议和类型提示起作用。 但是当我使用 PyDash(就像 JavaScript 中的 Lodash)的“find”方法时,无论内部传递什么,它都会返回“Any”类型。 ...


 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM