Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1c5164f

Browse filesBrowse files
authored
Add from_number for float, complex, and Fraction (3.14) (#14091)
1 parent 9430260 commit 1c5164f
Copy full SHA for 1c5164f

File tree

3 files changed

+9
-3
lines changed
Filter options

3 files changed

+9
-3
lines changed

‎stdlib/@tests/stubtest_allowlists/py314.txt

Copy file name to clipboardExpand all lines: stdlib/@tests/stubtest_allowlists/py314.txt
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ asyncio.tasks.eager_task_factory
2727
builtins.bytearray.resize
2828
builtins.classmethod.__annotate__
2929
builtins.classmethod.__class_getitem__
30-
builtins.complex.from_number
31-
builtins.float.from_number
3230
builtins.int.__round__
3331
builtins.memoryview.__class_getitem__
3432
builtins.staticmethod.__annotate__
@@ -56,7 +54,6 @@ enum.EnumType.__signature__
5654
faulthandler.dump_c_stack
5755
fractions.Fraction.__pow__
5856
fractions.Fraction.__rpow__
59-
fractions.Fraction.from_number
6057
gzip.GzipFile.readinto
6158
gzip.GzipFile.readinto1
6259
gzip.compress

‎stdlib/builtins.pyi

Copy file name to clipboardExpand all lines: stdlib/builtins.pyi
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,9 @@ class float:
400400
def __abs__(self) -> float: ...
401401
def __hash__(self) -> int: ...
402402
def __bool__(self) -> bool: ...
403+
if sys.version_info >= (3, 14):
404+
@classmethod
405+
def from_number(cls, number: float | SupportsIndex | SupportsFloat, /) -> Self: ...
403406

404407
class complex:
405408
# Python doesn't currently accept SupportsComplex for the second argument
@@ -435,6 +438,9 @@ class complex:
435438
def __bool__(self) -> bool: ...
436439
if sys.version_info >= (3, 11):
437440
def __complex__(self) -> complex: ...
441+
if sys.version_info >= (3, 14):
442+
@classmethod
443+
def from_number(cls, number: complex | SupportsComplex | SupportsFloat | SupportsIndex, /) -> Self: ...
438444

439445
class _FormatMapMapping(Protocol):
440446
def __getitem__(self, key: str, /) -> Any: ...

‎stdlib/fractions.pyi

Copy file name to clipboardExpand all lines: stdlib/fractions.pyi
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,6 @@ class Fraction(Rational):
145145
@property
146146
def imag(self) -> Literal[0]: ...
147147
def conjugate(self) -> Fraction: ...
148+
if sys.version_info >= (3, 14):
149+
@classmethod
150+
def from_number(cls, number: float | Rational | _ConvertibleToIntegerRatio) -> Self: ...

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.