-
Notifications
You must be signed in to change notification settings - Fork 324
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
Add screenshot 1342 #2039
base: development
Are you sure you want to change the base?
Add screenshot 1342 #2039
Conversation
changed doc subsection header renamed old subsection
This reverts commit e2c8b46.
…into development
…into development
…into development
…into development
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't speaks to the GL side, but there are some immediate changes I see as room for improvement. Included file in here + some possible improvements.
What about the old |
Is this HiDPI or strange edge cases where non-square pixels exist? To my knowledge, that only exists on ancient platforms, but I figured I should double check. |
* Add screenshot overview + example * Add HasStrftime Protocol type * Add arcade.get_timestamp * Add some cross-referencing between logging and other doc * Add doc on datetime replacements which are nicer for filename templating
* Fix typo in first line * Remove compaction of arcade.get_timestamp link
* Remove extra sentence * Add list item linking the better datetime overview
* Re-order arguments for get_timestamp * Improve default timestamp format string * Add time-machine test helper to pyproject.toml * Add tests for get_timestamp * Update doc to cover changes
* Add %Z to get_timestamp * Add doc on it + cross-refs * Clean datetime test imports
Begin strengthening screenshot PR
…into development
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TL;DR: _TzInfo
is protected and ugly, but so was my previous PR due to pyright breakage. Sorry about that.
I'd run a local pyright check on the changes I proposed. My pyright is broken because of nodejs issues on my distro, sadly. Sorry about my previous PR being a little broken because of it.
arcade/__init__.py
Outdated
@@ -34,6 +35,50 @@ def configure_logging(level: Optional[int] = None): | |||
LOG.addHandler(ch) | |||
|
|||
|
|||
def get_timestamp( | |||
how: str = "%Y_%m_%d_%H%M_%S_%f%Z", | |||
when: Optional[types.HasStrftime | datetime] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Did
HasStrftime
not matchdatetime
? Was it only pyright which complained? - To my understanding, the
|
syntax is a 3.9+ feature, but we support 3.8+
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it didn't. pyright complained for sure, but I don't remember if the build failed due to this check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure? I see references to line 41 in the GitHub CI builds on the previous commits. That's the other line it seems.
arcade/__init__.py
Outdated
@@ -9,7 +9,7 @@ | |||
# Error out if we import Arcade with an incompatible version of Python. | |||
import sys | |||
import os | |||
from datetime import datetime | |||
from datetime import datetime, _TzInfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My initial PR might have been a little busted due to my local nodejs breaking my pyright (I know pyright shouldn't depend on node, but it does 😢). This should work (I think):
from datetime import datetime, _TzInfo | |
from datetime import datetime, tzinfo |
The Python source for the datetime module shows it as a real ABC, and it should be less brittle than _TZInfo
.
arcade/__init__.py
Outdated
when: Optional[types.HasStrftime] = None, | ||
tzinfo: Optional[datetime.tzinfo] = None | ||
when: Optional[types.HasStrftime | datetime] = None, | ||
tzinfo: Optional[_TzInfo] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I removed a top-level datetime
import but left behind the broken property datetime.tzinfo
line earlier. With the import suggestion at the top, I think this should work.
tzinfo: Optional[_TzInfo] = None | |
tzinfo: Optional[tzinfo] = None |
I like having the additional docs. Although, in the past, when people have wanted to do a screenshot we've just pointed them to: image = get_image()
image.save('screenshot.png', 'PNG') This seems like a lot to add to the library for screenshots when two-lines can also run a screenshot. If we do add it, can we get some unit tests? |
TL;DR:
The Precedent is 2-3 Feature Exposures
In the past, we slowly added features to the top-level namespace,
Why Do It For Screenshots?
Unit Tests
Can you elaborate? We already have some here: If you'd like, we add some to explicitly cover |
…into development
…into development
We can revisit this in 3.x. Let's keep this PR around. There's things like docs in there that can be salvaged. |
Fixes #1342