Skip to content

Commit 61bf5d3

Browse files
authored
Merge pull request #59 from Metaswitch/md/freshen
Freshen up dependencies and remove dependabot config
2 parents c0f0b84 + 5f7ebb4 commit 61bf5d3

File tree

11 files changed

+625
-771
lines changed

11 files changed

+625
-771
lines changed

.github/dependabot.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ jobs:
2020
poetry install
2121
- name: Analysing the code with mypy
2222
run: |
23-
poetry run mypy $(git ls-files '*.py')
24-
- name: Analysing the code with flake8
23+
poetry run mypy
24+
- name: Analysing the code with ruff
2525
run: |
26-
poetry run flake8 .
26+
poetry run ruff check
27+
poetry run ruff format --check

function_app.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import os
1010
import tempfile
1111
from pathlib import Path
12+
from typing import Generator
1213

1314
import azure.functions as func
1415
import pydpkg
@@ -29,7 +30,7 @@
2930

3031

3132
@contextlib.contextmanager
32-
def temporary_filename():
33+
def temporary_filename() -> Generator[str, None, None]:
3334
"""Create a temporary file and return the filename."""
3435
try:
3536
with tempfile.NamedTemporaryFile(delete=False) as f:
@@ -198,7 +199,7 @@ def create_packages(self) -> None:
198199

199200
@app.function_name(name="eventGridTrigger")
200201
@app.event_grid_trigger(arg_name="event")
201-
def event_grid_trigger(event: func.EventGridEvent):
202+
def event_grid_trigger(event: func.EventGridEvent) -> None:
202203
"""Process an event grid trigger for a new blob in the container."""
203204
log.info("Processing event %s", event.id)
204205
rm = RepoManager()

mypy.ini

Lines changed: 0 additions & 4 deletions
This file was deleted.

poetry.lock

Lines changed: 517 additions & 724 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,38 @@
1-
[tool.poetry]
1+
[project]
22
name = "apt-package-function"
3-
version = "0.1.0"
43
description = "Functionality to create a Debian package repository in Azure Blob Storage"
5-
authors = ["Max Dymond <[email protected]>"]
64
license = "MIT"
5+
version = "0.1.0"
76
readme = "README.md"
7+
authors = [{name = "Max Dymond", email = "[email protected]"}]
8+
requires-python = '>=3.9.2,<4.0.0'
9+
dependencies = [
10+
'azure-functions (>=1.21.3,<2.0.0)',
11+
'azure-identity (>=1.19.0,<2.0.0)',
12+
'azure-storage-blob (>=12.23.1,<13.0.0)',
13+
'pydpkg (>=1.9.3,<2.0.0)'
14+
]
815

9-
[tool.poetry.dependencies]
10-
python = "^3.8.2"
11-
azure-functions = "^1.21.3"
12-
azure-identity = "^1.19.0"
13-
azure-storage-blob = "^12.23.1"
14-
pydpkg = "^1.9.3"
16+
[project.scripts]
17+
create-resources = "apt_package_function.create_resources:run"
18+
19+
[tool.poetry]
20+
requires-poetry = '>=2.0'
21+
22+
[tool.poetry.requires-plugins]
23+
poetry-plugin-export = ">=1.8"
1524

1625
[tool.poetry.group.dev.dependencies]
17-
mypy = "^1.14.1"
18-
flake8 = "^7.1.1"
19-
flake8-black = "^0.3.6"
20-
flake8-isort = "^6.1.1"
21-
flake8-docstrings = "^1.7.0"
22-
black = "^24.8.0"
26+
mypy = "^1"
27+
ruff = "^0.11.12"
2328

2429
[build-system]
25-
requires = ["poetry-core"]
30+
requires = ['poetry-core (>=2.0)']
2631
build-backend = "poetry.core.masonry.api"
2732

28-
[tool.poetry.scripts]
29-
# Script to create resources in Azure
30-
create-resources = "apt_package_function.create_resources:run"
33+
[tool.mypy]
34+
files = ["function_app.py", "src/apt_package_function"]
35+
36+
[[tool.mypy.overrides]]
37+
module = ["pydpkg.*"]
38+
ignore_missing_imports = true

ruff.toml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
exclude = [
2+
".venv",
3+
"__pycache__",
4+
".mypy_cache",
5+
".git"
6+
]
7+
8+
# Match black
9+
line-length = 88
10+
indent-width = 4
11+
12+
# Assume Python 3.9
13+
target-version = "py39"
14+
15+
[lint]
16+
extend-select = [
17+
"E",
18+
"I", # isort
19+
"D", # pydocstyle
20+
"S", # security
21+
"ARG", # flake8-unused-arguments
22+
"ANN", # flake8-annotations
23+
]
24+
25+
ignore = [
26+
"D203", # ignore incompatible rules
27+
"D213", # ignore incompatible rules
28+
"D400",
29+
"D401",
30+
"D415",
31+
# Allow long lines if needed
32+
"E501",
33+
# We trust the uses of tar extractall as we generate the tar files ourselves.
34+
"S202",
35+
# Subprocess module imported. Warning to be careful only.
36+
"S404",
37+
# Yaml loader
38+
"S506",
39+
# Subprocess used without shell=True. Warning to be careful only.
40+
"S603",
41+
# Starting a process with a partial executable path
42+
"S607",
43+
]
44+
45+
[lint.extend-per-file-ignores]
46+
"tests/*" = ["S", "D"]
47+
48+
[format]
49+
# Like Black, use double quotes for strings.
50+
quote-style = "double"
51+
52+
# Like Black, indent with spaces, rather than tabs.
53+
indent-style = "space"
54+
55+
# Like Black, respect magic trailing commas.
56+
skip-magic-trailing-comma = false
57+
58+
# Like Black, automatically detect the appropriate line ending.
59+
line-ending = "auto"

src/apt_package_function/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# Licensed under the MIT License.
33
"""Tooling for creating apt repositories in Azure."""
44

5-
65
import logging
76
import sys
87
from datetime import datetime

src/apt_package_function/azcmd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __init__(self, cmd: List[str]) -> None:
2020
"""Create an AzCmd object"""
2121
self.cmd = cmd
2222

23-
def _run_cmd(self, cmd: List[str]) -> Any:
23+
def _run_cmd(self, cmd: List[str]) -> Any: # noqa: ANN401
2424
"""Runs a command and may return output"""
2525
raise NotImplementedError
2626

@@ -62,7 +62,7 @@ class AzCmdJson(AzCmd):
6262

6363
OUTPUT = "json"
6464

65-
def run(self) -> Any:
65+
def run(self) -> Any: # noqa: ANN401
6666
"""Run the Azure CLI command and return the result."""
6767
data = self._az_cmd()
6868
return json.loads(data)

src/apt_package_function/bicep_deployment.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# Licensed under the MIT License.
33
"""Manages Bicep deployments."""
44

5-
65
import logging
76
from pathlib import Path
87
from typing import Any, Dict

src/apt_package_function/func_app.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
import time
1010
from pathlib import Path
1111
from subprocess import CalledProcessError
12-
from typing import Any, Dict
12+
from types import TracebackType
13+
from typing import Any, Dict, Optional, Type
1314
from zipfile import ZipFile
1415

1516
from apt_package_function.azcmd import AzCmdJson, AzCmdNone
@@ -63,15 +64,24 @@ def wait_for_event_trigger(self) -> None:
6364

6465
time.sleep(5)
6566

66-
def __enter__(self):
67+
def __enter__(self) -> "FuncApp":
6768
"""Return the object for use in a context manager."""
6869
return self
6970

70-
def __exit__(self, _exc_type, _exc_value, _traceback):
71+
def __exit__(
72+
self,
73+
_exc_type: Optional[Type[BaseException]],
74+
_exc_value: Optional[BaseException],
75+
_exc_traceback: Optional[TracebackType],
76+
) -> None:
7177
"""Clean up the object."""
7278
if self.output_path.exists():
7379
self.output_path.unlink()
7480

81+
def deploy(self) -> None:
82+
"""Deploy the function app code."""
83+
raise NotImplementedError("Subclasses must implement deploy method")
84+
7585

7686
class FuncAppZip(FuncApp):
7787
"""Class for managing zipped function apps."""

0 commit comments

Comments
 (0)