Apply black reformatting to Python files only in regions changed since a given commit. For a practical usage example, see the blog post at https://dev.to/akaihola/improving-python-code-incrementally-3f7a
OTHER License
[tool.darker]
, the Black configuration options skip_string_normalization
and skip_magic_trailing_comma
have been deprecated and will be removed in Darker 3.0. A deprecation warning is now displayed if they are still used.release_tools/update_contributors.py
script was moved to the darkgray-dev-tools
repository.-
) is now allowed as the single source filename when using the --stdout
option. This makes the option compatible with the new Black extension for VSCode.Published by akaihola 7 months ago
ioggstream/[email protected]
in CI.master
branch in the CI build.bump_version.py
is now in the separate darkgray-dev-tools
repository.rev: vX.Y.Z
instead of X.Y.Z
.|
) in the README to avoid RestructuredText rendering issues.Published by akaihola 8 months ago
darker --config=check-darker.toml
now runs Flake8, Mypy,[test]
extra.pyproject.toml
hassetup.py
in the build workflows.darker --help
and its output asREADME.rst
in case the two differ.shlex_join
compatibility wrapper for Python 3.7 and earlier.-L
/--lint
option for now.darkgraylib.files.find_project_root
black.parsing.ASTSafetyError
insteadAssertionError
when Black>=24.2.1 is in use.Published by akaihola 8 months ago
gen_python_files(gitignore_dict=...)
parameter.show_capture
option in Pytest configuration.Published by akaihola over 1 year ago
News
link on the PyPI page.-
as the single source filename when using the --stdin-filename
option.commit-range
from the repository itself. This broke the GitHub__init__.py
in the repository root.install-nix-action
to version 22 in CI to fix an issue with macOS.--target-version=py312
since newest Black supports it.bump_version
script.Published by akaihola over 1 year ago
Darker
for clarity since we'll have two additional related repositories soon in the same project.git worktree
to create a repository checkout for baseline linting. This avoids issues with the previous git clone
and git checkout
based approach.commit-range
action from the current checkout instead of pointing to a release tag. This fixes workflows when in a release branch.stacklevel=2
in warnings.warn()
calls as suggested by Flake8; skip Bandit check for virtualenv creation in the GitHub Action; use ignore[method-assign]
as suggested by Mypy.Published by akaihola over 1 year ago
-f
/ --flynt
option for converting old-style format strings to f-strings as supported in Python 3.6+.pytest --log-cli-level==DEBUG
. Doctests are still incompatible due topytest#5908 <https://github.com/pytest-dev/pytest/issues/5908>
_.target-version =
configuration file option and -t
/ --target-version
command line optionREADME.rst
, link to GitHub searches which find public repositories that use Darker.rev1
to get a baseline, and another time for rev2
to get the current situation. Old linter messages which fall on unmodified lines are hidden, so effectively the user gets new linter messages introduced by latest changes, as well as persistent linter messages on modified lines.--stdin-filename=PATH
now allows reading contents of a single file from standard input. This also makes :STDIN:
, a new magic value, the default rev2
for --revision
.darglint
and flake8-docstrings
, preparing for enabling those linters in CI builds.pip
command. This fixes the Windows builds.shlex
from the Python standard library. This deals with quoting correctly.coverage
to use relative paths in the Darker repository. This enables use of cov_to_lint.py
use-dict-literal
check in Darker's code base.!r
to quote values in format strings as suggested by recent Flake8 versions.Published by akaihola almost 2 years ago
CONTRIBUTING.rst
.pre-commit
.black-22.10.1.dev19+gffaaf48
and later – an argument wasblack.files.gen_python_files()
.revision:
since the commit range is obtainedtest-bump-version
workflow will now succeed also in a release branch.Published by akaihola almost 2 years ago
setup-python@v4
in all GitHub workflows.black-22.10.1.dev19+gffaaf48
and later – an argument wasblack.files.gen_python_files()
.set-output
method.help-in-readme.yml
workflow. SomethingPublished by akaihola about 2 years ago
darker --help
output in README.rst
isort
was run or not, onlyisort
file exclusions into one data structure.darker --revision=a..b .
now works since the repository root is now always.pylintrc
.bad-continuation
check now removed from Pylint.Published by akaihola over 2 years ago
--workers
/-W
option now specifies how many Darker jobs are used tolint:
option.color
option inpyproject.toml
, the PY_COLORS
and NO_COLOR
environment variables, and the--color
/--no-color
command line options.pytest>=6.2.0
now required for the test suite due to type hinting issues.@lru_cache
on a method.revision:
correctly.cachix/install-nix-action
to v17
to fix macOS build error.-c
/--config
, or in case a directory is specified, from pyproject.toml
Published by akaihola over 2 years ago
isort
's requirement to be run in the same environment as--lint
/-L
incompatibility in the README.isort
by testing against its main
test-future
GitHub Workflow.release_tools/bump_version.py
script for incrementing version numbers andpytest-darker
calls pylint
. Needed to activatePublished by akaihola over 2 years ago
main
branch to get an early warning of.py.tmp
as files which should be reformatted.Published by akaihola over 2 years ago
regex
module now always available for unit tests$PATH
intact so Git can be called.--stdout
flag#isort:file_skip
without an exception.Published by akaihola almost 3 years ago
--check
pre-commit
.args:
in pre-commit configuration.py.<hash>.tmp
files from VSCode are now correctly compared to corresponding.py
files in earlier revisions of the Git reposiotryisort
or linters.--revision rev1...rev2
now actually applies reformatting and filters linter outputrev1
and rev2
--stdout
optiontholo/pytest-flake8#81
Published by akaihola about 3 years ago
pre-commit -o HEAD
, but also emits a warning about this being an experimental feature/foo $ darker --diff /bar/my-repo
now works: the current working directory can be in a different part of the directory hierarchyisort
version now causes a short user-friendly error messagePublished by akaihola about 3 years ago
--skip-magic-trailing-comma
optiondarker --diff
output is now identical to that of black --diff
-d
/ --stdout
option outputs the reformatted contents of the single Python"--lint pylint"
.--revision <COMMIT_A>..<COMMIT_B>
where:WORKTREE:
works too.git show
doesn't find the file in rev1.git show
and git cat-file
fail when using backslashes.Published by akaihola over 3 years ago
types-toml
as a test dependency, andtypes-dataclasses
as well if running on Python 3.6~/.gitconfig
isort
isn't installed--isort
darker --diff --revision=v1.0..v1.1
now actuallyPublished by akaihola over 3 years ago
TextDocument
class to represent source code file contentsdarker.help
module--revision :PRE-COMMIT:
is set, but PRE_COMMIT_FROM_REF
orPRE_COMMIT_TO_REF
are not set.Published by akaihola almost 4 years ago
PRE_COMMIT_FROM_REF
andPRE_COMMIT_TO_REF
environment variables when using the --revision :PRE-COMMIT:
<commit>...
now compares always correctly to the latest common ancestor