| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
`_colorize` has been available since Python 3.13 and gained the experimental theming API in 3.14, which was extended considerably in 3.15. The stub covers all three versions: - 3.13+: `COLORIZE`, `ANSIColors`, `NoColors`, `get_colors`, `can_colorize` - 3.14+: `ColorCodes`, `decolor`, `ThemeSection`, the `Argparse`, `Syntax`, `Traceback` and `Unittest` sections, `Theme`, `get_theme` and `set_theme` - 3.15+: `CursesColors`, `BackgroundStyle`, ten further theme sections, and the `kw_only` dataclass signatures that 3.15 switched to `attr` and `code` are loop variables that leak into the module namespace, and `BackgroundStyle` is declared with the `type` statement, which stubtest compares against the alias value; all three are allowlisted. Closes python#16361
There was a problem hiding this comment.
Not a full review yet, but a few things I noticed. In general, the stub file should use the same ordering as the implementation, even if it means repeating version info checks.
Sorry, something went wrong.
There was a problem hiding this comment.
Nice one, @anistark you beat me to it on this 😉
Sorry, something went wrong.
| @dataclass(frozen=True, kw_only=True) | ||
| class Argparse(ThemeSection): | ||
| usage: str = ... | ||
| prog: str = ... | ||
| prog_extra: str = ... | ||
| heading: str = ... | ||
| summary_long_option: str = ... | ||
| summary_short_option: str = ... |
There was a problem hiding this comment.
This comment applies to every ThemeSection
I didn't mention this in #16361, but I was partly motivated by wanting to be able to see the default colors more easily.
These stubs show the names, but compared to the source, they seem less helpful than they could be:
@dataclass(frozen=True, kw_only=True)
class Argparse(ThemeSection):
usage: str = ANSIColors.BOLD_BLUE
prog: str = ANSIColors.BOLD_MAGENTA
prog_extra: str = ANSIColors.MAGENTA
heading: str = ANSIColors.BOLD_BLUE
summary_long_option: str = ANSIColors.CYAN
summary_short_option: str = ANSIColors.GREEN
Sorry, something went wrong.
There was a problem hiding this comment.
It isn't clear to me whether these values would be considered complex
Sorry, something went wrong.
There was a problem hiding this comment.
Kept these as ...: the style guide only allows literal defaults, and ruff PYI015 rewrites = ANSIColors.BOLD_BLUE back to ... under the repo config.
The values are now readable on ANSIColors itself since its members carry their literals.
Sorry, something went wrong.
|
Thanks for the reviews @srittau and @dangotbanned. Fixed most of it. |
Sorry, something went wrong.
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
_colorize has been available since Python 3.13 and gained the experimental theming API in 3.14, which was extended considerably in 3.15. The stub covers all three versions:
attr and code are loop variables that leak into the module namespace, and BackgroundStyle is declared with the type statement, which stubtest compares against the alias value; all three are allowlisted.
Closes #16361