Skip to content

Freshen up dependencies and remove dependabot config #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .github/dependabot.yml

This file was deleted.

7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ jobs:
poetry install
- name: Analysing the code with mypy
run: |
poetry run mypy $(git ls-files '*.py')
- name: Analysing the code with flake8
poetry run mypy
- name: Analysing the code with ruff
run: |
poetry run flake8 .
poetry run ruff check
poetry run ruff format --check
5 changes: 3 additions & 2 deletions function_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import os
import tempfile
from pathlib import Path
from typing import Generator

import azure.functions as func
import pydpkg
Expand All @@ -29,7 +30,7 @@


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

@app.function_name(name="eventGridTrigger")
@app.event_grid_trigger(arg_name="event")
def event_grid_trigger(event: func.EventGridEvent):
def event_grid_trigger(event: func.EventGridEvent) -> None:
"""Process an event grid trigger for a new blob in the container."""
log.info("Processing event %s", event.id)
rm = RepoManager()
Expand Down
4 changes: 0 additions & 4 deletions mypy.ini

This file was deleted.

1,241 changes: 517 additions & 724 deletions poetry.lock

Large diffs are not rendered by default.

46 changes: 27 additions & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
[tool.poetry]
[project]
name = "apt-package-function"
version = "0.1.0"
description = "Functionality to create a Debian package repository in Azure Blob Storage"
authors = ["Max Dymond <[email protected]>"]
license = "MIT"
version = "0.1.0"
readme = "README.md"
authors = [{name = "Max Dymond", email = "[email protected]"}]
requires-python = '>=3.9.2,<4.0.0'
dependencies = [
'azure-functions (>=1.21.3,<2.0.0)',
'azure-identity (>=1.19.0,<2.0.0)',
'azure-storage-blob (>=12.23.1,<13.0.0)',
'pydpkg (>=1.9.3,<2.0.0)'
]

[tool.poetry.dependencies]
python = "^3.8.2"
azure-functions = "^1.21.3"
azure-identity = "^1.19.0"
azure-storage-blob = "^12.23.1"
pydpkg = "^1.9.3"
[project.scripts]
create-resources = "apt_package_function.create_resources:run"

[tool.poetry]
requires-poetry = '>=2.0'

[tool.poetry.requires-plugins]
poetry-plugin-export = ">=1.8"

[tool.poetry.group.dev.dependencies]
mypy = "^1.14.1"
flake8 = "^7.1.1"
flake8-black = "^0.3.6"
flake8-isort = "^6.1.1"
flake8-docstrings = "^1.7.0"
black = "^24.8.0"
mypy = "^1"
ruff = "^0.11.12"

[build-system]
requires = ["poetry-core"]
requires = ['poetry-core (>=2.0)']
build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
# Script to create resources in Azure
create-resources = "apt_package_function.create_resources:run"
[tool.mypy]
files = ["function_app.py", "src/apt_package_function"]

[[tool.mypy.overrides]]
module = ["pydpkg.*"]
ignore_missing_imports = true
59 changes: 59 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
exclude = [
".venv",
"__pycache__",
".mypy_cache",
".git"
]

# Match black
line-length = 88
indent-width = 4

# Assume Python 3.9
target-version = "py39"

[lint]
extend-select = [
"E",
"I", # isort
"D", # pydocstyle
"S", # security
"ARG", # flake8-unused-arguments
"ANN", # flake8-annotations
]

ignore = [
"D203", # ignore incompatible rules
"D213", # ignore incompatible rules
"D400",
"D401",
"D415",
# Allow long lines if needed
"E501",
# We trust the uses of tar extractall as we generate the tar files ourselves.
"S202",
# Subprocess module imported. Warning to be careful only.
"S404",
# Yaml loader
"S506",
# Subprocess used without shell=True. Warning to be careful only.
"S603",
# Starting a process with a partial executable path
"S607",
]

[lint.extend-per-file-ignores]
"tests/*" = ["S", "D"]

[format]
# Like Black, use double quotes for strings.
quote-style = "double"

# Like Black, indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"
1 change: 0 additions & 1 deletion src/apt_package_function/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Licensed under the MIT License.
"""Tooling for creating apt repositories in Azure."""


import logging
import sys
from datetime import datetime
Expand Down
4 changes: 2 additions & 2 deletions src/apt_package_function/azcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, cmd: List[str]) -> None:
"""Create an AzCmd object"""
self.cmd = cmd

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

Expand Down Expand Up @@ -62,7 +62,7 @@ class AzCmdJson(AzCmd):

OUTPUT = "json"

def run(self) -> Any:
def run(self) -> Any: # noqa: ANN401
"""Run the Azure CLI command and return the result."""
data = self._az_cmd()
return json.loads(data)
Expand Down
1 change: 0 additions & 1 deletion src/apt_package_function/bicep_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Licensed under the MIT License.
"""Manages Bicep deployments."""


import logging
from pathlib import Path
from typing import Any, Dict
Expand Down
16 changes: 13 additions & 3 deletions src/apt_package_function/func_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import time
from pathlib import Path
from subprocess import CalledProcessError
from typing import Any, Dict
from types import TracebackType
from typing import Any, Dict, Optional, Type
from zipfile import ZipFile

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

time.sleep(5)

def __enter__(self):
def __enter__(self) -> "FuncApp":
"""Return the object for use in a context manager."""
return self

def __exit__(self, _exc_type, _exc_value, _traceback):
def __exit__(
self,
_exc_type: Optional[Type[BaseException]],
_exc_value: Optional[BaseException],
_exc_traceback: Optional[TracebackType],
) -> None:
"""Clean up the object."""
if self.output_path.exists():
self.output_path.unlink()

def deploy(self) -> None:
"""Deploy the function app code."""
raise NotImplementedError("Subclasses must implement deploy method")


class FuncAppZip(FuncApp):
"""Class for managing zipped function apps."""
Expand Down