-
Notifications
You must be signed in to change notification settings - Fork 24k
Remove Python 2 datetime compat fallbacks #81874
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
Remove Python 2 datetime compat fallbacks #81874
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
b64732e
to
4d16dc3
Compare
4d16dc3
to
a36fdaa
Compare
a36fdaa
to
4875507
Compare
This comment was marked as resolved.
This comment was marked as resolved.
4875507
to
f6f8075
Compare
f6f8075
to
4c9b5e5
Compare
This comment was marked as resolved.
This comment was marked as resolved.
0b5fcdb
to
b6c3f8d
Compare
b6c3f8d
to
886af13
Compare
So the CI failure is 01:24 _____________________ test_deprecate_without_list[stdin0] ______________________
01:24 [gw0] linux -- Python 3.12.0 /usr/bin/python3.12
01:24
01:24 am = <ansible.module_utils.basic.AnsibleModule object at 0x7fca11c53530>
01:24 capfd = <_pytest.capture.CaptureFixture object at 0x7fca11c2dfd0>
01:24
01:24 @pytest.mark.parametrize('stdin', [{}], indirect=['stdin'])
01:24 def test_deprecate_without_list(am, capfd):
01:24 with pytest.raises(SystemExit):
01:24 am.exit_json(deprecations='Simple deprecation warning')
01:24
01:24 out, err = capfd.readouterr()
01:24 output = json.loads(out)
01:24 E
01:24 E ...Full output truncated (21 lines hidden), use '-vv' to show
01:24
01:24 test/units/module_utils/basic/test_deprecate_warn.py:67: AssertionError Which is weird because I cannon reproduce it locally with |
Aha.. So $ while :; do if ! bin/ansible-test units --docker --python 3.12 -vvvvvv --debug -- test/units/module_utils/; then break; fi; done |
Reduced the repro to $ while :; do if ! bin/ansible-test units --docker --python 3.12 -vvvvvv --debug -- test/units/module_utils/basic/test_deprecate_warn.py test/units/module_utils/compat/test_datetime.py; then break; fi; done |
Apparently, |
886af13
to
16354c1
Compare
@mattclay should we only deprecate the |
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.
It's too early to deprecate this, since collections may need it for compatibility across multiple non-EOL versions of ansible-core. Instead of deprecating it, add a deprecated comment (detected by pylint) so we can defer deprecation until 2.16 (the first version with this module_util) is the oldest non-EOL version.
@mattclay so I wasn't sure about deprecating since most of these aren't exact implementations of what's in stdlib. |
Thanks for the hint to check other modules. Recording the findings for history: $ rg compat\\.datetime
lib/ansible/modules/wait_for.py
241:from ansible.module_utils.compat.datetime import utcnow
lib/ansible/modules/uri.py
446:from ansible.module_utils.compat.datetime import utcnow, utcfromtimestamp
lib/ansible/modules/get_url.py
379:from ansible.module_utils.compat.datetime import utcnow, utcfromtimestamp
lib/ansible/module_utils/compat/datetime.py
49: msg=f'The `ansible.module_utils.compat.datetime.{importable_name}` ' |
1a6bd2e
to
3b2a88b
Compare
This comment was marked as resolved.
This comment was marked as resolved.
3b2a88b
to
62e7c45
Compare
@mattclay I think I tracked down everything. |
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.
Include a changelog fragment for the deprecation.
Co-authored-by: Matt Clay <matt@mystile.com>
2e833d9
to
4c3bf05
Compare
This patch marks the `ansible.module_utils.compat.datetime` module as deprecated, including `UTC`, `utcfromtimestamp()` and `utcnow` shims that it provides, scheduling its removal for v2.21. It also replaces any uses of the compatibility helpers with non-deprecated calls to CPython stdlib. PR ansible#81874 Co-authored-by: Matt Clay <matt@mystile.com>
SUMMARY
$sbj.
ISSUE TYPE
ADDITIONAL INFORMATION
N/A