From 718f7cdd57aa403b9e3a8e5065a6362e0566a951 Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Mon, 23 Nov 2026 14:35:02 +0300 Subject: [PATCH 1/2] CI: pyright is added --- .github/workflows/ci.yml | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d14bb8..fa12a81 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,9 +44,33 @@ jobs: run: | validate-pyproject pyproject.toml + pyright: + runs-on: ubuntu-24.04 + needs: lint + strategy: + fail-fast: false + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] + + steps: + - name: Checkout + uses: actions/checkout@v7 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v7 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install pyright + python -m pip install -r tests/requirements.txt + - name: Type check with pyright + run: pyright . + build-check: runs-on: ubuntu-latest - needs: lint + needs: pyright steps: - name: Checkout uses: actions/checkout@v7 From 7b2425741f0559ca25f5473f8135edc9b9f12439 Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Mon, 23 Nov 2026 15:08:55 +0300 Subject: [PATCH 2/2] fix: get_default_encoding is refactored --- src/helpers.py | 8 +++++--- src/os_ops.py | 9 ++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/helpers.py b/src/helpers.py index 501eb6c..9f2e454 100644 --- a/src/helpers.py +++ b/src/helpers.py @@ -15,8 +15,10 @@ def encode(self, *args, **kwargs) -> _BinDataBox: def _make_get_default_encoding_func() -> typing.Callable: # locale.getencoding is added in Python 3.11 - if hasattr(locale, 'getencoding'): - return locale.getencoding + func = getattr(locale, 'getencoding', None) + if func is not None: + assert isinstance(func, typing.Callable) + return func # It must exist return locale.getpreferredencoding @@ -27,7 +29,7 @@ class Helpers: _get_default_encoding_func = _make_get_default_encoding_func() @staticmethod - def get_default_encoding(): + def get_default_encoding() -> str: # # Original idea/source was: # diff --git a/src/os_ops.py b/src/os_ops.py index 9fd0805..94e601d 100644 --- a/src/os_ops.py +++ b/src/os_ops.py @@ -8,8 +8,9 @@ from .types import T_OS_EXEC_INPUT from .types import T_OS_EXEC_ENV from .raise_error import RaiseError +from .helpers import Helpers + -import locale import typing import signal as os_signal import subprocess @@ -38,10 +39,8 @@ def __init__( return -def get_default_encoding(): - if not hasattr(locale, 'getencoding'): - locale.getencoding = locale.getpreferredencoding - return locale.getencoding() or 'UTF-8' +def get_default_encoding() -> str: + return Helpers.get_default_encoding() class OsProcessController: