From 7c89cd08fcce33724a09b2637c375f2fc91b0048 Mon Sep 17 00:00:00 2001 From: Hanka Date: Fri, 19 Jun 2026 18:49:11 +0200 Subject: [PATCH 1/5] ci: add GitHub Actions workflow for linting --- .github/workflows/linting.yaml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/linting.yaml diff --git a/.github/workflows/linting.yaml b/.github/workflows/linting.yaml new file mode 100644 index 0000000..23e5f90 --- /dev/null +++ b/.github/workflows/linting.yaml @@ -0,0 +1,30 @@ +name: Linting + +on: + push: + branches: [ "main", "master" ] + pull_request: + branches: [ "main", "master" ] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.13" + + - name: Install Ruff + run: | + python -m pip install --upgrade pip + pip install ruff + + - name: Run Ruff Lint + run: ruff check . + + - name: Run Ruff Format Check + run: ruff format --check . \ No newline at end of file From fb6bad3d25051ca176e9be43694c829d9db33684 Mon Sep 17 00:00:00 2001 From: Hanka Date: Fri, 19 Jun 2026 19:44:26 +0200 Subject: [PATCH 2/5] style(api): fix linting errors in controllers --- Canvas.py | 1 - CanvasThreeD.py | 1 - CheckCreateDirectory.py | 1 - Circle.py | 2 +- Cube.py | 2 +- Ellipse.py | 2 +- Ellipsoid.py | 2 +- MathApp.py | 21 +++++++++------------ Shape.py | 1 - Sphere.py | 2 +- Square.py | 2 +- Tests/test_circle.py | 1 - Tests/test_cube.py | 1 - Tests/test_ellipse.py | 1 - Tests/test_ellipsoid.py | 1 - Tests/test_sphere.py | 3 --- Tests/test_square.py | 1 - 17 files changed, 15 insertions(+), 30 deletions(-) diff --git a/Canvas.py b/Canvas.py index 4cb155c..3d199fe 100644 --- a/Canvas.py +++ b/Canvas.py @@ -3,7 +3,6 @@ class MplCanvas(FigureCanvasQTAgg): - def __init__(self, parent=None, width=6, height=6, dpi=100): fig = Figure(figsize=(width, height), dpi=dpi) self.axes = fig.add_subplot(111) diff --git a/CanvasThreeD.py b/CanvasThreeD.py index ab762a3..7536363 100644 --- a/CanvasThreeD.py +++ b/CanvasThreeD.py @@ -3,7 +3,6 @@ class MplCanvas(FigureCanvasQTAgg): - def __init__(self, parent=None, width=6, height=6, dpi=100): fig = Figure(figsize=(width, height), dpi=dpi) self.axes = fig.add_subplot(projection="3d") diff --git a/CheckCreateDirectory.py b/CheckCreateDirectory.py index ea2ef0b..082e467 100644 --- a/CheckCreateDirectory.py +++ b/CheckCreateDirectory.py @@ -7,7 +7,6 @@ def check_create_dir(path): isExist = os.path.exists(path) if not isExist: - # Create a new directory because it does not exist os.makedirs(path) print("The new directory is created!") diff --git a/Circle.py b/Circle.py index d4955da..2518a2d 100644 --- a/Circle.py +++ b/Circle.py @@ -27,7 +27,7 @@ import CircleCalc import Canvas import SaveFig -from Shape import * +from Shape import ShapeFunctionality # Get the absolute path to the directory where this script is located SCRIPT_DIR = Path(__file__).resolve().parent diff --git a/Cube.py b/Cube.py index 19c1263..b675dcf 100644 --- a/Cube.py +++ b/Cube.py @@ -27,7 +27,7 @@ import CubeCalc import CanvasThreeD import SaveFig -from Shape import * +from Shape import ShapeFunctionality # Get the absolute path to the directory where this script is located SCRIPT_DIR = Path(__file__).resolve().parent diff --git a/Ellipse.py b/Ellipse.py index 44ce08f..512bbed 100644 --- a/Ellipse.py +++ b/Ellipse.py @@ -27,7 +27,7 @@ import EllipseCalc import Canvas import SaveFig -from Shape import * +from Shape import ShapeFunctionality # Get the absolute path to the directory where this script is located SCRIPT_DIR = Path(__file__).resolve().parent diff --git a/Ellipsoid.py b/Ellipsoid.py index d221b52..37349c9 100644 --- a/Ellipsoid.py +++ b/Ellipsoid.py @@ -27,7 +27,7 @@ import EllipsoidCalc import CanvasThreeD import SaveFig -from Shape import * +from Shape import ShapeFunctionality # Get the absolute path to the directory where this script is located SCRIPT_DIR = Path(__file__).resolve().parent diff --git a/MathApp.py b/MathApp.py index ca721c4..c44b729 100644 --- a/MathApp.py +++ b/MathApp.py @@ -1,5 +1,8 @@ import sys from pathlib import Path +import matplotlib + +matplotlib.use("Qt5Agg") from PyQt5.QtWidgets import ( QApplication, @@ -25,23 +28,18 @@ # Get the absolute path to the directory where this script is located SCRIPT_DIR = Path(__file__).resolve().parent -from Circle import * -from Sphere import * -from Ellipse import * -from Ellipsoid import * -from Square import * -from Cube import * - -import matplotlib - -matplotlib.use("Qt5Agg") +from Circle import WindowCircle +from Sphere import WindowSphere +from Ellipse import WindowEllipse +from Ellipsoid import WindowEllipsoid +from Square import WindowSquare +from Cube import WindowCube from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg from matplotlib.figure import Figure class MplCanvas(FigureCanvasQTAgg): - def __init__(self, parent=None, width=5, height=5, dpi=100): fig = Figure(figsize=(width, height), dpi=dpi) self.axes = fig.add_subplot(111) @@ -50,7 +48,6 @@ def __init__(self, parent=None, width=5, height=5, dpi=100): class MainWindow(QMainWindow): - def __init__(self): super().__init__() diff --git a/Shape.py b/Shape.py index 772c84a..45de15b 100644 --- a/Shape.py +++ b/Shape.py @@ -18,7 +18,6 @@ class ShapeFunctionality: - def custom_messagebox(self, text="Error!"): """ Displays a custom message box with an error icon. diff --git a/Sphere.py b/Sphere.py index 3aa6d9d..b65eeec 100644 --- a/Sphere.py +++ b/Sphere.py @@ -23,7 +23,7 @@ import SphereCalc import CanvasThreeD import SaveFig -from Shape import * +from Shape import ShapeFunctionality # Get the absolute path to the directory where this script is located SCRIPT_DIR = Path(__file__).resolve().parent diff --git a/Square.py b/Square.py index e0c94e0..55d5409 100644 --- a/Square.py +++ b/Square.py @@ -27,7 +27,7 @@ import SquareCalc import Canvas import SaveFig -from Shape import * +from Shape import ShapeFunctionality # Get the absolute path to the directory where this script is located SCRIPT_DIR = Path(__file__).resolve().parent diff --git a/Tests/test_circle.py b/Tests/test_circle.py index 62b4dbd..45143f6 100644 --- a/Tests/test_circle.py +++ b/Tests/test_circle.py @@ -8,7 +8,6 @@ class CircleTest(unittest.TestCase): - def test_init_valid_radius(self): """Tests initialization with a valid positive radius.""" circle = Circle(5.0) diff --git a/Tests/test_cube.py b/Tests/test_cube.py index f3c9aa5..9e24f77 100644 --- a/Tests/test_cube.py +++ b/Tests/test_cube.py @@ -7,7 +7,6 @@ class TestSquare(unittest.TestCase): - def test_init_valid_side_length(self): """Tests initialization with a valid positive side length.""" cube = Cube(5.526) diff --git a/Tests/test_ellipse.py b/Tests/test_ellipse.py index 8cba2cc..33c32b8 100644 --- a/Tests/test_ellipse.py +++ b/Tests/test_ellipse.py @@ -8,7 +8,6 @@ class EllipseTest(unittest.TestCase): - def test_init_valid_axes(self): """Tests initialization with valid positive axis lengths.""" ellipse = Ellipse(5.0, 3.0) diff --git a/Tests/test_ellipsoid.py b/Tests/test_ellipsoid.py index e17665a..11390fc 100644 --- a/Tests/test_ellipsoid.py +++ b/Tests/test_ellipsoid.py @@ -8,7 +8,6 @@ class EllipsoidTest(unittest.TestCase): - def test_init_valid_dimensions(self): """Tests initialization with valid positive semi-axes.""" ellipsoid = Ellipsoid(5.0, 3.0, 2.0) diff --git a/Tests/test_sphere.py b/Tests/test_sphere.py index 1aca86e..c7dc1f3 100644 --- a/Tests/test_sphere.py +++ b/Tests/test_sphere.py @@ -1,17 +1,14 @@ import unittest import sys -from math import pi # setting path sys.path.append("../PyQtMathApp") from SphereCalc import * -import unittest import math class SphereTest(unittest.TestCase): - def test_init_valid_radius(self): """Tests initialization with a valid positive radius.""" sphere = Sphere(5.0) diff --git a/Tests/test_square.py b/Tests/test_square.py index 618e333..83077da 100644 --- a/Tests/test_square.py +++ b/Tests/test_square.py @@ -7,7 +7,6 @@ class TestSquare(unittest.TestCase): - def test_init_valid_side_length(self): """Tests initialization with a valid positive side length.""" square = Square(5.0) From 3bf06b80e8267fa29d8b2d3a8aebe6f45b602cdb Mon Sep 17 00:00:00 2001 From: Hanka Date: Fri, 19 Jun 2026 19:59:29 +0200 Subject: [PATCH 3/5] style(api): fix linting errors in controllers --- Tests/test_circle.py | 2 +- Tests/test_cube.py | 2 +- Tests/test_ellipse.py | 2 +- Tests/test_ellipsoid.py | 2 +- Tests/test_sphere.py | 2 +- Tests/test_square.py | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Tests/test_circle.py b/Tests/test_circle.py index 45143f6..3699292 100644 --- a/Tests/test_circle.py +++ b/Tests/test_circle.py @@ -4,7 +4,7 @@ # setting path sys.path.append("../PyQtMathApp") -from CircleCalc import * +from CircleCalc import Circle class CircleTest(unittest.TestCase): diff --git a/Tests/test_cube.py b/Tests/test_cube.py index 9e24f77..fc82f68 100644 --- a/Tests/test_cube.py +++ b/Tests/test_cube.py @@ -3,7 +3,7 @@ # setting path sys.path.append("../PyQtMathApp") -from CubeCalc import * +from CubeCalc import Cube class TestSquare(unittest.TestCase): diff --git a/Tests/test_ellipse.py b/Tests/test_ellipse.py index 33c32b8..513229e 100644 --- a/Tests/test_ellipse.py +++ b/Tests/test_ellipse.py @@ -4,7 +4,7 @@ # setting path sys.path.append("../PyQtMathApp") -from EllipseCalc import * +from EllipseCalc import Ellipse class EllipseTest(unittest.TestCase): diff --git a/Tests/test_ellipsoid.py b/Tests/test_ellipsoid.py index 11390fc..fa248c9 100644 --- a/Tests/test_ellipsoid.py +++ b/Tests/test_ellipsoid.py @@ -4,7 +4,7 @@ # setting path sys.path.append("../PyQtMathApp") -from EllipsoidCalc import * +from EllipsoidCalc import Ellipsoid class EllipsoidTest(unittest.TestCase): diff --git a/Tests/test_sphere.py b/Tests/test_sphere.py index c7dc1f3..52c7ae8 100644 --- a/Tests/test_sphere.py +++ b/Tests/test_sphere.py @@ -3,7 +3,7 @@ # setting path sys.path.append("../PyQtMathApp") -from SphereCalc import * +from SphereCalc import Sphere import math diff --git a/Tests/test_square.py b/Tests/test_square.py index 83077da..b78d3c0 100644 --- a/Tests/test_square.py +++ b/Tests/test_square.py @@ -3,7 +3,7 @@ # setting path sys.path.append("../PyQtMathApp") -from SquareCalc import * +from SquareCalc import Square class TestSquare(unittest.TestCase): From 0d2933793dbcdb3ce798142e137e5b6b4e3dc8dc Mon Sep 17 00:00:00 2001 From: Hanka Date: Fri, 19 Jun 2026 20:03:15 +0200 Subject: [PATCH 4/5] style(api): fix linting errors in controllers --- MathApp.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/MathApp.py b/MathApp.py index c44b729..c069495 100644 --- a/MathApp.py +++ b/MathApp.py @@ -25,9 +25,6 @@ from PyQt5 import QtCore -# Get the absolute path to the directory where this script is located -SCRIPT_DIR = Path(__file__).resolve().parent - from Circle import WindowCircle from Sphere import WindowSphere from Ellipse import WindowEllipse @@ -38,6 +35,9 @@ from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg from matplotlib.figure import Figure +# Get the absolute path to the directory where this script is located +SCRIPT_DIR = Path(__file__).resolve().parent + class MplCanvas(FigureCanvasQTAgg): def __init__(self, parent=None, width=5, height=5, dpi=100): @@ -72,9 +72,9 @@ def __init__(self): buttonClose = QPushButton("Close") buttonClose.clicked.connect(app.closeAllWindows) - l = QHBoxLayout() - l.addStretch(1) - l.addWidget(buttonClose) + layout = QHBoxLayout() + layout.addStretch(1) + layout.addWidget(buttonClose) l2 = QVBoxLayout() @@ -119,7 +119,7 @@ def __init__(self): button6.clicked.connect(lambda checked: self.toggle_window(self.window6)) l3.addWidget(button6, 3, 1) - l2.addLayout(l) + l2.addLayout(layout) w = QWidget() w.setLayout(l2) @@ -195,7 +195,7 @@ def _createMenuBar(self): geometryMenu.addAction(self.squareAction) geometryMenu.addAction(self.cubeAction) - helpMenu = menuBar.addMenu("&Help") + menuBar.addMenu("&Help") app = QApplication(sys.argv) From 98bdda2978c8cecd86d4a3d25f5fd0b00a67e503 Mon Sep 17 00:00:00 2001 From: Hanka Date: Fri, 19 Jun 2026 20:08:37 +0200 Subject: [PATCH 5/5] style(api): fix linting errors in controllers --- Tests/test_ellipse.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Tests/test_ellipse.py b/Tests/test_ellipse.py index 513229e..cb789bb 100644 --- a/Tests/test_ellipse.py +++ b/Tests/test_ellipse.py @@ -1,6 +1,6 @@ import unittest import sys -from math import pi +import math # setting path sys.path.append("../PyQtMathApp") @@ -67,7 +67,7 @@ def test_init_very_small_positive_major_axis(self): ellipse = Ellipse(0.000001, 3.0) self.assertAlmostEqual( ellipse.circumference(), - round(pi * math.sqrt(2 * (0.000001**2 + 3.0**2)), 5), + round(math.pi * math.sqrt(2 * (0.000001**2 + 3.0**2)), 5), ) def test_init_very_large_major_axis(self): @@ -75,7 +75,7 @@ def test_init_very_large_major_axis(self): ellipse = Ellipse(1000000.0, 3.0) self.assertAlmostEqual( ellipse.circumference(), - round(pi * math.sqrt(2 * (1000000.0**2 + 3.0**2)), 5), + round(math.pi * math.sqrt(2 * (1000000.0**2 + 3.0**2)), 5), ) def test_init_empty_string_major_axis(self): @@ -97,21 +97,21 @@ def test_init_empty_string_minor_axis(self): def test_circumference(self): """Tests circumference calculation for various axis lengths.""" ellipse = Ellipse(3.0, 1.0) - expected_circumference = round(pi * math.sqrt(2 * (3.0**2 + 1.0**2)), 5) + expected_circumference = round(math.pi * math.sqrt(2 * (3.0**2 + 1.0**2)), 5) self.assertEqual(ellipse.circumference(), expected_circumference) ellipse = Ellipse(8.0, 4.0) - expected_circumference = round(pi * math.sqrt(2 * (8.0**2 + 4.0**2)), 5) + expected_circumference = round(math.pi * math.sqrt(2 * (8.0**2 + 4.0**2)), 5) self.assertEqual(ellipse.circumference(), expected_circumference) def test_area(self): """Tests area calculation for various axis lengths.""" ellipse = Ellipse(2.0, 1.5) - expected_area = round(pi * 2.0 * 1.5, 5) + expected_area = round(math.pi * 2.0 * 1.5, 5) self.assertEqual(ellipse.area(), expected_area) ellipse = Ellipse(7.0, 3.0) - expected_area = round(pi * 7.0 * 3.0, 5) + expected_area = round(math.pi * 7.0 * 3.0, 5) self.assertEqual(ellipse.area(), expected_area) def test_get_description(self):