Skip to content

Commit

Permalink
v1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronny Vedrilla committed Nov 3, 2023
1 parent f73472e commit c860d05
Show file tree
Hide file tree
Showing 19 changed files with 107 additions and 94 deletions.
14 changes: 7 additions & 7 deletions .ambient-package-update/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
from ambient_package_update.metadata.readme import ReadmeContent

METADATA = PackageMetadata(
package_name='django_migration_zero',
package_name="django_migration_zero",
authors=[
PackageAuthor(
name='Ambient Digital',
email='[email protected]',
name="Ambient Digital",
email="[email protected]",
),
],
company='Ambient Innovation: GmbH',
company="Ambient Innovation: GmbH",
license=LICENSE_MIT,
license_year=2023,
development_status='5 - Production/Stable',
development_status="5 - Production/Stable",
has_migrations=True,
readme_content=ReadmeContent(
tagline="""Welcome to **django-migration-zero** - the holistic implementation of "migration zero" pattern for
Expand Down Expand Up @@ -68,12 +68,12 @@
```""",
),
dependencies=[
'Django>=3.2',
"Django>=3.2",
],
supported_django_versions=SUPPORTED_DJANGO_VERSIONS,
supported_python_versions=SUPPORTED_PYTHON_VERSIONS,
optional_dependencies={
'dev': [*DEV_DEPENDENCIES, "unittest-parametrize~=1.3"],
"dev": [*DEV_DEPENDENCIES, "unittest-parametrize~=1.3"],
},
ruff_ignore_list=[],
)
12 changes: 11 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,15 @@ omit =
setup.py,
*_test.py,
tests.py,
*tests*,
testapp/*
tests/*,
conftest.py

[report]
precision = 2
show_missing = True
exclude_lines =
# Don't complain if tests don't hit defensive assertion code:
raise NotImplementedError
# Ignore type checking conditions
if TYPE_CHECKING:
16 changes: 6 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@
# https://pre-commit.com/

repos:
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.10.0
hooks:
- id: black
args: [ --check, --diff, --config, ./pyproject.toml ]
stages: [ push ]

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.1.1'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.3
hooks:
# Run the Ruff linter.
- id: ruff
args: [ --fix, --unsafe-fixes, --exit-non-zero-on-fix ]
args: [--fix, --exit-non-zero-on-fix]
# Run the Ruff formatter.
- id: ruff-format

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

* *1.0.5* (2023-11-03)
* Switched formatter from `black` to `ruff`

* *1.0.4* (2023-10-31)
* Added `default_auto_field` to app config
* Linting and test fixes
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![Downloads](https://static.pepy.tech/badge/django-migration-zero)](https://pepy.tech/project/django-migration-zero)
[![Coverage](https://img.shields.io/badge/Coverage-100%25-success)](https://github.com/ambient-innovation/django-migration-zero/actions?workflow=CI)
[![Linting](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Coding Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
[![Coding Style](https://img.shields.io/badge/code%20style-Ruff-000000.svg)](https://github.com/astral-sh/ruff)
[![Documentation Status](https://readthedocs.org/projects/django-migration-zero/badge/?version=latest)](https://django-migration-zero.readthedocs.io/en/latest/?badge=latest)

Welcome to **django-migration-zero** - the holistic implementation of "migration zero" pattern for
Expand Down Expand Up @@ -72,7 +72,7 @@ fixing squashed migrations you won't need, you can use the "migration zero" patt
`python ./manage.py migrate`


* Add this block to your logging handlers in your main Django `settings.py` to show
* Add this block to your loggers in your main Django `settings.py` to show
logs in your console.

```python
Expand Down
2 changes: 1 addition & 1 deletion django_migration_zero/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
Holistic implementation of "migration zero" pattern for Django covering local changes and in-production database adjustments.
"""

__version__ = '1.0.4'
__version__ = "1.0.5"
2 changes: 1 addition & 1 deletion django_migration_zero/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def fetch_singleton(self) -> None:
except ProgrammingError:
logger.warning(
"The migration zero table is missing. This might be ok for the first installation of "
"\"django-migration-zero\" but if you see this warning after that point, something went sideways."
'"django-migration-zero" but if you see this warning after that point, something went sideways.'
)
return None

Expand Down
4 changes: 2 additions & 2 deletions django_migration_zero/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ def get_migration_zero_apps_dir() -> Path:
"""
Helper method to get the settings variable and validate the type
"""
migration_zero_apps_dir = getattr(settings, "MIGRATION_ZERO_APPS_DIR", Path('/'))
migration_zero_apps_dir = getattr(settings, "MIGRATION_ZERO_APPS_DIR", Path("/"))

if not isinstance(migration_zero_apps_dir, Path):
raise InvalidMigrationAppsDirPathError(
"Settings variable \"MIGRATION_ZERO_APPS_DIR\" has to be of type pathlib.Path."
'Settings variable "MIGRATION_ZERO_APPS_DIR" has to be of type pathlib.Path.'
)

return migration_zero_apps_dir
50 changes: 25 additions & 25 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,69 +16,69 @@
import django
from django.conf import settings

sys.path.insert(0, os.path.abspath('..')) # so that we can access the "django_migration_zero" package
sys.path.insert(0, os.path.abspath("..")) # so that we can access the "django_migration_zero" package
settings.configure(
INSTALLED_APPS=[
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_migration_zero',
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django_migration_zero",
],
SECRET_KEY='ASDFjklö123456890',
SECRET_KEY="ASDFjklö123456890",
)
django.setup()

from django_migration_zero import __version__ # noqa: E402

# -- Project information -----------------------------------------------------

project = 'django-migration-zero'
copyright = '2023, Ambient Innovation: GmbH' # noqa: A001
author = 'Ambient Innovation: GmbH <[email protected]>'
project = "django-migration-zero"
copyright = "2023, Ambient Innovation: GmbH" # noqa: A001
author = "Ambient Innovation: GmbH <[email protected]>"
version = __version__
release = __version__

# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# extensions coming with Sphinx (named "sphinx.ext.*") or your custom
# ones.
extensions = [
'sphinx_rtd_theme',
'sphinx.ext.autodoc',
'm2r2',
"sphinx_rtd_theme",
"sphinx.ext.autodoc",
"m2r2",
]

source_suffix = ['.rst', '.md']
source_suffix = [".rst", ".md"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
# html_theme = 'alabaster'
html_theme = 'sphinx_rtd_theme'
# html_theme = "alabaster"
html_theme = "sphinx_rtd_theme"
html_theme_options = {
'display_version': False,
'style_external_links': False,
"display_version": False,
"style_external_links": False,
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

# Set master doc file
master_doc = 'index'
master_doc = "index"
26 changes: 15 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ dev = [
'pytest-mock~=3.10',
'coverage~=7.3',
'pre-commit~=3.5',
'black~=23.10',
'ruff~=0.1',
'sphinx==4.2.0',
'sphinx-rtd-theme==1.0.0',
'm2r2==0.3.1',
'mistune<2.0.0',
'ambient-package-update~=23.10.5',
'ambient-package-update~=23.10.7',
'unittest-parametrize~=1.3',
]

Expand All @@ -61,15 +61,6 @@ name = "django_migration_zero"
'Bugtracker' = 'https://github.com/ambient-innovation/django-migration-zero/issues'
'Changelog' = 'https://django-migration-zero.readthedocs.io/en/latest/features/changelog.html'


[tool.black]
# use force-exclude, so that black also applies exclude when run using pre-commit: https://github.com/psf/black/issues/395
force-exclude = '''.*/migrations/.*'''
line-length = 120
multi_line_output = 3
skip-string-normalization = true
include_trailing_comma = true

[tool.ruff]
select = [
"E", # pycodestyle errors
Expand Down Expand Up @@ -152,6 +143,19 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
# Assume Python 3.12
target-version = "py312"

[tool.ruff.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"

[tool.tox]
legacy_tox_ini = """
[tox]
Expand Down
6 changes: 3 additions & 3 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
}
}

MIGRATION_ZERO_APPS_DIR = BASE_DIR / 'django-migration-zero'
MIGRATION_ZERO_APPS_DIR = BASE_DIR / "django-migration-zero"

# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
Expand Down Expand Up @@ -113,10 +113,10 @@

USE_TZ = True

LOCALE_PATHS = [str(BASE_DIR) + '/django_migration_zero/locale']
LOCALE_PATHS = [str(BASE_DIR) + "/django_migration_zero/locale"]

# Routing
ROOT_URLCONF = 'testapp.urls'
ROOT_URLCONF = "testapp.urls"

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/
Expand Down
2 changes: 1 addition & 1 deletion testapp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

urlpatterns = [
# django Admin
path('admin/', admin.site.urls),
path("admin/", admin.site.urls),
]
18 changes: 9 additions & 9 deletions tests/helpers/test_file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class HelperFileSystemTest(TestCase):
@override_settings(MIGRATION_ZERO_APPS_DIR=Path("/user/workspace/migration_zero/"))
def test_build_migration_directory_path_regular(self, *args):
self.assertEqual(
build_migration_directory_path(app_label='ilyta'), Path('/user/workspace/migration_zero/ilyta/migrations')
build_migration_directory_path(app_label="ilyta"), Path("/user/workspace/migration_zero/ilyta/migrations")
)

def test_get_local_django_apps_regular(self):
self.assertEqual(get_local_django_apps(), ['django_migration_zero', 'testapp'])
self.assertEqual(get_local_django_apps(), ["django_migration_zero", "testapp"])

def test_has_migration_directory_positive_case(self):
self.assertTrue(has_migration_directory(app_label="django_migration_zero"))
Expand All @@ -29,21 +29,21 @@ def test_has_migration_directory_negative_case(self):
self.assertFalse(has_migration_directory(app_label="testapp"))

def test_get_migration_files_regular(self):
self.assertEqual(get_migration_files(app_label="django_migration_zero"), ['0001_initial.py'])
self.assertEqual(get_migration_files(app_label="django_migration_zero"), ["0001_initial.py"])

def test_get_migration_files_exclude_initials(self):
self.assertEqual(get_migration_files(app_label="django_migration_zero", exclude_initials=True), [])

@mock.patch('django_migration_zero.helpers.file_system.os.unlink')
@mock.patch("django_migration_zero.helpers.file_system.os.unlink")
def test_delete_file_regular(self, mocked_unlink):
delete_file(app_label='testapp', filename='my_file.py')
delete_file(app_label="testapp", filename="my_file.py")
mocked_unlink.assert_called_once()

@mock.patch('django_migration_zero.helpers.file_system.os.unlink')
@mock.patch("django_migration_zero.helpers.file_system.os.unlink")
def test_delete_file_dry_run(self, mocked_unlink):
delete_file(app_label='testapp', filename='my_file.py', dry_run=True)
delete_file(app_label="testapp", filename="my_file.py", dry_run=True)
mocked_unlink.assert_not_called()

@mock.patch('django_migration_zero.helpers.file_system.os.unlink', side_effect=OSError)
@mock.patch("django_migration_zero.helpers.file_system.os.unlink", side_effect=OSError)
def test_delete_file_os_error(self, *args):
self.assertIsNone(delete_file(app_label='testapp', filename='my_file.py', dry_run=False))
self.assertIsNone(delete_file(app_label="testapp", filename="my_file.py", dry_run=False))
6 changes: 3 additions & 3 deletions tests/management/commands/test_handle_migration_zero_reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@


class ManagementCommandHandleMigrationZeroResetTest(TestCase):
@mock.patch.object(DatabasePreparationService, '__init__', return_value=None)
@mock.patch.object(DatabasePreparationService, 'process')
@mock.patch.object(DatabasePreparationService, "__init__", return_value=None)
@mock.patch.object(DatabasePreparationService, "process")
def test_call_parameter_no_parameters(self, mocked_process, mocked_init):
call_command('handle_migration_zero_reset')
call_command("handle_migration_zero_reset")
mocked_init.assert_called_once_with()
Loading

0 comments on commit c860d05

Please sign in to comment.