Skip to content

Commit

Permalink
fix: Reexport Empty/EmptyType types at the root.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanCardin committed Jan 15, 2025
1 parent c489574 commit ec59a80
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 42 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## 0.26

### 0.26.3
- fix: Reexport Empty/EmptyType types at the root.

### 0.26.2

- fix: Optional positional arguments should not get a default value from their action.
Expand Down
16 changes: 16 additions & 0 deletions docs/source/arg.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,15 @@ As noted above, a value produced by `Default.default` **does not** invoke the `A
for similar reasons as to native dataclass defaults. The programmer is supplying the default value
which should not **need** to be parsed.
```{note}
`Default`'s fallback behavior will fallback to lower priority handlers in the "default sequence" when
that item's default returns `cappa.Empty`. All the native (`Env`, `Prompt`, `Confirm`)
handlers will do this natively, when they fail to produce a value.
A `ValueFrom` (described below) accepts a user-provided function, so it **may** need to be aware of
this and return `cappa.Empty`, depending on the desired behavior.
```
### `Env`
[cappa.Env](cappa.Env) performs environment variable lookups in an attempt to provide a value to the
Expand Down Expand Up @@ -297,6 +306,13 @@ As noted above, a value produced by `ValueFrom` **does not** invoke the `Arg.par
because the called function is programmer-supplied and can/should just return the correct end
value.
```{info}
If there are scenarios where `ValueFrom` **should** fail to provide a value and fall back to the
class-level, or `Default`-level default value, it should return `cappa.Empty` in order to indicate
to cappa that it shouldn't accept the returned value as the **actual** value to used when constructing
the resulting class instance.
```
## `Arg.show_default`
Defaults to `True` (e.g. `DefaultFormatter(format='{default}', show=True)`). This field controls **both**:
Expand Down
50 changes: 9 additions & 41 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,36 +1,18 @@
[project]
name = "cappa"
version = "0.26.2"
version = "0.26.3"
description = "Declarative CLI argument parser."

urls = {repository = "https://github.com/dancardin/cappa"}
authors = [
{name = "Dan Cardin", email = "[email protected]"},
]
license = {file = "LICENSE"}
urls = { repository = "https://github.com/dancardin/cappa" }
authors = [{ name = "Dan Cardin", email = "[email protected]" }]
license = { file = "LICENSE" }
readme = "README.md"
keywords = [
"CLI",
"parser",
"argparse",
"click",
"typer",
]
classifiers = [
"Topic :: Software Development :: Libraries :: Python Modules",
]

include = [
"py.typed",
]
keywords = ["CLI", "parser", "argparse", "click", "typer"]
classifiers = ["Topic :: Software Development :: Libraries :: Python Modules"]

requires-python = ">=3.8,<4"

dependencies = [
"rich",
"typing-extensions >= 4.8.0",
"type-lens >= 0.2.3",
]
dependencies = ["rich", "typing-extensions >= 4.8.0", "type-lens >= 0.2.3"]

[project.optional-dependencies]
docstring = ["docstring-parser >= 0.15"]
Expand All @@ -54,19 +36,7 @@ target-version = "py38"

[tool.ruff.lint]
select = ["C", "D", "E", "F", "I", "N", "Q", "RET", "RUF", "S", "T", "UP", "YTT"]
ignore = [
"C901",
"E501",
"S101",
"D1",
"D203",
"D213",
"D406",
"D407",
"D408",
"D409",
"D413",
]
ignore = ["C901", "E501", "S101", "D1", "D203", "D213", "D406", "D407", "D408", "D409", "D413"]

[tool.ruff.lint.per-file-ignores]
"tests/*" = ["T201"]
Expand Down Expand Up @@ -103,9 +73,7 @@ doctest_optionflags = "NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL ELLIPSIS"
addopts = "--doctest-modules -vv --ff --strict-markers"
norecursedirs = ".* build dist *.egg bin"
pytester_example_dir = "examples"
markers = [
"help",
]
markers = ["help"]

[build-system]
requires = ["hatchling"]
Expand Down
3 changes: 3 additions & 0 deletions src/cappa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from cappa.parse import unpack_arguments
from cappa.state import State
from cappa.subcommand import Subcommand, Subcommands
from cappa.type_view import Empty, EmptyType

# isort: split
from cappa.arg import Arg, ArgAction, Group
Expand All @@ -25,6 +26,8 @@
"Confirm",
"Default",
"Dep",
"Empty",
"EmptyType",
"Env",
"Exit",
"FileMode",
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ec59a80

Please sign in to comment.