Skip to content
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

pygments: Correct Formatter generics #7435

Closed
wants to merge 1 commit into from

Conversation

not-my-profile
Copy link
Contributor

933fec0 made
pygments.formatter.Formatter generic to improve the type-safety
of pygments.format() and pygments.highlight().

The actual pygments.formatter.Formatter however is not generic,
meaning that pygments.formatter.Formatter[str] should not type check
(since it leads to a runtime type error).

Furthermore the pygments ImageFormatter always expects BinaryIO,
no matter which constructor arguments are passed.

This commit addresses both problems.

@not-my-profile not-my-profile force-pushed the fix-pygments branch 4 times, most recently from ab779a2 to 33c6ba8 Compare March 4, 2022 07:41
933fec0 made
pygments.formatter.Formatter generic to improve the type-safety
of pygments.format() and pygments.highlight().

The actual pygments.formatter.Formatter however is not generic,
meaning that pygments.formatter.Formatter[str] should not type check
(since it leads to a runtime type error).

Furthermore the pygments ImageFormatter always expects BinaryIO,
no matter which constructor arguments are passed.

This commit addresses both problems.
@not-my-profile not-my-profile marked this pull request as draft March 4, 2022 11:25
@not-my-profile
Copy link
Contributor Author

not-my-profile commented Mar 4, 2022

Ok I am confused the current Formatter.__init__ overloads do not appear to work at all.

I am closing this for now, so that we can discuss this properly in #7436.

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