Skip to content

Commit

Permalink
linting & pin docformatter
Browse files Browse the repository at this point in the history
- fix for 'pylint: disable'

- pin docformatter, As it seems the bug that @avylove created may not
  been addressed, freeze docformatter for now, to prevent failing CI

  PyCQA/docformatter#264
  • Loading branch information
jquast committed Dec 14, 2023
1 parent 8eb91f9 commit 47328d9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
7 changes: 6 additions & 1 deletion blessed/keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,11 @@ def _read_until(term, pattern, timeout):
#: 350ms, or 0.35 seconds. It is still a bit conservative, for remote telnet or
#: ssh servers, for example.
DEFAULT_ESCDELAY = 0.35


def _reinit_escdelay():
# pylint: disable=W0603 Using the global statement, this is necessary to
# pylint: disable=W0603
# Using the global statement: this is necessary to
# allow test coverage without complex module reload
global DEFAULT_ESCDELAY
if os.environ.get('ESCDELAY'):
Expand All @@ -465,6 +468,8 @@ def _reinit_escdelay():
except ValueError:
# invalid values of 'ESCDELAY' are ignored
pass


_reinit_escdelay()


Expand Down
6 changes: 3 additions & 3 deletions blessed/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@

# local
from .color import COLOR_DISTANCE_ALGORITHMS
from .keyboard import (_time_left,
from .keyboard import (DEFAULT_ESCDELAY,
_time_left,
_read_until,
resolve_sequence,
get_keyboard_codes,
get_leading_prefixes,
get_keyboard_sequences,
DEFAULT_ESCDELAY)
get_keyboard_sequences)
from .sequences import Termcap, Sequence, SequenceTextWrapper
from .colorspace import RGB_256TABLE
from .formatters import (COLORS,
Expand Down
2 changes: 1 addition & 1 deletion tests/accessories.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class as_subprocess(object): # pylint: disable=too-few-public-methods
def __init__(self, func):
self.func = func

def __call__(self, *args, **kwargs): # pylint: disable=too-many-locals, too-complex
def __call__(self, *args, **kwargs): # pylint: disable=too-many-locals,too-complex
if IS_WINDOWS:
self.func(*args, **kwargs)
return
Expand Down
3 changes: 3 additions & 0 deletions tests/test_keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ def child(kind): # pylint: disable=too-many-statements

child('xterm')


def test_ESCDELAY_unset_unchanged():
"""Unset ESCDELAY leaves DEFAULT_ESCDELAY unchanged in _reinit_escdelay()."""
if 'ESCDELAY' in os.environ:
Expand All @@ -374,6 +375,7 @@ def test_ESCDELAY_unset_unchanged():
blessed.keyboard._reinit_escdelay()
assert blessed.keyboard.DEFAULT_ESCDELAY == prev_value


def test_ESCDELAY_bad_value_unchanged():
"""Invalid ESCDELAY leaves DEFAULT_ESCDELAY unchanged in _reinit_escdelay()."""
os.environ['ESCDELAY'] = 'XYZ123!'
Expand All @@ -383,6 +385,7 @@ def test_ESCDELAY_bad_value_unchanged():
assert blessed.keyboard.DEFAULT_ESCDELAY == prev_value
del os.environ['ESCDELAY']


def test_ESCDELAY_10ms():
"""Verify ESCDELAY modifies DEFAULT_ESCDELAY in _reinit_escdelay()."""
os.environ['ESCDELAY'] = '1234'
Expand Down
6 changes: 4 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ commands =
autopep8 --in-place --recursive --aggressive --aggressive blessed/ bin/ setup.py

[testenv:docformatter]
# docformatter pinned due to https://github.com/PyCQA/docformatter/issues/264
deps =
docformatter
docformatter<1.7.4
untokenize
commands =
docformatter \
Expand All @@ -83,8 +84,9 @@ commands =
{toxinidir}/docs/conf.py

[testenv:docformatter_check]
# docformatter pinned due to https://github.com/PyCQA/docformatter/issues/264
deps =
docformatter
docformatter<1.7.4
untokenize
commands =
docformatter \
Expand Down

0 comments on commit 47328d9

Please sign in to comment.