Skip to content

Commit 377ec0b

Browse files
Merge pull request #95 from PyCalendar/ci/tooling-fixes
fix: CI tooling bugs in Make, Read the Docs, and Vale config
2 parents 9977760 + 4a2aa64 commit 377ec0b

11 files changed

Lines changed: 41 additions & 18 deletions

File tree

‎.github/workflows/tests.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ jobs:
5353
with:
5454
version: "0.13.6"
5555

56-
- name: Lint and format code
57-
run: make format
56+
- name: Lint and check the format
57+
run: make lint
5858

5959
mypy:
6060
name: Type check with mypy

‎.pre-commit-config.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ repos:
1414
hooks:
1515
- id: trailing-whitespace
1616
- id: end-of-file-fixer
17+
# Jinja drops a template's last newline, so the apidoc templates end with a
18+
# blank line for each page they write to end with one newline.
19+
exclude: ^docs/_templates/apidoc/
1720
- id: check-yaml
1821
- id: check-added-large-files
1922

‎.readthedocs.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ build:
1515
# If there are no changes (git diff exits with 0) we force the command to return with 183.
1616
# This is a special exit code on Read the Docs that will cancel the build immediately.
1717
- |
18-
if [ "$READTHEDOCS_VERSION_TYPE" = "external" ] && git diff --quiet origin/main -- . docs/ \
18+
if [ "$READTHEDOCS_VERSION_TYPE" = "external" ] && git diff --quiet origin/main -- docs/ \
1919
src/calendaring_jmap/**/*.py \
2020
.github/workflows/documentation.yml \
2121
.readthedocs.yml \
2222
.vale.ini \
2323
Makefile \
2424
pyproject.toml \
25+
uv.lock \
2526
':!src/calendaring_jmap/tests';
2627
then
2728
exit 183;

‎.vale.ini‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ Microsoft.Units = suggestion
1717

1818
# Ignore Sphinx Python object roles, such as ":class:" and ":meth:",
1919
# to prevent false positives from Microsoft.Spacing on dotted Python names.
20-
TokenIgnores = :[a-z]+:\x60.+\x60
20+
TokenIgnores = :[a-z]+:\x60[^\x60]+\x60

‎Makefile‎

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ VERSION ?=
1010
TOWNCRIEROPTS ?=
1111

1212
# Internal variables.
13-
RUFFPATH = "$(realpath .venv/bin/ruff)"
14-
SPHINXAUTOBUILD = "$(realpath .venv/bin/sphinx-autobuild)"
15-
SPHINXBUILD = "$(realpath .venv/bin/sphinx-build)"
16-
SPHINXAPIDOC = "$(realpath .venv/bin/sphinx-apidoc)"
17-
TOWNCRIERPATH = "$(realpath .venv/bin/towncrier)"
13+
# uv installs executables to .venv/Scripts/ on Windows and .venv/bin/ on
14+
# Linux/macOS, so `uv run` resolves the right one instead of a hardcoded path.
15+
RUN = uv run --no-sync
16+
RUFFPATH = $(RUN) ruff
17+
SPHINXAUTOBUILD = $(RUN) sphinx-autobuild
18+
SPHINXBUILD = $(RUN) sphinx-build
19+
SPHINXAPIDOC = $(RUN) sphinx-apidoc
20+
TOWNCRIERPATH = $(RUN) towncrier
1821
# sphinx-apidoc's own SPHINX_APIDOC_OPTIONS env var is never set as a real
1922
# shell variable here, so it's passed explicitly via --automodule-options
2023
# on the apidoc target below instead.
@@ -129,8 +132,13 @@ linkcheck: .venv apidoc ## Run linkcheck
129132
"or in $(BUILDDIR)/linkcheck/ ."
130133

131134
.PHONY: linkcheckbroken
135+
# Passes only when sphinx-build succeeds and grep finds no broken or redirected
136+
# link. sphinx-build colors its output on Windows even into a pipe, which grep
137+
# wouldn't match, and checking only grep's own exit status hides a crashed
138+
# sphinx-build, so both stages' exit codes are checked explicitly below.
132139
linkcheckbroken: .venv apidoc ## Run linkcheck and show only broken links
133-
cd $(DOCS_DIR) && $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck | GREP_COLORS='0;31' grep -wi "[^.]broken\|redirect" --color=always && if test $$? = 0; then exit 1; fi || test $$? = 1
140+
cd $(DOCS_DIR) && $(SPHINXBUILD) --no-color -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck | GREP_COLORS='0;31' grep -wi "[^.]broken\|redirect" --color=always; \
141+
status=("$${PIPESTATUS[@]}"); test "$${status[0]}" = 0 && test "$${status[1]}" = 1
134142
@echo
135143
@echo "Link check complete; look for any errors in the above output " \
136144
"or in $(BUILDDIR)/linkcheck/ ."
@@ -215,6 +223,11 @@ dev: .venv ## Install required Python, create Python virtual environment, insta
215223
format: .venv ## Format the code base with ruff
216224
$(RUFFPATH) format
217225
$(RUFFPATH) check --fix
226+
227+
.PHONY: lint
228+
lint: .venv ## Check the code base with ruff, changing nothing
229+
$(RUFFPATH) check .
230+
$(RUFFPATH) format --check .
218231
# /development
219232

220233
# deployment

‎docs/contribute.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Docker Desktop
7272

7373
calendaring-jmap's integration tests require Docker Desktop to run.
7474

75-
Install `Docker Desktop <https://docs.docker.com/get-started/get-docker/>`_ for your operating system.
75+
Install `Docker Desktop <https://docs.docker.com/get-docker/>`_ for your operating system.
7676
Docker Desktop includes all Docker tools.
7777

7878
.. note::

‎docs/explanation/design.rst‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Why there's a sync and an async client
1717

1818
:class:`~calendaring_jmap.async_client.AsyncJMAPClient` mirrors every public method of :class:`~calendaring_jmap.client.JMAPClient` as a coroutine, rather than the library offering only one and asking callers to wrap it. Both share their parsing and request-building logic through a common base class (``_JMAPClientBase``), so the two clients don't duplicate that logic, only the transport call itself differs (blocking request vs. ``await``).
1919

20-
:class:`~calendaring_jmap.objects.calendar.JMAPCalendar` and :class:`~calendaring_jmap.objects.calendar_object.JMAPCalendarObject` need to support both: the same calendar object type is returned whether it came from the sync or the async client, and its methods (``search``, ``add_event``, and similar) need to return a plain value in the sync case and a coroutine in the async case. Python's type system can't narrow a return type based on a runtime flag, so calendaring-jmap uses a generic type parameter on :class:`~calendaring_jmap.objects.calendar.JMAPCalendar` purely for static typing: it lets type checkers give a correctly-typed result depending on whether the calendar came from :meth:`~calendaring_jmap.client.JMAPClient.get_calendars` or :meth:`~calendaring_jmap.async_client.AsyncJMAPClient.get_calendars`, without changing anything at runtime.
20+
:class:`~calendaring_jmap.objects.calendar.JMAPCalendar` and :class:`~calendaring_jmap.objects.calendar_object.JMAPCalendarObject` need to support both: the same calendar object type is returned whether it came from the sync or the async client, and its methods (``search``, ``add_event``, and similar) need to return a plain value in the sync case and a coroutine in the async case. Python's type system can't narrow a return type based on a runtime flag, so calendaring-jmap uses a generic type parameter on :class:`~calendaring_jmap.objects.calendar.JMAPCalendar` purely for static typing: it lets type checkers give a correctly typed result depending on whether the calendar came from :meth:`~calendaring_jmap.client.JMAPClient.get_calendars` or :meth:`~calendaring_jmap.async_client.AsyncJMAPClient.get_calendars`, without changing anything at runtime.
2121

2222
Why there's a fix up step
2323
=========================
@@ -27,7 +27,7 @@ Servers can return iCalendar data that doesn't fully comply with :rfc:`5545`: a
2727
Why CONFERENCE and VCONFERENCE correlate by URI
2828
===============================================
2929

30-
A CONFERENCE property (:rfc:`7986`) and a VCONFERENCE component both describe the same video or phone link, but the spec gives them no shared identifier: iCalendar has no concept of one property pointing at a specific sibling component by ID. The conversion layer matches them by comparing the CONFERENCE property's own value against the VCONFERENCE component's ``URI`` property, string for string. A VCONFERENCE whose URI matches no CONFERENCE property on the same component converts to nothing: there's no VirtualLocation for it to attach its description to.
30+
A CONFERENCE property (:rfc:`7986`) and a VCONFERENCE component both describe the same video or phone link, but the specification gives them no shared identifier: iCalendar has no concept of one property pointing at a specific sibling component by ID. The conversion layer matches them by comparing the CONFERENCE property's own value against the VCONFERENCE component's ``URI`` property, string for string. A VCONFERENCE whose URI matches no CONFERENCE property on the same component converts to nothing: there's no VirtualLocation for it to attach its description to.
3131

3232
Within a matched VCONFERENCE, ``STYLED-DESCRIPTION`` (:rfc:`9073`) is preferred over plain ``DESCRIPTION`` when both are present, since only ``STYLED-DESCRIPTION`` carries a content type. The draft's own ``DERIVED`` parameter decides which one actually describes the conference and which one a server generated from the other: a non-derived ``STYLED-DESCRIPTION`` is treated as the one carrying real content, even when a ``DESCRIPTION`` also happens to be present.
3333

@@ -39,8 +39,12 @@ A recurrence override patch only needs to carry what actually changed on that on
3939
Why participants carry ``calendarAddress``, not ``sendTo``
4040
==========================================================
4141

42+
.. vale Microsoft.Terms = NO
43+
4244
An ``ORGANIZER``/``ATTENDEE`` value is a URI (:rfc:`5545#section-3.3.3`). It doesn't have to use the ``mailto:`` scheme; ``sip:alice@example.com`` is valid too. JSCalendar's Participant ``email`` property is narrower: :rfc:`8984#section-4.4.6` defines it as an :rfc:`5322#section-3.4.1` addr-spec, not an arbitrary URI. So a non-mailto address converts to ``calendarAddress`` as-is, and ``email`` is left unset rather than filled with a value that isn't actually an email address.
4345

46+
.. vale Microsoft.Terms = YES
47+
4448
JSCalendar's own Participant object defines ``sendTo`` (a map of delivery method to URI), not ``calendarAddress``; the latter belongs to JMAP Calendars' ParticipantIdentity/Principal objects instead. Cyrus doesn't accept ``sendTo`` at all: ``CalendarEvent/set`` rejects it outright with ``invalidProperties`` on both create and update, and requires ``calendarAddress`` in its place. Tested against a running Cyrus container: ``sendTo`` alone is rejected, ``calendarAddress`` alone is accepted, and having both still gets rejected for ``sendTo``. calendaring-jmap sets ``calendarAddress`` to ``sendTo``'s would-be ``imip`` value, its natural equivalent per ParticipantIdentity's own definition, and omits ``sendTo`` entirely. Stalwart accepts the ``calendarAddress``-only form too.
4549

4650
Why an Alert's trigger is an object, not a string

‎docs/how-to/sync.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Fetch a token, then the delta
2929
for event_id in deleted:
3030
print("Deleted ID:", event_id)
3131
32-
``added`` and ``modified`` are lists of :class:`~calendaring_jmap.objects.calendar_object.JMAPCalendarObject`. ``deleted`` is a list of event IDs: those objects no longer exist on the server, so their data can't be fetched. ``new_state`` is the server's new sync token; chaining straight from it avoids the race window a separate :meth:`~calendaring_jmap.client.JMAPClient.get_sync_token` round trip would open. ``old_state`` is the ``token`` argument echoed back, useful for detecting a server that silently accepted a stale or invalid token instead of reporting an error; see :meth:`~calendaring_jmap.client.JMAPClient.get_objects_by_sync_token`'s own docs for what both Cyrus and Stalwart actually do here. This example ignores ``has_more_changes``, fine for a small change set; see the next section for what it means and how to use it.
32+
``added`` and ``modified`` are lists of :class:`~calendaring_jmap.objects.calendar_object.JMAPCalendarObject`. ``deleted`` is a list of event IDs: those objects no longer exist on the server, so their data can't be fetched. ``new_state`` is the server's new sync token; chaining straight from it avoids the race window a separate :meth:`~calendaring_jmap.client.JMAPClient.get_sync_token` round trip would open. ``old_state`` is the ``token`` argument echoed back, useful for detecting a server that accepted a stale or invalid token instead of reporting an error; see :meth:`~calendaring_jmap.client.JMAPClient.get_objects_by_sync_token`'s own docs for what both Cyrus and Stalwart actually do here. This example ignores ``has_more_changes``, fine for a small change set; see the next section for what it means and how to use it.
3333

3434
Handle a truncated change list
3535
==============================

‎docs/how-to/tasks.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Create a task
3838
timeZone="Europe/Oslo",
3939
)
4040
41-
Optional keyword arguments for :meth:`~calendaring_jmap.client.JMAPClient.create_task` use JMAP wire property names, not snake_case: ``description``, ``start``, ``due``, ``timeZone``, ``estimatedDuration``, ``percentComplete``, ``progress``, ``priority``.
41+
Optional keyword arguments for :meth:`~calendaring_jmap.client.JMAPClient.create_task` use JMAP wire property names, not ``snake_case``: ``description``, ``start``, ``due``, ``timeZone``, ``estimatedDuration``, ``percentComplete``, ``progress``, ``priority``.
4242

4343
Fetch a task
4444
============

‎docs/styles/config/vocabularies/calendaring-jmap/accept.txt‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ hardcoding
2323
i[Cc]alendar
2424
# IETF
2525
inlined
26+
Jinja's?
2627
JMAP
2728
JSCalendar
2829
niquests
@@ -37,8 +38,8 @@ READMEs'?
3738
repo
3839
RFC's
3940
# RST
40-
# snake_case
41-
# subclassing
41+
snake_case
42+
subclassing
4243
subcomponent
4344
Subpackages
4445
substrings?
@@ -53,4 +54,5 @@ uv
5354
# VCONFERENCE
5455
VEVENTs?
5556
VEVENT's
57+
wassima
5658
Xcode

0 commit comments

Comments
 (0)