From 3d5acd9062a7c8629d2d498441770423b70dc19d Mon Sep 17 00:00:00 2001 From: Sveinbjorn Thordarson Date: Mon, 18 Sep 2023 21:51:20 +0000 Subject: [PATCH] Updated CI to use pyproject.toml, ruff linter --- .github/workflows/python-package.yml | 19 ++++++++++++------- pyproject.toml | 3 ++- src/iceaddr/postcodes.py | 4 +--- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 31b4a7d..03e7b19 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -2,9 +2,11 @@ name: tests on: push: - branches: [ master ] + branches: + - '*' pull_request: - branches: [ master ] + branches: + - '*' jobs: build: @@ -12,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8"] steps: - uses: actions/checkout@v2 @@ -22,13 +24,16 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python -m pip install --upgrade pip wheel setuptools pytest types-setuptools mypy - - name: Run mypy + python -m pip install ".[dev]" + - name: Run ruff linter run: | - mypy iceaddr/*.py + ruff src/iceaddr - name: Test with pytest run: | - python -m pytest + python -m pytest -vvv + - name: Build package + run: | + python -m build diff --git a/pyproject.toml b/pyproject.toml index 4a670fb..ee6ed4c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,6 +42,7 @@ dev = [ "pre-commit>=3.3.3", "black>=23.7.0", "mypy>=1.5.1", + "types-setuptools>=68.2.0", "ruff>=0.0.285", "coverage[toml]>=7.3.1", ] @@ -135,7 +136,7 @@ section-order = [ [tool.ruff.isort.sections] # Have typing libraries above other imports -typehints = ["typing", "typing_extensions", "types"] +typehints = ["typing", "typing_extensions", "types", "types-setuptools"] # *** Build system configuration *** diff --git a/src/iceaddr/postcodes.py b/src/iceaddr/postcodes.py index 64f9cfb..75e0228 100644 --- a/src/iceaddr/postcodes.py +++ b/src/iceaddr/postcodes.py @@ -1428,9 +1428,7 @@ def _filter_postcodes(key: str, searchstr: str, partial: bool = False) -> List[i for k, v in POSTCODES.items(): nf = v[k1].lower() tgf = v[k2].lower() - if partial and (nf.startswith(p) or tgf.startswith(p)): - matches.append(k) - elif nf == p or tgf == p: + if (partial and (nf.startswith(p) or tgf.startswith(p))) or p in (nf, tgf): matches.append(k) return matches