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

Add type annotations and optimize urwid.font #540

Merged
merged 2 commits into from
Apr 21, 2023

Conversation

penguinolog
Copy link
Collaborator

  • optimize separate_glyphs: do not mutate gl, less temporary variables
  • add __repr__ and human-friendly exception reraise on render
  • add type annotations to satisfy mypy

Partial: #406

Checklist
  • I've ensured that similar functionality has not already been implemented
  • I've ensured that similar functionality has not earlier been proposed and declined
  • I've branched off the master or python-dual-support branch
  • I've merged fresh upstream into my branch recently
  • I've ran tox successfully in local environment

@penguinolog penguinolog requested a review from wardi April 18, 2023 16:57
obj: str | bytes,
encoding: str = 'utf-8',
errors: Literal['strict', 'ignore', 'replace'] | str = 'strict',
) -> str:
if isinstance(obj, str):
return obj
elif isinstance(obj, bytes):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double transcoding is a bit overkill, just use strings directly

* optimize `separate_glyphs`: do not mutate `gl`, less temporary variables
* add `__repr__` and human-friendly exception reraise on render
* add type annotations to satisfy mypy

Partial: urwid#406
@penguinolog penguinolog force-pushed the font_annotate_optimize branch from 1bee0d6 to aeb07b2 Compare April 19, 2023 07:17
@penguinolog penguinolog force-pushed the font_annotate_optimize branch from aeb07b2 to 6593a99 Compare April 19, 2023 07:43
@penguinolog
Copy link
Collaborator Author

Font list output (changes: repr for symbols, so space characters will be not "invisible"):

Available Fonts:     (U) = UTF-8 required
----------------
Thin 3x3                  Characters: ' !"#$%\'*+,-./0123456789:;=?[\\]^_`'
Thin 4x3                  Characters: ' !"#$%\'*+,-./0123456789:;=?[\\]^_`'
Sextant 3x3          (U)  Characters: ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`'
Sextant 2x2          (U)  Characters: '%,.0123456789'
Half Block 5x4       (U)  Full ASCII + '´'
Half Block 6x5       (U)  Characters: ' ./0123456789:'
Half Block Heavy 6x5 (U)  Characters: ' ./0123456789:'
Thin 6x6                  Full ASCII
Half Block 7x7       (U)  Full ASCII + '´'

@penguinolog penguinolog merged commit a53fd34 into urwid:master Apr 21, 2023
@penguinolog penguinolog deleted the font_annotate_optimize branch April 21, 2023 13:05
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