Add screenshot 1342#2039
Add screenshot 1342#2039sabadam32 wants to merge 46 commits intopythonarcade:developmentfrom sabadam32:add_screenshot_1342
Conversation
pushfoo
left a comment
There was a problem hiding this comment.
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
pushfoo
left a comment
There was a problem hiding this comment.
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
|
|
||
| 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.
- Did
HasStrftimenot 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.
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.
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
| import sys | ||
| import os | ||
| from datetime import datetime | ||
| from datetime import datetime, _TzInfo |
There was a problem hiding this comment.
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.
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 |
|
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