black-fix - split from ls_color for separate review (#3431)

* black-fix - split from ls_color for separate review
This commit is contained in:
Bob Hyman 2020-02-14 09:09:34 -05:00 committed by GitHub
parent 5584f818f2
commit 94ac8f67f5
Failed to generate hash of commit
5 changed files with 110 additions and 2 deletions

23
news/black-fix.rst Normal file
View file

@ -0,0 +1,23 @@
**Added:**
* pyproject.toml -- so vscode can use black as python formatter interactively
**Changed:**
* <news item>
**Deprecated:**
* <news item>
**Removed:**
* <news item>
**Fixed:**
* setup.cfg -- duplicated flake8 config so interactive use and test runs enforce same rules. (Implementation is arguably a regression.)
**Security:**
* <news item>

31
pyproject.toml Normal file
View file

@ -0,0 +1,31 @@
[tool.black]
# better to keep default line-length than to match flake8
exclude = '''
( # exclude entire contents of these top level directories...
/( \.eggs
| \.git
| \.hg
| \.mypy
| _cache
| \.nox
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
)
|
(
# and these additional random rules
/( __pycache__
| \.circleci
| \.github
| \.vscode
| \.pytest_cache
| tests
)/
)
'''

View file

@ -50,3 +50,56 @@ flake8-ignore =
xonsh/completers/python.py E722
xonsh/parsers/context_check.py E305
xonsh/xoreutils/*.py E722 E305
[flake8]
max-line-length = 180
ignore =
*.py E122
*.py E203 # E203 whitespace before ':'
*.py E402
*.py W503 # line break before binary operators is a good thing
tests/tools.py E128
xonsh/pygments_cache.py ALL
# flake8 gives incorrect unused import errors, F401
xonsh/ast.py F401
xonsh/platform.py F401
xonsh/built_ins.py F821 E721
xonsh/commands_cache.py F841
xonsh/history.py F821
xonsh/jupyter_kernel.py E203
xonsh/pyghooks.py F821
xonsh/style_tools.py F821
xonsh/readline_shell.py F401
xonsh/timings.py F401
xonsh/tokenize.py F821 F841
xonsh/tools.py E731
xonsh/xonfig.py E731
xonsh/proc.py E261 E265
xonsh/ptk/key_bindings.py F841
xonsh/ptk/shell.py E731
xontrib/vox.py F821
__amalgam__.py ALL
# test files should be PEP8 but a ton of errors for now
test_*.py ALL
# we don't care about sphinx autogenerated files
docs/*.py ALL
# we don't care about ply files?
ply/*.py ALL
# these run VERY slowly and give tons of errors
parser*_table.py ALL
# oh come on
setup.py ALL
# remove these later
*.py E741 # ambiguous variable name
xonsh/color_tools.py E305
xonsh/inspectors.py E722
xonsh/lexer.py E741
xonsh/platform.py E305
xonsh/style_tools.py E305
xonsh/tools.py E305
xonsh/winutils.py E305
xonsh/completers/_aliases.py E305
xonsh/completers/python.py E722
xonsh/parsers/context_check.py E305
xonsh/xoreutils/*.py E722 E305

View file

@ -114,6 +114,7 @@ def test_recursive_callable_partial_none(xonsh_execer, xonsh_builtins):
assert args == "wakka"
assert len(obs) == 0
@pytest.mark.parametrize(
"alias",
[

View file

@ -268,8 +268,8 @@ class CommandsCache(cabc.Mapping):
def default_predictor_alias(self, cmd0):
alias_recursion_limit = (
10
) # this limit is se to handle infinite loops in aliases definition
10 # this limit is se to handle infinite loops in aliases definition
)
first_args = [] # contains in reverse order args passed to the aliased command
alss = getattr(builtins, "aliases", dict())
while cmd0 in alss: