Skip to content

Use better types for time.get_clock_info#7040

Merged
Akuli merged 6 commits into
python:masterfrom
sobolevn:patch-115
Jan 26, 2022
Merged

Use better types for time.get_clock_info#7040
Akuli merged 6 commits into
python:masterfrom
sobolevn:patch-115

Conversation

@sobolevn

Copy link
Copy Markdown
Member

Demo:

>>> import time
>>> time.get_clock_info('time')
namespace(implementation='clock_gettime(CLOCK_REALTIME)', monotonic=False, adjustable=True, resolution=1.0000000000000002e-06)

>>> time.get_clock_info('other')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: unknown clock

Docs: https://docs.python.org/3/library/time.html#time.get_clock_info

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Comment thread stdlib/time.pyi Outdated
monotonic: bool
resolution: float

def get_clock_info(name: Literal["monotonic", "perf_counter", "process_time", "time"]) -> _ClockInfo: ...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CPython tests also call this with "thread_time". Looking at the C source code, that's the only missing name.

@sobolevn sobolevn Jan 26, 2022

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it is also missing from the tests in some places 🤔
I will investigate! Thank you!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@Akuli
Akuli merged commit 9651f6f into python:master Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants