本文整理匯總了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
示例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)
示例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)
示例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)
示例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)
示例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))
示例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
示例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