Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/docs_test_action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: "actions/checkout@v4"
uses: "actions/checkout@v6"

- name: Check for changed files
uses: dorny/paths-filter@v2
uses: dorny/paths-filter@v4
id: changes
with:
list-files: "json"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:

steps:
- name: Checkout 🛎️
uses: "actions/checkout@v4"
uses: "actions/checkout@v6"

- name: Check for changed files
uses: dorny/paths-filter@v2
uses: dorny/paths-filter@v4
id: changes
with:
list-files: "json"
Expand All @@ -32,7 +32,7 @@ jobs:

- name: Setup Python 🐍
if: steps.changes.outputs.code == 'true'
uses: "actions/setup-python@v5"
uses: "actions/setup-python@v6"
with:
python-version: "3.9"

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:

steps:
- name: Checkout 🛎️
uses: "actions/checkout@v4"
uses: "actions/checkout@v6"

- name: Check for changed files
uses: dorny/paths-filter@v2
uses: dorny/paths-filter@v4
id: changes
with:
list-files: "json"
Expand All @@ -37,7 +37,7 @@ jobs:

- name: Setup Python 🐍
if: steps.changes.outputs.code == 'true'
uses: "actions/setup-python@v5"
uses: "actions/setup-python@v6"
with:
python-version: "3.9"

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/python_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ jobs:
- {python-version: "pypy-3.7", testenvs: "pypy37,build", experimental: False}
- {python-version: "pypy-3.8", testenvs: "pypy38", experimental: False}
- {python-version: "pypy-3.9-v7.3.16", testenvs: "pypy39", experimental: True}
- {python-version: "pypy-3.10-v7.3.19", testenvs: "pypy310,build", experimental: True}
- {python-version: "pypy-3.10-v7.3.19", testenvs: "pypy310", experimental: True}

steps:
- name: Checkout 🛎️
uses: "actions/checkout@v4"
uses: "actions/checkout@v6"

- name: Check for changed files
if: startsWith(github.ref, 'refs/tags/') != true
uses: dorny/paths-filter@v2
uses: dorny/paths-filter@v4
id: changes
with:
list-files: "json"
Expand All @@ -56,7 +56,7 @@ jobs:
- name: Setup Python 🐍
id: setup-python
if: ${{ steps.changes.outputs.code == 'true' || steps.changes.outcome == 'skipped' }}
uses: "actions/setup-python@v5"
uses: "actions/setup-python@v6"
with:
python-version: "${{ matrix.config.python-version }}"

Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/python_ci_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ jobs:

steps:
- name: Checkout 🛎️
uses: "actions/checkout@v4"
uses: "actions/checkout@v6"

- name: Check for changed files
if: startsWith(github.ref, 'refs/tags/') != true
uses: dorny/paths-filter@v2
uses: dorny/paths-filter@v4
id: changes
with:
list-files: "json"
Expand All @@ -57,7 +57,7 @@ jobs:
- name: Setup Python 🐍
id: setup-python
if: ${{ steps.changes.outputs.code == 'true' || steps.changes.outcome == 'skipped' }}
uses: "actions/setup-python@v5"
uses: "actions/setup-python@v6"
with:
python-version: "${{ matrix.config.python-version }}"

Expand Down Expand Up @@ -91,10 +91,10 @@ jobs:
runs-on: "ubuntu-22.04"
steps:
- name: Checkout 🛎️
uses: "actions/checkout@v4"
uses: "actions/checkout@v6"

- name: Setup Python 🐍
uses: "actions/setup-python@v5"
uses: "actions/setup-python@v6"
with:
python-version: 3.8

Expand Down Expand Up @@ -144,11 +144,11 @@ jobs:
runs-on: "ubuntu-22.04"
steps:
- name: Checkout 🛎️
uses: "actions/checkout@v4"
uses: "actions/checkout@v6"
if: startsWith(github.ref, 'refs/tags/')

- name: Setup Python 🐍
uses: "actions/setup-python@v5"
uses: "actions/setup-python@v6"
if: startsWith(github.ref, 'refs/tags/')
with:
python-version: 3.8
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/python_ci_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ jobs:

steps:
- name: Checkout 🛎️
uses: "actions/checkout@v4"
uses: "actions/checkout@v6"

- name: Check for changed files
if: startsWith(github.ref, 'refs/tags/') != true
uses: dorny/paths-filter@v2
uses: dorny/paths-filter@v4
id: changes
with:
list-files: "json"
Expand All @@ -56,7 +56,7 @@ jobs:
- name: Setup Python 🐍
id: setup-python
if: ${{ steps.changes.outputs.code == 'true' || steps.changes.outcome == 'skipped' }}
uses: "actions/setup-python@v5"
uses: "actions/setup-python@v6"
with:
python-version: "${{ matrix.config.python-version }}"

Expand Down
12 changes: 10 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exclude: ^domdf_python_tools/compat/importlib_resources.py$

ci:
autoupdate_schedule: quarterly
skip: [taplo-lint]

repos:
- repo: https://github.com/repo-helper/pyproject-parser
Expand All @@ -21,7 +22,6 @@ repos:
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-json
- id: check-toml
- id: check-yaml
- id: check-merge-conflict
- id: check-symlinks
Expand All @@ -31,6 +31,12 @@ repos:
- id: mixed-line-ending
- id: end-of-file-fixer

- repo: https://github.com/domdfcoding/taplo-pre-commit
rev: v0.10.0
hooks:
- id: taplo-lint
args: []

- repo: https://github.com/domdfcoding/pre-commit-hooks
rev: v0.7.0
hooks:
Expand Down Expand Up @@ -78,9 +84,11 @@ repos:
- id: forbid-crlf

- repo: https://github.com/python-formate/snippet-fmt
rev: v0.1.5
rev: v0.3.1
hooks:
- id: snippet-fmt
additional_dependencies:
- formate-trailing-commas>=0.1.1

- repo: https://github.com/python-formate/formate
rev: v1.2.1
Expand Down
2 changes: 1 addition & 1 deletion doc-source/api/bases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ from :class:`NamedList` rather than from :func:`~.namedlist`. For example, do th
.. code-block:: python

>>> class ShoppingList(NamedList):
... pass
... pass
>>>

and not this:
Expand Down
4 changes: 2 additions & 2 deletions domdf_python_tools/doctools.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ def sphinxify_docstring() -> Callable[[_F], _F]:
.. code-block:: python

intersphinx_mapping = {
"python": ("https://docs.python.org/3/", None),
}
"python": ("https://docs.python.org/3/", None),
}
"""

def wrapper(target: _F) -> _F:
Expand Down
20 changes: 10 additions & 10 deletions domdf_python_tools/getters.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ class attrgetter:
.. code-block:: python

>>> from pathlib import Path
>>> attrgetter(0, 'name')([Path("dir/code.py")])
>>> attrgetter(0, "name")([Path("dir/code.py")])
'code.py'
>>> attrgetter(2, 'parent.name')([Path("dir/coincidence.py"), Path("dir/wheel.py"), Path("dir/operator.py")])
>>> attrgetter(2, "parent.name")([Path("dir/coincidence.py"), Path("dir/wheel.py"), Path("dir/operator.py")])
'dir'

.. seealso:: :func:`operator.attrgetter` and :func:`operator.itemgetter`
Expand Down Expand Up @@ -110,14 +110,14 @@ class itemgetter:

.. code-block:: python

>>> itemgetter(0, 1)(['ABCDEFG'])
>>> itemgetter(0, 1)(["ABCDEFG"])
'B'
>>> itemgetter(1, 2)(['ABC', 'DEF'])
>>> itemgetter(1, 2)(["ABC", "DEF"])
'F'
>>> itemgetter(0, slice(2, None))(['ABCDEFG'])
>>> itemgetter(0, slice(2, None))(["ABCDEFG"])
'CDEFG'
>>> army = [dict(rank='captain', name='Blackadder'), dict(rank='Private', name='Baldrick')]
>>> itemgetter(0, 'rank')(army)
>>> army = [dict(rank="captain", name="Blackadder"), dict(rank="Private", name="Baldrick")]
>>> itemgetter(0, "rank")(army)
'captain'

.. seealso:: :func:`operator.itemgetter`
Expand Down Expand Up @@ -158,11 +158,11 @@ class methodcaller:
.. code-block:: python

>>> from datetime import date
>>> methodcaller(0, 'upper')(["hello", "world"])
>>> methodcaller(0, "upper")(["hello", "world"])
'HELLO'
>>> methodcaller(1, 'center', 9, "=")(["hello", "world"])
>>> methodcaller(1, "center", 9, '=')(["hello", "world"])
'==world=='
>>> methodcaller(0, 'replace', year=2019)([date(2021, 7, 6)])
>>> methodcaller(0, "replace", year=2019)([date(2021, 7, 6)])
datetime.date(2019, 7, 6)

.. seealso:: :func:`operator.methodcaller` and :func:`operator.itemgetter`
Expand Down
6 changes: 3 additions & 3 deletions domdf_python_tools/iterative.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,9 @@ def groupfloats(
.. code-block:: python

>>> list(groupfloats(
... [170.0, 170.05, 170.1, 170.15, 171.05, 171.1, 171.15, 171.2],
... step=0.05,
... ))
... [170.0, 170.05, 170.1, 170.15, 171.05, 171.1, 171.15, 171.2],
... step=0.05,
... ))
[(170.0, 170.05, 170.1, 170.15), (171.05, 171.1, 171.15, 171.2)]
>>> list(groupfloats([1, 2, 3, 4, 5, 7, 8, 9, 10]))
[(1, 2, 3, 4, 5), (7, 8, 9, 10)]
Expand Down
38 changes: 19 additions & 19 deletions domdf_python_tools/pagesizes/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,26 @@ class Unit(float):

.. code-block:: python

>>> (3*mm) + (7*mm)
>>> (3 * mm) + (7 * mm)
<Unit '10.000 mm': 28.346pt>

When adding different :class:`~domdf_python_tools.pagesizes.units.Unit` objects,
the result has the type of the former unit:

.. code-block:: python

>>> (2.54*cm) + inch
>>> (2.54 * cm) + inch
<Unit '5.080 cm': 144.000pt>
>>> inch + (2.54*cm)
>>> inch + (2.54 * cm)
<Unit '2.000 inch': 144.000pt>

:class:`~domdf_python_tools.pagesizes.units.Unit` objects can also be added to :class:`float` and :class:`int` objects:

.. code-block:: python

>>> (3*cm) + 7
>>> (3 * cm) + 7
<Unit '10.000 cm': 283.465pt>
>>> 7 + (3*cm)
>>> 7 + (3 * cm)
<Unit '10.000 cm': 283.465pt>


Expand All @@ -109,15 +109,15 @@ class Unit(float):

.. code-block:: python

>>> (17*mm) - (7*mm)
>>> (17 * mm) - (7 * mm)
<Unit '10.000 mm': 28.346pt>
>>> (2.54*cm) - inch
>>> (2.54 * cm) - inch
<Unit '0.000 cm': 0.000pt>
>>> inch - (2.54*cm)
>>> inch - (2.54 * cm)
<Unit '0.000 inch': 0.000pt>
>>> (17*cm) - 7
>>> (17 * cm) - 7
<Unit '10.000 cm': 283.465pt>
>>> 17 - (7*cm)
>>> 17 - (7 * cm)
<Unit '10.000 cm': 283.465pt>


Expand All @@ -128,11 +128,11 @@ class Unit(float):

.. code-block:: python

>>> (3*mm) * 3
>>> (3 * mm) * 3
<Unit '9.000 mm': 25.512pt>
>>> 3 * (3*mm)
>>> 3 * (3 * mm)
<Unit '9.000 mm': 25.512pt>
>>> 3.5 * (3*mm)
>>> 3.5 * (3 * mm)
<Unit '10.500 mm': 29.764pt>

Multiplication works either way round.
Expand All @@ -142,7 +142,7 @@ class Unit(float):

.. code-block:: python

>>> inch * (7*cm)
>>> inch * (7 * cm)
Traceback (most recent call last):
NotImplementedError: Multiplying a unit by another unit is not allowed.

Expand All @@ -153,16 +153,16 @@ class Unit(float):

.. code-block:: python

>>> (3*mm) / 3
>>> (3 * mm) / 3
<Unit '1.000 mm': 2.835pt>
>>> (10*mm) / 2.5
>>> (10 * mm) / 2.5
<Unit '4.000 mm': 11.339pt>

Dividing by another unit results in a :exc:`NotImplementedError`:

.. code-block:: python

>>> inch / (7*cm)
>>> inch / (7 * cm)
Traceback (most recent call last):
NotImplementedError: Dividing a unit by another unit is not allowed.

Expand All @@ -171,7 +171,7 @@ class Unit(float):

.. code-block:: python

>>> 3 / (3*mm)
>>> 3 / (3 * mm)
Traceback (most recent call last):
NotImplementedError: Dividing by a unit is not allowed.

Expand All @@ -188,7 +188,7 @@ class Unit(float):

.. code-block:: python

>>> (3*mm) % 2.5
>>> (3 * mm) % 2.5
<Unit '0.500 mm': 1.417pt>

Dividing by a unit, or modulo division of two units, is not officially supported.
Expand Down
Loading
Loading