kopia lustrzana https://github.com/jedie/PyInventory
Update project, e.g.: Darker -> Ruff and fix tests
rodzic
f29d28900b
commit
d0b0fa8add
|
@ -8,6 +8,6 @@ default_install_hook_types:
|
|||
|
||||
repos:
|
||||
- repo: https://github.com/jedie/cli-base-utilities
|
||||
rev: v0.17.0
|
||||
rev: v0.23.0
|
||||
hooks:
|
||||
- id: update-readme-history
|
||||
|
|
|
@ -166,7 +166,8 @@ To make a new release, do this:
|
|||
|
||||
[comment]: <> (✂✂✂ auto generated history start ✂✂✂)
|
||||
|
||||
* [**dev**](https://github.com/jedie/PyInventory/compare/v0.21.1...main)
|
||||
* [v0.21.2](https://github.com/jedie/PyInventory/compare/v0.21.1...v0.21.2)
|
||||
* 2025-09-09 - Update project, e.g.: Darker -> Ruff and fix tests
|
||||
* 2025-05-01 - Fix local dev server: Don't enforce https
|
||||
* [v0.21.1](https://github.com/jedie/PyInventory/compare/v0.21.0...v0.21.1)
|
||||
* 2025-05-01 - Replace setuptools with hatchling
|
||||
|
|
|
@ -8,5 +8,5 @@
|
|||
"""
|
||||
|
||||
# See https://packaging.python.org/en/latest/specifications/version-specifiers/
|
||||
__version__ = '0.21.1'
|
||||
__version__ = '0.21.2'
|
||||
__author__ = 'Jens Diemer <PyInventory@jensdiemer.de>'
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
import uuid
|
||||
|
||||
|
||||
import django.db.models.deletion
|
||||
import tagulous.models.fields
|
||||
import tagulous.models.models
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
import uuid
|
||||
|
||||
|
||||
import django.db.models.deletion
|
||||
import django_tools.serve_media_app.models
|
||||
import tagulous.models.fields
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# flake8: noqa: E405
|
||||
# ruff: noqa: F405
|
||||
|
||||
"""
|
||||
Django settings for local development
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
"""
|
||||
Base Django settings
|
||||
Django settings for production
|
||||
"""
|
||||
|
||||
import logging
|
||||
from pathlib import Path as __Path
|
||||
|
||||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
# flake8: noqa: E405
|
||||
"""
|
||||
Settings used to run tests
|
||||
"""
|
||||
import os
|
||||
|
||||
|
||||
# ruff: noqa: F405
|
||||
|
||||
"""
|
||||
Django settings for running tests
|
||||
"""
|
||||
from inventory_project.settings.prod import * # noqa
|
||||
|
||||
|
||||
|
@ -25,7 +27,11 @@ DATABASES = {
|
|||
}
|
||||
}
|
||||
|
||||
SECRET_KEY = 'No individual secret for tests ;)'
|
||||
SECRET_KEY = '''
|
||||
No individual secret for tests...
|
||||
But it must be longer than 50 characters, less than 5 unique characters.
|
||||
Or the "security.W009" check will fail ;)
|
||||
'''
|
||||
|
||||
DEBUG = True
|
||||
|
||||
|
|
|
@ -1,29 +1,25 @@
|
|||
import subprocess
|
||||
from pathlib import Path
|
||||
from unittest import TestCase
|
||||
|
||||
from bx_py_utils.path import assert_is_dir, assert_is_file
|
||||
from cli_base.cli_tools.code_style import assert_code_style
|
||||
from django.conf import settings
|
||||
from django.core import checks
|
||||
from django.core.cache import cache
|
||||
from django.core.management import call_command
|
||||
from manage_django_project.management.commands import code_style
|
||||
from django.test import SimpleTestCase, override_settings
|
||||
from manageprojects.test_utils.project_setup import check_editor_config, get_py_max_line_length
|
||||
from packaging.version import Version
|
||||
|
||||
from inventory import __version__
|
||||
from manage import BASE_PATH
|
||||
|
||||
|
||||
class ProjectSetupTestCase(TestCase):
|
||||
class ProjectSetupTestCase(SimpleTestCase):
|
||||
def test_project_path(self):
|
||||
project_path = settings.BASE_PATH
|
||||
assert_is_dir(project_path)
|
||||
assert_is_dir(project_path / 'inventory')
|
||||
assert_is_dir(project_path / 'inventory_project')
|
||||
|
||||
self.assertEqual(project_path, BASE_PATH)
|
||||
|
||||
def test_template_dirs(self):
|
||||
assert len(settings.TEMPLATES) == 1
|
||||
dirs = settings.TEMPLATES[0].get('DIRS')
|
||||
|
@ -32,6 +28,7 @@ class ProjectSetupTestCase(TestCase):
|
|||
assert template_path.is_dir()
|
||||
|
||||
def test_manage_check(self):
|
||||
with override_settings(DEBUG=False):
|
||||
all_issues = checks.run_checks(
|
||||
app_configs=None,
|
||||
tags=None,
|
||||
|
@ -41,7 +38,6 @@ class ProjectSetupTestCase(TestCase):
|
|||
all_issue_ids = {issue.id for issue in all_issues}
|
||||
excpeted_issues = {
|
||||
'async.E001', # DJANGO_ALLOW_ASYNC_UNSAFE set, because of playwright tests
|
||||
'security.W009', # ignore fake SECRET_KEY in tests
|
||||
}
|
||||
if all_issue_ids != excpeted_issues:
|
||||
print('=' * 100)
|
||||
|
@ -71,14 +67,14 @@ class ProjectSetupTestCase(TestCase):
|
|||
version = Version(__version__) # Will raise InvalidVersion() if wrong formatted
|
||||
self.assertEqual(str(version), __version__)
|
||||
|
||||
manage_bin = BASE_PATH / 'manage.py'
|
||||
manage_bin = settings.BASE_PATH / 'manage.py'
|
||||
assert_is_file(manage_bin)
|
||||
|
||||
output = subprocess.check_output([manage_bin, 'version'], text=True)
|
||||
self.assertIn(__version__, output)
|
||||
|
||||
def test_manage(self):
|
||||
manage_bin = BASE_PATH / 'manage.py'
|
||||
manage_bin = settings.BASE_PATH / 'manage.py'
|
||||
assert_is_file(manage_bin)
|
||||
|
||||
output = subprocess.check_output([manage_bin, 'project_info'], text=True)
|
||||
|
@ -94,10 +90,11 @@ class ProjectSetupTestCase(TestCase):
|
|||
self.assertIn("No changes detected", output)
|
||||
|
||||
def test_code_style(self):
|
||||
call_command(code_style.Command())
|
||||
return_code = assert_code_style(package_root=settings.BASE_PATH)
|
||||
self.assertEqual(return_code, 0, 'Code style error, see output above!')
|
||||
|
||||
def test_check_editor_config(self):
|
||||
check_editor_config(package_root=BASE_PATH)
|
||||
check_editor_config(package_root=settings.BASE_PATH)
|
||||
|
||||
max_line_length = get_py_max_line_length(package_root=BASE_PATH)
|
||||
max_line_length = get_py_max_line_length(package_root=settings.BASE_PATH)
|
||||
self.assertEqual(max_line_length, 119)
|
||||
|
|
|
@ -2,9 +2,9 @@ from unittest import TestCase
|
|||
|
||||
from bx_py_utils.auto_doc import assert_readme_block
|
||||
from cli_base.cli_tools.git_history import get_git_history
|
||||
from django.conf import settings
|
||||
|
||||
import inventory
|
||||
from manage import BASE_PATH
|
||||
|
||||
|
||||
class ReadmeHistoryTestCase(TestCase):
|
||||
|
@ -15,7 +15,7 @@ class ReadmeHistoryTestCase(TestCase):
|
|||
)
|
||||
history = '\n'.join(git_history)
|
||||
assert_readme_block(
|
||||
readme_path=BASE_PATH / 'README.md',
|
||||
readme_path=settings.BASE_PATH / 'README.md',
|
||||
text_block=f'\n{history}\n',
|
||||
start_marker_line='[comment]: <> (✂✂✂ auto generated history start ✂✂✂)',
|
||||
end_marker_line='[comment]: <> (✂✂✂ auto generated history end ✂✂✂)',
|
||||
|
|
|
@ -14,7 +14,7 @@ urlpatterns = [ # Don't use i18n_patterns() here
|
|||
]
|
||||
|
||||
|
||||
if settings.DEBUG:
|
||||
if 'debug_toolbar' in settings.INSTALLED_APPS:
|
||||
import debug_toolbar
|
||||
|
||||
urlpatterns = [path('__debug__/', include(debug_toolbar.urls))] + urlpatterns
|
||||
|
|
|
@ -11,7 +11,7 @@ keywords=['inventory','django']
|
|||
requires-python = ">=3.11"
|
||||
dependencies = [
|
||||
# Stay with Django v5.1.x until https://github.com/radiac/django-tagulous/issues/187 is fixed
|
||||
"django!=5.2.0", # https://docs.djangoproject.com
|
||||
"django<5.2,>5.1", # https://docs.djangoproject.com
|
||||
|
||||
"colorlog", # https://github.com/borntyping/python-colorlog
|
||||
"gunicorn", # https://github.com/benoimyproject.wsgitc/gunicorn
|
||||
|
@ -47,12 +47,9 @@ dev = [
|
|||
"hatchling", # https://github.com/pypa/hatch/tree/master/backend
|
||||
"playwright", # https://github.com/microsoft/playwright-python
|
||||
"tblib", # https://github.com/ionelmc/python-tblib
|
||||
# TODO: "nox", # https://github.com/wntrblm/nox
|
||||
"coverage", # https://github.com/nedbat/coveragepy
|
||||
"autopep8", # https://github.com/hhatto/autopep8
|
||||
"pyupgrade", # https://github.com/asottile/pyupgrade
|
||||
"flake8", # https://github.com/pycqa/flake8
|
||||
"flake8-bugbear", # https://github.com/PyCQA/flake8-bugbear
|
||||
"pyflakes", # https://github.com/PyCQA/pyflakes
|
||||
"ruff", # https://github.com/astral-sh/ruff
|
||||
"codespell", # https://github.com/codespell-project/codespell
|
||||
"EditorConfig", # https://github.com/editorconfig/editorconfig-core-py
|
||||
"pip-audit", # https://github.com/pypa/pip-audit
|
||||
|
@ -61,12 +58,6 @@ dev = [
|
|||
"pre-commit", # https://github.com/pre-commit/pre-commit
|
||||
"typeguard", # https://github.com/agronholm/typeguard/
|
||||
|
||||
# https://github.com/akaihola/darker
|
||||
# https://github.com/ikamensh/flynt
|
||||
# https://github.com/pycqa/isort
|
||||
# https://github.com/pygments/pygments
|
||||
"darker[flynt, isort, color]",
|
||||
|
||||
"model_bakery", # https://github.com/model-bakers/model_bakery
|
||||
"requests-mock", # https://github.com/jamielennox/requests-mock
|
||||
"django-override-storage", # https://github.com/danifus/django-override-storage
|
||||
|
@ -115,33 +106,30 @@ ignore-vuln=[
|
|||
]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[tool.darker]
|
||||
src = ['.']
|
||||
revision = "origin/main..."
|
||||
line_length = 119
|
||||
color = true
|
||||
skip_string_normalization = true
|
||||
diff = false
|
||||
check = false
|
||||
stdout = false
|
||||
isort = true
|
||||
lint = [
|
||||
"flake8",
|
||||
[tool.ruff]
|
||||
# https://docs.astral.sh/ruff/configuration/
|
||||
line-length = 120
|
||||
exclude = [
|
||||
".*/",
|
||||
]
|
||||
log_level = "INFO"
|
||||
|
||||
[tool.ruff.lint]
|
||||
preview = true # Needed for some of the rules
|
||||
extend-select = [
|
||||
"E", # pycodestyle: https://docs.astral.sh/ruff/rules/#error-e
|
||||
"I", # isort: https://docs.astral.sh/ruff/rules/#isort-i
|
||||
]
|
||||
ignore = [
|
||||
"E402", # https://docs.astral.sh/ruff/rules/module-import-not-at-top-of-file/
|
||||
"E731", # https://docs.astral.sh/ruff/rules/lambda-assignment/
|
||||
]
|
||||
|
||||
[tool.isort]
|
||||
# https://pycqa.github.io/isort/docs/configuration/config_files/#pyprojecttoml-preferred-format
|
||||
atomic=true
|
||||
profile='black'
|
||||
skip_glob=['.*', '*/htmlcov/*','*/migrations/*']
|
||||
known_first_party=['inventory']
|
||||
line_length=119
|
||||
lines_after_imports=2
|
||||
[tool.ruff.lint.isort]
|
||||
# https://docs.astral.sh/ruff/settings/#lintisort
|
||||
lines-after-imports = 2
|
||||
|
||||
[tool.ruff.format]
|
||||
quote-style = "single"
|
||||
|
||||
|
||||
[tool.coverage.run] # https://coverage.readthedocs.io/en/latest/config.html#run
|
||||
|
@ -181,6 +169,7 @@ applied_migrations = [
|
|||
"141b3e4", # 2024-09-05T17:53:31+02:00
|
||||
"a36dd75", # 2025-03-23T11:39:23+01:00
|
||||
"b3e0624", # 2025-05-01T00:07:45+02:00
|
||||
"46497a1", # 2025-09-05T08:45:19+02:00
|
||||
]
|
||||
|
||||
[manageprojects.cookiecutter_context.cookiecutter]
|
||||
|
|
Ładowanie…
Reference in New Issue