From 0a3d279eb5213b0b8a407e4ef57de29d37640f9d Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Thu, 19 Sep 2024 20:36:40 +0800 Subject: [PATCH 1/2] Configure and format the project --- .github/dependabot.yml | 1 - .github/release-drafter.yml | 54 +++++++++++----------- .github/workflows/pages.yml | 51 +++++++++----------- .github/workflows/pypi.yml | 32 ++++++------- .github/workflows/pytest.yaml | 31 ++++++------- .github/workflows/release-drafter.yml | 2 +- .pre-commit-config.yaml | 49 ++++++++++++++++++++ .readthedocs.yml | 3 +- docs/conf.py | 34 +++++++------- docs/requirements.txt | 5 -- pyproject.toml | 22 ++++++++- requirements.txt | 8 ---- svgdatagrabber/__init__.py | 6 ++- svgdatagrabber/filters/__init__.py | 10 ++++ svgdatagrabber/filters/rectangle.py | 2 +- svgdatagrabber/filters/specialline.py | 2 +- svgdatagrabber/geometry/__init__.py | 54 ++++++++++++++++++---- svgdatagrabber/geometry/arc.py | 5 +- svgdatagrabber/geometry/bezier.py | 2 +- svgdatagrabber/geometry/circle.py | 2 +- svgdatagrabber/geometry/closedshape.py | 2 +- svgdatagrabber/geometry/ellipse.py | 2 +- svgdatagrabber/geometry/geometrybase.py | 2 +- svgdatagrabber/geometry/linebase.py | 2 +- svgdatagrabber/geometry/path.py | 13 ++++-- svgdatagrabber/geometry/point.py | 2 +- svgdatagrabber/geometry/polygon.py | 2 +- svgdatagrabber/geometry/quadrilateral.py | 3 +- svgdatagrabber/geometry/sequence.py | 8 ++-- svgdatagrabber/geometry/triangle.py | 2 +- svgdatagrabber/graphics/__main__.py | 1 + svgdatagrabber/graphics/annotations.py | 4 +- svgdatagrabber/graphics/geometricobject.py | 2 +- svgdatagrabber/graphics/graphicsview.py | 12 ++--- svgdatagrabber/graphics/mainwindow.py | 2 +- svgdatagrabber/parser.py | 8 ++-- tests/conftest.py | 1 + 37 files changed, 269 insertions(+), 174 deletions(-) create mode 100644 .pre-commit-config.yaml delete mode 100644 docs/requirements.txt delete mode 100644 requirements.txt diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3bf155a..aea0462 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,6 +1,5 @@ version: 2 updates: - # Dependencies for GitHub Actions - package-ecosystem: "github-actions" directory: "/" diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 20025ae..a231eb0 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,47 +1,47 @@ # .github/release-drafter.yml -name-template: 'v$RESOLVED_VERSION 🌈' -tag-template: 'v$RESOLVED_VERSION' +name-template: "v$RESOLVED_VERSION 🌈" +tag-template: "v$RESOLVED_VERSION" filter-by-commitish: true commitish: main categories: - - title: '🚀 New Features' + - title: "🚀 New Features" labels: - - 'feature' - - 'new feature' - - 'enhancement' - - 'customization' - - title: '🐛 Bug Fixes' + - "feature" + - "new feature" + - "enhancement" + - "customization" + - title: "🐛 Bug Fixes" labels: - - 'fix' - - 'bugfix' - - 'bug' - - 'test' - - 'typo' - - 'refactor' - - title: '📝 Documentation' + - "fix" + - "bugfix" + - "bug" + - "test" + - "typo" + - "refactor" + - title: "📝 Documentation" labels: - - 'documentation' - - 'docs' - - 'doc' - - title: '🤖 Automation' + - "documentation" + - "docs" + - "doc" + - title: "🤖 Automation" labels: - - 'automation' - - 'release' - - 'workflow' -version-template: '$MAJOR.$MINOR.$PATCH' -change-template: '- $TITLE @$AUTHOR (#$NUMBER)' + - "automation" + - "release" + - "workflow" +version-template: "$MAJOR.$MINOR.$PATCH" +change-template: "- $TITLE @$AUTHOR (#$NUMBER)" change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. version-resolver: major: labels: - - 'major' + - "major" minor: labels: - - 'minor' + - "minor" patch: labels: - - 'patch' + - "patch" default: patch template: | ## Changes diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 2c71870..c58553d 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -1,41 +1,36 @@ -name: docs-test +name: docs + on: push: branches: - - main + - main paths: - - 'SSI/**' - - 'docs/source/**' - - '.github/workflows/pages.yml' + - "svgdatagrabber/**" + - "docs/source/**" + - ".github/workflows/pages.yml" pull_request: branches: - - main + - main paths: - - 'SSI/**' - - 'docs/source/**' - - '.github/workflows/pages.yml' + - "svgdatagrabber/**" + - "docs/source/**" + - ".github/workflows/pages.yml" workflow_dispatch: jobs: build: runs-on: ubuntu-latest - concurrency: pages_staging_environment - strategy: - matrix: - python-version: ['3.10'] steps: - - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Installing the library - shell: bash -l {0} - run: | - pip install -r docs/requirements.txt - pip install . - - name: Build and Commit - uses: sphinx-notes/pages@v2 - with: - documentation_path: docs + - uses: actions/setup-python@v4 + with: + python-version: "3.12" + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Installing the library + run: | + pip install -e .[docs] + - name: Build and Commit + uses: sphinx-notes/pages@v2 + with: + documentation_path: docs diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index bbd331a..38752c1 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -20,19 +20,19 @@ jobs: publish: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build - - name: Build package - run: python -m build - - name: Publish package - uses: pypa/gh-action-pypi-publish@v1.6.4 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@v1.6.4 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 56e5a25..0c20cfc 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -3,17 +3,17 @@ name: pytest on: push: branches: - - main + - main paths: - - 'svgdatagrabber/**' - - 'tests/**' - - '.github/workflows/pytest.yaml' + - "svgdatagrabber/**" + - "tests/**" + - ".github/workflows/pytest.yaml" pull_request: types: [opened, reopened, synchronize] paths: - - 'svgdatagrabber/**' - - 'tests/**' - - '.github/workflows/pytest.yaml' + - "svgdatagrabber/**" + - "tests/**" + - ".github/workflows/pytest.yaml" workflow_dispatch: jobs: @@ -22,7 +22,12 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: + - "3.8" + - "3.9" + - "3.10" + - "3.11" + - "3.12" os: [ubuntu-latest] steps: - uses: actions/checkout@v3 @@ -33,15 +38,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 pytest pytest-cov - pip install -r requirements.txt - pip install -e . - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + pip install -e .[dev] - name: Test with pytest run: | pytest diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 6ad7fbf..9395e8f 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -1,7 +1,7 @@ name: Release Drafter on: push: - branches: [ "main" ] + branches: ["main"] # pull_request event is required only for autolabeler pull_request: # Only following types are handled by the action, but one can default to all as well diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..4808350 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,49 @@ +repos: + - repo: https://github.com/psf/black + rev: "24.2.0" + hooks: + - id: black + args: + - --line-length=120 + - --include='(micromechanical/.*\.pyi?|tests/.*\.py|docs/conf\.py)' + + - repo: https://github.com/pycqa/isort + rev: "5.13.2" + hooks: + - id: isort + args: + - --profile=black + - id: isort + name: isort (pyi) + types: [pyi] + args: + - --profile=black + - --line-length=120 + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: "v0.3.2" + hooks: + - id: ruff + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: "v4.5.0" + hooks: + - id: check-added-large-files + - id: check-case-conflict + - id: check-merge-conflict + - id: check-yaml + args: + - --allow-multiple-documents + - id: debug-statements + - id: name-tests-test + args: + - --pytest-test-first + - id: requirements-txt-fixer + - id: trailing-whitespace + + - repo: https://github.com/pre-commit/mirrors-prettier + rev: "v3.1.0" + hooks: + - id: prettier + additional_dependencies: + - prettier@3.1.0 diff --git a/.readthedocs.yml b/.readthedocs.yml index 11866f5..17c98a1 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -8,6 +8,7 @@ sphinx: formats: [] python: install: - - requirements: docs/requirements.txt - method: pip path: . + extra: + - docs diff --git a/docs/conf.py b/docs/conf.py index d3e4d6e..3c44616 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -9,41 +9,41 @@ import os import sys -project = 'SvgDataGrabber' -copyright = '2022, WANG Hailin' -author = 'WANG Hailin' +project = "SvgDataGrabber" +copyright = "2022, WANG Hailin" +author = "WANG Hailin" try: import svgdatagrabber - release = version = svgdatagrabber.__version__.split('+')[0] + release = version = svgdatagrabber.__version__.split("+")[0] except (ImportError, AttributeError): import warnings - warnings.warn('svgdatagrabber is not installed, using 0.0.1') - release = version = '0.0.1' -sys.path.insert(0, os.path.abspath('..')) + warnings.warn("svgdatagrabber is not installed, using 0.0.1") + release = version = "0.0.1" +sys.path.insert(0, os.path.abspath("..")) # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration extensions = [ - 'autoapi.extension', - 'myst_parser', - 'nbsphinx', - 'sphinx.ext.autodoc', - 'sphinx_copybutton', + "autoapi.extension", + "myst_parser", + "nbsphinx", + "sphinx.ext.autodoc", + "sphinx_copybutton", ] # AutoAPI configuration -autoapi_dirs = ['../svgdatagrabber'] +autoapi_dirs = ["../svgdatagrabber"] # Templates -templates_path = ['_templates'] -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] +templates_path = ["_templates"] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] # -- Options for HTML output ------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output -html_theme = 'furo' -html_static_path = ['_static'] +html_theme = "furo" +html_static_path = ["_static"] diff --git a/docs/requirements.txt b/docs/requirements.txt deleted file mode 100644 index c8e1fba..0000000 --- a/docs/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -furo -myst-parser -nbsphinx -sphinx-autoapi -sphinx-copybutton diff --git a/pyproject.toml b/pyproject.toml index e932b54..63e7326 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,4 @@ -# pyproject.toml, for more information about configuration options, see +# pyproject.toml, for more information about configuration options, see # https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html [build-system] @@ -20,12 +20,19 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Programming Language :: Python :: Implementation :: PyPy", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ] dependencies = [ - 'sphinx-toolbox', + "matplotlib", + "numpy", + "pandas", + "qtpy", + "PyQt5", + "shapely", + "svgpathtools", ] [project.urls] @@ -35,6 +42,17 @@ dependencies = [ [project.scripts] svgdatagrabber-graphics = "svgdatagrabber.graphics.__main__:main" +[project.optional-dependencies] +dev = ["pytest", "pytest-cov"] +docs = [ + "furo", + "myst-parser", + "nbsphinx", + "sphinx", + "sphinx-autoapi", + "sphinx-copybutton", +] + [tool.setuptools_scm] root = "." relative_to = "__file__" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index d519129..0000000 --- a/requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -matplotlib -numpy -pytest -pandas -qtpy -pyqt5 -shapely -svgpathtools diff --git a/svgdatagrabber/__init__.py b/svgdatagrabber/__init__.py index 0317ffc..452e517 100644 --- a/svgdatagrabber/__init__.py +++ b/svgdatagrabber/__init__.py @@ -1,3 +1,7 @@ from .parser import SvgPathParser - from .version import __version__ + +__all__ = [ + "SvgPathParser", + "__version__", +] diff --git a/svgdatagrabber/filters/__init__.py b/svgdatagrabber/filters/__init__.py index ce193be..e4fe0b4 100644 --- a/svgdatagrabber/filters/__init__.py +++ b/svgdatagrabber/filters/__init__.py @@ -4,3 +4,13 @@ from .rectangle import RectangleRangeFilter from .segmentnumber import SegmentNumberFilter from .specialline import HorizontalLineFilter, VerticalLineFilter + +__all__ = [ + "ClosedPathFilter", + "CustomFilter", + "FilterBase", + "RectangleRangeFilter", + "SegmentNumberFilter", + "HorizontalLineFilter", + "VerticalLineFilter", +] diff --git a/svgdatagrabber/filters/rectangle.py b/svgdatagrabber/filters/rectangle.py index 5c48d5f..b9c1118 100644 --- a/svgdatagrabber/filters/rectangle.py +++ b/svgdatagrabber/filters/rectangle.py @@ -3,7 +3,7 @@ from typing import Union import numpy as np -from svgpathtools.path import Path, Line, QuadraticBezier, CubicBezier, Arc +from svgpathtools.path import Arc, CubicBezier, Line, Path, QuadraticBezier from .filterbase import FilterBase diff --git a/svgdatagrabber/filters/specialline.py b/svgdatagrabber/filters/specialline.py index e1ff44a..31ddf97 100644 --- a/svgdatagrabber/filters/specialline.py +++ b/svgdatagrabber/filters/specialline.py @@ -2,7 +2,7 @@ from typing import Union -from svgpathtools.path import Path, Line, QuadraticBezier, CubicBezier, Arc +from svgpathtools.path import Arc, CubicBezier, Line, Path, QuadraticBezier from .filterbase import FilterBase diff --git a/svgdatagrabber/geometry/__init__.py b/svgdatagrabber/geometry/__init__.py index 5d6ee25..27867d5 100644 --- a/svgdatagrabber/geometry/__init__.py +++ b/svgdatagrabber/geometry/__init__.py @@ -4,25 +4,59 @@ from .closedshape import ClosedShape from .ellipse import Ellipse from .geometrybase import GeometryBase -from .linebase import LineBase, StraightLineBase, CurveLineBase +from .linebase import CurveLineBase, LineBase, StraightLineBase from .path import Path, PathSequence -from .point import Point, Vector, PointType +from .point import Point, PointType, Vector from .polygon import Polygon from .quadrilateral import ( - Quadrilateral, - Trapezoid, + IsoscelesTrapezoid, + Kite, Parallelogram, + Quadrilateral, Rectangle, - Square, - Kite, RightKite, - IsoscelesTrapezoid, + Square, + Trapezoid, ) from .straightline import ( + ExtendedLineRay, + ExtendedLineSegment, Line, - LineSegment, LineRay, - ExtendedLineSegment, - ExtendedLineRay, + LineSegment, ) from .triangle import Triangle + +__all__ = [ + "Arc", + "Bezier", + "CubicBezier", + "QuadraticBezier", + "Circle", + "ClosedShape", + "Ellipse", + "GeometryBase", + "LineBase", + "StraightLineBase", + "CurveLineBase", + "Path", + "PathSequence", + "Point", + "Vector", + "PointType", + "Polygon", + "Quadrilateral", + "Trapezoid", + "Parallelogram", + "Rectangle", + "Square", + "Kite", + "RightKite", + "IsoscelesTrapezoid", + "Line", + "LineSegment", + "LineRay", + "ExtendedLineSegment", + "ExtendedLineRay", + "Triangle", +] diff --git a/svgdatagrabber/geometry/arc.py b/svgdatagrabber/geometry/arc.py index 7eec3a6..2bce7ad 100644 --- a/svgdatagrabber/geometry/arc.py +++ b/svgdatagrabber/geometry/arc.py @@ -1,13 +1,12 @@ from __future__ import annotations -from typing import List, Iterable, Tuple +from typing import Iterable, List, Tuple import numpy as np from svgpathtools import Arc as SvgPathToolsArc from .ellipse import Ellipse -from .linebase import CurveLineBase -from .linebase import LineBase +from .linebase import CurveLineBase, LineBase from .point import Point, PointType diff --git a/svgdatagrabber/geometry/bezier.py b/svgdatagrabber/geometry/bezier.py index a809443..97a4b3e 100644 --- a/svgdatagrabber/geometry/bezier.py +++ b/svgdatagrabber/geometry/bezier.py @@ -5,7 +5,7 @@ from svgpathtools import QuadraticBezier as SvgPathToolsQuadraticBezier from .linebase import CurveLineBase -from .point import PointType, Point +from .point import Point, PointType class Bezier(CurveLineBase, ABC): diff --git a/svgdatagrabber/geometry/circle.py b/svgdatagrabber/geometry/circle.py index f25568b..5464cfd 100644 --- a/svgdatagrabber/geometry/circle.py +++ b/svgdatagrabber/geometry/circle.py @@ -1,7 +1,7 @@ from typing import Tuple from .ellipse import Ellipse -from .point import PointType, Point +from .point import Point, PointType class Circle(Ellipse): diff --git a/svgdatagrabber/geometry/closedshape.py b/svgdatagrabber/geometry/closedshape.py index 762856f..f0e2a55 100644 --- a/svgdatagrabber/geometry/closedshape.py +++ b/svgdatagrabber/geometry/closedshape.py @@ -1,7 +1,7 @@ from __future__ import annotations from abc import ABC -from typing import Tuple, Iterable, List +from typing import Iterable, List, Tuple from .geometrybase import GeometryBase from .linebase import LineBase diff --git a/svgdatagrabber/geometry/ellipse.py b/svgdatagrabber/geometry/ellipse.py index c6d4d26..e436866 100644 --- a/svgdatagrabber/geometry/ellipse.py +++ b/svgdatagrabber/geometry/ellipse.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Tuple, Iterable, List +from typing import Iterable, List, Tuple import numpy as np diff --git a/svgdatagrabber/geometry/geometrybase.py b/svgdatagrabber/geometry/geometrybase.py index 7a0f672..e8ff716 100644 --- a/svgdatagrabber/geometry/geometrybase.py +++ b/svgdatagrabber/geometry/geometrybase.py @@ -9,7 +9,7 @@ from qtpy.QtGui import QPen from qtpy.QtWidgets import QApplication, QGraphicsScene -from ..graphics.annotations import QPenType, QBrushType, QGraphicsItemType +from ..graphics.annotations import QBrushType, QGraphicsItemType, QPenType class GeometryDrawAs(IntEnum): diff --git a/svgdatagrabber/geometry/linebase.py b/svgdatagrabber/geometry/linebase.py index 2b14f37..1844fe8 100644 --- a/svgdatagrabber/geometry/linebase.py +++ b/svgdatagrabber/geometry/linebase.py @@ -1,6 +1,6 @@ from abc import ABC -from .geometrybase import GeometryBase, DrawAsLine +from .geometrybase import DrawAsLine, GeometryBase class LineBase(GeometryBase, ABC): diff --git a/svgdatagrabber/geometry/path.py b/svgdatagrabber/geometry/path.py index 538eb0a..07fcadf 100644 --- a/svgdatagrabber/geometry/path.py +++ b/svgdatagrabber/geometry/path.py @@ -1,7 +1,7 @@ from __future__ import annotations import math -from typing import List, Union, Iterable +from typing import Iterable, List, Union import numpy as np import pandas as pd @@ -12,12 +12,13 @@ from svgpathtools import Line as SvgPathToolsLine from svgpathtools import Path as SvgPathToolsPath from svgpathtools import QuadraticBezier as SvgPathToolsQuadraticBezier +from typing_extensions import Self from .arc import Arc -from .bezier import QuadraticBezier, CubicBezier, Bezier +from .bezier import Bezier, CubicBezier, QuadraticBezier from .csys import CoordinateSystem -from .linebase import StraightLineBase, LineBase -from .sequence import LineSequence, GeometrySequence +from .linebase import LineBase, StraightLineBase +from .sequence import GeometrySequence, LineSequence from .straightline import LineSegment SvgPathToolsSegmentType = Union[SvgPathToolsLine, SvgPathToolsArc, SvgPathToolsQuadraticBezier, SvgPathToolsCubicBezier] @@ -78,6 +79,10 @@ class PathSequence(GeometrySequence): def __init__(self, *paths: Path): GeometrySequence.__init__(self, *paths) + def __getitem__(self, item) -> Self | Path: + items = self.items[item] + return self.__class__(*items) if isinstance(items, list) else items + @property def paths(self) -> List[Path]: return self.items diff --git a/svgdatagrabber/geometry/point.py b/svgdatagrabber/geometry/point.py index 8945e1b..61513da 100644 --- a/svgdatagrabber/geometry/point.py +++ b/svgdatagrabber/geometry/point.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Iterable, Union, Tuple +from typing import Iterable, Tuple, Union import numpy as np from qtpy.QtCore import QLineF diff --git a/svgdatagrabber/geometry/polygon.py b/svgdatagrabber/geometry/polygon.py index bf68e73..3b85435 100644 --- a/svgdatagrabber/geometry/polygon.py +++ b/svgdatagrabber/geometry/polygon.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import List, Iterable, Tuple +from typing import Iterable, List, Tuple from qtpy.QtCore import QPointF from qtpy.QtGui import QPolygonF diff --git a/svgdatagrabber/geometry/quadrilateral.py b/svgdatagrabber/geometry/quadrilateral.py index c797f9d..2a325f3 100644 --- a/svgdatagrabber/geometry/quadrilateral.py +++ b/svgdatagrabber/geometry/quadrilateral.py @@ -1,8 +1,7 @@ import numpy as np -from .point import Point, PointType +from .point import PointType from .polygon import Polygon -from .straightline import LineSegment class Quadrilateral(Polygon): diff --git a/svgdatagrabber/geometry/sequence.py b/svgdatagrabber/geometry/sequence.py index bd54663..3427fb8 100644 --- a/svgdatagrabber/geometry/sequence.py +++ b/svgdatagrabber/geometry/sequence.py @@ -1,7 +1,7 @@ from __future__ import annotations from abc import abstractmethod -from typing import Iterable, Sequence, overload, List, Union +from typing import Iterable, List, Sequence, Union, overload from .geometrybase import GeometryBase from .point import Point, PointType @@ -39,13 +39,11 @@ def __repr__(self) -> str: @overload @abstractmethod - def __getitem__(self, index: int) -> SequenceItem: - ... + def __getitem__(self, index: int) -> SequenceItem: ... @overload @abstractmethod - def __getitem__(self, index: slice) -> Sequence[SequenceItem]: - ... + def __getitem__(self, index: slice) -> Sequence[SequenceItem]: ... def __getitem__(self, index: int) -> SequenceItem | Sequence[SequenceItem]: """Get a point from the sequence. diff --git a/svgdatagrabber/geometry/triangle.py b/svgdatagrabber/geometry/triangle.py index ed39efe..9ecc9c8 100644 --- a/svgdatagrabber/geometry/triangle.py +++ b/svgdatagrabber/geometry/triangle.py @@ -1,6 +1,6 @@ from __future__ import annotations -from .point import PointType, Point +from .point import Point, PointType from .polygon import Polygon diff --git a/svgdatagrabber/graphics/__main__.py b/svgdatagrabber/graphics/__main__.py index 54c494c..f35f30b 100644 --- a/svgdatagrabber/graphics/__main__.py +++ b/svgdatagrabber/graphics/__main__.py @@ -8,6 +8,7 @@ def main(): import sys from qtpy.QtWidgets import QApplication + from svgdatagrabber.graphics.mainwindow import SvgDataGrabberMainWindow app = QApplication(sys.argv) diff --git a/svgdatagrabber/graphics/annotations.py b/svgdatagrabber/graphics/annotations.py index bf64b8e..d6370a2 100644 --- a/svgdatagrabber/graphics/annotations.py +++ b/svgdatagrabber/graphics/annotations.py @@ -1,8 +1,8 @@ from typing import Union from qtpy.QtCore import Qt -from qtpy.QtGui import QPen, QBrush, QColor, QGradient -from qtpy.QtWidgets import QGraphicsLineItem, QGraphicsPolygonItem, QGraphicsEllipseItem +from qtpy.QtGui import QBrush, QColor, QGradient, QPen +from qtpy.QtWidgets import QGraphicsEllipseItem, QGraphicsLineItem, QGraphicsPolygonItem QPenType = Union[QPen, QColor, Qt.GlobalColor, QGradient] QBrushType = Union[QBrush, QColor, Qt.GlobalColor, QGradient] diff --git a/svgdatagrabber/graphics/geometricobject.py b/svgdatagrabber/graphics/geometricobject.py index 98a987c..3b9f2af 100644 --- a/svgdatagrabber/graphics/geometricobject.py +++ b/svgdatagrabber/graphics/geometricobject.py @@ -1,7 +1,7 @@ from qtpy.QtWidgets import QGraphicsScene -from .annotations import QPenType, QBrushType, QGraphicsItemType from ..geometry import GeometryBase +from .annotations import QBrushType, QGraphicsItemType, QPenType class GeometricObject: diff --git a/svgdatagrabber/graphics/graphicsview.py b/svgdatagrabber/graphics/graphicsview.py index 1a23bcd..702ef32 100644 --- a/svgdatagrabber/graphics/graphicsview.py +++ b/svgdatagrabber/graphics/graphicsview.py @@ -4,11 +4,11 @@ from qtpy.QtCore import Qt from qtpy.QtGui import QPainter -from qtpy.QtWidgets import QGraphicsView, QGraphicsScene, QOpenGLWidget, QWidget +from qtpy.QtWidgets import QGraphicsScene, QGraphicsView, QOpenGLWidget, QWidget -from .annotations import QPenType, QBrushType -from .geometricobject import GeometricObject from ..geometry import GeometryBase +from .annotations import QBrushType, QPenType +from .geometricobject import GeometricObject class GraphicsView(QGraphicsView): @@ -18,12 +18,10 @@ class GraphicsView(QGraphicsView): geometric_objects: List[GeometricObject] @overload - def __init__(self, parent: QWidget | None = None, *, useOpenGL: bool = False): - ... + def __init__(self, parent: QWidget | None = None, *, useOpenGL: bool = False): ... @overload - def __init__(self, scene: QGraphicsScene = None, parent: QWidget | None = None, *, useOpenGL: bool = False): - ... + def __init__(self, scene: QGraphicsScene = None, parent: QWidget | None = None, *, useOpenGL: bool = False): ... def __init__( self, diff --git a/svgdatagrabber/graphics/mainwindow.py b/svgdatagrabber/graphics/mainwindow.py index 3452ede..8220170 100644 --- a/svgdatagrabber/graphics/mainwindow.py +++ b/svgdatagrabber/graphics/mainwindow.py @@ -1,8 +1,8 @@ from qtpy.QtCore import Qt from qtpy.QtWidgets import QMainWindow +from ..geometry import Circle, Point, Polygon from .graphicsview import GraphicsView -from ..geometry import Polygon, Point, Circle class SvgDataGrabberMainWindow(QMainWindow): diff --git a/svgdatagrabber/parser.py b/svgdatagrabber/parser.py index 62ee9e0..f48bcf2 100644 --- a/svgdatagrabber/parser.py +++ b/svgdatagrabber/parser.py @@ -7,13 +7,13 @@ from svgpathtools.svg_to_paths import svg2paths from .filters import ( + ClosedPathFilter, + CustomFilter, + FilterBase, + HorizontalLineFilter, RectangleRangeFilter, SegmentNumberFilter, - HorizontalLineFilter, VerticalLineFilter, - FilterBase, - ClosedPathFilter, - CustomFilter, ) from .geometry import PathSequence from .geometry.csys import CoordinateSystem diff --git a/tests/conftest.py b/tests/conftest.py index 3b3e2f1..fb62c28 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,7 @@ """ conftest.py: sharing fixtures across multiple files. https://docs.pytest.org/en/7.1.x/reference/fixtures.html#conftest-py-sharing-fixtures-across-multiple-files. """ + import os import sys From ad77177a929c4fd9d63b8b5122bde012c041289b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Sep 2024 12:43:03 +0000 Subject: [PATCH 2/2] Bump codecov/codecov-action from 3 to 4 Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3 to 4. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v3...v4) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/pytest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 0c20cfc..8dfa16d 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -48,7 +48,7 @@ jobs: cond: ${{ github.event_name == 'pull_request' }} if_true: ${{ github.base_ref }} if_false: ${{ github.ref_name }} - - uses: codecov/codecov-action@v3 + - uses: codecov/codecov-action@v4 if: ${{ matrix.python-version == '3.11' }} with: token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos