-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #270 from akaihola/black-22
Add compatibility with Black >= 22.1
- Loading branch information
Showing
12 changed files
with
98 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Constraints for pip to pin dependencies to oldest supported versions. | ||
# This is used in a GitHub Workflow matrix job which ensures everything | ||
# still works against oldest supported versions of both the Python | ||
# interpreter and Python ependencies. Keep this up-to-date with minimum | ||
# versions in `setup.cfg`. | ||
black==21.8b0 | ||
mypy==0.910 | ||
pytest==6.1.0 | ||
pytest-flake8==1.0.6 | ||
pytest-isort==1.1.0 | ||
pytest-kwparametrize==0.0.3 | ||
regex==2021.4.4 | ||
types-toml==0.1.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""Functions for maintaining compatibility with multiple Black versions""" | ||
|
||
from pathlib import Path | ||
from typing import Any, Sequence, Tuple, cast | ||
|
||
from black import find_project_root as black_find_project_root | ||
|
||
|
||
def find_project_root(srcs: Sequence[str]) -> Path: | ||
"""Hide changed return value type in Black behind this wrapper | ||
:param srcs: Files and directories to find the common root for | ||
:return: Project root path | ||
""" | ||
root = cast(Any, black_find_project_root(tuple(srcs or ["."]))) | ||
if isinstance(root, tuple): | ||
# Black >= 22.1 | ||
return cast(Tuple[Path], root)[0] | ||
# Black < 22 | ||
return cast(Path, root) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters