diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee65930f..8c2e8339 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -149,10 +149,10 @@ jobs: fail-fast: false matrix: python: - # Using second most recent minor release for whatever little - # increase in stability over using the latest minor. - - name: CPython 3.9 - python-version: '3.9' + # Use a recent version to avoid having common disconnects between + # local development setups and CI. + - name: CPython 3.11 + python-version: '3.11' task: - name: Check Newsfragment nox: check_newsfragment diff --git a/noxfile.py b/noxfile.py index 4dedd219..3f792708 100644 --- a/noxfile.py +++ b/noxfile.py @@ -55,7 +55,9 @@ def check_newsfragment(session: nox.Session) -> None: @nox.session def typecheck(session: nox.Session) -> None: - session.install(".", "mypy") + # Click 8.1.4 is bad type hints -- lets not complicate packaging and only + # pin here. + session.install(".", "mypy", "click!=8.1.4") session.run("mypy", "src") diff --git a/src/towncrier/_settings/load.py b/src/towncrier/_settings/load.py index d228340e..0b845662 100644 --- a/src/towncrier/_settings/load.py +++ b/src/towncrier/_settings/load.py @@ -161,8 +161,9 @@ def parse_toml(base_path: str, config: Mapping[str, Any]) -> Config: package, resource = template.split(":", 1) if not Path(resource).suffix: resource += ".md" if markdown_file else ".rst" - if not resources.is_resource(package, resource): - if resources.is_resource(package + ".templates", resource): + + if not _pkg_file_exists(package, resource): + if _pkg_file_exists(package + ".templates", resource): package += ".templates" else: raise ConfigError( @@ -190,3 +191,10 @@ def parse_toml(base_path: str, config: Mapping[str, Any]) -> Config: # Return the parsed config. return Config(**parsed_data) + + +def _pkg_file_exists(pkg: str, file: str) -> bool: + """ + Check whether *file* exists within *pkg*. + """ + return resources.files(pkg).joinpath(file).is_file() diff --git a/src/towncrier/build.py b/src/towncrier/build.py index ef7c5f35..60e0e861 100644 --- a/src/towncrier/build.py +++ b/src/towncrier/build.py @@ -165,7 +165,9 @@ def __main( click.echo("Loading template...", err=to_err) if isinstance(config.template, tuple): - template = resources.read_text(*config.template) + template = ( + resources.files(config.template[0]).joinpath(config.template[1]).read_text() + ) else: with open(config.template, encoding="utf-8") as tmpl: template = tmpl.read() diff --git a/src/towncrier/newsfragments/529.misc b/src/towncrier/newsfragments/529.misc new file mode 100644 index 00000000..e69de29b