Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
IngoMeyer441 committed Nov 7, 2023
2 parents 04049a6 + 10c5e8e commit dde8621
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-python-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
- name: Setup simple-term-menu on Python 3.5
run: python3.5 -m pip install .
- name: Run a simple-term-menu check on Python 3.5
run: python3.5 -m simple_term_menu --version
run: TERM=dumb python3.5 -m simple_term_menu --version
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- name: Check out repository code
uses: actions/checkout@v2
- name: Install pre-commit
run: pip install "pre-commit==2.17.0"
run: pip install "pre-commit==3.5.0"
- name: Run pre-commit checks
run: |
TMP_MSG_FILE="$(mktemp)" &&
Expand Down
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pre-commit:
stage: check
image: python:3
before_script:
- pip install "pre-commit==2.17.0"
- pip install "pre-commit==3.5.0"
script:
- TMP_MSG_FILE="$(mktemp)"
- git log -1 --pretty=%B > "${TMP_MSG_FILE}"
Expand Down Expand Up @@ -39,7 +39,7 @@ check-python-compatibility:py35:
image: sciapp/python-testing:latest-ubuntu-20.04
script:
- python3.5 -m pip install .
- python3.5 -m simple_term_menu --version
- TERM=dumb python3.5 -m simple_term_menu --version

build-linux-executable:
stage: build
Expand Down
22 changes: 11 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ default_stages: ['commit']
repos:
# pre-commit repo:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.5.0
hooks:
# general hooks:
- id: check-added-large-files # Prevent giant files from being committed
Expand All @@ -29,7 +29,7 @@ repos:
- id: requirements-txt-fixer # Sorts entries in requirements.txt and removes incorrect entry `pkg-resources==0.0.0`
# General repos:
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: 2.4.0
rev: 2.7.3
hooks:
- id: editorconfig-checker
exclude_types: [markdown]
Expand All @@ -39,26 +39,26 @@ repos:
- id: detect-direct-checkins
args: ['--branch=master', '--allow-root']
- repo: https://github.com/jorisroovers/gitlint
rev: v0.17.0
rev: v0.19.1
hooks:
- id: gitlint
args: [
'--ignore=body-is-missing,title-must-not-contain-word',
'--msg-filename',
]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.31.1
rev: v0.37.0
hooks:
- id: markdownlint
- repo: https://github.com/adrienverge/yamllint
rev: v1.26.3
rev: v1.32.0
hooks:
- id: yamllint
args: [
'--config-data={extends: default, rules: {indentation: {indent-sequences: consistent}, line-length: {max: 120}}}'
]
- repo: https://github.com/sirosen/check-jsonschema
rev: 0.14.0
rev: 0.27.1
hooks:
- id: check-jsonschema
name: 'Validate GitLab CI configuration'
Expand All @@ -68,17 +68,17 @@ repos:
'https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json',
]
- repo: https://github.com/sirosen/check-jsonschema
rev: 0.14.0
rev: 0.27.1
hooks:
- id: check-github-workflows
# Python specific repos:
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 23.10.1
hooks:
- id: black
args: ['--line-length=120']
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
args: [ # Arguments for `black` compatibility
Expand All @@ -90,15 +90,15 @@ repos:
'--ensure-newline-before-comments',
]
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
rev: 6.1.0
hooks:
- id: flake8
args: [
'--max-line-length=120',
'--ignore=E203,W503', # Otherwise, `flake8` is not compatible with `black`
]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.910
rev: v1.6.1
hooks:
- id: mypy
args: ['--ignore-missing-imports', '--strict']
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PRECOMMIT_VERSION = 2.17.0
PRECOMMIT_VERSION = 3.5.0

PRECOMMIT_ENV := $(shell git rev-parse --git-dir 2>/dev/null || echo ".")/.pre-commit_env

Expand Down
9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import os
import runpy
import subprocess
from distutils.cmd import Command
from tempfile import TemporaryDirectory
from typing import List, Optional, Tuple, cast
from typing import List, Optional, Tuple, cast # noqa: F401

from setuptools import setup
from setuptools import Command, setup


class PyinstallerCommand(Command):
class PyinstallerCommand(Command): # type: ignore
description = "create a self-contained executable with PyInstaller"
user_options = [] # type: List[Tuple[str, Optional[str], str]]

Expand Down Expand Up @@ -51,6 +50,8 @@ def run(self) -> None:


def get_version_from_pyfile(version_file: str = "simple_term_menu.py") -> str:
if "TERM" not in os.environ:
os.environ["TERM"] = "" # Avoid error messages when simple-term-menu is not installed on a terminal
file_globals = runpy.run_path(version_file)
return cast(str, file_globals["__version__"])

Expand Down
14 changes: 11 additions & 3 deletions simple_term_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,20 @@
except ImportError as e:
raise NotImplementedError('"{}" is currently not supported.'.format(platform.system())) from e

if "TERM" not in os.environ:
if "PYCHARM_HOSTED" in os.environ:
raise NotImplementedError(
"simple-term-menu does not work in the PyCharm output console. Use a terminal instead (Alt + F12) or "
'activate "Emulate terminal in output console".'
)
raise NotImplementedError("simple-term-menu can only be used in a terminal emulator")


__author__ = "Ingo Meyer"
__email__ = "[email protected]"
__copyright__ = "Copyright © 2021 Forschungszentrum Jülich GmbH. All rights reserved."
__license__ = "MIT"
__version_info__ = (1, 6, 1)
__version_info__ = (1, 6, 2)
__version__ = ".".join(map(str, __version_info__))


Expand Down Expand Up @@ -1270,7 +1278,7 @@ def limit_string_with_escape_codes(string: str, max_len: int) -> Tuple[str, int]
BoxDrawingCharacters.upper_left
+ (2 * BoxDrawingCharacters.horizontal + " " + self._preview_title)[: num_cols - 3]
+ " "
+ (num_cols - len(self._preview_title) - 6) * BoxDrawingCharacters.horizontal
+ (num_cols - wcswidth(self._preview_title) - 6) * BoxDrawingCharacters.horizontal
+ BoxDrawingCharacters.upper_right
)[:num_cols]
+ "\n"
Expand Down Expand Up @@ -1475,7 +1483,7 @@ def _read_next_key(self, ignore_case: bool = True) -> str:
def show(self) -> Optional[Union[int, Tuple[int, ...]]]:
def init_signal_handling() -> None:
# `SIGWINCH` is send on terminal resizes
def handle_sigwinch(signum: signal.Signals, frame: FrameType) -> None:
def handle_sigwinch(signum: int, frame: Optional[FrameType]) -> None:
# pylint: disable=unused-argument
if self._reading_next_key:
self._paint_menu()
Expand Down

0 comments on commit dde8621

Please sign in to comment.