Skip to content
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

gh-97955: Migrate zoneinfo to Argument Clinic #97958

Merged
merged 1 commit into from Oct 7, 2022
Merged

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Oct 6, 2022

I am not sure that it is worth converting these functions:

    {"utcoffset", (PyCFunction)zoneinfo_utcoffset, METH_O,
     PyDoc_STR("Retrieve a timedelta representing the UTC offset in a zone at "
               "the given datetime.")},
    {"dst", (PyCFunction)zoneinfo_dst, METH_O,
     PyDoc_STR("Retrieve a timedelta representing the amount of DST applied "
               "in a zone at the given datetime.")},
    {"tzname", (PyCFunction)zoneinfo_tzname, METH_O,
     PyDoc_STR("Retrieve a string containing the abbreviation for the time "
               "zone that applies in a zone at a given datetime.")},
    {"fromutc", (PyCFunction)zoneinfo_fromutc, METH_O,
     PyDoc_STR("Given a datetime with local time in UTC, retrieve an adjusted "
               "datetime in local time.")},

Because they don't have any argument parsing logic in them.
Just improving the signature? If this is desired, I can send an extra PR later :)

New help output:

>>> import _zoneinfo
>>> help(_zoneinfo.ZoneInfo)
Help on class ZoneInfo in module zoneinfo:

class ZoneInfo(datetime.tzinfo)
 |  Method resolution order:
 |      ZoneInfo
 |      datetime.tzinfo
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __reduce__(...)
 |      Function for serialization with the pickle protocol.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __str__(self, /)
 |      Return str(self).
 |
 |  dst(...)
 |      Retrieve a timedelta representing the amount of DST applied in a zone at the given datetime.
 |
 |  fromutc(...)
 |      Given a datetime with local time in UTC, retrieve an adjusted datetime in loca
l time.
 |
 |  tzname(...)
 |      Retrieve a string containing the abbreviation for the time zone that applies i
n a zone at a given datetime.
 |
 |  utcoffset(...)
 |      Retrieve a timedelta representing the UTC offset in a zone at the given dateti
me.
 |
 |  ----------------------------------------------------------------------
 |  Class methods defined here:
 |
 |  __init_subclass__(...) from builtins.type
 |      Function to initialize subclasses.
 |
 |  clear_cache(*, only_keys=None) from builtins.type
 |      Clear the ZoneInfo cache.
 |
 |  from_file(file_obj, /, key=None) from builtins.type
 |      Create a ZoneInfo file from a file object.
 |
 |  no_cache(key) from builtins.type
 |      Get a new instance of ZoneInfo, bypassing the cache.
 |
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |
 |  __new__(*args, **kwargs) from builtins.type
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  key

@ambv ambv merged commit 24a6645 into python:main Oct 7, 2022
mpage pushed a commit to mpage/cpython that referenced this pull request Oct 11, 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

4 participants