Skip to content

Commit

Permalink
Fix guerrilla patching of RationalLikeMethods.__doc__ to work wit…
Browse files Browse the repository at this point in the history
…h ``python -OO`
  • Loading branch information
posita committed Jul 27, 2023
1 parent 9ab251e commit 0c231f4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
4 changes: 4 additions & 0 deletions docs/notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

# ``numerary`` release notes

## [0.4.4](https://github.com/posita/numerary/releases/tag/v0.4.4)

* Fixes guerrilla patching of ``#!python RationalLikeMethods.__doc__`` to work with ``python -OO`.

## [0.4.3](https://github.com/posita/numerary/releases/tag/v0.4.3)

* Migrates from [``setuptools_scm``](https://pypi.org/project/setuptools-scm/) to [``versioningit``](https://pypi.org/project/versioningit/) for more flexible version number formatting.
Expand Down
15 changes: 8 additions & 7 deletions numerary/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1313,14 +1313,15 @@ def __hash__(self) -> int:
{RationalLikeMixedT!r}
"""
assert RationalLikeMixedU.__args__ == RationalLikeMixedT # type: ignore [attr-defined]
assert RationalLikeMethods.__doc__
RationalLikeMethods.__doc__ += rf"""

``` python
RationalLikeMixedU = {RationalLikeMixedU!r}
RationalLikeMixedT = ({", ".join(cls.__name__ for cls in RationalLikeMixedT)})
```
"""
if RationalLikeMethods.__doc__:
RationalLikeMethods.__doc__ += rf"""
``` python
RationalLikeMixedU = {RationalLikeMixedU!r}
RationalLikeMixedT = ({", ".join(cls.__name__ for cls in RationalLikeMixedT)})
```
"""


@runtime_checkable
Expand Down
9 changes: 6 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ allowlist_externals =
# * <https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes>
# * <https://flake8.readthedocs.io/en/latest/user/error-codes.html>
ignore =
E203, # whitespace before ':'
E501, # line too long (... > ... characters)
W503, # line break occurred before a binary operator
# whitespace before ':'
E203
# line too long (... > ... characters)
E501
# line break occurred before a binary operator
W503

0 comments on commit 0c231f4

Please sign in to comment.