Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to PEP621 #121

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: 🚀 Release
run-name: 🚀 Release ${{ github.ref_name }}

on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hynek/build-and-inspect-python-package@v2
upload_pypi:
name: Upload to PyPI repository
needs: [ build ]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/click-repl/
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: Packages
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
release:
needs: [ upload_pypi ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: softprops/action-gh-release@v2
with:
name: ${{ github.ref_name }}
generate_release_notes: true
10 changes: 10 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@ on:
- pull_request

jobs:
pre-commit:
name: pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- uses: pre-commit/action@v3.0.1
test:
runs-on: ${{ matrix.os }}
needs: [ pre-commit ]
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
Expand Down
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.3
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
- id: ruff-format
2 changes: 1 addition & 1 deletion Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@

- Backwards compatibility between click 7 & 8
- support for click 8 changes
- Update tests to expect hyphens
- Update tests to expect hyphens
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
release:
@python setup.py sdist bdist_wheel upload
.PHONY: release

testrepl:
@python bin/testrepl.py repl
.PHONY: testrepl
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def myrepl():
'history': FileHistory('/etc/myrepl/myrepl-history'),
}
repl(click.get_current_context(), prompt_kwargs=prompt_kwargs)

cli()
```
And then your custom `myrepl` command will be available on your CLI, which
Expand Down
1 change: 0 additions & 1 deletion click_repl/_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ def _get_completion_for_Boolean_type(self, param, incomplete):
]

def _get_completion_from_params(self, autocomplete_ctx, args, param, incomplete):

choices = []
param_type = param.type

Expand Down
101 changes: 100 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,51 @@
[build-system]
requires = ["setuptools", "wheel"]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "click-repl"
description = "REPL plugin for Click"
readme = "README.md"
authors = [
{ name = "Markus Unterwaditzer", email = "markus@unterwaditzer.net" },
]
license = { text = "MIT" }
requires-python = ">=3.7"
dynamic = ["version"]
dependencies = [
"click>=7.0",
"prompt_toolkit>=3.0.36",
"typing-extensions>=4.7.0",
]
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"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.12",
]

[project.optional-dependencies]
testing = [
"pytest>=7.2.1",
"pytest-cov>=4.0.0",
"tox>=4.4.3",
]

[project.urls]
Homepage = "https://github.com/click-contrib/click-repl"
Repository = "https://github.com/click-contrib/click-repl"

[tool.setuptools]
packages = ["click_repl"]
zip-safe = false

[tool.setuptools.dynamic]
version = { attr = "click_repl.__version__" }

[tool.pytest.ini_options]
addopts = [
"--cov=click_repl"
Expand All @@ -10,3 +54,58 @@ addopts = [
testpaths = [
"tests",
]

[tool.ruff]
line-length = 90

[tool.ruff.lint]
select = [
"F", # pyflakes
"W", # pycodestyle-warnings
"E", # pycodestyle-errors
# "I", # isort
# "N", # pep8-naming
# "D", # pydocstyle
# "UP", # pyupgrade
# "YTT", # flake8-2020
# "ANN", # flake8-annotations
# "S", # flake8-banditF
# "FBT", # flake8-boolean-trap
# "B", # flake8-bugbear
# "A", # flake8-builtins
# "COM", # flake8-comma
# "C4", # flake8-comprehensions
# "EM", # flake8-errmsg
# "FA", # flake8-future-annotations
"ISC", # flake8-implicit-str-concat
"ICN", # flake8-import-conventions
# "G", # flake8-logging-format
"PIE", # flake8-pie
# "T20", # flake8-print
# "PYI", # flake8-pyi
# "PT", # flake8-pytest-style
# "Q", # flake8-quotes
# "RSE", # flake8-raise
# "RET", # flake8-return
# "SLF", # flake8-self
# "SIM", # flake8-simplify
# "TID", # flake8-tidy-imports
# "TCH", # flake8-type-checking
# "ARG", # flake8-unused-arguments
# "PTH", # flake8-use-pathlib
# "TD", # flake8-todos
# "ERA", # eradicate
# "PGH", # pygrep-hooks
# "PL", # pylint
# "TRY", # tryceratops
# "FLY", # flynt
# "PERF", # perflint
# "FURB", # refurb
# "RUF", # Ruff-specific
]
ignore = [
"E203", "E266", "E402", "E731", "C901",
]

[tool.ruff.lint.mccabe]
max-complexity = 18
47 changes: 0 additions & 47 deletions setup.cfg

This file was deleted.

7 changes: 0 additions & 7 deletions setup.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,8 @@ def shell_complete_func(ctx, param, incomplete):
def autocompletion_cmd2(handler):
pass

completions = list(
c.get_completions(Document("autocompletion-cmd2 --handler "))
)
completions = list(c.get_completions(Document("autocompletion-cmd2 --handler ")))
assert {x.text for x in completions} == {"foo", "bar"}

completions = list(
c.get_completions(Document("autocompletion-cmd2 --handler "))
)
completions = list(c.get_completions(Document("autocompletion-cmd2 --handler ")))
assert {x.text for x in completions} == {"foo", "bar"}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,5 @@ def shell_complete_func(ctx, args, incomplete):
def autocompletion_opt_cmd2(handler):
pass

completions = list(
c.get_completions(Document("autocompletion-opt-cmd2 --handler "))
)
completions = list(c.get_completions(Document("autocompletion-opt-cmd2 --handler ")))
assert {x.text for x in completions} == {"foo", "bar"}
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ def args_choices_hidden_cmd(handler):
completions = list(c.get_completions(Document("args-choices-hidden-cmd foo ")))
assert {x.text for x in completions} == set()

completions = list(
c.get_completions(Document("args-choices-hidden-cmd --handler "))
)
completions = list(c.get_completions(Document("args-choices-hidden-cmd --handler ")))
assert {x.text for x in completions} == set()


Expand Down
4 changes: 1 addition & 3 deletions tests/test_dev/test_get_internal_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,4 @@ def test_get_registered_target_exit_cmd(test_input, expected):

@pytest.mark.parametrize("test_input", ["hi", "hello", "76q358767"])
def test_get_registered_target(test_input):
assert (
click_repl.utils._get_registered_target(test_input, "Not Found") == "Not Found"
)
assert click_repl.utils._get_registered_target(test_input, "Not Found") == "Not Found"
5 changes: 0 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ deps =
commands =
pytest --basetemp={envtmpdir}

[testenv:flake8]
basepython = python3.7
deps = flake8
commands = flake8 click_repl tests

[testenv:click7]
basepython = python3.10
deps =
Expand Down
Loading