From 71e8a58465aeccd2ba47daa1705091ba1daa3d44 Mon Sep 17 00:00:00 2001 From: Naz Date: Fri, 10 Apr 2026 12:35:03 +0100 Subject: [PATCH 1/4] Add CI pipeline with GitHub Actions --- .DS_Store | Bin 0 -> 6148 bytes .github/workflows/ci.yml | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 .DS_Store create mode 100644 .github/workflows/ci.yml diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..0b9a44bd2ada453415acdcb4f1a3b8e052beac74 GIT binary patch literal 6148 zcmeH~Jr2S!425kd5)w;C#w;9w8$_s_fD0ff8xlid&(V2yytFW*3O!5qi=CuD-_X<| zqK8+%7imRg4L6mYg^4Nhl|1Dp1LDvR*Zbx1xLa8kvDOket}&jEX$lFD011!)36Q{y z2>2n6^M5m=XX2xf013>4fPEhl+%$)ls{ZLf@D>2tpzMaR_Y%-#1!xW}RZ)RybPpO^ z)!PuO`*vuGbvd+Dt=mPT`OvttS{DP;x?MCOfoXPOAORAX5Lni{we$Z7|JMIcwlF0D z68JL$+H|MxfR~E1_2c!devYb*3modp5k@}&NbD%y!rd^RYyi!nr79{g{s=e*1`_xw Ffj1-y6RZFL literal 0 HcmV?d00001 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..18e400a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,37 @@ +name: CI Pipeline + +on: + push: + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: [3.9, 3.10, 3.11] + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + pip install pytest flake8 coverage + + - name: Lint code + run: flake8 . + + - name: Run tests + run: pytest + + - name: Run coverage + run: | + coverage run -m pytest + coverage report \ No newline at end of file From f00787dd612c39c761f98b4ce38b8b37b815a1c3 Mon Sep 17 00:00:00 2001 From: Naz Date: Fri, 10 Apr 2026 13:08:05 +0100 Subject: [PATCH 2/4] Quote Python versions in CI matrix --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 18e400a..7b1425a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: strategy: matrix: - python-version: [3.9, 3.10, 3.11] + python-version: ["3.9", "3.10", "3.11"] steps: - name: Checkout code From e8fc23ff3ae0db6c9e9246884b448359de7ea5f2 Mon Sep 17 00:00:00 2001 From: Naz Date: Fri, 10 Apr 2026 13:38:22 +0100 Subject: [PATCH 3/4] Fix flake8 lint issues --- calculator/__init__.py | 2 +- calculator/calculator.py | 27 ++++++++++++++------------- tests/test_calculator.py | 2 -- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/calculator/__init__.py b/calculator/__init__.py index 871f6fd..80ffad9 100644 --- a/calculator/__init__.py +++ b/calculator/__init__.py @@ -1 +1 @@ -from .calculator import Calculator +from .calculator import Calculator # noqa: F401 \ No newline at end of file diff --git a/calculator/calculator.py b/calculator/calculator.py index 934990d..d907f13 100644 --- a/calculator/calculator.py +++ b/calculator/calculator.py @@ -3,7 +3,8 @@ class Calculator: - """Calculator class with methods to sum, subtract, multiply, divide square and find square root""" + """Calculator class with methods to sum, subtract, multiply, +divide, square, and find square root.""" def __init__(self, memory=0): self.memory = memory @@ -28,12 +29,12 @@ def sum(self, a, b=None): """ try: - if b == None: + if b is None: b = self.memory self.memory = float(a) + float(b) return self.memory - except: + except Exception: return 'Invalid input' def subtract(self, a, b=None): @@ -49,13 +50,13 @@ def subtract(self, a, b=None): """ try: - if b == None: + if b is None: b = a a = self.memory self.memory = float(a) - float(b) return self.memory - except: + except Exception: return 'Invalid input' def multiply(self, a, b=None): @@ -71,12 +72,12 @@ def multiply(self, a, b=None): """ try: - if b == None: + if b is None: b = self.memory self.memory = float(a) * float(b) return self.memory - except: + except Exception: return 'Invalid input' def divide(self, a, b=None): @@ -92,7 +93,7 @@ def divide(self, a, b=None): """ try: - if b == None: + if b is None: b = a a = self.memory @@ -100,7 +101,7 @@ def divide(self, a, b=None): return self.memory except ZeroDivisionError: return 'Can not divide by zero.' - except: + except Exception: return 'Invalid input' def square(self, a=None): @@ -115,12 +116,12 @@ def square(self, a=None): """ try: - if a == None: + if a is None: a = self.memory self.memory = float(a) ** 2 return self.memory - except: + except Exception: return 'Invalid input' def sqrt(self, a=None): @@ -135,10 +136,10 @@ def sqrt(self, a=None): """ try: - if a == None: + if a is None: a = self.memory self.memory = math.sqrt(float(a)) return self.memory - except: + except Exception: return 'Invalid input' diff --git a/tests/test_calculator.py b/tests/test_calculator.py index 1a2d7b6..84f283f 100644 --- a/tests/test_calculator.py +++ b/tests/test_calculator.py @@ -1,5 +1,3 @@ -import pytest - from calculator.calculator import Calculator c = Calculator() From 714de61b4dd5a34fde00e2812478a41a2862dab2 Mon Sep 17 00:00:00 2001 From: Naz Date: Fri, 10 Apr 2026 13:41:16 +0100 Subject: [PATCH 4/4] Add newline to __init__.py --- calculator/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/calculator/__init__.py b/calculator/__init__.py index 80ffad9..3891761 100644 --- a/calculator/__init__.py +++ b/calculator/__init__.py @@ -1 +1 @@ -from .calculator import Calculator # noqa: F401 \ No newline at end of file +from .calculator import Calculator # noqa: F401