| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
|
||
| class GettzFunc(object): | ||
| """ | ||
| gettz is designed not to be a public function. It is defined in a closure as a private function and called once. |
There was a problem hiding this comment.
This is not true. GettzFunc is not a public function. gettz is very much a public function, otherwise it wouldn't be in __all__ and wouldn't be getting any documentation.
Sorry, something went wrong.
There was a problem hiding this comment.
Ah sorry about that. I misunderstood your other comment in the original issue.
Sorry, something went wrong.
|
You seem to have checked in a .DS_STORE file. You should add that to your global gitignore patterns. I think this also needs to be rebased against master: git checkout master
git pull upstream master
git checkout WIP-gettz-documentation
git rebase -i masterIf you don't have an upstream remote already, then you need to do: git remote add upstream git@github.com:dateutil/dateutil.git |
Sorry, something went wrong.
|
Thanks for the quick responses. I'll do another pass as soon as I'm able, but it might take a couple of days. |
Sorry, something went wrong.
add name added PR dateutil#704
|
I rebased my branch, which took a while. I correct the gettz description and added my name in the correct position. Thanks for your help with on this, if you'd like me to fix anything else, please let me know. |
Sorry, something went wrong.
|
Something seems to have gone wrong with the rebase because this PR now includes a bunch of commits unrelated to it. I'll go in there and clean up the history. |
Sorry, something went wrong.
|
Yeah, sorry about that, it was a bit of a mess trying to get all the merge conflicts sorted out. Thanks in advance for cleaning up the history. |
Sorry, something went wrong.
|
OK, I've significantly cleaned up the history, including squashing all the fixup stuff. You'll need to do git pull --force before making any additional changes or pushing to your branch. Also, I noticed that your user.email is set to raymondcha@MacBook-Air-2.local. If that is not the e-mail you use on Github (and I assume it is not), Github won't know to associate those commits with you. If you don't want your e-mail address in the git history, you can set it to weatherpattern@users.noreply.github.com and your commits will be associated with your Github username, if you care about that. I can rewrite the git history to use that e-mail address if you'd prefer. |
Sorry, something went wrong.
| ..code-block:: | ||
|
|
||
| >>> from dateutil.tz import tzutc, UTC | ||
| >>> tgettz('AEST-10AEDT-11,M10.1.0/2,M4.1.0/3') |
There was a problem hiding this comment.
The UTC and tzutc imports are unnecessary, and tgettz is definitely not right.
Sorry, something went wrong.
|
Hi for the clean up. I did a git pull --force and my commit matches upstream, which is a good sign. |
Sorry, something went wrong.
|
OK done. Note that you'll need to do another git pull --force, since I rewrote the history again. |
Sorry, something went wrong.
|
Hello! I removed the import lines and corrected the gettz() typo. Had trouble with the pull --force again but I think I got it sorted out. Thanks for your patience! |
Sorry, something went wrong.
| Given a variety of inputs, like time zone name and ``TZ`` varible, | ||
| return a time zone. | ||
|
|
||
| :param object: |
There was a problem hiding this comment.
This is not actually the interface. GettzFunc is a class representing a callable function. object is the name of the base type of all objects in Python 3 ("new style classes"), and so GettzFunc is a subclass of object for backwards compatibility with Python 2.
I realize it's confusing, but what's being written here is actually the documentation for tz.gettz, which is an instance of GettzFunc, but for practical purposes is equivalent to a function.
When you call tz.gettz(), it actually invokes GettzFunc.__call__, which itself is a thin wrapper around GettzFunc.nocache.
The reason it's built this way is partially for performance reasons, but mostly because I want tz.gettz to satisfy the following invariant:
assert tz.gettz(name) is tz.gettz(name)So I need to store a reference to the arguments that have been passed to tz.gettz and all the results, so that I can return the same object if I get the same arguments. Those get stored on the GettzFunc instance in the _cache. Because you might want the old semantics, I've exposed a "nocache" variant that bypasses the cache: tz.gettz.nocache(name), and since cache misses are identical to calls to nocache, __call__ is implemented in terms of nocache.
There are also functions on gettz for manipulating the cache, like clear_cache.
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for the extended comments. I'm going to a little more time digest and a bit more research and make another pass. More coming.
Do you have an example (could be anywhere) of how much detail you prefer in the docstring?
Sorry, something went wrong.
There was a problem hiding this comment.
OK I took another pass and it's hopefully more accurate now. I also added the assertion as an example.
A couple questions:
Your explanation above was really helpful. Do you want me to make a new issue to put that information into the individual methods and functions as comments?
Also, I wanted to double check:
>>tz.gettz() is tz.gettz() False
This is as designed (I think.) Because if name=None, then the time zone is not cached. Is that correct?
Sorry, something went wrong.
There was a problem hiding this comment.
Do you have an example (could be anywhere) of how much detail you prefer in the docstring?
I'm not really satisfied with the dateutil documentation in general. I personally originated the functions (and hence the docstrings) for isoparse and default_tzinfo, so something like that is likely what I would write, but I actually need to do a full re-organization of the documentation, and I'm not sure where information should go for each function / class.
I'm thinking in the end that however it's organized, somewhere in the documentation, the functions and classes would be documented roughly with a man page level of detail.
Your explanation above was really helpful. Do you want me to make a new issue to put that information into the individual methods and functions as comments?
Sure.
Also, I wanted to double check:
>>> tz.gettz() is tz.gettz
FalseThis is as designed (I think.) Because if name=None, then the time zone is not cached. Is that correct?
Yes and no. Ideally that would be True even for None, but since tz.gettz() represents local time it's made a bit more complicated by the fact that local time might change over the runtime of a program (which leads to a bunch of bugs, but we don't want to add to the bugginess by adding to the problem). As such, I'd rather err on the side of the previous non-cached behavior until we can work out how best to figure out if the "local zone" cache has been invalidated by changes in the execution environment.
Sorry, something went wrong.
There was a problem hiding this comment.
I think at this point the most productive thing would be for me to make an accurate description with the right level of detail. This is a complicated function and it's a bit much to ask anyone else to understand precisely what it does and what it is intended to do.
Sorry, something went wrong.
| A time zone name, a ``TZ`` variable, or ``None``. | ||
|
|
||
| :return: | ||
| A :class:`dateutil.tz.tzfile`. If name is ``None``, |
There was a problem hiding this comment.
This is also not accurate. If you look at the code, it can return tzfile, tzlocal, tzstr, possibly others.
This function is that it takes a string representing a time zone and returns the best-matching tzinfo subclass instance. The specific subclass returned is not part of the function's contract.
Sorry, something went wrong.
| tzlocal_classes += (tzwinlocal,) | ||
|
|
||
| class GettzFunc(object): | ||
| """gettz(name=None) |
There was a problem hiding this comment.
The function prototype will be auto-generated by sphinx and should not be included.
Sorry, something went wrong.
There was a problem hiding this comment.
Maybe there is another way, but without this added line, generating the docs locally, gettz() is returned without the name=None.
Sorry, something went wrong.
|
I agree that it would be good pause and regroup on this. If I can be of help, let me know. Thanks your time and all your responses. |
Sorry, something went wrong.
Add changelog for PR dateutil#704
|
@weatherpattern Thanks for your hard work on this! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary of changes
Added parameters, return and examples to gettz.
Closes #647
Pull Request Checklist