From 9b2fde258d73e798df17da7e5757ee08acb6193c Mon Sep 17 00:00:00 2001 From: Camden Narzt Date: Tue, 3 Oct 2023 16:38:41 -0600 Subject: [PATCH 1/6] typings --- .github/workflows/python-package.yml | 5 +- .gitignore | 1 + MANIFEST.in | 3 + Makefile | 4 + setup.py | 42 ++++++----- src/getargv/__init__.py | 16 ++-- src/getargv/__init__.pyi | 107 +++++++++++++++++++++++++++ src/getargv/_getargv.pyi | 2 + src/getargv/py.typed | 0 typings/_getargv.pyi | 1 + 10 files changed, 156 insertions(+), 25 deletions(-) create mode 100644 src/getargv/__init__.pyi create mode 100644 src/getargv/_getargv.pyi create mode 100644 src/getargv/py.typed create mode 120000 typings/_getargv.pyi diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index cd256f9..642dd42 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -45,7 +45,7 @@ jobs: - name: Upgrade pip & Install deps run: | python3 -m pip install --upgrade pip - python3 -m pip install build + python3 -m pip install build pyright - name: Build run: | python3 -m build @@ -54,6 +54,9 @@ jobs: - name: Test run: python3 tests/testgetargv.py working-directory: getargv.py + - name: Types Test + run: pyright --verifytypes getargv + working-directory: getargv.py - uses: actions/upload-artifact@v3 with: name: ${{ matrix.os }}.zip diff --git a/.gitignore b/.gitignore index 2f0079a..dba698b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ build *.egg-info *getargv.cpython-*-darwin.so getargv.html +/pyrightconfig.json diff --git a/MANIFEST.in b/MANIFEST.in index d9a348b..7ad6d7e 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,9 @@ # https://packaging.python.org/en/latest/guides/using-manifest-in/ include src/getargv/_getargvmodule.c +include src/getargv/__init__.pyi include src/getargv/__init__.py +include src/getargv/py.typed +include src/getargv/_getargv.pyi include README.md include LICENSE.txt include setup.py diff --git a/Makefile b/Makefile index 4a73ff5..9f31d7e 100644 --- a/Makefile +++ b/Makefile @@ -33,6 +33,10 @@ sign: check: python setup.py check +types: + pyright --verifytypes getargv + pyright + test: devel python tests/testgetargv.py diff --git a/setup.py b/setup.py index e85847a..307e838 100644 --- a/setup.py +++ b/setup.py @@ -1,22 +1,23 @@ from setuptools import setup, Extension from distutils.ccompiler import new_compiler from platform import processor -from sys import platform +from sys import platform, version_info from sysconfig import get_config_var from os import environ, path +from typing import Any, TypedDict, Literal, cast, Union import subprocess -try: +if version_info >= (3, 11): import tomllib -except ModuleNotFoundError: +else: import tomli as tomllib # debug by setting DISTUTILS_DEBUG env var in shell to anything assert platform == "darwin" -encoding = 'UTF-8' +encoding:str = 'UTF-8' -def get_macos_target(lib_dirs, lib_name): +def get_macos_target(lib_dirs:list[str], lib_name:str)->str: default = get_config_var('MACOSX_DEPLOYMENT_TARGET') compiler = new_compiler() lib_file = compiler.find_library_file(lib_dirs,lib_name) @@ -26,7 +27,7 @@ def get_macos_target(lib_dirs, lib_name): except subprocess.CalledProcessError: return default -def homebrew_prefix(inpath, package): +def homebrew_prefix(inpath:str, package:str)->str: if processor() == 'arm': hb_path = "/opt/homebrew" else: @@ -36,10 +37,10 @@ def homebrew_prefix(inpath, package): else: return path.join(hb_path, "opt", package, inpath) -def macports_prefix(inpath): +def macports_prefix(inpath:str)->str: return path.join("/opt/local/", inpath) -def platform_prefix(inpath, package): +def platform_prefix(inpath:str, package:str)->str: if path.exists("/opt/local/bin/port"): return macports_prefix(inpath) elif path.exists("/opt/homebrew/bin/brew") or path.exists("/usr/local/bin/brew"): @@ -47,25 +48,32 @@ def platform_prefix(inpath, package): else: return (environ.get("PREFIX") or "/").join(inpath) -def pkgconfig(package): - kw = {} +class Params(TypedDict): + libraries: list[str] + include_dirs: list[str] + library_dirs: list[str] + +def pkgconfig(package:str)-> Params: + kw: Params = {'include_dirs':[], 'library_dirs':[], 'libraries':[]} flag_map = {'-I': 'include_dirs', '-L': 'library_dirs', '-l': 'libraries'} try: output = subprocess.check_output('pkg-config --cflags --libs {}'.format(package),shell=True) for token in output.strip().split(): - kw.setdefault(flag_map.get(token[:2].decode(encoding,errors='ignore')), []).append(token[2:].decode(encoding)) + key: Union[str, None] = flag_map.get(token[:2].decode(encoding,errors='ignore')) + assert key is not None + kw[cast(Literal['include_dirs','library_dirs','libraries'],key)].append(token[2:].decode(encoding)) finally: return kw try: - dev_path = subprocess.check_output('xcode-select -p',shell=True).strip().decode(encoding,errors='ignore') + dev_path:str = subprocess.check_output('xcode-select -p',shell=True).strip().decode(encoding,errors='ignore') except: raise Exception('''You must have either the CLT or Xcode installed to build extensions. You can install the CLT with `xcode-select --install`, which is much smaller than the full Xcode. ''') -package_name = 'getargv' -kw = pkgconfig(package_name) +package_name:str = 'getargv' +kw: Params = pkgconfig(package_name) kw['include_dirs'].append(platform_prefix('include', package_name)) kw['include_dirs'].append('{}/Library/Frameworks/Python3.framework/Headers'.format(dev_path)) kw['library_dirs'].append(platform_prefix('lib', package_name)) @@ -74,11 +82,11 @@ def pkgconfig(package): environ["MACOSX_DEPLOYMENT_TARGET"] = get_macos_target(kw['library_dirs'],package_name) with open("pyproject.toml", mode="rb") as fp: - project = tomllib.load(fp)['project'] - config = project.copy() + project: dict[str, Any] = tomllib.load(fp)['project'] + config: dict[str, Any] = project.copy() for k in project.keys(): if k == 'authors': - author = config[k][0] + author: dict[str, str] = config[k][0] config['author'] = author['name'] config['author_email'] = author['email'] del config[k] diff --git a/src/getargv/__init__.py b/src/getargv/__init__.py index 967ee29..2290fe8 100644 --- a/src/getargv/__init__.py +++ b/src/getargv/__init__.py @@ -23,20 +23,22 @@ __version__ The package version """ -import sys -if sys.version_info >= (3, 8): +from sys import platform, version_info +if version_info >= (3, 8): from importlib import metadata else: import importlib_metadata as metadata -if sys.platform != 'darwin': +if platform != 'darwin': from warnings import warn warn("only macOS is supported") -from _getargv import * -__version__ = metadata.version('getargv') +from _getargv import as_bytes, as_list -def as_string(pid, encoding, skip = 0, nuls = False): +# pyright: reportUnknownMemberType=false +__version__: str = metadata.version('getargv') + +def as_string(pid: int, encoding: str, skip: int = 0, nuls: bool = False) -> str: """Returns the arguments of a pid as a string decoded using specified encoding. Parameters: @@ -50,7 +52,7 @@ def as_string(pid, encoding, skip = 0, nuls = False): """ return as_bytes(pid, skip, nuls).decode(encoding) -def as_string_list(pid, encoding): +def as_string_list(pid: int, encoding: str) -> list[str]: """Returns the arguments of a pid as an list of strings decoded using specified encoding. Parameters: diff --git a/src/getargv/__init__.pyi b/src/getargv/__init__.pyi new file mode 100644 index 0000000..782ace6 --- /dev/null +++ b/src/getargv/__init__.pyi @@ -0,0 +1,107 @@ +# encoding info: https://docs.python.org/3/library/codecs.html#standard-encodings +from typing import Literal +ASCII = Literal["ascii", "646", "us-ascii"] +BIG5 = Literal["big5", "big5-tw", "csbig5"] +BIG5HKSCS = Literal["big5hkscs", "big5-hkscs", "hkscs"] +CP037 = Literal["cp037", "IBM037", "IBM039"] +CP273 = Literal["cp273", "273", "IBM273", "csIBM273"] +CP424 = Literal["cp424", "EBCDIC-CP-HE", "IBM424"] +CP437 = Literal["cp437", "437", "IBM437"] +CP500 = Literal["cp500", "EBCDIC-CP-BE", "EBCDIC-CP-CH", "IBM500"] +CP720 = Literal["cp720"] +CP737 = Literal["cp737"] +CP775 = Literal["cp775", "IBM775"] +CP850 = Literal["cp850", "850", "IBM850"] +CP852 = Literal["cp852", "852", "IBM852"] +CP855 = Literal["cp855", "855", "IBM855"] +CP856 = Literal["cp856"] +CP857 = Literal["cp857", "857", "IBM857"] +CP858 = Literal["cp858", "858", "IBM858"] +CP860 = Literal["cp860", "860", "IBM860"] +CP861 = Literal["cp861", "861", "CP-IS", "IBM861"] +CP862 = Literal["cp862", "862", "IBM862"] +CP863 = Literal["cp863", "863", "IBM863"] +CP864 = Literal["cp864", "IBM864"] +CP865 = Literal["cp865", "865", "IBM865"] +CP866 = Literal["cp866", "866", "IBM866"] +CP869 = Literal["cp869", "869", "CP-GR", "IBM869"] +CP874 = Literal["cp874"] +CP875 = Literal["cp875"] +CP932 = Literal["cp932", "932", "ms932", "mskanji", "ms-kanji"] +CP949 = Literal["cp949", "949", "ms949", "uhc"] +CP950 = Literal["cp950", "950", "ms950"] +CP1006 = Literal["cp1006"] +CP1026 = Literal["cp1026", "ibm1026"] +CP1125 = Literal["cp1125", "1125", "ibm1125", "cp866u", "ruscii"] +CP1140 = Literal["cp1140", "ibm1140"] +CP1250 = Literal["cp1250", "windows-1250"] +CP1251 = Literal["cp1251", "windows-1251"] +CP1252 = Literal["cp1252", "windows-1252"] +CP1253 = Literal["cp1253", "windows-1253"] +CP1254 = Literal["cp1254", "windows-1254"] +CP1255 = Literal["cp1255", "windows-1255"] +CP1256 = Literal["cp1256", "windows-1256"] +CP1257 = Literal["cp1257", "windows-1257"] +CP1258 = Literal["cp1258", "windows-1258"] +EUC_JP = Literal["euc_jp", "eucjp", "ujis", "u-jis"] +EUC_JIS_2004 = Literal["euc_jis_2004", "jisx0213", "eucjis2004"] +EUC_JISX0213 = Literal["euc_jisx0213", "eucjisx0213"] +EUC_KR = Literal["euc_kr", "euckr", "korean", "ksc5601", "ks_c-5601", "ks_c-5601-1987", "ksx1001", "ks_x-1001"] +GB2312 = Literal["gb2312", "chinese", "csiso58gb231280", "euc-cn", "euccn", "eucgb2312-cn", "gb2312-1980", "gb2312-80", "iso-ir-58"] +GBK = Literal["gbk", "936", "cp936", "ms936"] +GB18030 = Literal["gb18030", "gb18030-2000"] +HZ = Literal["hz", "hzgb", "hz-gb", "hz-gb-2312"] +ISO2022_JP = Literal["iso2022_jp", "csiso2022jp", "iso2022jp", "iso-2022-jp"] +ISO2022_JP_1 = Literal["iso2022_jp_1", "iso2022jp-1", "iso-2022-jp-1"] +ISO2022_JP_2 = Literal["iso2022_jp_2", "iso2022jp-2", "iso-2022-jp-2"] +ISO2022_JP_2004 = Literal["iso2022_jp_2004", "iso2022jp-2004", "iso-2022-jp-2004"] +ISO2022_JP_3 = Literal["iso2022_jp_3", "iso2022jp-3", "iso-2022-jp-3"] +ISO2022_JP_EXT = Literal["iso2022_jp_ext", "iso2022jp-ext", "iso-2022-jp-ext"] +ISO2022_KR = Literal["iso2022_kr", "csiso2022kr", "iso2022kr", "iso-2022-kr"] +LATIN_1 = Literal["latin_1", "iso-8859-1", "iso8859-1", "8859", "cp819", "latin", "latin1", "L1"] +ISO8859_2 = Literal["iso8859_2", "iso-8859-2", "latin2", "L2"] +ISO8859_3 = Literal["iso8859_3", "iso-8859-3", "latin3", "L3"] +ISO8859_4 = Literal["iso8859_4", "iso-8859-4", "latin4", "L4"] +ISO8859_5 = Literal["iso8859_5", "iso-8859-5", "cyrillic"] +ISO8859_6 = Literal["iso8859_6", "iso-8859-6", "arabic"] +ISO8859_7 = Literal["iso8859_7", "iso-8859-7", "greek", "greek8"] +ISO8859_8 = Literal["iso8859_8", "iso-8859-8", "hebrew"] +ISO8859_9 = Literal["iso8859_9", "iso-8859-9", "latin5", "L5"] +ISO8859_10 = Literal["iso8859_10", "iso-8859-10", "latin6", "L6"] +ISO8859_11 = Literal["iso8859_11", "iso-8859-11", "thai"] +ISO8859_13 = Literal["iso8859_13", "iso-8859-13", "latin7", "L7"] +ISO8859_14 = Literal["iso8859_14", "iso-8859-14", "latin8", "L8"] +ISO8859_15 = Literal["iso8859_15", "iso-8859-15", "latin9", "L9"] +ISO8859_16 = Literal["iso8859_16", "iso-8859-16", "latin10", "L10"] +JOHAB = Literal["johab", "cp1361", "ms1361"] +KOI8_R = Literal["koi8_r"] +KOI8_T = Literal["koi8_t"] +KOI8_U = Literal["koi8_u"] +KZ1048 = Literal["kz1048", "kz_1048", "strk1048_2002", "rk1048"] +MAC_CYRILLIC = Literal["mac_cyrillic", "maccyrillic"] +MAC_GREEK = Literal["mac_greek", "macgreek"] +MAC_ICELAND = Literal["mac_iceland", "maciceland"] +MAC_LATIN2 = Literal["mac_latin2", "maclatin2", "maccentraleurope", "mac_centeuro"] +MAC_ROMAN = Literal["mac_roman", "macroman", "macintosh"] +MAC_TURKISH = Literal["mac_turkish", "macturkish"] +PTCP154 = Literal["ptcp154", "csptcp154", "pt154", "cp154", "cyrillic-asian"] +SHIFT_JIS = Literal["shift_jis", "csshiftjis", "shiftjis", "sjis", "s_jis"] +SHIFT_JIS_2004 = Literal["shift_jis_2004", "shiftjis2004", "sjis_2004", "sjis2004"] +SHIFT_JISX0213 = Literal["shift_jisx0213", "shiftjisx0213", "sjisx0213", "s_jisx0213"] +UTF_32 = Literal["utf_32", "U32", "utf32"] +UTF_32_BE = Literal["utf_32_be", "UTF-32BE"] +UTF_32_LE = Literal["utf_32_le", "UTF-32LE"] +UTF_16 = Literal["utf_16", "U16", "utf16"] +UTF_16_BE = Literal["utf_16_be", "UTF-16BE"] +UTF_16_LE = Literal["utf_16_le", "UTF-16LE"] +UTF_7 = Literal["utf_7", "U7", "unicode-1-1-utf-7"] +UTF_8 = Literal["utf_8", "U8", "UTF", "utf8", "cp65001"] +UTF_8_SIG = Literal["utf_8_sig"] + +Encodings = Literal[ASCII, BIG5, BIG5HKSCS, CP037, CP273, CP424, CP437, CP500, CP720, CP737, CP775, CP850, CP852, CP855, CP856, CP857, CP858, CP860, CP861, CP862, CP863, CP864, CP865, CP866, CP869, CP874, CP875, CP932, CP949, CP950, CP1006, CP1026, CP1125, CP1140, CP1250, CP1251, CP1252, CP1253, CP1254, CP1255, CP1256, CP1257, CP1258, EUC_JP, EUC_JIS_2004, EUC_JISX0213, EUC_KR, GB2312, GBK, GB18030, HZ, ISO2022_JP, ISO2022_JP_1, ISO2022_JP_2, ISO2022_JP_2004, ISO2022_JP_3, ISO2022_JP_EXT, ISO2022_KR, LATIN_1, ISO8859_2, ISO8859_3, ISO8859_4, ISO8859_5, ISO8859_6, ISO8859_7, ISO8859_8, ISO8859_9, ISO8859_10, ISO8859_11, ISO8859_13, ISO8859_14, ISO8859_15, ISO8859_16, JOHAB, KOI8_R, KOI8_T, KOI8_U, KZ1048, MAC_CYRILLIC, MAC_GREEK, MAC_ICELAND, MAC_LATIN2, MAC_ROMAN, MAC_TURKISH, PTCP154, SHIFT_JIS, SHIFT_JIS_2004, SHIFT_JISX0213, UTF_32, UTF_32_BE, UTF_32_LE, UTF_16, UTF_16_BE, UTF_16_LE, UTF_7, UTF_8, UTF_8_SIG] + +__version__: str +from _getargv import * + +def as_string(pid: int, encoding: Encodings, skip: int = 0, nuls: bool = False) -> str: ... +def as_string_list(pid: int, encoding: Encodings) -> list[str]: ... diff --git a/src/getargv/_getargv.pyi b/src/getargv/_getargv.pyi new file mode 100644 index 0000000..9123fbd --- /dev/null +++ b/src/getargv/_getargv.pyi @@ -0,0 +1,2 @@ +def as_bytes(pid: int, skip: int = 0, nuls: bool = False) -> bytes: ... +def as_list(pid: int) -> list[bytes]: ... diff --git a/src/getargv/py.typed b/src/getargv/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/typings/_getargv.pyi b/typings/_getargv.pyi new file mode 120000 index 0000000..bb53639 --- /dev/null +++ b/typings/_getargv.pyi @@ -0,0 +1 @@ +../src/getargv/_getargv.pyi \ No newline at end of file From 80c2e6ca5d2f408e8f26d49e6014230eca2ccea4 Mon Sep 17 00:00:00 2001 From: Camden Narzt Date: Thu, 5 Oct 2023 10:45:39 -0600 Subject: [PATCH 2/6] apply suggested fixes --- pyproject.toml | 5 +++++ setup.py | 6 +++--- src/getargv/__init__.py | 6 +++--- typings/_getargv.pyi | 1 - 4 files changed, 11 insertions(+), 7 deletions(-) delete mode 120000 typings/_getargv.pyi diff --git a/pyproject.toml b/pyproject.toml index 979ee5f..5521327 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,3 +37,8 @@ classifiers = [ "Bug Reports" = "https://github.com/getargv/getargv.py/issues" "Homepage" = "https://getargv.narzt.cam" "Funding" = "https://github.com/sponsors/CamJN" + +[tool.pyright] +include = ["src", "setup.py"] +typeCheckingMode = "strict" +reportMissingModuleSource = false diff --git a/setup.py b/setup.py index 307e838..dd13495 100644 --- a/setup.py +++ b/setup.py @@ -1,19 +1,19 @@ from setuptools import setup, Extension from distutils.ccompiler import new_compiler from platform import processor -from sys import platform, version_info from sysconfig import get_config_var from os import environ, path from typing import Any, TypedDict, Literal, cast, Union import subprocess -if version_info >= (3, 11): +import sys +if sys.version_info >= (3, 11): import tomllib else: import tomli as tomllib # debug by setting DISTUTILS_DEBUG env var in shell to anything -assert platform == "darwin" +assert sys.platform == "darwin" encoding:str = 'UTF-8' diff --git a/src/getargv/__init__.py b/src/getargv/__init__.py index 2290fe8..18da017 100644 --- a/src/getargv/__init__.py +++ b/src/getargv/__init__.py @@ -23,13 +23,13 @@ __version__ The package version """ -from sys import platform, version_info -if version_info >= (3, 8): +import sys +if sys.version_info >= (3, 8): from importlib import metadata else: import importlib_metadata as metadata -if platform != 'darwin': +if sys.platform != 'darwin': from warnings import warn warn("only macOS is supported") diff --git a/typings/_getargv.pyi b/typings/_getargv.pyi deleted file mode 120000 index bb53639..0000000 --- a/typings/_getargv.pyi +++ /dev/null @@ -1 +0,0 @@ -../src/getargv/_getargv.pyi \ No newline at end of file From 8f8a8fbe1bab026d1d64435faaa99d0d410118c9 Mon Sep 17 00:00:00 2001 From: Camden Narzt Date: Thu, 5 Oct 2023 11:19:53 -0600 Subject: [PATCH 3/6] small updates from learned lessons --- .gitignore | 5 ++--- MANIFEST.in | 1 - Makefile | 12 +++++++++--- src/getargv/__init__.pyi | 2 ++ 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index dba698b..4c52225 100644 --- a/.gitignore +++ b/.gitignore @@ -2,11 +2,10 @@ compile_commands.json .cache /bin /lib +/dist +/build pyvenv.cfg MANIFEST -dist -build *.egg-info *getargv.cpython-*-darwin.so getargv.html -/pyrightconfig.json diff --git a/MANIFEST.in b/MANIFEST.in index 7ad6d7e..c0d0f37 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,7 +3,6 @@ include src/getargv/_getargvmodule.c include src/getargv/__init__.pyi include src/getargv/__init__.py include src/getargv/py.typed -include src/getargv/_getargv.pyi include README.md include LICENSE.txt include setup.py diff --git a/Makefile b/Makefile index 9f31d7e..0e04f71 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,16 @@ -version := $(shell python -c 'import tomli; print(tomli.load(open("pyproject.toml", mode="rb"))["project"]["version"])') +version := $(shell awk '/version = /{print $3}' pyproject.toml | tr -d '"') -.PHONY: activate db version upload-production upload-test build build-sdist sign check test clean console load devel docs +.PHONY: activate deps db version upload-production upload-test build build-sdist sign check test clean console load devel docs activate: @echo run this: source bin/activate +deactivate: + @echo run this: deactivate + +deps: + pip install build + db: compile_commands.json compile_commands.json: @@ -41,7 +47,7 @@ test: devel python tests/testgetargv.py clean: - rm -rf build dist getargv.egg-info src/getargv.egg-info MANIFEST src/_getargv.cpython-*-darwin.so + rm -rf build dist getargv.egg-info src/getargv.egg-info MANIFEST src/_getargv.cpython-*-darwin.so .cache .mypy_cache getargv.html console load: devel python -ic 'import getargv' diff --git a/src/getargv/__init__.pyi b/src/getargv/__init__.pyi index 782ace6..fcd5537 100644 --- a/src/getargv/__init__.pyi +++ b/src/getargv/__init__.pyi @@ -105,3 +105,5 @@ from _getargv import * def as_string(pid: int, encoding: Encodings, skip: int = 0, nuls: bool = False) -> str: ... def as_string_list(pid: int, encoding: Encodings) -> list[str]: ... +def as_bytes(pid: int, skip: int = 0, nuls: bool = False) -> bytes: ... +def as_list(pid: int) -> list[bytes]: ... From f103da769abfa9713f63560bb196735046dda5bf Mon Sep 17 00:00:00 2001 From: Camden Narzt Date: Tue, 28 Nov 2023 16:44:45 -0700 Subject: [PATCH 4/6] fix types for python 3.8 --- setup.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index dd13495..de06b56 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from platform import processor from sysconfig import get_config_var from os import environ, path -from typing import Any, TypedDict, Literal, cast, Union +from typing import Any, TypedDict, Literal, cast, Union, List, Dict import subprocess import sys if sys.version_info >= (3, 11): @@ -17,7 +17,7 @@ encoding:str = 'UTF-8' -def get_macos_target(lib_dirs:list[str], lib_name:str)->str: +def get_macos_target(lib_dirs:List[str], lib_name:str)->str: default = get_config_var('MACOSX_DEPLOYMENT_TARGET') compiler = new_compiler() lib_file = compiler.find_library_file(lib_dirs,lib_name) @@ -49,9 +49,9 @@ def platform_prefix(inpath:str, package:str)->str: return (environ.get("PREFIX") or "/").join(inpath) class Params(TypedDict): - libraries: list[str] - include_dirs: list[str] - library_dirs: list[str] + libraries: List[str] + include_dirs: List[str] + library_dirs: List[str] def pkgconfig(package:str)-> Params: kw: Params = {'include_dirs':[], 'library_dirs':[], 'libraries':[]} @@ -82,11 +82,11 @@ def pkgconfig(package:str)-> Params: environ["MACOSX_DEPLOYMENT_TARGET"] = get_macos_target(kw['library_dirs'],package_name) with open("pyproject.toml", mode="rb") as fp: - project: dict[str, Any] = tomllib.load(fp)['project'] - config: dict[str, Any] = project.copy() + project: Dict[str, Any] = tomllib.load(fp)['project'] + config: Dict[str, Any] = project.copy() for k in project.keys(): if k == 'authors': - author: dict[str, str] = config[k][0] + author: Dict[str, str] = config[k][0] config['author'] = author['name'] config['author_email'] = author['email'] del config[k] From 7a64f0d28ee7a40d72e5537ad969937b8fa79423 Mon Sep 17 00:00:00 2001 From: Camden Narzt Date: Tue, 28 Nov 2023 16:49:13 -0700 Subject: [PATCH 5/6] Continue fixing types for python 3.8 --- src/getargv/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/getargv/__init__.py b/src/getargv/__init__.py index 18da017..0c74b1c 100644 --- a/src/getargv/__init__.py +++ b/src/getargv/__init__.py @@ -24,6 +24,7 @@ """ import sys +from typing import List if sys.version_info >= (3, 8): from importlib import metadata else: @@ -52,7 +53,7 @@ def as_string(pid: int, encoding: str, skip: int = 0, nuls: bool = False) -> str """ return as_bytes(pid, skip, nuls).decode(encoding) -def as_string_list(pid: int, encoding: str) -> list[str]: +def as_string_list(pid: int, encoding: str) -> List[str]: """Returns the arguments of a pid as an list of strings decoded using specified encoding. Parameters: From ae4cfc5f28b5b11a50f191fe49db5d1f6dc99e5a Mon Sep 17 00:00:00 2001 From: Camden Narzt Date: Tue, 28 Nov 2023 16:56:22 -0700 Subject: [PATCH 6/6] fix upload path --- .github/workflows/python-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 642dd42..e04aeba 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -61,8 +61,8 @@ jobs: with: name: ${{ matrix.os }}.zip path: | - dist/*.whl - dist/*.tar.gz + getargv.py/dist/*.whl + getargv.py/dist/*.tar.gz release: if: ${{ github.ref_type == 'tag' }}