From 0da62d1dfda24aff8a2fc282e37a04dfedc8d9b7 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Mon, 4 Nov 2024 00:55:31 -0500 Subject: [PATCH] Add/apply pyproject-fmt --- .pre-commit-config.yaml | 5 + pdm.lock | 32 ++++- pyproject.toml | 289 ++++++++++++++++++++-------------------- 3 files changed, 178 insertions(+), 148 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2716806..18aaade 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,6 +24,11 @@ repos: hooks: - id: pdm-lock-check + - repo: https://github.com/tox-dev/pyproject-fmt + rev: v2.5.0 + hooks: + - id: pyproject-fmt + - repo: local hooks: - id: django-migrations diff --git a/pdm.lock b/pdm.lock index d8c81c6..80a19f8 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "debug", "dev", "lint", "server", "typing"] strategy = ["inherit_metadata"] lock_version = "4.5.0" -content_hash = "sha256:0370ba34b4b455984520a720fb294746c04f2c525c3bbcde2f3e81056877266e" +content_hash = "sha256:62afd725635547b246ccd4644ad3882b3384f6c6c3ed49d8d9b164cc694219e1" [[metadata.targets]] requires_python = "==3.11.*" @@ -1827,6 +1827,21 @@ files = [ {file = "pyphen-0.16.0.tar.gz", hash = "sha256:2c006b3ddf072c9571ab97606d9ab3c26a92eaced4c0d59fd1d26988f308f413"}, ] +[[package]] +name = "pyproject-fmt" +version = "2.5.0" +requires_python = ">=3.9" +summary = "Format your pyproject.toml file" +groups = ["lint"] +marker = "python_version == \"3.11\"" +dependencies = [ + "toml-fmt-common==1.0.1", +] +files = [ + {file = "pyproject_fmt-2.5.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a167bb8598801e16dd69fe96530da843dffce83843a4b4fd52b91793399b1c7b"}, + {file = "pyproject_fmt-2.5.0.tar.gz", hash = "sha256:d8d9064bf740cda9b30386fc40f34deb8014a9a59f10e89bfb991df4c9dcbf15"}, +] + [[package]] name = "python-dateutil" version = "2.9.0.post0" @@ -2127,6 +2142,21 @@ files = [ {file = "tinycss2-1.3.0.tar.gz", hash = "sha256:152f9acabd296a8375fbca5b84c961ff95971fcfc32e79550c8df8e29118c54d"}, ] +[[package]] +name = "toml-fmt-common" +version = "1.0.1" +requires_python = ">=3.9" +summary = "Common logic to the TOML formatter." +groups = ["lint"] +marker = "python_version == \"3.11\"" +dependencies = [ + "tomli>=2.0.2; python_version < \"3.11\"", +] +files = [ + {file = "toml_fmt_common-1.0.1-py3-none-any.whl", hash = "sha256:7a6542e36a7167fa94b8b997d3f8debadbb4ab757c7d78a77304579bd7a0cc7d"}, + {file = "toml_fmt_common-1.0.1.tar.gz", hash = "sha256:7a29e99e527ffac456043296a0f1d8c03aaa1b06167bd39ad5e3cc5041f31c17"}, +] + [[package]] name = "tqdm" version = "4.66.5" diff --git a/pyproject.toml b/pyproject.toml index c3bc41d..c86ab56 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,95 +1,146 @@ +[build-system] +build-backend = "pdm.backend" +requires = [ "pdm-backend" ] + [project] -name = "CMSManage" +name = "cmsmanage" version = "0.1.0" description = "" authors = [ - {name = "Adam Goldsmith", email = "contact@adamgoldsmith.name"}, -] -dependencies = [ - "django~=5.1", - "django-admin-logs~=1.3", - "django-auth-ldap~=5.0", - "django-markdownx~=4.0", - "django-recurrence~=1.11", - "django-widget-tweaks~=1.5", - "django-stubs-ext~=5.1", - "markdownify~=0.13", - "mdformat~=0.7", - "mdformat-tables~=1.0", - "django-autocomplete-light~=3.11", - "weasyprint~=62.3", - "requests~=2.32", - "semver~=3.0", - "djangorestframework~=3.15", - "django-q2~=1.7", - "lxml~=5.3", - "django-object-actions~=4.3", - "bitstring~=4.2", - "udm-rest-client~=1.2", - "openapi-client-udm~=1.0", - "django-nh3~=0.1", - "nh3~=0.2", - "django-tables2~=2.7", - "tablib[ods,xlsx]~=3.7", - "django-filter~=24.3", - "django-db-views~=0.1", - "django-weasyprint~=2.3", - "django-sendfile2~=0.7", - "django-bootstrap5~=24.3", - "django-configurations[database,email]~=2.5", - "django-vite~=3.0", - "django-template-partials~=24.4", - "google-api-python-client~=2.148", - "google-auth-oauthlib~=1.2", - "django-model-utils~=5.0", - "psycopg[binary,pool]~=3.2", - "django-simple-history~=3.7", - "django-postgres-metrics~=0.15", + { name = "Adam Goldsmith", email = "contact@adamgoldsmith.name" }, ] requires-python = ">=3.11" -[project.optional-dependencies] -server = [ - "uvicorn[standard]~=0.31", - "setuptools~=75.1", +classifiers = [ + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +dependencies = [ + "bitstring~=4.2", + "django~=5.1", + "django-admin-logs~=1.3", + "django-auth-ldap~=5.0", + "django-autocomplete-light~=3.11", + "django-bootstrap5~=24.3", + "django-configurations[database,email]~=2.5", + "django-db-views~=0.1", + "django-filter~=24.3", + "django-markdownx~=4.0", + "django-model-utils~=5.0", + "django-nh3~=0.1", + "django-object-actions~=4.3", + "django-postgres-metrics~=0.15", + "django-q2~=1.7", + "django-recurrence~=1.11", + "django-sendfile2~=0.7", + "django-simple-history~=3.7", + "django-stubs-ext~=5.1", + "django-tables2~=2.7", + "django-template-partials~=24.4", + "django-vite~=3.0", + "django-weasyprint~=2.3", + "django-widget-tweaks~=1.5", + "djangorestframework~=3.15", + "google-api-python-client~=2.148", + "google-auth-oauthlib~=1.2", + "lxml~=5.3", + "markdownify~=0.13", + "mdformat~=0.7", + "mdformat-tables~=1.0", + "nh3~=0.2", + "openapi-client-udm~=1.0", + "psycopg[binary,pool]~=3.2", + "requests~=2.32", + "semver~=3.0", + "tablib[ods,xlsx]~=3.7", + "udm-rest-client~=1.2", + "weasyprint~=62.3", +] +optional-dependencies.server = [ + "setuptools~=75.1", + "uvicorn[standard]~=0.31", +] +entry-points."djangoq.errorreporters".admin_email = "cmsmanage.django_q2_admin_email_reporter:AdminEmailReporter" + +[[tool.pdm.source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[[tool.pdm.source]] +url = "https://git.claremontmakerspace.org/api/packages/CMS/pypi/simple" +verify_ssl = true +name = "CMS" +include_packages = [ "openapi-client-udm" ] + +[tool.pdm.dev-dependencies] +lint = [ + "djlint~=1.35", + "ruff~=0.6", + "pyproject-fmt~=2.5", +] +typing = [ + "mypy~=1.11", + "django-stubs~=5.1", + "setuptools~=75.1", + "types-bleach~=6.1", + "types-requests~=2.32", + "types-urllib3~=1.26", + "djangorestframework-stubs[compatible-mypy]~=3.15", + "types-Markdown~=3.7", + "types-Pygments~=2.18", + "types-psycopg2~=2.9", + "types-lxml~=2024.9", + "google-api-python-client-stubs~=1.28", + "types-python-dateutil~=2.9", +] +debug = [ + "django-debug-toolbar~=4.4", +] +dev = [ + "django-extensions~=3.2", + "ipython~=8.28", + "hypothesis[django]~=6.112", + "tblib~=3.0", + "coverage~=7.6", ] -[project.entry-points."djangoq.errorreporters"] -admin_email = "cmsmanage.django_q2_admin_email_reporter:AdminEmailReporter" +[tool.pdm.scripts] +start = "./manage.py runserver" +fmt.shell = "ruff check --fix ; ruff format . ; djlint --reformat ." [tool.ruff] line-length = 88 -[tool.ruff.lint] -select = [ +lint.select = [ + "A", + "B", + "C4", + "DJ012", "E4", "E7", "E9", "F", - "I", - "C4", - "UP", - "PERF", - "PL", - "SIM", "FIX003", - "DJ012", - "A", + "FURB", + "I", "INP", "ISC", - "Q", - "PIE", "LOG", - "RSE", - "TCH", + "PERF", + "PIE", + "PL", "PTH", - "FURB", - "B", + "Q", + "RSE", + "SIM", + "TCH", + "UP", ] -ignore = ["ISC001"] - -[tool.ruff.lint.isort] -known-first-party = [ +lint.ignore = [ "ISC001" ] +lint.isort.known-first-party = [ "cmsmanage", "dashboard", "doorcontrol", @@ -99,38 +150,8 @@ known-first-party = [ "reservations", "tasks", ] -section-order = ["future", "standard-library", "django", "third-party", "first-party", "local-folder"] - -[tool.ruff.lint.isort.sections] -"django" = ["django"] - -[tool.djlint] -profile="django" -extension = ".dj.html" -indent = 2 -blank_line_after_tag = "load,extends" -max_blank_lines = 1 -ignore = "T003,H017,H021,H030,H031" -custom_blocks = "partialdef" -format_css = true -format_js = true - -[tool.djlint.css] -indent_size = 2 - -[tool.djlint.js] -indent_size = 2 - -[tool.mypy] -plugins = [ - "./cmsmanage/mypy_django_configurations_plugin.py", - "mypy_django_plugin.main", - "mypy_drf_plugin.main", -] - -[tool.django-stubs] -django_settings_module = "cmsmanage.settings" -strict_settings = false +lint.isort.section-order = [ "future", "standard-library", "django", "third-party", "first-party", "local-folder" ] +lint.isort.sections."django" = [ "django" ] [tool.coverage.run] source = [ @@ -146,52 +167,26 @@ omit = [ "*/migrations/*", ] -[[tool.pdm.source]] -url = "https://pypi.org/simple" -verify_ssl = true -name = "pypi" - -[[tool.pdm.source]] -url = "https://git.claremontmakerspace.org/api/packages/CMS/pypi/simple" -verify_ssl = true -name = "CMS" -include_packages = ["openapi-client-udm"] - -[tool.pdm.dev-dependencies] -lint = [ - "djlint~=1.35", - "ruff~=0.6", -] -typing = [ - "mypy~=1.11", - "django-stubs~=5.1", - "setuptools~=75.1", - "types-bleach~=6.1", - "types-requests~=2.32", - "types-urllib3~=1.26", - "djangorestframework-stubs[compatible-mypy]~=3.15", - "types-Markdown~=3.7", - "types-Pygments~=2.18", - "types-psycopg2~=2.9", - "types-lxml~=2024.9", - "google-api-python-client-stubs~=1.28", - "types-python-dateutil~=2.9", -] -debug = [ - "django-debug-toolbar~=4.4", -] -dev = [ - "django-extensions~=3.2", - "ipython~=8.28", - "hypothesis[django]~=6.112", - "tblib~=3.0", - "coverage~=7.6", +[tool.mypy] +plugins = [ + "./cmsmanage/mypy_django_configurations_plugin.py", + "mypy_django_plugin.main", + "mypy_drf_plugin.main", ] -[tool.pdm.scripts] -start = "./manage.py runserver" -fmt.shell = "ruff check --fix ; ruff format . ; djlint --reformat ." +[tool.djlint] +profile = "django" +extension = ".dj.html" +indent = 2 +blank_line_after_tag = "load,extends" +max_blank_lines = 1 +ignore = "T003,H017,H021,H030,H031" +custom_blocks = "partialdef" +format_css = true +format_js = true +css.indent_size = 2 +js.indent_size = 2 -[build-system] -requires = ["pdm-backend"] -build-backend = "pdm.backend" +[tool.django-stubs] +django_settings_module = "cmsmanage.settings" +strict_settings = false