Skip to content

Conversation

@henryiii
Copy link
Contributor

Some cleanup, focused on some things 3.11 provides.

  • chore: cleanup for 3.11+
  • chore: use StrEnum from Python 3.11
  • chore: some cleanup from ruff --preview checks

@henryiii henryiii force-pushed the henryiii/chore/cleanup311 branch from 2c489f7 to 64e75d8 Compare February 12, 2025 20:20
@joerick
Copy link
Contributor

joerick commented Feb 28, 2025

I had a thought - can we remove from __future__ import annotations now? I can't remember how all that shook out but I think annotations are deferred by default now? Maybe worth trying it and seeing what breaks!

@henryiii
Copy link
Contributor Author

henryiii commented Feb 28, 2025

I think you are referring to Python π making them lazy by default? However, we might not need the annotations because the main reason it's used is to enable invalid expressions that became valid in 3.9 and 3.10 (and stuff that is often better spelled as Self). So I could try and see.

String annotations are still slightly faster, but not measurably for something like cibuildwheel. ;)

@joerick
Copy link
Contributor

joerick commented Feb 28, 2025

Ahh, yeah it's the expression thing. So we might still want it to use more modern type features than exist in 3.11. So I guess 3.14 is where it's gonna get simple again :)

@henryiii henryiii force-pushed the henryiii/chore/cleanup311 branch from e3c7af3 to 1e83f5c Compare February 28, 2025 17:33
@henryiii
Copy link
Contributor Author

henryiii commented Feb 28, 2025

I removed from __future__ import annotations. A few places needed strings, lots of things I moved to Self, and I was able to remove the one place we were using TYPE_CHECKING since the thing it was protecting was valid on 3.10+. A few things needed reordering since the class must exist before it's in an annotation.

I also added the Path checks, and fixed all of them except the open -> Path.open one, which I ignored for now, as it would require more changes.

@henryiii henryiii force-pushed the henryiii/chore/cleanup311 branch from 1e83f5c to ac248bb Compare February 28, 2025 17:38
@henryiii
Copy link
Contributor Author

(PS: I can split this up, commits are kept focused on one-ish thing. The future import one is large enough to be a PR if you'd rather)

Copy link
Contributor

@joerick joerick left a comment

Choose a reason for hiding this comment

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

Looks good to me.


@staticmethod
def native_arch(platform: PlatformName) -> Architecture | None:
def native_arch(platform: PlatformName) -> "Architecture | None":
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI, I tried Self on these (with @classmethod), but typing didn't seem to understand that enum is final (even if you tell it it's final), so it sees cls.wasm32 as Architecture.wasm32 and therefore not Self. Wrapping it in an extra cls() does make it happy, but cls(cls.wasm32) just to make the type checker happy wasn't worth it. Just added strings here instead of Self. It's technically correct since enums are always final.

if moved_wheel != output_wheel.resolve():
log.warning(
"{repaired_wheel} was moved to {moved_wheel} instead of {output_wheel}"
f"{repaired_wheel} was moved to {moved_wheel} instead of {output_wheel}"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a fix, I believe.

@henryiii henryiii merged commit 708cf1d into pypa:main Feb 28, 2025
26 checks passed
@henryiii henryiii deleted the henryiii/chore/cleanup311 branch February 28, 2025 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants