当前位置: 首页>>代码示例>>Python>>正文


Python typing.SupportsFloat方法代码示例

本文整理汇总了Python中typing.SupportsFloat方法的典型用法代码示例。如果您正苦于以下问题:Python typing.SupportsFloat方法的具体用法?Python typing.SupportsFloat怎么用?Python typing.SupportsFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在typing的用法示例。


在下文中一共展示了typing.SupportsFloat方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _arithm_convert

# 需要导入模块: import typing [as 别名]
# 或者: from typing import SupportsFloat [as 别名]
def _arithm_convert(self, node: NodeNG, method: str, t1: type, t2: type) -> Optional[TypeInfo]:
        if t1 is complex and t2 is complex:
            common_type = complex
        elif ((t1 is complex and issubclass(t2, typing.SupportsFloat)) or
                (t2 is complex and issubclass(t1, typing.SupportsFloat))):
            # TODO: handle complex better. Looks like int, float don't
            # support typing.SupportsComplex.
            common_type = complex
        elif ((t1 is float and issubclass(t2, typing.SupportsFloat)) or
                (t2 is float and issubclass(t1, typing.SupportsFloat))):
            common_type = float
        else:
            common_type = None

        if common_type:
            return self._handle_call(node, method, common_type, common_type)
        else:
            return None 
开发者ID:pyta-uoft,项目名称:pyta,代码行数:20,代码来源:type_inference_visitor.py

示例2: test_supports_float

# 需要导入模块: import typing [as 别名]
# 或者: from typing import SupportsFloat [as 别名]
def test_supports_float(self):
        assert issubclass(float, typing.SupportsFloat)
        assert not issubclass(str, typing.SupportsFloat) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:5,代码来源:test_typing.py

示例3: scalar

# 需要导入模块: import typing [as 别名]
# 或者: from typing import SupportsFloat [as 别名]
def scalar(x: Union[SupportsFloat, str, bytes]) -> float:
        from . import lib
        return lib.floating_point(x) 
开发者ID:fuzzylite,项目名称:pyfuzzylite,代码行数:5,代码来源:operation.py

示例4: floating_point

# 需要导入模块: import typing [as 别名]
# 或者: from typing import SupportsFloat [as 别名]
def floating_point(self, value: Union[SupportsFloat, str, bytes]) -> float:
        return self.floating_point_type(value) 
开发者ID:fuzzylite,项目名称:pyfuzzylite,代码行数:4,代码来源:library.py

示例5: test_supports_float

# 需要导入模块: import typing [as 别名]
# 或者: from typing import SupportsFloat [as 别名]
def test_supports_float(self):
        self.assertIsSubclass(float, typing.SupportsFloat)
        self.assertNotIsSubclass(str, typing.SupportsFloat) 
开发者ID:ShikyoKira,项目名称:Project-New-Reign---Nemesis-Main,代码行数:5,代码来源:test_typing.py

示例6: write_config

# 需要导入模块: import typing [as 别名]
# 或者: from typing import SupportsFloat [as 别名]
def write_config(**config: Dict[str, Union[str, SupportsFloat, bool]]) -> None:
    """
    Updates the existing local config with the given additional arguments

    ### Parameters:

    - `config`: the new configuration items to add to the configuration

    """
    existing = get_config()
    for key, val in config.items():
        existing[key] = val
    with open(os.path.expanduser("~/maildown.toml"), "w") as f:
        f.write(toml.dumps(config)) 
开发者ID:chris104957,项目名称:maildown,代码行数:16,代码来源:utilities.py

示例7: __new__

# 需要导入模块: import typing [as 别名]
# 或者: from typing import SupportsFloat [as 别名]
def __new__(cls: Type, value: SupportsFloat, unit: str) -> 'Float_Units_Ugly':
        obj = cast('Float_Units_Ugly', cast(type, super()).__new__(cls, float(value)))
        obj.unit = unit
        return obj 
开发者ID:PacktPublishing,项目名称:Mastering-Object-Oriented-Python-Second-Edition,代码行数:6,代码来源:ch03_ex4.py

示例8: __new__

# 需要导入模块: import typing [as 别名]
# 或者: from typing import SupportsFloat [as 别名]
def __new__(cls: Type, value: SupportsFloat, unit: str) -> "Float_Units_Ugly":
        # print(f"Float_Units_Ugly {cls}")
        obj = cast("Float_Units_Ugly", cast(type, super()).__new__(cls, float(value)))
        obj.unit = unit
        return obj 
开发者ID:PacktPublishing,项目名称:Mastering-Object-Oriented-Python-Second-Edition,代码行数:7,代码来源:ch03_ex5.py


注:本文中的typing.SupportsFloat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。