Run `pyupgrade` on python code blocks in documentation files
Project description
pyupgrade-docs
Run pyupgrade
on python code blocks in documentation files.
install
pip install pyupgrade-docs
usage
pyupgrade-docs
provides a single executable (pyupgrade-docs
) which will modify
.rst
/ .md
/ .tex
files in place.
It currently supports the following pyupgrade
options:
--keep-percent-format
--keep-mock
--keep-runtime-typing
--py3-plus
--py3-only
--py36-plus
--py37-plus
--py38-plus
--py39-plus
--py310-plus
The following additional parameters can be used:
-E
/--skip-errors
pyupgrade-docs
will format code in the following block types:
(markdown)
```python
def hello():
print("hello world")
```
(rst)
.. code-block:: python
def hello():
print("hello world")
(rst pycon
)
.. code-block:: pycon
>>> def hello():
... print("hello world")
...
(latex)
\begin{minted}{python}
def hello():
print("hello world")
\end{minted}
(latex with pythontex)
\begin{pycode}
def hello():
print("hello world")
\end{pycode}
(markdown/rst in python docstrings)
def f():
"""docstring here
.. code-block:: python
print("hello world")
```python
print("hello world")
```
"""
usage with pre-commit
See pre-commit for instructions
Sample .pre-commit-config.yaml
:
- repo: https://github.com/verhovsky/pyupgrade-docs
rev: v0.2.3
hooks:
- id: pyupgrade-docs
additional_dependencies: [pyupgrade==...]
Since pyupgrade
is currently a moving target, it is suggested to pin pyupgrade
to a specific version using additional_dependencies
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pyupgrade_docs-0.2.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61b7b030a4b822d62e2c572e7f4adff8a9e18977ccae6ba2b7528f6d252a1353 |
|
MD5 | adf67a92c9489dae6aaac21fd7f368dc |
|
BLAKE2b-256 | fb8e3852746c66ddbd62fa7045764f0d30369293aa3d89afdcd8140878c84428 |