From f61d641f375953a151dfcb41af57fc1d8789ba70 Mon Sep 17 00:00:00 2001 From: Nicholas Lundgaard Date: Mon, 3 Mar 2025 20:23:28 +0000 Subject: [PATCH 1/4] Don't use `is not` to compare to literals This has been a bad-ish idea since python 3.8. Fix is easy enough. Resolves: ``` /mfab/Dockerfiles/deps/PackagesPartsAndPlacements/apps/AnalysisWorker/.venv/lib/python3.11/site-packages/gerber/excellon_statements.py:458: SyntaxWarning: "is not" with a literal. Did you mean "!="? if stmt['xdelta'] is not '' else None) /mfab/Dockerfiles/deps/PackagesPartsAndPlacements/apps/AnalysisWorker/.venv/lib/python3.11/site-packages/gerber/excellon_statements.py:461: SyntaxWarning: "is not" with a literal. Did you mean "!="? if stmt['ydelta'] is not '' else None) /mfab/Dockerfiles/deps/PackagesPartsAndPlacements/apps/AnalysisWorker/.venv/lib/python3.11/site-packages/gerber/excellon_statements.py:609: SyntaxWarning: "is not" with a literal. Did you mean "!="? if stmt['x'] is not '' else None) /mfab/Dockerfiles/deps/PackagesPartsAndPlacements/apps/AnalysisWorker/.venv/lib/python3.11/site-packages/gerber/excellon_statements.py:612: SyntaxWarning: "is not" with a literal. Did you mean "!="? if stmt['y'] is not '' else None) /mfab/Dockerfiles/deps/PackagesPartsAndPlacements/apps/AnalysisWorker/.venv/lib/python3.11/site-packages/gerber/ipc356.py:385: SyntaxWarning: "is not" with a literal. Did you mean "!="? x = int(coord_dict['x']) if coord_dict['x'] is not '' else x /mfab/Dockerfiles/deps/PackagesPartsAndPlacements/apps/AnalysisWorker/.venv/lib/python3.11/site-packages/gerber/ipc356.py:386: SyntaxWarning: "is not" with a literal. Did you mean "!="? y = int(coord_dict['y']) if coord_dict['y'] is not '' else y /mfab/Dockerfiles/deps/PackagesPartsAndPlacements/apps/AnalysisWorker/.venv/lib/python3.11/site-packages/gerber/ipc356.py:415: SyntaxWarning: "is not" with a literal. Did you mean "!="? scale if aperture_dict['x'] is not '' else None /mfab/Dockerfiles/deps/PackagesPartsAndPlacements/apps/AnalysisWorker/.venv/lib/python3.11/site-packages/gerber/ipc356.py:417: SyntaxWarning: "is not" with a literal. Did you mean "!="? scale if aperture_dict['y'] is not '' else None /mfab/Dockerfiles/deps/PackagesPartsAndPlacements/apps/AnalysisWorker/.venv/lib/python3.11/site-packages/gerber/ipc356.py:431: SyntaxWarning: "is not" with a literal. Did you mean "!="? x = int(coord_dict['x']) if coord_dict['x'] is not '' else x /mfab/Dockerfiles/deps/PackagesPartsAndPlacements/apps/AnalysisWorker/.venv/lib/python3.11/site-packages/gerber/ipc356.py:432: SyntaxWarning: "is not" with a literal. Did you mean "!="? y = int(coord_dict['y']) if coord_dict['y'] is not '' else y ``` --- gerber/excellon_statements.py | 8 ++++---- gerber/ipc356.py | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gerber/excellon_statements.py b/gerber/excellon_statements.py index 2c50ef9..4d11a9e 100644 --- a/gerber/excellon_statements.py +++ b/gerber/excellon_statements.py @@ -455,10 +455,10 @@ def from_excellon(cls, line, settings, **kwargs): count = int(stmt['rcount']) xdelta = (parse_gerber_value(stmt['xdelta'], settings.format, settings.zero_suppression) - if stmt['xdelta'] is not '' else None) + if stmt['xdelta'] != '' else None) ydelta = (parse_gerber_value(stmt['ydelta'], settings.format, settings.zero_suppression) - if stmt['ydelta'] is not '' else None) + if stmt['ydelta'] != '' else None) c = cls(count, xdelta, ydelta, **kwargs) c.units = settings.units return c @@ -606,10 +606,10 @@ def from_excellon(cls, line, settings, **kwargs): stmt = match.groupdict() x = (parse_gerber_value(stmt['x'], settings.format, settings.zero_suppression) - if stmt['x'] is not '' else None) + if stmt['x'] != '' else None) y = (parse_gerber_value(stmt['y'], settings.format, settings.zero_suppression) - if stmt['y'] is not '' else None) + if stmt['y'] != '' else None) c = cls(x, y, **kwargs) c.units = settings.units return c diff --git a/gerber/ipc356.py b/gerber/ipc356.py index 52eb676..4ca7005 100644 --- a/gerber/ipc356.py +++ b/gerber/ipc356.py @@ -382,8 +382,8 @@ def from_line(cls, line, settings): coord_strings = line.strip().split()[1:] for coord in coord_strings: coord_dict = _COORD.match(coord).groupdict() - x = int(coord_dict['x']) if coord_dict['x'] is not '' else x - y = int(coord_dict['y']) if coord_dict['y'] is not '' else y + x = int(coord_dict['x']) if coord_dict['x'] != '' else x + y = int(coord_dict['y']) if coord_dict['y'] != '' else y points.append((x * scale, y * scale)) return cls(type, points) @@ -412,9 +412,9 @@ def from_line(cls, line, settings): x = 0 y = 0 x = int(aperture_dict['x']) * \ - scale if aperture_dict['x'] is not '' else None + scale if aperture_dict['x'] != '' else None y = int(aperture_dict['y']) * \ - scale if aperture_dict['y'] is not '' else None + scale if aperture_dict['y'] != '' else None aperture = (x, y) # Parse out conductor shapes @@ -428,8 +428,8 @@ def from_line(cls, line, settings): coords = rshape.split() for coord in coords: coord_dict = _COORD.match(coord).groupdict() - x = int(coord_dict['x']) if coord_dict['x'] is not '' else x - y = int(coord_dict['y']) if coord_dict['y'] is not '' else y + x = int(coord_dict['x']) if coord_dict['x'] != '' else x + y = int(coord_dict['y']) if coord_dict['y'] != '' else y shape.append((x * scale, y * scale)) shapes.append(tuple(shape)) return cls(net_name, layer, aperture, tuple(shapes)) From 02e8de0f8c6062a708280678186a9d931096ec6e Mon Sep 17 00:00:00 2001 From: Nicholas Lundgaard Date: Tue, 4 Mar 2025 15:32:35 +0000 Subject: [PATCH 2/4] Remove python 3.7/3.8 from GHA It looks like these have been removed: > Version 3.7 with arch x64 not found > Version 3.8 with arch x64 not found --- .github/workflows/python37.yaml | 35 --------------------------------- .github/workflows/python38.yaml | 35 --------------------------------- 2 files changed, 70 deletions(-) delete mode 100644 .github/workflows/python37.yaml delete mode 100644 .github/workflows/python38.yaml diff --git a/.github/workflows/python37.yaml b/.github/workflows/python37.yaml deleted file mode 100644 index 1bde5eb..0000000 --- a/.github/workflows/python37.yaml +++ /dev/null @@ -1,35 +0,0 @@ -name: Unit Tests for Python 3.7 - -on: - pull_request: - types: - - opened - - reopened - - ready_for_review - - synchronize - push: - branches: - - master - -jobs: - test: - name: Python Version Gauntlet - strategy: - fail-fast: false - matrix: - python-version: [3.7] - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - pip install -r requirements-dev.txt - - name: Run Unit Tests - run: | - pytest diff --git a/.github/workflows/python38.yaml b/.github/workflows/python38.yaml deleted file mode 100644 index d99d9c2..0000000 --- a/.github/workflows/python38.yaml +++ /dev/null @@ -1,35 +0,0 @@ -name: Unit Tests for Python 3.8 - -on: - pull_request: - types: - - opened - - reopened - - ready_for_review - - synchronize - push: - branches: - - master - -jobs: - test: - name: Python Version Gauntlet - strategy: - fail-fast: false - matrix: - python-version: [3.8] - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - pip install -r requirements-dev.txt - - name: Run Unit Tests - run: | - pytest From 70d9dc5d8fc6007bc0179b5afbf5c4d79e5c34f0 Mon Sep 17 00:00:00 2001 From: Nicholas Lundgaard Date: Tue, 4 Mar 2025 15:32:54 +0000 Subject: [PATCH 3/4] Add python 3.13 to test matrix on GHA --- .github/workflows/python313.yaml | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/python313.yaml diff --git a/.github/workflows/python313.yaml b/.github/workflows/python313.yaml new file mode 100644 index 0000000..d4c9e60 --- /dev/null +++ b/.github/workflows/python313.yaml @@ -0,0 +1,35 @@ +name: Unit Tests for Python 3.13 + +on: + pull_request: + types: + - opened + - reopened + - ready_for_review + - synchronize + push: + branches: + - master + +jobs: + test: + name: Python Version Gauntlet + strategy: + fail-fast: false + matrix: + python-version: ['3.13'] + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + pip install -r requirements-dev.txt + - name: Run Unit Tests + run: | + pytest From 87a8d04a9b38bedbc7bcd634a190498263e2d31b Mon Sep 17 00:00:00 2001 From: Nicholas Lundgaard Date: Tue, 4 Mar 2025 15:53:52 +0000 Subject: [PATCH 4/4] Additional fixes for the 3.7/3.8 GHA retirement, addition of 3.13 --- .github/workflows/unit-tests.yml | 2 +- README.md | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 7037bd4..ae2fc7a 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.7, 3.8, 3.9, '3.10', '3.11', '3.12'] + python-version: [3.9, '3.10', '3.11', '3.12'] runs-on: ubuntu-latest diff --git a/README.md b/README.md index 1435455..1eeccb7 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,11 @@ Tools to handle Gerber and Excellon files in Python. In the pipeline column output the status of a certain step in github actions workflow | Version | Supported | Notes | | ------- | ------------------ | -------- | -| 3.7.x | [![Python 3.7](https://github.com/MacroFab/pcb-tools/actions/workflows/python37.yaml/badge.svg)](https://github.com/MacroFab/pcb-tools/actions/workflows/python37.yaml) | End of Life | -| 3.8.x | [![Python 3.8](https://github.com/MacroFab/pcb-tools/actions/workflows/python38.yaml/badge.svg)](https://github.com/MacroFab/pcb-tools/actions/workflows/python38.yaml) | | | 3.9.x | [![Python 3.9](https://github.com/MacroFab/pcb-tools/actions/workflows/python39.yaml/badge.svg)](https://github.com/MacroFab/pcb-tools/actions/workflows/python39.yaml) | | | 3.10.x | [![Python 3.10](https://github.com/MacroFab/pcb-tools/actions/workflows/python310.yaml/badge.svg)](https://github.com/MacroFab/pcb-tools/actions/workflows/python310.yaml) | | | 3.11.x | [![Python 3.11](https://github.com/MacroFab/pcb-tools/actions/workflows/python311.yaml/badge.svg)](https://github.com/MacroFab/pcb-tools/actions/workflows/python311.yaml) | | | 3.12.x | [![Python 3.12](https://github.com/MacroFab/pcb-tools/actions/workflows/python312.yaml/badge.svg)](https://github.com/MacroFab/pcb-tools/actions/workflows/python312.yaml) | | +| 3.13.x | [![Python 3.13](https://github.com/MacroFab/pcb-tools/actions/workflows/python313.yaml/badge.svg)](https://github.com/MacroFab/pcb-tools/actions/workflows/python313.yaml) | | Usage Example: ---------------