Skip to content

Commit

Permalink
black => yapf, 88 => 99 line length
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Nov 16, 2021
1 parent eafdebd commit b6661ce
Show file tree
Hide file tree
Showing 12 changed files with 133 additions and 284 deletions.
9 changes: 5 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ repos:
- flake8-debugger
- flake8-isort
- flake8-string-format
- repo: https://github.com/psf/black
rev: 21.9b0
- repo: https://github.com/google/yapf
rev: v0.31.0
hooks:
- id: black
- id: yapf
args: [-i]
- repo: https://github.com/PyCQA/isort
rev: 5.9.3
rev: 5.10.1
hooks:
- id: isort
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ object from `docopt <https://pypi.org/project/docopt>`_ syntax:
<you> : Your name [default: Anon]
<me> : My name [default: Casper]
"""
import sys, argopt, shtab # NOQA
import argopt, shtab
parser = argopt.argopt(__doc__)
shtab.add_argument_to(parser, ["-s", "--print-completion"]) # magic!
Expand Down
5 changes: 2 additions & 3 deletions docs/pydoc_markdown_shtab.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ def _process(self, node):
if not getattr(node, "docstring", None):
return super()._process(node)
# convert parameter lists to markdown list
node.docstring = re.sub(
r"^(\w+)\s{2,}(:.*?)$", r"* __\1__*\2* ", node.docstring, flags=re.M
)
node.docstring = re.sub(r"^(\w+)\s{2,}(:.*?)$", r"* __\1__*\2* ", node.docstring,
flags=re.M)
return super()._process(node)
2 changes: 1 addition & 1 deletion docs/use.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ Add direct support to scripts for a little more configurability:
<you> : Your name [default: Anon]
<me> : My name [default: Casper]
"""
import sys, argopt, shtab # NOQA
import argopt, shtab

parser = argopt.argopt(__doc__)
shtab.add_argument_to(parser, ["-s", "--print-completion"]) # magic!
Expand Down
29 changes: 10 additions & 19 deletions examples/customcomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@

import shtab # for completion magic

TXT_FILE = {
"bash": "_shtab_greeter_compgen_TXTFiles",
"zsh": "_files -g '(*.txt|*.TXT)'",
}
TXT_FILE = {"bash": "_shtab_greeter_compgen_TXTFiles", "zsh": "_files -g '(*.txt|*.TXT)'"}
PREAMBLE = {
"bash": """
# $1=COMP_WORDS[1]
Expand All @@ -20,16 +17,12 @@
compgen -f -X '!*?.txt' -- $1
compgen -f -X '!*?.TXT' -- $1
}
""",
"zsh": "",
}
""", "zsh": ""}


def process(args):
print(
"received <input_txt>=%r --input-file=%r --output-name=%r"
% (args.input_txt, args.input_file, args.output_name)
)
print("received <input_txt>=%r --input-file=%r --output-name=%r" %
(args.input_txt, args.input_file, args.output_name))


def get_main_parser():
Expand All @@ -40,9 +33,7 @@ def get_main_parser():
subparsers.dest = "subcommand"

parser = subparsers.add_parser("completion", help="print tab completion")
shtab.add_argument_to(
parser, "shell", parent=main_parser, preamble=PREAMBLE
) # magic!
shtab.add_argument_to(parser, "shell", parent=main_parser, preamble=PREAMBLE) # magic!

parser = subparsers.add_parser("process", help="parse files")
# `*.txt` file tab completion
Expand All @@ -52,11 +43,11 @@ def get_main_parser():
parser.add_argument(
"-o",
"--output-name",
help=(
"output file name. Completes directory names to avoid users"
" accidentally overwriting existing files."
),
).complete = shtab.DIRECTORY # directory tab completion builtin shortcut
help=("output file name. Completes directory names to avoid users"
" accidentally overwriting existing files."),
).complete = shtab.DIRECTORY
# directory tab completion builtin shortcut

parser.set_defaults(func=process)
return main_parser

Expand Down
4 changes: 1 addition & 3 deletions examples/docopt-greeter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@
<you> : Your name [default: Anon]
<me> : My name [default: Casper]
"""
import sys # NOQA

import argopt

import shtab

parser = argopt.argopt(__doc__)
shtab.add_argument_to(parser, ["-s", "--print-completion"]) # magic!
shtab.add_argument_to(parser, ["-s", "--print-completion"]) # magic!
if __name__ == "__main__":
args = parser.parse_args()

Expand Down
3 changes: 2 additions & 1 deletion examples/pathcomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

def get_main_parser():
parser = argparse.ArgumentParser(prog="pathcomplete")
shtab.add_argument_to(parser, ["-s", "--print-completion"]) # magic!
shtab.add_argument_to(parser, ["-s", "--print-completion"]) # magic!

# file & directory tab complete
parser.add_argument("file", nargs="?").complete = shtab.FILE
parser.add_argument("--dir", default=".").complete = shtab.DIRECTORY
Expand Down
4 changes: 0 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
[build-system]
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "shtab/_dist_ver.py"
write_to_template = "__version__ = '{version}'\n"

[tool.black]
target_version = ["py27", "py36", "py38"]
20 changes: 16 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ classifiers=
Topic :: Terminals
Topic :: Utilities
[options]
setup_requires=setuptools>=42; setuptools_scm[toml]>=3.4
setup_requires=setuptools>=42; wheel; setuptools_scm[toml]>=3.4
install_requires=
argparse; python_version < "2.7" or ("3.0" <= python_version and python_version < "3.2")
python_requires= >=2.7, !=3.0.*, !=3.1.*
python_requires=>=2.7, !=3.0.*, !=3.1.*
packages=find:
[options.entry_points]
console_scripts=
Expand All @@ -80,12 +80,24 @@ exclude=docs,tests
universal=1

[flake8]
max_line_length=88
extend-ignore=E203,P1
max_line_length=99
extend-ignore=E261,P1
exclude=build,dist,.eggs,.git,__pycache__

[yapf]
spaces_before_comment=15, 20
arithmetic_precedence_indication=true
allow_split_before_dict_value=false
coalesce_brackets=True
column_limit=99
each_dict_entry_on_separate_line=False
space_between_ending_comma_and_closing_bracket=False
split_before_named_assigns=False
split_before_closing_bracket=False

[isort]
profile=black
line_length=99
known_first_party=shtab,tests

[tool:pytest]
Expand Down
Loading

0 comments on commit b6661ce

Please sign in to comment.