Skip to content
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
20 changes: 19 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
## Version 8.6.0
## Version 9.0.0
Comment thread
Rowlando13 marked this conversation as resolved.
Resolved

Unreleased

- The old parser, deprecated in 8.2, is removed. {meth}`Command.parse_args`
parses arguments directly. {issue}`2205`

- `OptionParser` is removed from `click` and `click.parser`, along with
`click.parser.Option`, `Argument`, `ParsingState`, `normalize_opt`, and
`split_opt`. `split_arg_string` is available as
{func}`click.split_arg_string`.
Use `optparse` from the standard library if you need the old parser.
- `Command.make_parser` and `Parameter.add_to_parser` are removed.
Comment thread
Rowlando13 marked this conversation as resolved.
Resolved
- `Context.protected_args` always returns an empty list. The subcommand

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You simply tell that protected_args property is removed from the Context class.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change.

name and its arguments are in `Context.args`.
- Better error messages when parsing fails.

- Option names that only become equal after `token_normalize_func`, such as
`-v` and `-V` with a lower-casing function, raise a `TypeError` when parsing
instead of one silently making the other unreachable. This includes the on
and off names of a boolean flag, such as `-s/-S`.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a note about fixing --level=-2 kind of option value that have a dash in their string. This is related to #2871 and #2676.

Ah, maybe we should add test coverage for these cases:

  • --level=-2
  • -l-2
  • --level -2

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add tests for this. And add note. I was not aware this was incidentally fixed.

- Drop support for Python 3.10. {pr}`3920` {pr}`3921`
- A parameter name that is not a valid Python identifier, or that is a Python
keyword, is deprecated and raises `TypeError` in Click 9.0. {pr}`3866`
Expand Down
12 changes: 4 additions & 8 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,6 @@ classes and functions.
.. autofunction:: wrap_text
```

## Parsing
Comment thread
Rowlando13 marked this conversation as resolved.
Resolved

```{eval-rst}
.. autoclass:: OptionParser
:members:
```

## Shell Completion

See {doc}`/shell-completion` for information about enabling and
Expand All @@ -346,6 +338,10 @@ customizing Click's shell completion system.
```

```{eval-rst}
.. autofunction:: click.split_arg_string
```

(testing)=

## Testing
Expand Down
4 changes: 2 additions & 2 deletions docs/shell-completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,13 @@ must return a `(args, incomplete)` tuple.

```python
import os
from click.parser import split_arg_string
import click

class MyshComplete(ShellComplete):
...

def get_completion_args(self):
args = split_arg_string(os.environ["COMP_WORDS"])
args = click.split_arg_string(os.environ["COMP_WORDS"])

if os.environ["COMP_PARTIAL"] == "1":
incomplete = args.pop()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "click"
version = "8.6.0.dev"
version = "9.0.0.dev"
description = "Composable command line interface toolkit"
readme = "README.md"
license = "BSD-3-Clause"
Expand Down
12 changes: 1 addition & 11 deletions src/click/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from .formatting import HelpFormatter as HelpFormatter
from .formatting import wrap_text as wrap_text
from .globals import get_current_context as get_current_context
from .shell_completion import split_arg_string as split_arg_string
from .termui import clear as clear
from .termui import confirm as confirm
from .termui import echo_via_pager as echo_via_pager
Expand Down Expand Up @@ -98,17 +99,6 @@ def __getattr__(name: str) -> object:
)
return _MultiCommand

if name == "OptionParser":
from .parser import _OptionParser

warnings.warn(
"'OptionParser' is deprecated and will be removed in Click 9.0. The"
" old parser is available in 'optparse'.",
DeprecationWarning,
stacklevel=2,
)
return _OptionParser

if name == "__version__":
import importlib.metadata

Expand Down
14 changes: 14 additions & 0 deletions src/click/_base_utils.py
Comment thread
Rowlando13 marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Private utilities that must not import anything else from the package. Keeping
# them dependency-free lets any module use them without creating circular imports.
# This module will also be used to help unwind circular imports in core.py.
from __future__ import annotations


def _split_opt(opt: str) -> tuple[str, str]:
"""Splits an option into a prefix and a value."""
first = opt[:1]
if first.isalnum():
return "", opt
if opt[1:2] == first:
return opt[:2], opt[2:]
return first, opt[1:]
Loading
Loading