handle-typing#7
Conversation
The following 3 issues can be upvoted to resolve this inconsistency between mypy and Ruff: |
| if sys.platform != "linux": | ||
| raise OSError(f"Cannot import {__name__} on {sys.platform}") |
There was a problem hiding this comment.
👍
I'm surprised I hadn't done this change in this repo, I think I did so everywhere else.
Anyway it's more explicit, and won't get stripped out with python -O
There was a problem hiding this comment.
Do not discard it was myself messing around with updates, pushes, PRs, new branches... I am trying to learn as fast as I can (e.g. I was completely terrified when I made this PR... it's the first time I do it, so I was really scared to break something). Thank you for your patience!
| _HandleTypeIn :TypeAlias = Union[tuple[str, str], AppKit.NSWindow, None] | ||
| _HandleTypeOut :TypeAlias = Union[_macOSNSHandle, _macOSCGHandle, None] |
There was a problem hiding this comment.
- _HandleTypeIn :TypeAlias = Union[tuple[str, str], AppKit.NSWindow, None]
- _HandleTypeOut :TypeAlias = Union[_macOSNSHandle, _macOSCGHandle, None]
+ _HandleTypeIn: TypeAlias = Union[tuple[str, str], AppKit.NSWindow, None]
+ _HandleTypeOut: TypeAlias = Union[_macOSNSHandle, _macOSCGHandle, None]Have you considered using a formatter? Formatting on save can also be run by your editor (just like Ruff autofixes on save).
Options:
- This exact case would've been caught by https://docs.astral.sh/ruff/rules/whitespace-before-punctuation/, I haven't enabled all pycodestyle (
E) rules yet (by default they're not all enabled, ref, because some are covered by the Ruff formatter, which also isn't enabled in your repos) - Using the Ruff Formatter Ruff has it's own formatter (based on Black style). Since Ruff is already in the repo, you can avoid considering Black entirely (similar styles).
- If you don't like the Black/Ruff formatter style, autopep8 is one I liked for a long time, autopep8 is technically more of an autofixer for Flake8's pycodestyle (E) rules. So most (but not all) would be covered by option 1 anyway. (Completing and promoting autopep8 parity astral-sh/ruff#9057 (comment) for more details on which style rules have autofixes)
There was a problem hiding this comment.
Unfortunately I know nothing about formatters (first time I hear about them). I will give a try to autopep8 (I have already installed and configured it on PyCharm). Thank you for your suggestion!!!
There was a problem hiding this comment.
If you're wondering about the separation of concerns between a linter (with autofixes) and a formatter, here's a great writeup: https://typescript-eslint.io/users/what-about-formatting/
Feel free to play around with styles of autopep8 (pydocstyle autofixes), Ruff formatter (strongly opinionated, mostly follows Black style), or yapf (literally "Yet Another Python Formatter," based on clang-format).
This is my attempt to propery type
handlevariable. Not sure if it is right.Apart from this, you changed this:
by this:
assert sys.platform == "linux"but I had to revert it back because of ruff complaining:
import not at top of the file