Skip to content

Comments

[refurb] Manual timezone monkeypatching (FURB162)#16113

Merged
MichaReiser merged 7 commits intoastral-sh:mainfrom
InSyncWithFoo:um
Feb 18, 2025
Merged

[refurb] Manual timezone monkeypatching (FURB162)#16113
MichaReiser merged 7 commits intoastral-sh:mainfrom
InSyncWithFoo:um

Conversation

@InSyncWithFoo
Copy link
Contributor

@InSyncWithFoo InSyncWithFoo commented Feb 12, 2025

Summary

Part of #1348.

FURB162 reports datetime.fromisoformat() calls where the lone argument is of one of the following forms:

  • date.replace("Z", <zero_offset>)
  • date[:-1] + <zero_offset>
  • date.strip("Z") + <zero_offset>/date.rstrip("Z") + <zero_offset>

...and where <zero_offset> is a string literal whose content is one of 00:00, 0000 or 00 prefixed with + or -.

Before Python 3.11, this was necessary, as .fromisoformat() wasn't able to handle strings with Z as the affix. Now it can.

The logic was taken from that of the upstream rule.

Test Plan

cargo nextest run and cargo insta test.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@MichaReiser MichaReiser added rule Implementing or modifying a lint rule preview Related to preview mode features labels Feb 12, 2025
Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you

@MichaReiser MichaReiser merged commit 711af0d into astral-sh:main Feb 18, 2025
21 checks passed
@InSyncWithFoo InSyncWithFoo deleted the um branch February 18, 2025 13:46
dcreager added a commit that referenced this pull request Feb 18, 2025
* main: (60 commits)
  [`refurb`] Manual timezone monkeypatching (`FURB162`) (#16113)
  [`pyupgrade`] Do not upgrade functional TypedDicts with private field names to the class-based syntax (`UP013`) (#16219)
  Improve docs for PYI019 (#16229)
  Refactor `CallOutcome` to `Result` (#16161)
  Fix minor punctuation errors (#16228)
  Include document specific debug info (#16215)
  Update server to return the debug info as string (#16214)
  [`airflow`] Group `ImportPathMoved` and `ProviderName` to avoid misusing (`AIR303`) (#16157)
  Fix unstable formatting of trailing end-of-line comments of parenthesized attribute values (#16187)
  Ignore source code actions for a notebook cell (#16154)
  Add FAQ entry for `source.*` code actions in Notebook (#16212)
  red-knot: move symbol lookups in `symbol.rs` (#16152)
  better error messages while loading configuration `extend`s (#15658)
  Format `index.css` (#16207)
  Improve API exposed on `ExprStringLiteral` nodes (#16192)
  Update Rust crate tempfile to v3.17.0 (#16202)
  Update cloudflare/wrangler-action action to v3.14.0 (#16203)
  Update NPM Development dependencies (#16199)
  Update Rust crate smallvec to v1.14.0 (#16201)
  Update Rust crate codspeed-criterion-compat to v2.8.0 (#16200)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview Related to preview mode features rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants