-
Notifications
You must be signed in to change notification settings - Fork 194
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
Overload fast_plain_mtext
to different return types depending on split=
#1172
Overload fast_plain_mtext
to different return types depending on split=
#1172
Conversation
bswck-hai
commented
Sep 23, 2024
•
edited
Loading
edited
- Type checked the code.
@mozman Please review. |
Thanks for your contribution, but currently I integrate only bug fixes for more information see my latest posting #1175. |
Union, | ||
Optional, | ||
Callable, | ||
NamedTuple, | ||
Any, | ||
overload, |
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.
has to be imported from typing_extensions
, not available in Python 3.9 (requires 3.11)
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.
typing.overload
is part of PEP 484 and has always been in the typing
module.
@@ -9,11 +9,13 @@ | |||
Iterable, | |||
Iterator, | |||
TYPE_CHECKING, | |||
Literal, |
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.
from typing_extensions?
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.
Why? Literal
has been there since Python 3.8, ezdxf
supports 3.9+.
# pylint: disable-next=too-many-branches | ||
def fast_plain_mtext(text: str, split=False) -> Union[list[str], str]: | ||
def fast_plain_mtext(text: str, split: bool = False) -> Union[list[str], str]: |
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.
I don't add bool
for such cases, type inference by False
and True
, shorter signatures are better, therefore return list[str]|str
.
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.
I'd argue that shorter signatures aren't better when compared against actually accurate signatures.
Type inference from False
is Any
in mypy (not mentioning it erroring in strict mode).
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.
therefore return
list[str]|str
Migrating to PEP 604 is a topic for a different PR.
Thank you, you are right on all points, but I'm afraid I don't want to deal with this or any future contributions from you. |
I'm very sorry to have caused you feel this way.
I agree that my replies weren't necessarily kind. Please forgive the tone I am sometimes having, I didn't intend this personally. Are we good now?
|
@mozman could you please reopen this? |