Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add conversion to f-strings using flynt #308

Merged
merged 10 commits into from
Jan 22, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/help-in-readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: pip install '.[isort]'
- run: pip install '.[flynt,isort]'
- name: Verify that README contains output of darker --help
shell: python
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
- run: |
pip install -U \
black \
flynt \
isort \
mypy>=0.990 \
pytest \
Expand Down
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ These features will be included in the next release:

Added
-----
- ``-f`` / ``--flynt`` option for converting old-style format strings to f-strings as
supported in Python 3.6+.
- Make unit tests compatible with ``pytest --log-cli-level==DEBUG``.
Doctests are still incompatible due to
`pytest#5908 <https://github.com/pytest-dev/pytest/issues/5908>`_.
Expand Down
10 changes: 10 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ The reformatters supported are:

- Black_ for code reformatting
- isort_ for sorting imports
- flynt_ for turning old-style format strings to f-strings

See `Using linters`_ below for the list of supported linters.

Expand All @@ -53,6 +54,7 @@ see the relevant sections below in this document.

.. _Black: https://github.com/python/black
.. _isort: https://github.com/timothycrosley/isort
.. _flynt: https://github.com/ikamensh/flynt
.. _Pytest: https://docs.pytest.org/
.. _pytest-darker: https://pypi.org/project/pytest-darker/

Expand Down Expand Up @@ -164,10 +166,13 @@ You can enable additional features with command line options:
- ``-i`` / ``--isort``: Reorder imports using isort_. Note that isort_ must be
run in the same Python environment as the packages to process, as it imports
your modules to determine whether they are first or third party modules.
- ``-f`` / ``--flynt``: Also convert string formatting to use f-strings using the
``flynt`` package
- ``-L <linter>`` / ``--lint <linter>``: Run a supported linter (see `Using linters`_)

*New in version 1.1.0:* The ``-L`` / ``--lint`` option.
*New in version 1.2.2:* Package available in conda-forge_.
*New in version 1.7.0:* The ``-f`` / ``--flynt`` option

.. _Conda: https://conda.io/
.. _conda-forge: https://conda-forge.org/
Expand Down Expand Up @@ -314,6 +319,8 @@ The following `command line arguments`_ can also be used to modify the defaults:
--check
Don't write the files back, just return the status. Return code 0 means nothing
would change. Return code 1 means some files would be reformatted.
-f, --flynt
Also convert string formatting to use f-strings using the ``flynt`` package
-i, --isort
Also sort imports using the ``isort`` package
-L CMD, --lint CMD
Expand Down Expand Up @@ -365,6 +372,7 @@ project's root directory, or to a different TOML file specified using the ``-c``
diff = true
check = true
isort = true
flynt = true
lint = [
"pylint",
]
Expand Down Expand Up @@ -421,6 +429,8 @@ command line options

*New in version 1.7.0:* The ``-t`` / ``--target-version`` command line option

*New in version 1.7.0:* The ``-f`` / ``--flynt`` command line option

.. _Black documentation about pyproject.toml: https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#configuration-via-a-file
.. _isort documentation about config files: https://timothycrosley.github.io/isort/docs/configuration/config_files/
.. _public GitHub repositories which install and run Darker: https://github.com/search?q=%2Fpip+install+.*darker%2F+path%3A%2F%5E.github%5C%2Fworkflows%5C%2F.*%2F&type=code
Expand Down
1 change: 1 addition & 0 deletions constraints-oldest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ defusedxml==0.7.1
flake8-2020==1.6.1
flake8-bugbear==22.1.11
flake8-comprehensions==3.7.0
flynt==0.76
Pygments==2.4.0
pytest==6.2.0
pytest-kwparametrize==0.0.3
Expand Down
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ warn_return_any = False
[mypy-defusedxml.*]
ignore_missing_imports = True

[mypy-flynt.*]
ignore_missing_imports = True

[mypy-isort.*]
ignore_missing_imports = True

Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ pygments.lexers =
lint_description = darker.highlighting.lexers:DescriptionLexer

[options.extras_require]
flynt =
flynt>=0.76
isort =
isort>=5.0.1
color =
Expand All @@ -55,6 +57,7 @@ test =
black>=21.7b1 # to prevent Mypy error about `gen_python_files`, see issue #189
cryptography>=3.3.2 # through twine, fixes CVE-2020-36242
defusedxml>=0.7.1
flynt>=0.76
isort>=5.0.1
pygments
pytest>=6.2.0
Expand Down
Loading