Skip to content

Use better types for time.get_clock_info #7040

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 26, 2022
Merged

Use better types for time.get_clock_info #7040

merged 6 commits into from
Jan 26, 2022

Conversation

sobolevn
Copy link
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.

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

def get_clock_info(name: Literal["monotonic", "perf_counter", "process_time", "time"]) -> _ClockInfo: ...
Copy link
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.

Copy link
Member Author

@sobolevn sobolevn Jan 26, 2022

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
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
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.

None yet

2 participants