當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。