jquast / blessed

Blessed is an easy, practical library for making python terminal apps
http://pypi.python.org/pypi/blessed
MIT License
1.18k stars 71 forks source link

Pylint fixes for .pyi files #265

Closed avylove closed 5 months ago

avylove commented 6 months ago

Pylint recently started checking .pyi files but there are some messages that either don't make sense (ex: unused argument) or aren't strictly necessary in a type hints file (ex: no function docstring).

There is some discussion in https://github.com/pylint-dev/pylint/issues/9096 of quieting these, but rather than wait, I figured we can fix the ones that made sense to fix and disable the others.

codecov[bot] commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 95.42%. Comparing base (c28b53f) to head (8c36af6).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #265 +/- ## ======================================= Coverage 95.42% 95.42% ======================================= Files 9 9 Lines 1027 1027 Branches 216 216 ======================================= Hits 980 980 Misses 43 43 Partials 4 4 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

avylove commented 6 months ago

Might have to look at this a little more. Getting this (Although only in the pull_request test run not the push test run. The references are wrong, but still points to something.

blessed/colorspace.py:1: [R0401(cyclic-import), ] Cyclic import (blessed.sequences -> blessed.terminal)
jquast commented 6 months ago

looks like it comes from the blessed/sequences.pyi file, importing blessed/terminal.py to use the Terminal type https://github.com/jquast/blessed/blob/c28b53fccab1c1966e06c31f58a44b9359838711/blessed/sequences.pyi#L6

I'm not sure what could be done, except to move all of sequences. into terminal. so that they are in the same file

jquast commented 6 months ago

I am ok with moving all of sequences into terminal, so long as there is some alias that allows from blessed.sequences import .. statements to continue to work, there are several test cases covering this already.

avylove commented 5 months ago

@jquast, sorry for the delay. I went the route of using a guard if TYPE_CHECKING: in the .pyi files and quoting Terminal in the type annotations. This seems to make Pylint happy without breaking anything else.

We could use from __future__ import annotations to avoid using quotes, but this only works in 3.7+ so could cause issues with someone using 3.5 or 3.6 with typing.

avylove commented 5 months ago

Looks like there are some errors due to missing type annotations for the ESC_DELAY changes. Not sure why that should matter, but looks like it does. I'll do a PR for that soon. Of course it doesn't fail locally, so not sure what's different in CI or why it didn't fail when this PR ran it's tests.