Skip to content

Commit e26a0dd

Browse files
committed
Merge branch 'develop'
2 parents 7f8f06f + 9306bf2 commit e26a0dd

File tree

7 files changed

+57
-37
lines changed

7 files changed

+57
-37
lines changed

.editorconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,8 @@ indent_style = tab
2525
# 2 space indentation for YAML files
2626
[*.{yml,yaml}]
2727
indent_size = 2
28+
29+
# Only allow 72 character line length for commit messages
30+
# See <https://www.git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project#_commit_guidelines> for a reference
31+
[COMMIT_EDITMSG]
32+
max_line_length = 72

.github/workflows/pre-commit.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ jobs:
66
container: python:3
77
steps:
88
- name: Check out repository code
9-
uses: actions/checkout@v2
9+
uses: actions/checkout@v3
10+
- name: Add the project directory to safe directories in Git
11+
run: git config --global --add safe.directory "${GITHUB_WORKSPACE}"
1012
- name: Install pre-commit
11-
run: |
12-
pip install "virtualenv<v20.24.6" && # temporary fix for gitlint
13-
pip install "pre-commit==3.5.0"
13+
run: pip install "pre-commit==4.0.1"
1414
- name: Run pre-commit checks
1515
run: |
1616
TMP_MSG_FILE="$(mktemp)" &&
@@ -19,7 +19,7 @@ jobs:
1919
--all-files \
2020
--color=always \
2121
--show-diff-on-failure \
22-
--hook-stage commit &&
22+
--hook-stage pre-commit &&
2323
pre-commit run \
2424
--all-files \
2525
--color=always \

.gitlab-ci.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,24 @@ stages:
77
pre-commit:
88
stage: check
99
image: python:3
10+
variables:
11+
GIT_CLONE_PATH: "${CI_BUILDS_DIR}/${CI_PROJECT_NAME}"
12+
PIP_CACHE_DIR: "${CI_PROJECT_DIR}/.cache/pip"
13+
PRE_COMMIT_HOME: "${CI_PROJECT_DIR}/.cache/pre-commit"
14+
cache:
15+
key: pre-commit
16+
paths:
17+
- .cache
1018
before_script:
11-
- pip install "virtualenv<v20.24.6" # temporary fix for gitlint
12-
- pip install "pre-commit==3.5.0"
19+
- pip install "pre-commit==4.0.1"
1320
script:
1421
- TMP_MSG_FILE="$(mktemp)"
1522
- git log -1 --pretty=%B > "${TMP_MSG_FILE}"
1623
- pre-commit run
1724
--all-files
1825
--color=always
1926
--show-diff-on-failure
20-
--hook-stage commit &&
27+
--hook-stage pre-commit &&
2128
pre-commit run
2229
--all-files
2330
--color=always
@@ -44,13 +51,13 @@ check-python-compatibility:py35:
4451

4552
build-linux-executable:
4653
stage: build
47-
image: centos:7
54+
image: rockylinux:8
4855
before_script:
49-
- yum install -y epel-release
50-
- yum install -y python36-pip upx
56+
- dnf install -y epel-release
57+
- dnf install -y python39-pip upx
5158
script:
52-
- python3 setup.py bdist_pyinstaller
53-
- PLATFORM=$(python3 -c 'import platform; print("{}_{}".format(platform.system(), platform.machine()).lower())');
59+
- python3.9 setup.py bdist_pyinstaller
60+
- PLATFORM=$(python3.9 -c 'import platform; print(f"{platform.system()}_{platform.machine()}".lower())');
5461
mv "dist/${CI_PROJECT_NAME}" "dist/${CI_PROJECT_NAME}_${PLATFORM}"
5562
artifacts:
5663
expire_in: 1 week
@@ -64,7 +71,7 @@ build-macos-executable:
6471
- libvirt
6572
script:
6673
- python3 setup.py bdist_pyinstaller
67-
- PLATFORM=$(python3 -c 'import platform; print("{}_{}".format(platform.system(), platform.machine()).lower())');
74+
- PLATFORM=$(python3 -c 'import platform; print(f"{platform.system()}_{platform.machine()}".lower())');
6875
mv "dist/${CI_PROJECT_NAME}" "dist/${CI_PROJECT_NAME}_${PLATFORM}"
6976
artifacts:
7077
expire_in: 1 week

.pre-commit-config.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
default_stages: ['commit']
1+
default_stages: ['pre-commit']
22
repos:
33
# pre-commit repo:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.5.0
5+
rev: v5.0.0
66
hooks:
77
# general hooks:
88
- id: check-added-large-files # Prevent giant files from being committed
@@ -29,7 +29,7 @@ repos:
2929
- id: requirements-txt-fixer # Sorts entries in requirements.txt and removes incorrect entry `pkg-resources==0.0.0`
3030
# General repos:
3131
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
32-
rev: 2.7.3
32+
rev: 3.0.3
3333
hooks:
3434
- id: editorconfig-checker
3535
exclude_types: [markdown]
@@ -47,18 +47,18 @@ repos:
4747
'--msg-filename',
4848
]
4949
- repo: https://github.com/igorshubovych/markdownlint-cli
50-
rev: v0.37.0
50+
rev: v0.43.0
5151
hooks:
5252
- id: markdownlint
5353
- repo: https://github.com/adrienverge/yamllint
54-
rev: v1.32.0
54+
rev: v1.35.1
5555
hooks:
5656
- id: yamllint
5757
args: [
5858
'--config-data={extends: default, rules: {indentation: {indent-sequences: consistent}, line-length: {max: 120}}}'
5959
]
6060
- repo: https://github.com/sirosen/check-jsonschema
61-
rev: 0.27.1
61+
rev: 0.29.4
6262
hooks:
6363
- id: check-jsonschema
6464
name: 'Validate GitLab CI configuration'
@@ -68,17 +68,17 @@ repos:
6868
'https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json',
6969
]
7070
- repo: https://github.com/sirosen/check-jsonschema
71-
rev: 0.27.1
71+
rev: 0.29.4
7272
hooks:
7373
- id: check-github-workflows
7474
# Python specific repos:
7575
- repo: https://github.com/psf/black
76-
rev: 23.10.1
76+
rev: 24.10.0
7777
hooks:
7878
- id: black
7979
args: ['--line-length=120']
8080
- repo: https://github.com/PyCQA/isort
81-
rev: 5.12.0
81+
rev: 5.13.2
8282
hooks:
8383
- id: isort
8484
args: [ # Arguments for `black` compatibility
@@ -90,15 +90,15 @@ repos:
9090
'--ensure-newline-before-comments',
9191
]
9292
- repo: https://github.com/pycqa/flake8
93-
rev: 6.1.0
93+
rev: 7.1.1
9494
hooks:
9595
- id: flake8
9696
args: [
9797
'--max-line-length=120',
9898
'--ignore=E203,W503', # Otherwise, `flake8` is not compatible with `black`
9999
]
100100
- repo: https://github.com/pre-commit/mirrors-mypy
101-
rev: v1.6.1
101+
rev: v1.13.0
102102
hooks:
103103
- id: mypy
104104
args: ['--ignore-missing-imports', '--strict']

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PRECOMMIT_VERSION = 3.5.0
1+
PRECOMMIT_VERSION = 4.0.1
22

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

@@ -41,7 +41,7 @@ check: install-pre-commit
4141
"$(PRECOMMIT_ENV)/bin/pre-commit" run \
4242
--all-files \
4343
--show-diff-on-failure \
44-
--hook-stage commit && \
44+
--hook-stage pre-commit && \
4545
"$(PRECOMMIT_ENV)/bin/pre-commit" run \
4646
--all-files \
4747
--show-diff-on-failure \

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ yay -S python-simple-term-menu
4545

4646
You also find self-contained executables for 64-bit Linux distributions and macOS High Sierra and newer on the
4747
[releases page](https://github.com/IngoMeyer441/simple-term-menu/releases/latest). They are created with
48-
[PyInstaller](http://www.pyinstaller.org) and only require glibc >= 2.17 on Linux (should be fine on any recent
48+
[PyInstaller](http://www.pyinstaller.org) and only require glibc >= 2.28 on Linux (should be fine on any recent
4949
Linux system).
5050

5151
## Usage

simple_term_menu.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
__email__ = "[email protected]"
4444
__copyright__ = "Copyright © 2021 Forschungszentrum Jülich GmbH. All rights reserved."
4545
__license__ = "MIT"
46-
__version_info__ = (1, 6, 4)
46+
__version_info__ = (1, 6, 5)
4747
__version__ = ".".join(map(str, __version_info__))
4848

4949

@@ -904,9 +904,11 @@ def _init_terminal_codes(cls) -> None:
904904
return
905905
supported_colors = int(cls._query_terminfo_database("colors"))
906906
cls._codename_to_terminal_code = {
907-
codename: cls._query_terminfo_database(codename)
908-
if not (codename.startswith("bg_") or codename.startswith("fg_")) or supported_colors >= 8
909-
else ""
907+
codename: (
908+
cls._query_terminfo_database(codename)
909+
if not (codename.startswith("bg_") or codename.startswith("fg_")) or supported_colors >= 8
910+
else ""
911+
)
910912
for codename in cls._codenames
911913
}
912914
cls._codename_to_terminal_code.update(cls._name_to_control_character)
@@ -964,10 +966,14 @@ def _init_term(self) -> None:
964966
self._tty_out = open("/dev/tty", "w", encoding=self._user_locale, errors="replace")
965967
self._old_term = termios.tcgetattr(self._tty_in.fileno())
966968
self._new_term = termios.tcgetattr(self._tty_in.fileno())
967-
# set the terminal to: unbuffered, no echo and no <CR> to <NL> translation (so <enter> sends <CR> instead of
968-
# <NL, this is necessary to distinguish between <enter> and <Ctrl-j> since <Ctrl-j> generates <NL>)
969+
# set the terminal to: no line-buffering, no echo and no <CR> to <NL> translation (so <enter> sends <CR> instead
970+
# of <NL, this is necessary to distinguish between <enter> and <Ctrl-j> since <Ctrl-j> generates <NL>)
969971
self._new_term[3] = cast(int, self._new_term[3]) & ~termios.ICANON & ~termios.ECHO & ~termios.ICRNL
970972
self._new_term[0] = cast(int, self._new_term[0]) & ~termios.ICRNL
973+
# Set the timings for an unbuffered read: Return immediately after at least one character has arrived and don't
974+
# wait for further characters
975+
cast(list[bytes], self._new_term[6])[termios.VMIN] = b"\x01"
976+
cast(list[bytes], self._new_term[6])[termios.VTIME] = b"\x00"
971977
termios.tcsetattr(
972978
self._tty_in.fileno(), termios.TCSAFLUSH, cast(List[Union[int, List[Union[bytes, int]]]], self._new_term)
973979
)
@@ -1220,9 +1226,11 @@ def get_preview_string() -> Optional[str]:
12201226
)
12211227
def strip_ansi_codes_except_styling(string: str) -> str:
12221228
stripped_string = strip_ansi_codes_except_styling.ansi_escape_regex.sub( # type: ignore
1223-
lambda match_obj: match_obj.group(0)
1224-
if strip_ansi_codes_except_styling.ansi_sgr_regex.match(match_obj.group(0)) # type: ignore
1225-
else "",
1229+
lambda match_obj: (
1230+
match_obj.group(0)
1231+
if strip_ansi_codes_except_styling.ansi_sgr_regex.match(match_obj.group(0)) # type: ignore
1232+
else ""
1233+
),
12261234
string,
12271235
)
12281236
return cast(str, stripped_string)

0 commit comments

Comments
 (0)