diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1cf5a68..c2d550b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -31,12 +31,6 @@ repos: hooks: - id: conventional-pre-commit stages: [commit-msg] - - repo: https://github.com/python-poetry/poetry - rev: "1.5.0" - hooks: - - id: poetry-check - - id: poetry-lock - args: ["--no-update"] - repo: https://github.com/provinzkraut/unasyncd rev: "v0.4.0" hooks: @@ -84,20 +78,22 @@ repos: exclude: "tools|docs" additional_dependencies: [ - click, - hypothesis, - jsbeautifier, - opentelemetry-instrumentation-asgi, - opentelemetry-sdk, pydantic, - pytest, - pytest-lazy-fixture, - pytest-mock, - pytest_docker, - python-dotenv, + pylint-pydantic, + jinja2, rich, + click, rich-click, + polyfactory, + pydantic_openapi_schema, structlog, + pytest, + pytest-docker, + litestar, + types-click, + types-passlib, + types-click, + types-PyYAML, uvicorn, prometheus_client, ] diff --git a/README.md b/README.md index e6d3f0d..bc58684 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ | Project | | Status | |-----------|:----|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| CI/CD | | [![Latest Release](https://github.com/JacobCoffee/niapi/actions/workflows/publish.yaml/badge.svg?branch=main)](https://github.com/JacobCoffee/niapi/actions/workflows/publish.yaml) [![ci](https://github.com/JacobCoffee/niapi/actions/workflows/ci.yaml/badge.svg)](https://github.com/JacobCoffee/niapi/actions/workflows/ci.yaml) [![Documentation Building](https://github.com/JacobCoffee/niapi/actions/workflows/docs.yaml/badge.svg?branch=main)](https://github.com/JacobCoffee/niapi/actions/workflows/docs.yaml) | +| CI/CD | | [![Latest Release](https://github.com/JacobCoffee/niapi/actions/workflows/publish.yaml/badge.svg?branch=main)](https://github.com/JacobCoffee/niapi/actions/workflows/publish.yaml) [![ci](https://github.com/JacobCoffee/niapi/actions/workflows/ci.yaml/badge.svg)](https://github.com/JacobCoffee/niapi/actions/workflows/ci.yaml) [![Documentation Building](https://github.com/JacobCoffee/niapi/actions/workflows/docs.yaml/badge.svg?branch=main)](https://github.com/JacobCoffee/niapi/actions/workflows/docs.yaml) [![CodeQL](https://github.com/JacobCoffee/niapi/actions/workflows/github-code-scanning/codeql/badge.svg?branch=main)](https://github.com/JacobCoffee/niapi/actions/workflows/github-code-scanning/codeql) | | Package | | [![PyPI - Version](https://img.shields.io/pypi/v/niapi)](https://badge.fury.io/py/niapi) ![PyPI - Support Python Versions](https://img.shields.io/pypi/pyversions/niapi) | | Quality | | [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=jacobcoffee_niapi&metric=coverage)](https://sonarcloud.io/summary/new_code?id=jacobcoffee_niapi) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=jacobcoffee_niapi&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=jacobcoffee_niapi) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=jacobcoffee_niapi&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=jacobcoffee_niapi) [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=jacobcoffee_niapi&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=jacobcoffee_niapi) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=jacobcoffee_niapi&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=jacobcoffee_niapi) [![Known Vulnerabilities](https://snyk.io/test/github/JacobCoffee/niapi/badge.svg)](https://snyk.io/test/github/JacobCoffee/niapi) | | Community | | [![Twitter](https://img.shields.io/twitter/follow/_scriptr?style=social&logo=twitter)](https://twitter.com/_scriptr) | diff --git a/docs/PYPI_README.md b/docs/PYPI_README.md index 6b63bb1..f2852e6 100644 --- a/docs/PYPI_README.md +++ b/docs/PYPI_README.md @@ -25,5 +25,4 @@ # `niapi` - Network Information API -[//]: # (TODO) - +[//]: # "TODO" diff --git a/docs/conf.py b/docs/conf.py index 8ddbe3d..ef14210 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -54,10 +54,12 @@ html_show_sourcelink = False html_title = "Network Information API" -html_theme_options = { - "use_page_nav": False, - "github_repo_name": "niapi", - "logo": { - "link": "https://github.com/JacobCoffee/niapi", - } -}, +html_theme_options = ( + { + "use_page_nav": False, + "github_repo_name": "niapi", + "logo": { + "link": "https://github.com/JacobCoffee/niapi", + }, + }, +) diff --git a/docs/images/SVG/Transparent/badge-dark.svg b/docs/images/SVG/Transparent/badge-dark.svg index 31ce0eb..72c12e2 100644 --- a/docs/images/SVG/Transparent/badge-dark.svg +++ b/docs/images/SVG/Transparent/badge-dark.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/docs/images/SVG/Transparent/badge.svg b/docs/images/SVG/Transparent/badge.svg index 6fa99b3..92dc26c 100644 --- a/docs/images/SVG/Transparent/badge.svg +++ b/docs/images/SVG/Transparent/badge.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/docs/images/SVG/Transparent/logo-dark-thin.svg b/docs/images/SVG/Transparent/logo-dark-thin.svg index 421ac99..29093e2 100644 --- a/docs/images/SVG/Transparent/logo-dark-thin.svg +++ b/docs/images/SVG/Transparent/logo-dark-thin.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/docs/images/SVG/Transparent/logo-dark.svg b/docs/images/SVG/Transparent/logo-dark.svg index c6197ef..4c4290f 100644 --- a/docs/images/SVG/Transparent/logo-dark.svg +++ b/docs/images/SVG/Transparent/logo-dark.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/docs/images/SVG/Transparent/logo-minimal-dark.svg b/docs/images/SVG/Transparent/logo-minimal-dark.svg index b29a0ff..20f43b9 100644 --- a/docs/images/SVG/Transparent/logo-minimal-dark.svg +++ b/docs/images/SVG/Transparent/logo-minimal-dark.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/docs/images/SVG/Transparent/logo-minimal.svg b/docs/images/SVG/Transparent/logo-minimal.svg index cd5402e..f1aa641 100644 --- a/docs/images/SVG/Transparent/logo-minimal.svg +++ b/docs/images/SVG/Transparent/logo-minimal.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/docs/images/SVG/Transparent/logo-thin.svg b/docs/images/SVG/Transparent/logo-thin.svg index 354e550..5665b68 100644 --- a/docs/images/SVG/Transparent/logo-thin.svg +++ b/docs/images/SVG/Transparent/logo-thin.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/docs/images/SVG/Transparent/logo.svg b/docs/images/SVG/Transparent/logo.svg index d1661fa..7594f59 100644 --- a/docs/images/SVG/Transparent/logo.svg +++ b/docs/images/SVG/Transparent/logo.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/docs/images/SVG/Transparent/wordmark-dark.svg b/docs/images/SVG/Transparent/wordmark-dark.svg index b423114..6f2bca8 100644 --- a/docs/images/SVG/Transparent/wordmark-dark.svg +++ b/docs/images/SVG/Transparent/wordmark-dark.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/docs/images/SVG/Transparent/wordmark.svg b/docs/images/SVG/Transparent/wordmark.svg index b906c46..463aa5a 100644 --- a/docs/images/SVG/Transparent/wordmark.svg +++ b/docs/images/SVG/Transparent/wordmark.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/docs/images/SVG/badge-dark.svg b/docs/images/SVG/badge-dark.svg index 6e451c2..f4f748d 100644 --- a/docs/images/SVG/badge-dark.svg +++ b/docs/images/SVG/badge-dark.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/docs/images/SVG/badge.svg b/docs/images/SVG/badge.svg index 446b711..df3c641 100644 --- a/docs/images/SVG/badge.svg +++ b/docs/images/SVG/badge.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/docs/images/SVG/logo-dark.svg b/docs/images/SVG/logo-dark.svg index dcb5643..5931a9c 100644 --- a/docs/images/SVG/logo-dark.svg +++ b/docs/images/SVG/logo-dark.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/docs/images/SVG/logo-minimal-dark.svg b/docs/images/SVG/logo-minimal-dark.svg index 124b32f..91ccf39 100644 --- a/docs/images/SVG/logo-minimal-dark.svg +++ b/docs/images/SVG/logo-minimal-dark.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/docs/images/SVG/logo-minimal.svg b/docs/images/SVG/logo-minimal.svg index dc03a34..361850b 100644 --- a/docs/images/SVG/logo-minimal.svg +++ b/docs/images/SVG/logo-minimal.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/docs/images/SVG/logo.svg b/docs/images/SVG/logo.svg index ac79ec8..4ac82d4 100644 --- a/docs/images/SVG/logo.svg +++ b/docs/images/SVG/logo.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/docs/images/SVG/wordmark-dark.svg b/docs/images/SVG/wordmark-dark.svg index 56981ae..7488e88 100644 --- a/docs/images/SVG/wordmark-dark.svg +++ b/docs/images/SVG/wordmark-dark.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/docs/images/SVG/wordmark.svg b/docs/images/SVG/wordmark.svg index f40f94a..aba63c2 100644 --- a/docs/images/SVG/wordmark.svg +++ b/docs/images/SVG/wordmark.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/niapi/asgi.py b/niapi/asgi.py index 0d4181f..5e18d85 100644 --- a/niapi/asgi.py +++ b/niapi/asgi.py @@ -12,22 +12,25 @@ def create_app() -> Litestar: """Create ASGI application.""" + from litestar import Litestar + from pydantic import SecretStr + from niapi import domain from niapi.lib import ( cors, exceptions, log, + openapi, settings, static_files, template, - openapi, ) - from litestar import Litestar - from pydantic import SecretStr return Litestar( # Handlers - exception_handlers={exceptions.ApplicationError: exceptions.exception_to_http_response}, + exception_handlers={ + exceptions.ApplicationError: exceptions.exception_to_http_response # type: ignore[dict-item] + }, route_handlers=[*domain.routes], # Configs cors_config=cors.config, diff --git a/niapi/cli.py b/niapi/cli.py index 48b543a..bfe568e 100644 --- a/niapi/cli.py +++ b/niapi/cli.py @@ -28,9 +28,7 @@ def run_app(_: dict[str, Any]) -> None: """Launch Application Components.""" -@click.group( - name="run-all", invoke_without_command=True, help="Starts the application server." -) +@click.group(name="run-all", invoke_without_command=True, help="Starts the application server.") @click.option( "--host", help="Host interface to listen on. Use 0.0.0.0 for all available interfaces.", @@ -60,12 +58,12 @@ def run_app(_: dict[str, Any]) -> None: @click.option("-v", "--verbose", help="Enable verbose logging.", is_flag=True, default=False, type=bool) @click.option("-d", "--debug", help="Enable debugging.", is_flag=True, default=False, type=bool) def run_all_app( - host: str, - port: int | None, - http_workers: int | None, - reload: bool | None, - verbose: bool | None, - debug: bool | None, + host: str, + port: int | None, + http_workers: int | None, + reload: bool | None, + verbose: bool | None, + debug: bool | None, ) -> None: """Run the API server.""" log.config.configure() diff --git a/niapi/domain/web/resources/logo.svg b/niapi/domain/web/resources/logo.svg index 6fa99b3..92dc26c 100644 --- a/niapi/domain/web/resources/logo.svg +++ b/niapi/domain/web/resources/logo.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/niapi/domain/web/resources/style.css b/niapi/domain/web/resources/style.css index 05ade8a..b6db742 100644 --- a/niapi/domain/web/resources/style.css +++ b/niapi/domain/web/resources/style.css @@ -820,6 +820,10 @@ select { margin-right: auto; } +.mr-2 { + margin-right: 0.5rem; +} + .mr-4 { margin-right: 1rem; } @@ -840,8 +844,8 @@ select { margin-top: 0.5rem; } -.mt-32 { - margin-top: 8rem; +.mt-20 { + margin-top: 5rem; } .mt-6 { @@ -852,14 +856,6 @@ select { margin-top: 2rem; } -.mr-2 { - margin-right: 0.5rem; -} - -.mt-20 { - margin-top: 5rem; -} - .block { display: block; } @@ -880,6 +876,10 @@ select { display: none; } +.h-1 { + height: 0.25rem; +} + .h-4 { height: 1rem; } @@ -900,10 +900,6 @@ select { height: 100%; } -.h-1 { - height: 0.25rem; -} - .min-h-full { min-height: 100%; } @@ -1096,11 +1092,6 @@ select { background-color: rgb(96 165 250 / var(--tw-bg-opacity)); } -.bg-neutral-900 { - --tw-bg-opacity: 1; - background-color: rgb(23 23 23 / var(--tw-bg-opacity)); -} - .bg-transparent { background-color: transparent; } @@ -1110,11 +1101,6 @@ select { background-color: rgb(255 255 255 / var(--tw-bg-opacity)); } -.bg-blue-500 { - --tw-bg-opacity: 1; - background-color: rgb(59 130 246 / var(--tw-bg-opacity)); -} - .p-1 { padding: 0.25rem; } @@ -1181,18 +1167,10 @@ select { padding-left: 0.75rem; } -.pt-16 { - padding-top: 4rem; -} - .pt-8 { padding-top: 2rem; } -.pt-6 { - padding-top: 1.5rem; -} - .font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; @@ -1213,16 +1191,6 @@ select { line-height: 1rem; } -.text-lg { - font-size: 1.125rem; - line-height: 1.75rem; -} - -.text-4xl { - font-size: 2.25rem; - line-height: 2.5rem; -} - .font-medium { font-weight: 500; } @@ -1282,6 +1250,10 @@ select { color: rgb(17 24 39 / var(--tw-text-opacity)); } +.text-gray-900\/60 { + color: rgb(17 24 39 / 0.6); +} + .text-neutral-900 { --tw-text-opacity: 1; color: rgb(23 23 23 / var(--tw-text-opacity)); @@ -1292,27 +1264,6 @@ select { color: rgb(255 255 255 / var(--tw-text-opacity)); } -.text-gray-900\/20 { - color: rgb(17 24 39 / 0.2); -} - -.text-gray-900\/80 { - color: rgb(17 24 39 / 0.8); -} - -.text-gray-900\/60 { - color: rgb(17 24 39 / 0.6); -} - -.text-purple-900 { - --tw-text-opacity: 1; - color: rgb(88 28 135 / var(--tw-text-opacity)); -} - -.text-purple-900\/60 { - color: rgb(88 28 135 / 0.6); -} - .antialiased { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; @@ -1351,11 +1302,6 @@ select { --tw-ring-color: rgb(209 213 219 / var(--tw-ring-opacity)); } -.ring-purple-300 { - --tw-ring-opacity: 1; - --tw-ring-color: rgb(216 180 254 / var(--tw-ring-opacity)); -} - .blur { --tw-blur: blur(8px); filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) @@ -1373,26 +1319,6 @@ select { color: rgb(156 163 175 / var(--tw-text-opacity)); } -.placeholder\:text-blue-400::-moz-placeholder { - --tw-text-opacity: 1; - color: rgb(96 165 250 / var(--tw-text-opacity)); -} - -.placeholder\:text-blue-400::placeholder { - --tw-text-opacity: 1; - color: rgb(96 165 250 / var(--tw-text-opacity)); -} - -.placeholder\:text-purple-400::-moz-placeholder { - --tw-text-opacity: 1; - color: rgb(192 132 252 / var(--tw-text-opacity)); -} - -.placeholder\:text-purple-400::placeholder { - --tw-text-opacity: 1; - color: rgb(192 132 252 / var(--tw-text-opacity)); -} - .focus-within\:ring-2:focus-within { --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color); @@ -1411,11 +1337,6 @@ select { --tw-ring-color: rgb(96 165 250 / var(--tw-ring-opacity)); } -.focus-within\:ring-purple-400:focus-within { - --tw-ring-opacity: 1; - --tw-ring-color: rgb(192 132 252 / var(--tw-ring-opacity)); -} - .hover\:bg-blue-50:hover { --tw-bg-opacity: 1; background-color: rgb(239 246 255 / var(--tw-bg-opacity)); @@ -1478,11 +1399,6 @@ select { --tw-ring-color: rgb(96 165 250 / var(--tw-ring-opacity)); } -.focus\:ring-purple-400:focus { - --tw-ring-opacity: 1; - --tw-ring-color: rgb(192 132 252 / var(--tw-ring-opacity)); -} - .focus-visible\:outline:focus-visible { outline-style: solid; } @@ -1503,6 +1419,11 @@ select { outline-color: #dc2626; } +:is(.dark .dark\:bg-blue-900) { + --tw-bg-opacity: 1; + background-color: rgb(30 58 138 / var(--tw-bg-opacity)); +} + :is(.dark .dark\:bg-neutral-900) { --tw-bg-opacity: 1; background-color: rgb(23 23 23 / var(--tw-bg-opacity)); @@ -1513,11 +1434,6 @@ select { background-color: rgb(10 10 10 / var(--tw-bg-opacity)); } -:is(.dark .dark\:bg-blue-900) { - --tw-bg-opacity: 1; - background-color: rgb(30 58 138 / var(--tw-bg-opacity)); -} - :is(.dark .dark\:text-blue-200) { --tw-text-opacity: 1; color: rgb(191 219 254 / var(--tw-text-opacity)); @@ -1528,36 +1444,13 @@ select { color: rgb(229 229 229 / var(--tw-text-opacity)); } -:is(.dark .dark\:text-neutral-100) { - --tw-text-opacity: 1; - color: rgb(245 245 245 / var(--tw-text-opacity)); -} - -:is(.dark .dark\:text-neutral-400) { - --tw-text-opacity: 1; - color: rgb(163 163 163 / var(--tw-text-opacity)); -} - -:is(.dark .dark\:text-neutral-300) { - --tw-text-opacity: 1; - color: rgb(212 212 212 / var(--tw-text-opacity)); -} - -:is(.dark .dark\:text-neutral-200\/60) { - color: rgb(229 229 229 / 0.6); -} - :is(.dark .dark\:text-neutral-200\/80) { color: rgb(229 229 229 / 0.8); } -:is(.dark .dark\:text-purple-200) { +:is(.dark .dark\:text-neutral-300) { --tw-text-opacity: 1; - color: rgb(233 213 255 / var(--tw-text-opacity)); -} - -:is(.dark .dark\:text-purple-200\/80) { - color: rgb(233 213 255 / 0.8); + color: rgb(212 212 212 / var(--tw-text-opacity)); } :is(.dark .dark\:placeholder-neutral-500)::-moz-placeholder { @@ -1570,26 +1463,6 @@ select { color: rgb(115 115 115 / var(--tw-placeholder-opacity)); } -:is(.dark .dark\:placeholder-red-500)::-moz-placeholder { - --tw-placeholder-opacity: 1; - color: rgb(239 68 68 / var(--tw-placeholder-opacity)); -} - -:is(.dark .dark\:placeholder-red-500)::placeholder { - --tw-placeholder-opacity: 1; - color: rgb(239 68 68 / var(--tw-placeholder-opacity)); -} - -:is(.dark .dark\:placeholder-blue-500)::-moz-placeholder { - --tw-placeholder-opacity: 1; - color: rgb(59 130 246 / var(--tw-placeholder-opacity)); -} - -:is(.dark .dark\:placeholder-blue-500)::placeholder { - --tw-placeholder-opacity: 1; - color: rgb(59 130 246 / var(--tw-placeholder-opacity)); -} - :is(.dark .dark\:ring-neutral-800) { --tw-ring-opacity: 1; --tw-ring-color: rgb(38 38 38 / var(--tw-ring-opacity)); @@ -1615,14 +1488,6 @@ select { grid-column: span 3 / span 3; } - .sm\:mt-56 { - margin-top: 14rem; - } - - .sm\:mt-36 { - margin-top: 9rem; - } - .sm\:mt-20 { margin-top: 5rem; } @@ -1640,14 +1505,6 @@ select { padding-right: 1.5rem; } - .sm\:pt-24 { - padding-top: 6rem; - } - - .sm\:pt-4 { - padding-top: 1rem; - } - .sm\:pt-12 { padding-top: 3rem; } @@ -1719,14 +1576,6 @@ select { padding-right: 2rem; } - .lg\:pt-32 { - padding-top: 8rem; - } - - .lg\:pt-2 { - padding-top: 0.5rem; - } - .lg\:pt-16 { padding-top: 4rem; } diff --git a/niapi/domain/web/templates/base/base.html b/niapi/domain/web/templates/base/base.html index 28d83c4..47dc22b 100644 --- a/niapi/domain/web/templates/base/base.html +++ b/niapi/domain/web/templates/base/base.html @@ -1,77 +1,67 @@ - + - - - - + + + - + {% block title %}{% endblock %} {{ title }} - - - {% block extrahead %}{% endblock %} - {% block extrastyle %}{% endblock %} - - + - + {% block extrahead %}{% endblock %} {% block extrastyle %}{% endblock %} + -
- {% block nav %} - {% include 'base/nav.html' %} - {% endblock nav %} + +
+ {% block nav %} {% include 'base/nav.html' %} {% endblock nav %} -
+
- {% block basecontent %} -
- {% block body %} - {% endblock body %} -
- {% endblock basecontent %} + {% block basecontent %} +
{% block body %} {% endblock body %}
+ {% endblock basecontent %}
-
+
- {% block footer %} - {% include 'base/footer.html' %} - {% endblock footer %} -
+ {% block footer %} {% include 'base/footer.html' %} {% endblock footer %} +
+ - - - - - -{% block extrajs %} -{% endblock extrajs %} - + {% block extrajs %} {% endblock extrajs %} diff --git a/niapi/lib/__init__.py b/niapi/lib/__init__.py index 339f6d6..6cd957a 100644 --- a/niapi/lib/__init__.py +++ b/niapi/lib/__init__.py @@ -1,6 +1,6 @@ """NIAPI Lib.""" from __future__ import annotations -from niapi.lib import log, schema, settings, template, static_files, openapi, cors, exceptions, serialization +from niapi.lib import cors, exceptions, log, openapi, schema, serialization, settings, static_files, template __all__ = ["settings", "schema", "log", "template", "static_files", "openapi", "cors", "exceptions", "serialization"] diff --git a/niapi/lib/exceptions.py b/niapi/lib/exceptions.py index 6773165..0779de6 100644 --- a/niapi/lib/exceptions.py +++ b/niapi/lib/exceptions.py @@ -94,8 +94,8 @@ async def after_exception_hook_handler(exc: Exception, _scope: Scope) -> None: def exception_to_http_response( - request: Request[Any, Any, Any], - exc: ApplicationError | RepositoryError, + request: Request[Any, Any, Any], + exc: ApplicationError | RepositoryError, ) -> Response[ExceptionResponseContent]: """Transform repository exceptions to HTTP exceptions. diff --git a/niapi/lib/log/utils.py b/niapi/lib/log/utils.py index 249efe8..093154e 100644 --- a/niapi/lib/log/utils.py +++ b/niapi/lib/log/utils.py @@ -51,7 +51,7 @@ class EventFilter: ..., EventFilter(["color_message"]), ..., - ] + ], ) """ diff --git a/niapi/lib/openapi.py b/niapi/lib/openapi.py index 5e34e4c..97cb4a6 100644 --- a/niapi/lib/openapi.py +++ b/niapi/lib/openapi.py @@ -7,6 +7,8 @@ from niapi.lib import settings +__all__ = ("OverridenController",) + class OverridenController(OpenAPIController): """Override the default OpenAPIController to use the configured path. diff --git a/niapi/lib/settings.py b/niapi/lib/settings.py index 8780a16..3b9d180 100644 --- a/niapi/lib/settings.py +++ b/niapi/lib/settings.py @@ -14,6 +14,18 @@ from niapi import utils from niapi.metadata import __version__ as version +__all__ = ( + "APISettings", + "AppSettings", + "HTTPClientSettings", + "LogSettings", + "OpenAPISettings", + "ServerSettings", + "TemplateSettings", + "load_settings", +) + + load_dotenv() DEFAULT_MODULE_NAME = "niapi" @@ -123,8 +135,8 @@ def slug(self) -> str: @validator("BACKEND_CORS_ORIGINS", pre=True, allow_reuse=True) def assemble_cors_origins( - cls, - value: str | list[str], + cls, + value: str | list[str], ) -> list[str] | str: """Parse a list of origins. @@ -147,8 +159,8 @@ def assemble_cors_origins( @validator("SECRET_KEY", pre=True, always=True, allow_reuse=True) def generate_secret_key( - cls, - value: SecretBytes | None, + cls, + value: SecretBytes | None, ) -> SecretBytes: """Generate a secret key. @@ -266,7 +278,7 @@ class Config: """Document version.""" PATH: str = "/api" """Path to access the root API documentation.""" - DESCRIPTION: str | None = f"""The Network Information API gives you, well... network information! + DESCRIPTION: str | None = f"""The Network Information API gives you, well... network information! You can find out more about this project in the [docs]({os.getenv("NIAPI_URL", "http://localhost") + "docs"}).""" SERVERS: list[dict[str, str]] = [] @@ -334,15 +346,15 @@ class Config: # noinspection PyShadowingNames def load_settings() -> ( - tuple[ - AppSettings, - APISettings, - OpenAPISettings, - TemplateSettings, - ServerSettings, - LogSettings, - HTTPClientSettings, - ] + tuple[ + AppSettings, + APISettings, + OpenAPISettings, + TemplateSettings, + ServerSettings, + LogSettings, + HTTPClientSettings, + ] ): """Load Settings file. diff --git a/niapi/lib/template.py b/niapi/lib/template.py index 8c77176..ef1b7d0 100644 --- a/niapi/lib/template.py +++ b/niapi/lib/template.py @@ -13,6 +13,6 @@ engine=settings.template.ENGINE, ) """ -Template config for Network Information API. +Template config for Network Information API. See :class:`TemplateSettings <.settings.TemplateSettings>` for configuration. """ diff --git a/pyproject.toml b/pyproject.toml index 9958846..a636bbd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -114,31 +114,47 @@ line-length = 120 include = '\.pyi?$' [tool.codespell] -ignore-words-list = "selectin" +ignore-words-list = "selectin, alog" skip = 'poetry.lock' [tool.mypy] -plugins = ["pydantic.mypy"] +plugins = [ + "pydantic.mypy", +] warn_unused_ignores = true warn_redundant_casts = true warn_unused_configs = true warn_unreachable = true warn_return_any = true +disallow_incomplete_defs = true +disallow_untyped_defs = true strict = true disallow_untyped_decorators = true disallow_any_generics = false implicit_reexport = false show_error_codes = true +exclude = ''' + (?x)( + ^build/ + | ^dist/ + | ^.venv/ + ) +''' -[tool.mypy."tests.*"] +[[tool.mypy.overrides]] +module = ["tests.*"] disallow_untyped_decorators = false -[tool."pydantic-mypy"] +[pydantic-mypy] init_forbid_extra = true init_typed = true warn_required_dynamic_aliases = true warn_untyped_fields = true +[[tool.mypy.overrides]] +module = ["structlog.*", "uvicorn.*", ] +ignore_missing_imports = true + [tool.coverage.run] omit = ["*/tests/*"] @@ -260,4 +276,3 @@ known-first-party = ["niapi", "tests"] ] "docs/**/*.*" = ["S", "B", "DTZ", "A", "TCH", "ERA", "D", "RET"] "tools/**/*.*" = ["D", "ARG", "EM", "TRY", "G", "FBT"] - diff --git a/tailwind.config.js b/tailwind.config.js index 48e15f1..afe3e81 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,8 +1,12 @@ /** @type {import('tailwindcss').Config} */ -const defaultTheme = require("tailwindcss/defaultTheme") +const defaultTheme = require("tailwindcss/defaultTheme"); module.exports = { darkMode: "class", content: ["./niapi/domain/web/templates/**/*.{html,js,ts,jsx,tsx,j2,jinja2}"], - plugins: [require("@tailwindcss/forms"), require("@tailwindcss/typography"), require("@tailwindcss/aspect-ratio")], -} + plugins: [ + require("@tailwindcss/forms"), + require("@tailwindcss/typography"), + require("@tailwindcss/aspect-ratio"), + ], +};