Skip to content

Commit

Permalink
Update project from its own template via Copier. (v1.10)
Browse files Browse the repository at this point in the history
  • Loading branch information
emcd committed Feb 24, 2025
1 parent a5a8885 commit a656eba
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 40 deletions.
4 changes: 3 additions & 1 deletion .auxiliary/configuration/copier-answers.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# Changes here will be overwritten by Copier
_commit: v1.9
_commit: v1.10
_src_path: gh:emcd/python-project-common
author_email: emcd@users.noreply.github.com
author_name: Eric McDonald
description: Project management utilities.
development_status: 3 - Alpha
distribution_name: emcd-projects
enable_cli: false
enable_property_tests: false
enable_publication: false
enable_rust_extension: false
gh_owner: emcd
include_data_resources: false
inject_docstring_utils: false
inject_exceptions: true
inject_foundations: true
Expand Down
10 changes: 4 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,20 @@ root = true

[*]
charset = utf-8
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = false
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = 79

[*.{py,py.jinja}]
max_line_length = 79
insert_final_newline = true

[*.{rs,rs.jinja}]
max_line_length = 79
insert_final_newline = true

[*.{rst,rst.jinja}]
indent_size = 2
Expand All @@ -31,4 +29,4 @@ max_line_length = 79
indent_size = 2

[*.yaml]
indent_size = 2
indent_size = 2
10 changes: 6 additions & 4 deletions .github/workflows/releaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

test:
needs: [initialize]
uses: emcd/python-project-common/.github/workflows/xrepo--tester.yaml@v1.9
uses: emcd/python-project-common/.github/workflows/xrepo--tester.yaml@v1.10
with:
matrix-exclusions: '${{ needs.initialize.outputs.matrix-exclusions }}'
platforms: '${{ needs.initialize.outputs.platforms }}'
Expand All @@ -34,7 +34,7 @@ jobs:

report:
needs: [initialize, test]
uses: emcd/python-project-common/.github/workflows/xrepo--reporter.yaml@v1.9
uses: emcd/python-project-common/.github/workflows/xrepo--reporter.yaml@v1.10
with:
python-version: '${{ fromJSON(needs.initialize.outputs.python-versions)[0] }}'

Expand All @@ -44,18 +44,20 @@ jobs:
contents: write
id-token: write
pages: write
uses: emcd/python-project-common/.github/workflows/xrepo--documenter.yaml@v1.9
uses: emcd/python-project-common/.github/workflows/xrepo--documenter.yaml@v1.10
with:
include-reports: true
python-version: '${{ fromJSON(needs.initialize.outputs.python-versions)[0] }}'

package:
needs: [initialize, docsgen]
uses: emcd/python-project-common/.github/workflows/xrepo--packager.yaml@v1.9
uses: emcd/python-project-common/.github/workflows/xrepo--packager.yaml@v1.10
with:
artifacts-path: '.auxiliary/artifacts/hatch-build' # TODO: Use environment.
python-version: '${{ fromJSON(needs.initialize.outputs.python-versions)[0] }}'






4 changes: 2 additions & 2 deletions .github/workflows/tester.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

test:
needs: [initialize]
uses: emcd/python-project-common/.github/workflows/xrepo--tester.yaml@v1.9
uses: emcd/python-project-common/.github/workflows/xrepo--tester.yaml@v1.10
with:
matrix-exclusions: '${{ needs.initialize.outputs.matrix-exclusions }}'
platforms: '${{ needs.initialize.outputs.platforms }}'
Expand All @@ -24,6 +24,6 @@ jobs:

report:
needs: [initialize, test]
uses: emcd/python-project-common/.github/workflows/xrepo--reporter.yaml@v1.9
uses: emcd/python-project-common/.github/workflows/xrepo--reporter.yaml@v1.10
with:
python-version: '${{ fromJSON(needs.initialize.outputs.python-versions)[0] }}'
50 changes: 41 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# vim: set filetype=toml fileencoding=utf-8:
# -*- mode: toml ; coding: utf-8 -*-

[build-system]
requires = [
'hatchling',
Expand All @@ -13,6 +16,9 @@ readme = { 'file' = 'README.rst', 'content-type' = 'text/x-rst' }
requires-python = '>= 3.10'
dependencies = [
'typing-extensions',
# --- BEGIN: Injected by Copier ---

# --- END: Injected by Copier ---
]
classifiers = [ # https://pypi.org/classifiers
'Development Status :: 3 - Alpha',
Expand Down Expand Up @@ -49,7 +55,7 @@ branch = true
command_line = '-m pytest' # TODO? '--fail-under'
data_file = '.auxiliary/caches/pytest/coverage.sqlite3'
parallel = true
source = [ 'sources', 'tests' ]
source = [ 'sources' ]
[tool.coverage.html]
directory = '.auxiliary/artifacts/coverage-pytest'
[tool.coverage.xml]
Expand All @@ -59,13 +65,23 @@ output = '.auxiliary/artifacts/coverage-pytest/coverage.xml'
[tool.hatch.build]
directory = '.auxiliary/artifacts/hatch-build'
[tool.hatch.build.targets.sdist]
only-include = [ 'sources/emcd_projects' ]
only-include = [
'sources/emcd_projects',
# --- BEGIN: Injected by Copier ---

# --- END: Injected by Copier ---
]
strict-naming = false
[tool.hatch.build.targets.wheel]
only-include = [ 'sources/emcd_projects' ]
only-include = [
'sources/emcd_projects',
# --- BEGIN: Injected by Copier ---

# --- END: Injected by Copier ---
]
strict-naming = false
[tool.hatch.build.targets.wheel.sources]
'sources/emcd_projects' = 'emcd_projects'
'sources/emcd_projects' = 'emcd_projects'
[tool.hatch.envs.default]
python = '3.10'
[tool.hatch.envs.develop]
Expand All @@ -76,6 +92,7 @@ dependencies = [
'coverage[toml]',
'furo',
'icecream',
'isort',
'packaging',
'pre-commit',
'pylint',
Expand All @@ -90,8 +107,16 @@ dependencies = [
'towncrier',
'tryceratops',
'yapf',
# --- BEGIN: Injected by Copier ---



# --- END: Injected by Copier ---
]
post-install-commands = [
# --- BEGIN: Injected by Copier ---

# --- END: Injected by Copier ---
]
[tool.hatch.envs.develop.env-vars]
PYTHONUNBUFFERED = 'TRUE' # TODO: Only for coverage/pytest.
Expand All @@ -114,8 +139,10 @@ linters = [
sources/emcd_projects''',
]
packagers = [
'hatch build',
# TODO? Sign packages.
'''hatch build''',
# --- BEGIN: Injected by Copier ---

# --- END: Injected by Copier ---
]
testers = [
'coverage erase',
Expand Down Expand Up @@ -239,6 +266,8 @@ ignored-parents = [
'builtins.TypeError',
'builtins.ValueError',
'builtins.type',
'typing.Protocol',
'typing_extensions.Protocol',
# --- BEGIN: Injected by Copier ---
'emcd_projects.exceptions.Omnierror',
'emcd_projects.exceptions.Omniexception',
Expand Down Expand Up @@ -290,15 +319,17 @@ disable = [
'multiple-statements',
'reimported',
'too-few-public-methods',
'too-many-positional-arguments', # 'too-many-arguments' is good enough
'ungrouped-imports',
'unused-wildcard-import',
'use-dict-literal',
'using-exception-groups-in-unsupported-version',
'wrong-import-order',
'wrong-import-position',
]
# TODO: Latest 'per-file-ignores' code may supports dicts and lists in addition to strings.
per-file-ignores = '''
/tests/:attribute-defined-outside-init,comparison-with-itself,magic-value-comparison,missing-class-docstring,missing-function-docstring,protected-access,singleton-comparison,superfluous-parens,unexpected-keyword-arg
/tests/:attribute-defined-outside-init,comparison-with-itself,magic-value-comparison,missing-class-docstring,missing-function-docstring,protected-access,singleton-comparison,superfluous-parens,too-many-try-statements,unexpected-keyword-arg
__init__\.py:unused-import
''' # Note: Paths are regexes.
[tool.pylint.refactoring]
Expand Down Expand Up @@ -349,6 +380,7 @@ reportMatchNotExhaustive = true
reportMissingImports = true
reportMissingTypeStubs = true
reportMissingTypeArgument = true
reportPossiblyUnboundVariable = false # Covered by other linters.
reportPrivateImportUsage = false # Covered by other linters.
reportPrivateUsage = false # Covered by other linters.
reportSelfClsParameterName = false # Too opinionated.
Expand All @@ -374,8 +406,8 @@ stubPath = 'sources/emcd_projects/_typedecls'
# attribute on protected modules. Instead, we use Sphinx to run doctests.
minversion = '8.1'
addopts = '--capture=no --exitfirst -rfE'
testpaths = [ 'tests', 'sources' ]
python_files = [ '*.py' ]
testpaths = [ 'tests' ]
python_files = [ 'test_*.py' ]
python_functions = [ 'test_[0-9][0-9][0-9]_*' ]
cache_dir = '.auxiliary/caches/pytest'

Expand Down
3 changes: 3 additions & 0 deletions sources/emcd_projects/__/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
import types

import typing_extensions as typx
# --- BEGIN: Injected by Copier ---

# --- END: Injected by Copier ---


ComparisonResult: typx.TypeAlias = bool | types.NotImplementedType
2 changes: 2 additions & 0 deletions sources/emcd_projects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@


from . import __
# --- BEGIN: Injected by Copier ---
from . import exceptions
# --- END: Injected by Copier ---


__version__ = '1.7a0'
Expand Down
8 changes: 6 additions & 2 deletions tests/test_000_emcd_projects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@
'''


import types


from types import MappingProxyType as DictionaryProxy


PACKAGE_NAME = 'emcd_projects'
PACKAGES_NAMES = ( PACKAGE_NAME, )


_modules_cache = { }
_modules_cache: dict[ str, types.ModuleType ] = { }
def cache_import_module( qname ):
''' Imports module from package by name and caches it. '''
from importlib import import_module
Expand All @@ -49,7 +52,8 @@ def _discover_module_names( package_name ):
return tuple(
path.stem
for path in Path( package.__file__ ).parent.glob( '*.py' )
if '__init__.py' != path.name and path.is_file( ) )
if path.name not in ( '__init__.py', '__main__.py' )
and path.is_file( ) )


MODULES_NAMES_BY_PACKAGE_NAME = DictionaryProxy( {
Expand Down
32 changes: 16 additions & 16 deletions tests/test_000_emcd_projects/test_000_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import pytest

from . import (
MODULES_NAMES_BY_MODULE_QNAME,
# MODULES_NAMES_BY_MODULE_QNAME,
MODULES_QNAMES,
PACKAGES_NAMES,
PACKAGES_NAMES_BY_MODULE_QNAME,
Expand All @@ -40,23 +40,23 @@ def test_000_sanity( package_name ):
assert package.__name__ == package_name


@pytest.mark.parametrize( 'module_qname', MODULES_QNAMES )
def test_010_attribute_module_existence( module_qname ):
''' Package module is attribute of package. '''
package_name = PACKAGES_NAMES_BY_MODULE_QNAME[ module_qname ]
package = cache_import_module( package_name )
module_name = MODULES_NAMES_BY_MODULE_QNAME[ module_qname ]
assert module_name in package.__dict__
# @pytest.mark.parametrize( 'module_qname', MODULES_QNAMES )
# def test_010_attribute_module_existence( module_qname ):
# ''' Package module is attribute of package. '''
# package_name = PACKAGES_NAMES_BY_MODULE_QNAME[ module_qname ]
# package = cache_import_module( package_name )
# module_name = MODULES_NAMES_BY_MODULE_QNAME[ module_qname ]
# assert module_name in package.__dict__


@pytest.mark.parametrize( 'module_qname', MODULES_QNAMES )
def test_011_attribute_module_classification( module_qname ):
''' Package attribute is module. '''
from inspect import ismodule
package_name = PACKAGES_NAMES_BY_MODULE_QNAME[ module_qname ]
package = cache_import_module( package_name )
module_name = MODULES_NAMES_BY_MODULE_QNAME[ module_qname ]
assert ismodule( getattr( package, module_name ) )
# @pytest.mark.parametrize( 'module_qname', MODULES_QNAMES )
# def test_011_attribute_module_classification( module_qname ):
# ''' Package attribute is module. '''
# from inspect import ismodule
# package_name = PACKAGES_NAMES_BY_MODULE_QNAME[ module_qname ]
# package = cache_import_module( package_name )
# module_name = MODULES_NAMES_BY_MODULE_QNAME[ module_qname ]
# assert ismodule( getattr( package, module_name ) )


@pytest.mark.parametrize( 'module_qname', MODULES_QNAMES )
Expand Down

0 comments on commit a656eba

Please sign in to comment.