From 9cc8b83b025361d865ca5cc5cf8eee3060fc174e Mon Sep 17 00:00:00 2001 From: Adirelle Date: Mon, 17 Jul 2023 16:36:24 +0200 Subject: [PATCH 1/2] fix(!windows): prevents mypy from complaining about findpython.pep514tools --- src/findpython/pep514tools/_registry.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/findpython/pep514tools/_registry.py b/src/findpython/pep514tools/_registry.py index 16cd93a..7502b2a 100644 --- a/src/findpython/pep514tools/_registry.py +++ b/src/findpython/pep514tools/_registry.py @@ -12,18 +12,27 @@ "REGISTRY_SOURCE_CU", ] +import sys import re from itertools import count -try: - import winreg -except ImportError: - import _winreg as winreg - REGISTRY_SOURCE_LM = 1 REGISTRY_SOURCE_LM_WOW6432 = 2 REGISTRY_SOURCE_CU = 3 +# Simple tests direcly on sys variables are necessary to please mypy +if sys.platform == "win32": + if sys.version_info >= (3,): + import winreg + else: + import _winreg as winreg +else: + def open_source(): + pass + +# Prevents mypy (and python) from parsing further on non-win32 platforms +assert sys.platform == "win32" + _REG_KEY_INFO = { REGISTRY_SOURCE_LM: ( winreg.HKEY_LOCAL_MACHINE, From 1c711c5eb0d01b5dfab295e99da5b3b03d2941d6 Mon Sep 17 00:00:00 2001 From: Adirelle Date: Mon, 17 Jul 2023 16:59:02 +0200 Subject: [PATCH 2/2] ci: run pre-commit tests. --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff48d2d..b7e9eb1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,6 +34,8 @@ jobs: - name: Install packages run: pdm install + - name: Run Pre-Commit Tests + uses: pre-commit/action@v3.0.0 - name: Run Integration run: pdm run findpython --all -v - name: Run Tests