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 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,