[BUG]redundant-cast mypy error in rich/console.py:1542

#4220 · closed · 2 comments

View on GitHub ↗

H1lbert-kt

Running mypy -p rich --no-incremental produces: rich/console.py:1542: error: Redundant cast to "Literal['left', 'center', 'right']" [redundant-cast] Found 1 error in 1 file (checked 100 source files) rich/console.py:1542: if justify in ("left", "center", "right"): def align_append(renderable: RenderableType) -> None: _append(Align(renderable, cast(AlignMethod, justify))) append = align_append While running the full contribution checklist (make test, make typecheck, make format-check) as described in CONTRIBUTING.md, the mypy step flagged this redundant cast. The type guard on line 1539 already narrows justify to Literal['left', 'center', 'right'], making the explicit cast() unnecessary. Is this a bug? If so, I'd like to fix it. Could this issue be assigned to me?

Comments

willmcgugan

It's a non issue.

github-actions[bot]

I hope I helped! Consider [sponsoring](https://github.com/sponsors/willmcgugan) my work on Rich. I give tech support for free, in addition to maintaining Rich and Textual. If you like using Rich, you might also enjoy [Textual](https://textual.textualize.io). Will McGugan