Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ Additional `click` parameter types are built on top of the `validators` library,
- `clicktypes.mac_address()`
- `clicktypes.mastercard()`
- `clicktypes.md5()`
- `clicktypes.mir()`
- `clicktypes.ru_inn()`
- `clicktypes.sedol()`
- `clicktypes.sha1()`
- `clicktypes.sha224()`
Expand Down
21 changes: 21 additions & 0 deletions clicktypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,24 @@ def md5() -> click.ParamType:
return click_validatortype(validators.md5)()


def mir() -> click.ParamType:
"""
Return whether or not given value is a valid Mir card number.

Returns a `click.ParamType` instance which wraps `validators.mir`.
"""
return click_validatortype(validators.mir)()


def ru_inn() -> click.ParamType:
"""
Validate a Russian INN (Taxpayer Identification Number).

Returns a `click.ParamType` instance which wraps `validators.ru_inn`.
"""
return click_validatortype(validators.ru_inn)()


def sedol() -> click.ParamType:
"""
Return whether or not given value is a valid SEDOL.
Expand Down Expand Up @@ -479,6 +497,7 @@ def url(
private: Optional[bool] = None,
rfc_1034: bool = False,
rfc_2782: bool = False,
**kwargs,
) -> click.ParamType:
"""
Return whether or not given value is a valid URL.
Expand Down Expand Up @@ -544,6 +563,8 @@ def visa() -> click.ParamType:
"mac_address",
"mastercard",
"md5",
"mir",
"ru_inn",
"sedol",
"sha1",
"sha224",
Expand Down
16 changes: 15 additions & 1 deletion clicktypes/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,21 @@ def overload_info(func: Callable) -> Dict[str, Any]:

sig = inspect.signature(func)

params = ", ".join(str(p) for p in sig.parameters.values() if p.name != "value")
param_lst: List[str] = []
kwargs = False
for param in sig.parameters.values():
if param.name == "value":
continue
if callable(param.default):
kwargs = True
continue

param_lst.append(str(param))
else:
if kwargs:
param_lst.append("**kwargs")

params = ",".join(param_lst)
params = (params.rstrip(",") + ",") if params else ""

doc = inspect.getdoc(func) or ""
Expand Down
582 changes: 265 additions & 317 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ repository = "https://github.com/d-chris/click-validators"
documentation = "https://d-chris.github.io/click-validators"

[tool.poetry.dependencies]
python = "^3.8.1"
click = "^8.1.8"
validators = "^0.34.0"
python = "^3.9"
click = ">=8.1.8"
validators = ">=0.34.0"
eth-hash = { version = ">=0.7.0", extras = [ "pycryptodome" ], optional = true }

[tool.poetry.extras]
Expand Down Expand Up @@ -70,7 +70,7 @@ addopts = [
"-s",
"--color=yes",
"--cov=clicktypes",
"--cov-report=term-missing:skip-covered",
"--cov-report=term-missing",
"--cov-report=xml",
]

Expand Down
2 changes: 0 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ env_list =
py311
py310
py39
py38
cov

[testenv]
Expand Down Expand Up @@ -39,4 +38,3 @@ depends =
py311
py310
py39
py38