Skip to content

Commit

Permalink
Update to copier 2.5.0 (#888)
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicOram authored Nov 5, 2024
1 parent cc5c259 commit 8640900
Show file tree
Hide file tree
Showing 16 changed files with 103 additions and 46 deletions.
4 changes: 3 additions & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Changes here will be overwritten by Copier
_commit: 2.2.0
_commit: 2.5.0
_src_path: gh:DiamondLightSource/python-copier-template
author_email: dominic.oram@diamond.ac.uk
author_name: Dominic Oram
component_lifecycle: production
component_owner: group:data-acquisition
component_type: library
description: Ophyd devices and other utils that could be used across DLS beamlines
distribution_name: dls-dodal
docker: false
Expand Down
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ It is recommended that developers use a [vscode devcontainer](https://code.visua

This project was created using the [Diamond Light Source Copier Template](https://github.com/DiamondLightSource/python-copier-template) for Python projects.

For more information on common tasks like setting up a developer environment, running the tests, and setting a pre-commit hook, see the template's [How-to guides](https://diamondlightsource.github.io/python-copier-template/2.2.0/how-to.html).
For more information on common tasks like setting up a developer environment, running the tests, and setting a pre-commit hook, see the template's [How-to guides](https://diamondlightsource.github.io/python-copier-template/2.5.0/how-to.html).
14 changes: 8 additions & 6 deletions .github/pages/make_switcher.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Make switcher.json to allow docs to switch between different versions."""

import json
import logging
from argparse import ArgumentParser
Expand All @@ -6,6 +8,7 @@


def report_output(stdout: bytes, label: str) -> list[str]:
"""Print and return something received frm stdout."""
ret = stdout.decode().strip().split("\n")
print(f"{label}: {ret}")
return ret
Expand Down Expand Up @@ -52,21 +55,20 @@ def get_versions(ref: str, add: str | None) -> list[str]:
return versions


def write_json(path: Path, repository: str, versions: str):
def write_json(path: Path, repository: str, versions: list[str]):
"""Write the JSON switcher to path."""
org, repo_name = repository.split("/")
pages_url = f"https://{org}.github.io"
if repo_name != f"{org}.github.io":
# Only add the repo name if it isn't the source for the org pages site
pages_url += f"/{repo_name}"
struct = [
{"version": version, "url": f"{pages_url}/{version}/"} for version in versions
{"version": version, "url": f"https://{org}.github.io/{repo_name}/{version}/"}
for version in versions
]
text = json.dumps(struct, indent=2)
print(f"JSON switcher:\n{text}")
path.write_text(text, encoding="utf-8")


def main(args=None):
"""Parse args and write switcher."""
parser = ArgumentParser(
description="Make a versions.json file from gh-pages directories"
)
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ jobs:

- name: Publish to PyPI using trusted publishing
uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: false
2 changes: 1 addition & 1 deletion .github/workflows/_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Create GitHub Release
# We pin to the SHA, not the tag, for security reasons.
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
uses: softprops/action-gh-release@e7a8f85e1c67a31e6ed99a94b41bd0b71bbee6b8 # v2.0.9
with:
prerelease: ${{ contains(github.ref_name, 'a') || contains(github.ref_name, 'b') || contains(github.ref_name, 'rc') }}
files: "*"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ tmp/
# Sphinx documentation
docs/_build/
docs/reference/generated/
docs/_api

# PyBuilder
target/
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# The devcontainer should use the developer target and run as root with podman
# or docker with user namespaces.
ARG PYTHON_VERSION=3.11
FROM python:${PYTHON_VERSION} as developer
FROM python:${PYTHON_VERSION} AS developer

# Add any system dependencies for the developer/build environment here
RUN apt-get update && apt-get install -y --no-install-recommends \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![CI](https://github.com/DiamondLightSource/dodal/actions/workflows/ci.yml/badge.svg)](https://github.com/DiamondLightSource/dodal/actions/workflows/ci.yml)
[![Coverage](https://codecov.io/gh/DiamondLightSource/dodal/branch/main/graph/badge.svg)](https://codecov.io/gh/DiamondLightSource/dodal)
[![PyPI](https://img.shields.io/pypi/v/dls-dodal.svg)](https://pypi.org/project/dls-dodal)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)

# dodal

Expand Down
16 changes: 16 additions & 0 deletions docs/_api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
:orphan:

..
This page is not included in the TOC tree, but must exist so that the
autosummary pages are generated for dodal and all its
subpackages
API
===

.. autosummary::
:toctree: _api
:template: custom-module-template.rst
:recursive:

dodal
37 changes: 37 additions & 0 deletions docs/_templates/custom-module-template.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{ ('``' + fullname + '``') | underline }}

{%- set filtered_members = [] %}
{%- for item in members %}
{%- if item in functions + classes + exceptions + attributes %}
{% set _ = filtered_members.append(item) %}
{%- endif %}
{%- endfor %}

.. automodule:: {{ fullname }}
:members:

{% block modules %}
{% if modules %}
.. rubric:: Submodules

.. autosummary::
:toctree:
:template: custom-module-template.rst
:recursive:
{% for item in modules %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block members %}
{% if filtered_members %}
.. rubric:: Members

.. autosummary::
:nosignatures:
{% for item in filtered_members %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
18 changes: 13 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
"""Configuration file for the Sphinx documentation builder.
This file only contains a selection of the most common options. For a full
list see the documentation:
https://www.sphinx-doc.org/en/master/usage/configuration.html
"""

import sys
from inspect import isclass
Expand Down Expand Up @@ -33,6 +34,7 @@
extensions = [
# Use this for generating API docs
"sphinx.ext.autodoc",
# and making summary tables at the top of API docs
"sphinx.ext.autosummary",
# This can parse google style docstrings
"sphinx.ext.napoleon",
Expand Down Expand Up @@ -91,6 +93,12 @@
autosummary_generate = True
autosummary_imported_members = False

# Document only what is in __all__
autosummary_ignore_module_all = False

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

# Output graphviz directive produced images in a scalable format
graphviz_output_format = "svg"

Expand Down
2 changes: 1 addition & 1 deletion docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Technical reference material including APIs and release notes.
:maxdepth: 1
:glob:
reference/*
API <_api/dodal>
genindex
Release Notes <https://github.com/DiamondLightSource/dodal/releases>
```
26 changes: 0 additions & 26 deletions docs/reference/api.md

This file was deleted.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ dodal = ["*.txt"]
version_file = "src/dodal/_version.py"

[tool.pyright]
typeCheckingMode = "standard"
reportMissingImports = false # Ignore missing stubs in imported modules

[tool.pytest.ini_options]
Expand Down
8 changes: 8 additions & 0 deletions src/dodal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
"""Top level API.
.. data:: __version__
:type: str
Version number as calculated by https://github.com/pypa/setuptools_scm
"""

from ._version import __version__

__all__ = ["__version__"]
12 changes: 9 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from collections.abc import Mapping
from os import environ, getenv
from pathlib import Path
from typing import Any
from unittest.mock import MagicMock, patch

import pytest
Expand Down Expand Up @@ -67,11 +68,16 @@ def patched_open(*args, **kwargs):
if os.getenv("PYTEST_RAISE", "0") == "1":

@pytest.hookimpl(tryfirst=True)
def pytest_exception_interact(call):
raise call.excinfo.value
def pytest_exception_interact(call: pytest.CallInfo[Any]):
if call.excinfo is not None:
raise call.excinfo.value
else:
raise RuntimeError(
f"{call} has no exception data, an unknown error has occurred"
)

@pytest.hookimpl(tryfirst=True)
def pytest_internalerror(excinfo):
def pytest_internalerror(excinfo: pytest.ExceptionInfo[Any]):
raise excinfo.value


Expand Down

0 comments on commit 8640900

Please sign in to comment.