diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 80f5d56..75631d8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -52,7 +52,7 @@ jobs: with: python-version: ${{ matrix.python }} - name: Install - run: pip install -U -r requirements-dev.txt + run: pip install -U -e .[dev] - run: pytest - uses: codecov/codecov-action@v3 deploy: @@ -70,7 +70,6 @@ jobs: - id: dist uses: casperdcl/deploy-pypi@v2 with: - requirements: twine setuptools wheel setuptools_scm[toml] build: true password: ${{ secrets.PYPI_TOKEN }} upload: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }} diff --git a/.gitignore b/.gitignore index 5930e35..adc0314 100644 --- a/.gitignore +++ b/.gitignore @@ -2,8 +2,9 @@ __pycache__/ # Packages -/shtab/_dist_ver.py +/MANIFEST.in /*.egg*/ +/shtab/_dist_ver.py /build/ /dist/ /docs/build/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index be1fbe4..f57e8e5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,14 +36,15 @@ repos: - flake8-comprehensions - flake8-debugger - flake8-isort + - flake8-pyproject - flake8-string-format - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.1.1 + rev: v1.3.0 hooks: - id: mypy additional_dependencies: [types-setuptools] - repo: https://github.com/google/yapf - rev: v0.32.0 + rev: v0.33.0 hooks: - id: yapf args: [-i] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3e53784..9b22bd3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,7 +6,7 @@ When contributing pull requests, it's a good idea to run basic checks locally: ```bash # install development dependencies -shtab (main)$ pip install pre-commit -r requirements-dev.txt +shtab (main)$ pip install pre-commit -e .[dev] shtab (main)$ pre-commit install # install pre-commit checks shtab (main)$ pytest # run all tests ``` diff --git a/docs/requirements.txt b/docs/requirements.txt index ef22cfa..0569ebc 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,6 +1,6 @@ mkdocs-material git+https://github.com/tqdm/jsmin@python3-only#egg=jsmin mkdocs-minify-plugin -pydoc-markdown>=4 +pydoc-markdown>=4,!=4.8.0 pygments pymdown-extensions>=9 diff --git a/pyproject.toml b/pyproject.toml index f343697..df14506 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,3 +4,115 @@ requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"] [tool.setuptools_scm] write_to = "shtab/_dist_ver.py" write_to_template = "__version__ = '{version}'\n" + +[tool.setuptools.packages.find] +exclude = ["docs", "tests", "examples"] + +[tool.setuptools.exclude-package-data] +"*" = ["logo.png"] + +[project.urls] +documentation = "https://docs.iterative.ai/shtab" +repository = "https://github.com/iterative/shtab" +changelog = "https://github.com/iterative/shtab/releases" + +[project] +name = "shtab" +dynamic = ["version"] +authors = [{name = "Casper da Costa-Luis", email = "casper.dcl@physics.org"}] +maintainers = [{name = "Iterative", email = "support@iterative.ai"}] +description = "Automagic shell tab completion for Python CLI applications" +readme = "README.rst" +requires-python = ">=3.7" +keywords = ["tab", "complete", "completion", "shell", "bash", "zsh", "argparse"] +license = {text = "Apache-2.0"} +classifiers = [ + "Development Status :: 4 - Beta", + "Environment :: Console", + "Environment :: MacOS X", + "Environment :: Other Environment", + "Intended Audience :: Developers", + "Intended Audience :: Education", + "Intended Audience :: End Users/Desktop", + "Intended Audience :: Other Audience", + "Intended Audience :: System Administrators", + "License :: OSI Approved :: Apache Software License", + "Operating System :: MacOS", + "Operating System :: MacOS :: MacOS X", + "Operating System :: POSIX", + "Operating System :: POSIX :: BSD", + "Operating System :: POSIX :: BSD :: FreeBSD", + "Operating System :: POSIX :: Linux", + "Operating System :: POSIX :: SunOS/Solaris", + "Operating System :: Unix", + "Programming Language :: Other Scripting Engines", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: Implementation", + "Programming Language :: Python :: Implementation :: IronPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Programming Language :: Unix Shell", + "Topic :: Desktop Environment", + "Topic :: Education :: Computer Aided Instruction (CAI)", + "Topic :: Education :: Testing", + "Topic :: Office/Business", + "Topic :: Other/Nonlisted Topic", + "Topic :: Software Development", + "Topic :: Software Development :: Build Tools", + "Topic :: Software Development :: Libraries", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Software Development :: Pre-processors", + "Topic :: Software Development :: User Interfaces", + "Topic :: System", + "Topic :: System :: Installation/Setup", + "Topic :: System :: Shells", + "Topic :: System :: System Shells", + "Topic :: Terminals", + "Topic :: Utilities"] + +[project.optional-dependencies] +dev = ["pytest>=6", "pytest-cov", "pytest-timeout"] + +[project.scripts] +shtab = "shtab.main:main" + +[tool.flake8] +max_line_length = 99 +extend_ignore = ["E261", "P101"] +exclude = [".git", "__pycache__", "build", "dist", ".eggs"] + +[tool.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 +blank_line_before_nested_class_or_def = false + +[tool.isort] +profile = "black" +line_length = 99 +known_first_party = ["shtab", "tests"] + +[tool.mypy] +warn_unused_configs = true +warn_unused_ignores = true +show_error_codes = true + +[tool.pytest.ini_options] +minversion = "6.0" +timeout = 5 +log_level = "DEBUG" +python_files = ["test_*.py"] +testpaths = ["tests"] +addopts = "-v --tb=short -rxs -W=error --durations=0 --cov=shtab --cov-report=term-missing --cov-report=xml" diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index 08798aa..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,3 +0,0 @@ -pytest -pytest-cov -pytest-timeout diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 8a77cb8..0000000 --- a/setup.cfg +++ /dev/null @@ -1,115 +0,0 @@ -[metadata] -name=shtab -description=Automagic shell tab completion for Python CLI applications -long_description=file: README.rst -long_description_content_type=text/x-rst -license=Apache-2.0 -license_file=LICENCE -url=https://github.com/iterative/shtab -project_urls= - Changelog=https://github.com/iterative/shtab/releases - Documentation=https://docs.iterative.ai/shtab -author=Casper da Costa-Luis -author_email=casper.dcl@physics.org -maintainer=Iterative -maintainer_email=support@iterative.ai -keywords=tab, complete, completion, shell, bash, zsh, argparse -platforms=any -provides=shtab -classifiers= - Development Status :: 4 - Beta - Environment :: Console - Environment :: MacOS X - Environment :: Other Environment - Intended Audience :: Developers - Intended Audience :: Education - Intended Audience :: End Users/Desktop - Intended Audience :: Other Audience - Intended Audience :: System Administrators - License :: OSI Approved :: Apache Software License - Operating System :: MacOS - Operating System :: MacOS :: MacOS X - Operating System :: POSIX - Operating System :: POSIX :: BSD - Operating System :: POSIX :: BSD :: FreeBSD - Operating System :: POSIX :: Linux - Operating System :: POSIX :: SunOS/Solaris - Operating System :: Unix - Programming Language :: Other Scripting Engines - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: Implementation - Programming Language :: Python :: Implementation :: IronPython - Programming Language :: Python :: Implementation :: PyPy - Programming Language :: Unix Shell - Topic :: Desktop Environment - Topic :: Education :: Computer Aided Instruction (CAI) - Topic :: Education :: Testing - Topic :: Office/Business - Topic :: Other/Nonlisted Topic - Topic :: Software Development - Topic :: Software Development :: Build Tools - Topic :: Software Development :: Libraries - Topic :: Software Development :: Libraries :: Python Modules - Topic :: Software Development :: Pre-processors - Topic :: Software Development :: User Interfaces - Topic :: System - Topic :: System :: Installation/Setup - Topic :: System :: Shells - Topic :: System :: System Shells - Topic :: Terminals - Topic :: Utilities -[options] -setup_requires=setuptools>=42; wheel; setuptools_scm[toml]>=3.4 -python_requires=>=3.7 -packages=find: -[options.entry_points] -console_scripts= - shtab=shtab.main:main -[options.package_data] -shtab=py.typed -[options.packages.find] -exclude=docs,tests - -[flake8] -max_line_length=99 -extend-ignore=E261,P1 -exclude=build,dist,.eggs,.git,__pycache__ - -[mypy] -warn_unused_configs=True -warn_unused_ignores=True -show_error_codes=True -# https://github.com/pypa/setuptools_scm/issues/501 -[mypy-setuptools_scm] -ignore_missing_imports=True - -[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 -blank_line_before_nested_class_or_def=False - -[isort] -profile=black -line_length=99 -known_first_party=shtab,tests - -[tool:pytest] -timeout=5 -log_level=DEBUG -python_files=test_*.py -testpaths=tests -addopts=-v --tb=short -rxs -W=error --durations=0 --cov=shtab --cov-report=term-missing --cov-report=xml diff --git a/setup.py b/setup.py deleted file mode 100644 index d5d43d7..0000000 --- a/setup.py +++ /dev/null @@ -1,3 +0,0 @@ -from setuptools import setup - -setup(use_scm_version=True) diff --git a/shtab/__init__.py b/shtab/__init__.py index 21ae807..3564fb9 100644 --- a/shtab/__init__.py +++ b/shtab/__init__.py @@ -478,9 +478,8 @@ def format_optional(opt): return (('{nargs}{options}"[{help}]"' if isinstance( opt, FLAG_OPTION) else '{nargs}{options}"[{help}]:{dest}:{pattern}"').format( nargs=('"(- : *)"' if is_opt_end(opt) else '"*"' if is_opt_multiline(opt) else ""), - options=("{{{}}}".format(",".join(opt.option_strings)) - if len(opt.option_strings) > 1 else '"{}"'.format("".join( - opt.option_strings))), + options=("{{{}}}".format(",".join(opt.option_strings)) if len(opt.option_strings) + > 1 else '"{}"'.format("".join(opt.option_strings))), help=escape_zsh(opt.help or ""), dest=opt.dest, pattern=complete2pattern(opt.complete, "zsh", choice_type2fn) if hasattr(