Skip to content

Commit

Permalink
Support typer>=0.6.0 (#213)
Browse files Browse the repository at this point in the history
* make README consistent with gitignore (folder .pytest-cache)

* fix test_cli

* ensure test compatibility with typer ~=0.5.0

* relax requirements about typer in setup

* Update setup.py

* fix Ci

* fix pylint

* fix pylint

Co-authored-by: Alexander Guschin <1aguschin@gmail.com>
  • Loading branch information
francesco086 and aguschin authored Jul 18, 2022
1 parent a6c6aad commit 6a49b25
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ $ pip install --upgrade pip setuptools wheel ".[tests]"
### 3. Run

```console
$ pytest --basetemp=pytest-cache
$ pytest --basetemp=.pytest-cache
```

This will create `pytest-cache/` directory with some fixtures that can serve as
Expand All @@ -335,7 +335,7 @@ examples.
Notably, check out this dir:

```console
$ cd pytest-cache/test_api0/
$ cd .pytest-cache/test_api0/
$ gto show -v
```

Expand Down
8 changes: 4 additions & 4 deletions gto/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(
aliases: List[str] = None,
**kwargs,
):
super().__init__(name, **kwargs)
super().__init__(name=name, **kwargs)
self.examples = examples
self.section = section
self.aliases = aliases
Expand Down Expand Up @@ -75,7 +75,7 @@ def _extract_examples(
return help_str[examples + len("Examples:") + 1 :], help_str[:examples]


class GtoCommand(TyperCommand, GtoCliMixin):
class GtoCommand(GtoCliMixin, TyperCommand):
def __init__(
self,
name: Optional[str],
Expand All @@ -86,7 +86,7 @@ def __init__(
):
examples, help = _extract_examples(help)
super().__init__(
name,
name=name,
section=section,
aliases=aliases,
examples=examples,
Expand All @@ -95,7 +95,7 @@ def __init__(
)


class GtoGroup(TyperGroup, GtoCliMixin):
class GtoGroup(GtoCliMixin, TyperGroup):
order = [
CommandGroups.querying,
CommandGroups.modifying,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

install_requires = [
"gitpython",
"typer<0.6",
"typer>=0.4.1",
"rich",
"pydantic",
"ruamel.yaml",
Expand Down
15 changes: 14 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import git
import pytest
import typer
from packaging import version
from typer.main import get_command_from_info
from typer.testing import CliRunner

Expand Down Expand Up @@ -38,7 +40,18 @@ def app_cmd():

@pytest.fixture
def app_cli_cmd(app_cmd):
return (get_command_from_info(c) for c in app_cmd)
if version.parse(typer.__version__) < version.parse("0.6.0"):
return (
get_command_from_info(c) for c in app_cmd # pylint: disable=missing-kwoa
)
return (
get_command_from_info( # pylint: disable=unexpected-keyword-arg
c,
pretty_exceptions_short=False,
rich_markup_mode="rich",
)
for c in app_cmd
)


def test_commands_help(app_cli_cmd):
Expand Down

0 comments on commit 6a49b25

Please sign in to comment.