From 88ab53b0097fbbc482d8227e24f737c09fc5fee4 Mon Sep 17 00:00:00 2001 From: Bartosz Sokorski Date: Fri, 16 Aug 2024 15:28:15 +0200 Subject: [PATCH 1/2] Add typing to public API --- pyproject.toml | 12 ++++++++++++ src/shellingham/__init__.py | 12 +++++++++++- src/shellingham/py.typed | 0 tox.ini | 7 +++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/shellingham/py.typed diff --git a/pyproject.toml b/pyproject.toml index f195ab1..95e9888 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,3 +32,15 @@ showcontent = false directory = "removal" name = "Removals and Deprecations" showcontent = true + + +[tool.mypy] +files = "src" +mypy_path = "src" +namespace_packages = true + +[[tool.mypy.overrides]] +module = [ + "shellingham.nt" # Mypy complains that ctypes has no windll on non-Windows machines +] +ignore_errors = true diff --git a/src/shellingham/__init__.py b/src/shellingham/__init__.py index 15f7a90..006dab9 100644 --- a/src/shellingham/__init__.py +++ b/src/shellingham/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import importlib import os @@ -6,7 +8,15 @@ __version__ = "1.5.4" -def detect_shell(pid=None, max_depth=10): +__all__ = [ + "ShellDetectionFailure", + "detect_shell", +] + + +def detect_shell( + pid: int | None = None, max_depth: int = 10 +) -> tuple[int, int]: name = os.name try: impl = importlib.import_module(".{}".format(name), __name__) diff --git a/src/shellingham/py.typed b/src/shellingham/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/tox.ini b/tox.ini index 2102314..aa0fc44 100644 --- a/tox.ini +++ b/tox.ini @@ -21,3 +21,10 @@ deps = commands = pytest + + +[testenv:typing] +deps = + mypy +commands = + mypy From de4c413786097149b540cc4905e6b88c7ee209f9 Mon Sep 17 00:00:00 2001 From: Bartosz Sokorski Date: Sun, 27 Oct 2024 21:04:46 +0100 Subject: [PATCH 2/2] Update tox config for CI --- tox.ini | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/tox.ini b/tox.ini index aa0fc44..64b9c7a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,28 +1,21 @@ [tox] -envlist = py37, py38, py39, py310, py311, py312 +envlist = py37, py38, py39, py310, py311, py312, test, typing [gh-actions] python = - 3.7: py37 - 3.8: py38 - 3.9: py39 - 3.10: py310 - 3.11: py311 - 3.12: py312 + 3.7: py37, test, typing + 3.8: py38, test + 3.9: py39, test + 3.10: py310, test + 3.11: py311, test + 3.12: py312, test, typing [testenv] allowlist_externals = pipenv commands = pipenv install --dev - -[testenv:test] -deps = - pytest - -commands = pytest - [testenv:typing] deps = mypy