diff options
author | xNinjaKittyx <xNinjaKittyx@users.noreply.github.com> | 2020-12-15 17:21:33 -0800 |
---|---|---|
committer | xNinjaKittyx <xNinjaKittyx@users.noreply.github.com> | 2020-12-15 18:20:13 -0800 |
commit | 9aa54a5b27468d61337528cb1e1b5b9b11a80978 (patch) | |
tree | 567693115cc101efb9254a96d96d80e9f9ccd557 /cmd2/rl_utils.py | |
parent | 03c65c60b39e369958b056c5c844d36d515c8a63 (diff) | |
download | cmd2-git-ci_improvements.tar.gz |
Adds pre-commit config to run various lintersci_improvements
This ads black, isort, pyupgrade, and flake8 to pre-commit-config.yaml
There are also some small changes to travis.yml and tasks.py to reduce
some repeated configurations that should be consolidated into
setup.cfg. Most other changes are automated by the linter scripts.
Diffstat (limited to 'cmd2/rl_utils.py')
-rw-r--r-- | cmd2/rl_utils.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/cmd2/rl_utils.py b/cmd2/rl_utils.py index 099d76b7..aacd93cb 100644 --- a/cmd2/rl_utils.py +++ b/cmd2/rl_utils.py @@ -21,6 +21,7 @@ except ImportError: class RlType(Enum): """Readline library types we recognize""" + GNU = 1 PYREADLINE = 2 NONE = 3 @@ -39,9 +40,9 @@ _rl_warn_reason = '' if 'pyreadline' in sys.modules: rl_type = RlType.PYREADLINE + import atexit from ctypes import byref from ctypes.wintypes import DWORD, HANDLE - import atexit # Check if we are running in a terminal if sys.stdout.isatty(): # pragma: no cover @@ -105,7 +106,7 @@ if 'pyreadline' in sys.modules: saved_cursor = readline.rl.mode._history.history_cursor # Delete the history item - del(readline.rl.mode._history.history[pos]) + del readline.rl.mode._history.history[pos] # Update the cursor if needed if saved_cursor > pos: @@ -119,10 +120,13 @@ elif 'gnureadline' in sys.modules or 'readline' in sys.modules: try: # Load the readline lib so we can access members of it import ctypes + readline_lib = ctypes.CDLL(readline.__file__) except AttributeError: # pragma: no cover - _rl_warn_reason = ("this application is running in a non-standard Python environment in\n" - "which readline is not loaded dynamically from a shared library file.") + _rl_warn_reason = ( + "this application is running in a non-standard Python environment in\n" + "which readline is not loaded dynamically from a shared library file." + ) else: rl_type = RlType.GNU vt100_support = sys.stdout.isatty() @@ -130,10 +134,11 @@ elif 'gnureadline' in sys.modules or 'readline' in sys.modules: # Check if readline was loaded if rl_type == RlType.NONE: # pragma: no cover if not _rl_warn_reason: - _rl_warn_reason = ("no supported version of readline was found. To resolve this, install\n" - "pyreadline on Windows or gnureadline on Mac.") - rl_warning = ("Readline features including tab completion have been disabled because\n" - + _rl_warn_reason + '\n\n') + _rl_warn_reason = ( + "no supported version of readline was found. To resolve this, install\n" + "pyreadline on Windows or gnureadline on Mac." + ) + rl_warning = "Readline features including tab completion have been disabled because\n" + _rl_warn_reason + '\n\n' else: rl_warning = '' |