Skip to content

Commit

Permalink
add type hinting and integrate with pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
ctheune committed Feb 3, 2024
1 parent 952a7c6 commit b3bd22e
Show file tree
Hide file tree
Showing 116 changed files with 5,394 additions and 16 deletions.
1 change: 1 addition & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
env.PYTHONUNBUFFERED = "true";
env.ALEMBIC_CONFIG = "development.ini";
env.PGDATABASE = "aramaki";
env.MYPYPATH="stubs";

packages = [
pkgs.git
Expand Down
95 changes: 94 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pytest = ">=7.4"
pytest-cov = ">=4.1"
pytest-cache = ">=1.0"
pytest-timeout = ">=2.2"
pytest-mypy = ">=0.10"

[tool.poetry.plugins."paste.app_factory"]
main = "aramaki.server.web.main:main"
Expand All @@ -62,3 +63,20 @@ Issues = "https://github.com/flyingcircusio/aramaki/issues"

[tool.black]
line-length = 79


[[tool.mypy.overrides]]
module = "webob.*"
ignore_errors = true

[[tool.mypy.overrides]]
module = "zope.*"
ignore_errors = true

[[tool.mypy.overrides]]
module = "pkg_resources.*"
ignore_errors = true

[[tool.mypy.overrides]]
module = "pyramid.*"
ignore_errors = true
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[pytest]
addopts = --timeout=30 --cov=src --cov-report=html --ignore lib --ignore lib64 --strict-markers
addopts = --timeout=30 --mypy --cov=src --cov-report=html --ignore lib --ignore lib64 --strict-markers
testpaths = src/aramaki
5 changes: 3 additions & 2 deletions src/aramaki/server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
def main():
parser = argparse.ArgumentParser(
prog="aramaki-server",
description="Server implementation of Aramaki, the federated DevOps control plane.",
description="Server implementation of Aramaki, the federated DevOps "
"control plane.",
epilog="Text at the bottom of help",
)

parser.add_argument("subsystem")

args = parser.parse_args()
if args.subsystem == "ui":
from .ui.main import main as real_main
from .web.main import main as real_main
elif args.subsystem == "processing":
from .processing.main import main as real_main
elif args.subsystem == "federation":
Expand Down
7 changes: 5 additions & 2 deletions src/aramaki/server/models/meta.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from sqlalchemy.orm import declarative_base
from sqlalchemy.orm import DeclarativeBase
from sqlalchemy.schema import MetaData

# Recommended naming convention used by Alembic, as various different database
Expand All @@ -13,4 +13,7 @@
}

metadata = MetaData(naming_convention=NAMING_CONVENTION)
Base = declarative_base(metadata=metadata)


class Base(DeclarativeBase):
metadata = metadata
19 changes: 9 additions & 10 deletions src/aramaki/server/models/system.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
import uuid

from sqlalchemy import Column, String, func
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy import func
from sqlalchemy.orm import Mapped, mapped_column

from .meta import Base
from . import meta


class System(Base):
class System(meta.Base):
__tablename__ = "system"

id = Column(
UUID(as_uuid=True),
id: Mapped[uuid.UUID] = mapped_column(
primary_key=True,
default=uuid.uuid4,
server_default=func.gen_random_uuid(),
)

title = Column(String, nullable=False)
title: Mapped[str]

# Make this a dictionary.
type_ = Column(String, nullable=False)
# Make this a dictionary, use references
type_: Mapped[str]

# XXX Turn into relationship
primary_instance = Column(UUID(as_uuid=True))
primary_instance: Mapped[uuid.UUID]
Loading

0 comments on commit b3bd22e

Please sign in to comment.