Skip to content

Commit

Permalink
v23.10.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronny Vedrilla committed Nov 3, 2023
1 parent b25c27b commit 07559fc
Show file tree
Hide file tree
Showing 13 changed files with 125 additions and 119 deletions.
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
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

**23.10.6 (2023-11-03)**
* Replaced `black` formatter with `ruff format`
* Improved coverage configuration

**23.10.5 (2023-10-26)**
* Fixed RTD build

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![PyPI release](https://img.shields.io/pypi/v/ambient-package-update.svg)](https://pypi.org/project/ambient-package-update/)
[![Downloads](https://static.pepy.tech/badge/ambient-package-update)](https://pepy.tech/project/ambient-package-update)
[![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)

# Ambient Package Update

Expand Down Expand Up @@ -98,7 +98,7 @@ The dependencies of this package are being maintained with `pip-tools`.
To add/update/remove a package, please do so in the main `pyproject.toml`. Afterward, call the following command to
reflect your changes in the `requirements.txt`.

> pip-compile --upgrade
> pip-compile --extra dev -o requirements.txt pyproject.toml --resolver=backtracking
To install the packages, run:

Expand Down
2 changes: 1 addition & 1 deletion ambient_package_update/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Ambient package update tool for clean and swift maintenance"""

__version__ = '23.10.5'
__version__ = "23.10.6"
20 changes: 10 additions & 10 deletions ambient_package_update/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
def get_metadata() -> PackageMetadata:
sys.path.append("./.ambient-package-update")
try:
m = import_module('metadata')
m = import_module("metadata")
except ModuleNotFoundError as e:
raise RuntimeError('Please create a directory ".ambient-package-update" and add a "metadata.py".') from e
sys.path.pop()
Expand All @@ -40,9 +40,9 @@ def create_rendered_file(*, template: Path, relative_target_path: Path | str) ->
metadata_dict = get_metadata().__dict__

j2_template = Template(template.read_text(), keep_trailing_newline=True)
j2_template.globals['current_year'] = datetime.now(tz=UTC).date().year
j2_template.globals['license_label'] = (
"GNU General Public License (GPL)" if metadata_dict['license'] == LICENSE_GPL else "MIT License"
j2_template.globals["current_year"] = datetime.now(tz=UTC).date().year
j2_template.globals["license_label"] = (
"GNU General Public License (GPL)" if metadata_dict["license"] == LICENSE_GPL else "MIT License"
)

print(f"> Rendering template {basename(template)!r}...")
Expand All @@ -53,7 +53,7 @@ def create_rendered_file(*, template: Path, relative_target_path: Path | str) ->
if relative_target_dir:
os.makedirs(os.path.dirname(relative_target_path), exist_ok=True)

with open(relative_target_path, 'w') as f:
with open(relative_target_path, "w") as f:
f.write(rendered_string)

abs_path = Path(relative_target_path).resolve()
Expand All @@ -68,7 +68,7 @@ def render_templates():
print(path, subdirs, files)
[template_list.append(Path(f"{path}/{file}")) for file in files]

print('Start rending distribution templates.')
print("Start rending distribution templates.")

for template in template_list:
create_rendered_file(
Expand All @@ -78,10 +78,10 @@ def render_templates():
# License file is conditional so we have to render it separately
metadata_dict = get_metadata().__dict__
create_rendered_file(
template=BASE_PATH / f"licenses/{metadata_dict['license']}.md", relative_target_path='LICENSE.md'
template=BASE_PATH / f"licenses/{metadata_dict['license']}.md", relative_target_path="LICENSE.md"
)

print('Rendering finished.')
print("Rendering finished.")


@app.command()
Expand All @@ -92,7 +92,7 @@ def build_docs(package_name: str):

@app.command()
def run_tests():
print('Running tests')
print("Running tests")

package_data = get_metadata()
dependency_list = package_data.dependencies
Expand All @@ -101,7 +101,7 @@ def run_tests():
for opt_dependency in package_data.optional_dependencies.values():
dependency_list += opt_dependency

dependency_list = ' '.join(f'"{d}"' for d in dependency_list)
dependency_list = " ".join(f'"{d}"' for d in dependency_list)
subprocess.call(f"pip install {dependency_list}", shell=True)

subprocess.call("pytest --ds settings tests", shell=True)
Expand Down
38 changes: 19 additions & 19 deletions ambient_package_update/metadata/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@

DEV_DEPENDENCIES = [
# Test runner
'freezegun~=1.2',
'pytest-django~=4.5',
'pytest-mock~=3.10',
'coverage~=7.3',
"freezegun~=1.2",
"pytest-django~=4.5",
"pytest-mock~=3.10",
"coverage~=7.3",
# Linting
'pre-commit~=3.5',
'black~=23.10',
"pre-commit~=3.5",
"ruff~=0.1",
# Documentation
'sphinx==4.2.0',
'sphinx-rtd-theme==1.0.0',
'm2r2==0.3.1',
'mistune<2.0.0', # fixes a problem mit m2r2
"sphinx==4.2.0",
"sphinx-rtd-theme==1.0.0",
"m2r2==0.3.1",
"mistune<2.0.0", # fixes a problem mit m2r2
# Build
f'ambient-package-update~={__version__}',
f"ambient-package-update~={__version__}",
]

SUPPORTED_DJANGO_VERSIONS = [
'3.2',
'4.1',
'4.2',
"3.2",
"4.1",
"4.2",
]

SUPPORTED_PYTHON_VERSIONS = [
'3.8',
'3.9',
'3.10',
'3.11',
'3.12',
"3.8",
"3.9",
"3.10",
"3.11",
"3.12",
]

LICENSE_MIT = "MIT"
Expand Down
9 changes: 9 additions & 0 deletions ambient_package_update/templates/.coveragerc.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,12 @@ omit =
tests.py,
*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 ambient_package_update/templates/.pre-commit-config.yaml.tpl
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
2 changes: 1 addition & 1 deletion ambient_package_update/templates/README.md.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![Downloads](https://static.pepy.tech/badge/{{ package_name|replace("_", "-") }})](https://pepy.tech/project/{{ package_name|replace("_", "-") }})
[![Coverage](https://img.shields.io/badge/Coverage-100%25-success)](https://github.com/ambient-innovation/{{ package_name|replace("_", "-") }}/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/{{ package_name|replace("_", "-") }}/badge/?version=latest)](https://{{ package_name|replace("_", "-") }}.readthedocs.io/en/latest/?badge=latest)

{{ readme_content.tagline }}
Expand Down
50 changes: 25 additions & 25 deletions ambient_package_update/templates/docs/conf.py.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,69 +16,69 @@ import sys
import django
from django.conf import settings

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

from {{ package_name }} import __version__ # noqa: E402

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

project = '{{ package_name|replace("_", "-") }}'
copyright = '{{ current_year }}, Ambient Innovation: GmbH' # noqa: A001
author = 'Ambient Innovation: GmbH <hello@ambient.digital>'
project = "{{ package_name|replace("_", "-") }}"
copyright = "{{ current_year }}, Ambient Innovation: GmbH" # noqa: A001
author = "Ambient Innovation: GmbH <hello@ambient.digital>"
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"
22 changes: 13 additions & 9 deletions ambient_package_update/templates/pyproject.toml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,6 @@ name = "{{ package_name }}"
'Bugtracker' = 'https://github.com/ambient-innovation/{{ package_name|replace("_", "-") }}/issues'
'Changelog' = 'https://{{ package_name|replace("_", "-") }}.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 @@ -136,6 +127,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
21 changes: 14 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dev = [
'keyring~=24.2',
# Linting
'pre-commit~=3.5',
'black~=23.10',
'ruff~=0.1',
]

[project.urls]
Expand All @@ -47,12 +47,6 @@ dev = [
'Bugtracker' = 'https://github.com/ambient-innovation/ambient-package-update/issues'
'Changelog' = 'https://github.com/ambient-innovation/ambient-package-update/blob/master/CHANGES.md'

[tool.black]
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 @@ -137,3 +131,16 @@ 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"
Loading

0 comments on commit 07559fc

Please sign in to comment.