Skip to content

Manual ruff fixes#6

Merged
Kalmat merged 9 commits into
masterfrom
Manual-ruff-fixes
Jun 29, 2026
Merged

Manual ruff fixes#6
Kalmat merged 9 commits into
masterfrom
Manual-ruff-fixes

Conversation

@Avasam

@Avasam Avasam commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

@Avasam Avasam requested a review from Kalmat June 24, 2026 19:02
Base automatically changed from Add-full-tests-+-Ruff-autofixes to master June 24, 2026 22:19
@Kalmat

Kalmat commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Hi! I completely forgot this PR! Sorry... I hope it's not a problem for you.

I realized while reviewing this module that it was wrong. I focused in the window area functionality (which is the one used by PyWinCtl) but not much in the screen area one. When using the module for screen areas (similar to PyGame.Rect object), it was confusing and hard to properly use.

Since I had to update it to imprve it anyway, I took the opportunity to include other additional methods that I left unuploaded about 2 years ago, as well as improving the docs. However, I am not generating a new version on PyPi yet, since I have to fully test everything first.

Again, I hope it's not a problem. If it is, please let me know what can I do to help.

@Avasam

Avasam commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator Author

No problem, take your time. Always a good thing if the recent wave of changes and reviews made you realize things to improve :)

The main big improvements I'm going for right now that will be useful to me are:

  • General performance improvements (very small, but a few loops got optimized, less imports, etc.)
  • Removing typing_extensions from runtime imports
  • Typing and tests cleanups, so it's easier for you to maintain, whilst keeping correctness
  • Python 3.15 lazy imports support (not done yet)

@Kalmat

Kalmat commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Awesome!

You are totally right that this new wave is really a boost, since one can look same things with new eyes.

I have (hopefully) improved all modules docs. I am also working in your suggestions for PyWinCtl (as well as adapting it to this new PyWinBox version). This will take me longer, since I have to test everything, though my environment is... well, not prepared as it was, let's say.

Thanks!

@Kalmat

Kalmat commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Sorry. Your last checks for this PR failed because of a mistake of mine (not typing self._clamp variable, no more and no less). I am not touching anything else until you finish this PR!!! Promissed... XD

@Kalmat Kalmat merged commit b574e3a into master Jun 29, 2026
40 checks passed
@Avasam Avasam deleted the Manual-ruff-fixes branch June 29, 2026 20:27
@Kalmat

Kalmat commented Jun 30, 2026

Copy link
Copy Markdown
Owner

Hi! Sorry to use this way to contact you (I don't know how to do it otherwise).

I've trying to properly type handle variable in PyWinBox classes inside _main.py file, but not sure if it is right.

TypeAlias does not exist in typing module for Python3.9, so I had to use a TYPE_CHECKING block, and then import TypeAlias from type_extensions... Is this OK (I believe you wanted to get rid of these blocks and execution dependencies)? Is there any other (better) way? We can always let it untyped, as it was.

Thanks for your help!

@Avasam

Avasam commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

Just as a quick context before my answer:
Type checkers can't clearly differentiate between a value assignment, and a type alias, but they try to guess ! That's why using TypeAlias is not always needed, and sometimes you have to.

So yes, using TypeAlias annotation to explicitly identify a type alias is correct. You have to use the typing_extensions backport on Python 3.9, and you have to lock it behind if TYPE_CHECKING to avoid a runtime dependency.

As long as you string-quote your annotations, the symbols won't be evaluated at runtime

# Ambiguous alias, type checkers may not be happy or think this is a value assignement
SomethingParam = Sequence[str]
# TypeAlias gets evaluated, breaks because the symbol isn't imported at runtime
SomethingParam: TypeAlias = Sequence[str]
# TypeAlias doesn't get evaluated
SomethingParam: "TypeAlias" = Sequence[str]
from __future__ import annotations
# TypeAlias doesn't get evaluated, because all annotations in this file are auto-quoted
SomethingParam: TypeAlias = Sequence[str]
# Python 3.12+ syntax
type SomethingParam = Sequence[str]

Btw, if you ever want me to validate some code, you can open a PR and request me as a reviewer, makes it easy to show the changes and comment on specific lines.

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.

2 participants