Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[TYP] Change typing for texts to StrLike#26867

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
oscargus wants to merge1 commit intomatplotlib:main
base:main
Choose a base branch
Loading
fromoscargus:texttyping

Conversation

oscargus
Copy link
Member

@oscargusoscargus commentedSep 22, 2023
edited
Loading

PR summary

Related to#26858.

It is a bit unintuitive (maybe) to change like this, but apparently people are relying onset_text making thestr-conversion.

Setting as draft for now as we probably should discuss it (and I have most likely missed some).

Additional classes/methods to change:

  • Annotation/annotate
  • TextArea
  • Figure.text
  • QuiverKey (label)
  • set_title etc.

PR checklist

@timhoffm
Copy link
Member

timhoffm commentedSep 22, 2023
edited
Loading

One can see this as similar to %s or f-strings, where the parameter is implicitly converted to str. OTOH I'm reluctant to officially broaden the type to Any. This would be very general, and IHMO would loose the semantic aspect of the type definition.
The automatic str conversion decision may be intentional and for convenience. Due to compatibility, we're bound to the behavior whether we want or not. But I'm inclined to regard this rather as a gone-public implementation detail that we have to support, and not as an intended feature that we want to advertise.

Therefore, at least for the docstrings, I'm very much in favor of keepingstr. It may be a technical solution to make a type aliasStrLike = Any for annotations in this case, including a description why we use that. That'd be a somewhat simpler solution than thepropsedSupportsStr protocol. It would placate the type system for current code, but still carry the semantics.

oscargus and story645 reacted with thumbs up emoji

@oscargusoscargus changed the title[TYP] Change typing for texts to Any/object[TYP] Change typing for texts to StrLikeDec 18, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@oscargus@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp