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

fix: Support Typer 0.14 and 0.15 #1173

Merged
merged 4 commits into from
Dec 24, 2024
Merged

fix: Support Typer 0.14 and 0.15 #1173

merged 4 commits into from
Dec 24, 2024

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Nov 28, 2024

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
typer (changelog) >0.6,<0.14 -> >0.6,<0.16 age adoption passing confidence

Release Notes

fastapi/typer (typer)

v0.15.0

Compare Source

Features
Internal

v0.14.0

Compare Source

Breaking Changes
  • 🔥 Remove auto naming of groups added via add_typer based on the group's callback function name. PR #​1052 by @​patrick91.

Before, it was supported to infer the name of a command group from the callback function name in the sub-app, so, in this code:

import typer

app = typer.Typer()
users_app = typer.Typer()

app.add_typer(users_app)

@&#8203;users_app.callback()
def users():  # <-- This was the inferred command group name
    """
    Manage users in the app.
    """

@&#8203;users_app.command()
def create(name: str):
    print(f"Creating user: {name}")

...the command group would be named users, based on the name of the function def users().

Now you need to set it explicitly:

import typer

app = typer.Typer()
users_app = typer.Typer()

app.add_typer(users_app, name="users")  # <-- Explicitly set the command group name

@&#8203;users_app.callback()
def users():
    """
    Manage users in the app.
    """

@&#8203;users_app.command()
def create(name: str):
    print(f"Creating user: {name}")

Updated docs SubCommand Name and Help.

Note: this change will enable important features in the next release. 🤩

Internal

v0.13.1

Compare Source

Features
Refactors
Docs
Internal

v0.13.0

Compare Source

Features
Fixes
Refactors
Internal

Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate bot changed the title chore(deps): update dependency typer to >0.6,<0.15 chore(deps): update dependency typer to >0.6,<0.16 Dec 3, 2024
@renovate renovate bot force-pushed the renovate/typer-0.x branch 3 times, most recently from b30f4e0 to 82a064b Compare December 9, 2024 17:58
@johnthagen
Copy link
Collaborator

johnthagen commented Dec 11, 2024

It would be nice to support Typer >=0.15 for users who lock openapi-python-client as a development dependency. We hit an issue where we depend on typer-slim 0.15.1 and it caused an error in openapi-python-client, I assume because typer-slim is shadowing the site-packages path for typer.

openapi_python_client/cli.py", line 66, in <module>
    @app.callback(name="openapi-python-client")
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Typer.callback() got an unexpected keyword argument 'name'

@dbanty
Copy link
Collaborator

dbanty commented Dec 11, 2024

@johnthagen any chance you have time to investigate the type checker issue and solve it? Hopefully while retaining support for older Typer versions.

@johnthagen
Copy link
Collaborator

@dbanty So looking into it, this is the failing line:

@app.callback(name="openapi-python-client")

It looks like according to Typer docs

Looks like they want users to use app.add_typer(users_app, name="users") style to name groups.

The upstream PR

@renovate renovate bot force-pushed the renovate/typer-0.x branch from 82a064b to 2fd1f58 Compare December 24, 2024 20:51
@renovate renovate bot force-pushed the renovate/typer-0.x branch from 2fd1f58 to a252722 Compare December 24, 2024 21:12
Copy link
Contributor Author

renovate bot commented Dec 24, 2024

Edited/Blocked Notification

Renovate will not automatically rebase this PR, because it does not recognize the last commit author and assumes somebody else may have edited the PR.

You can manually request rebase by checking the rebase/retry box above.

⚠️ Warning: custom changes will be lost.

@dbanty dbanty changed the title chore(deps): update dependency typer to >0.6,<0.16 fix: Support Typer 0.14 and 0.15 Dec 24, 2024
@dbanty dbanty enabled auto-merge December 24, 2024 21:58
@dbanty dbanty added this pull request to the merge queue Dec 24, 2024
Merged via the queue into main with commit 233ac66 Dec 24, 2024
22 checks passed
@dbanty dbanty deleted the renovate/typer-0.x branch December 24, 2024 22:01
@knope-bot knope-bot bot mentioned this pull request Dec 24, 2024
github-merge-queue bot pushed a commit that referenced this pull request Dec 24, 2024
> [!IMPORTANT]
> Merging this pull request will create this release

## Breaking Changes

### Delete fewer files with `--overwrite`

`--overwrite` will no longer delete the entire output directory before
regenerating. Instead, it will only delete
specific, known directories within that directory. Right now, that is
only the generated `models` and `api` directories.

Other generated files, like `README.md`, will be overwritten. Extra
files and directories outside of those listed above
will be left untouched, so you can any extra modules or files around
while still updating `pyproject.toml` automatically.

Closes #1105.

## Features

- Support httpx 0.28 (#1172)

### Add `generate_all_tags` config option

You can now, optionally, generate **duplicate** endpoint
functions/modules using _every_ tag for an endpoint,
not just the first one, by setting `generate_all_tags: true` in your
configuration file.

## Fixes

- Support Typer 0.14 and 0.15 (#1173)

### Fix minimum `attrs` version

The minimum `attrs` dependency version was incorrectly set to 21.3.0.
This has been corrected to 22.2.0, the minimum
supported version since `openapi-python-client` 0.19.1.

Closes #1084, thanks @astralblue!

### Fix compatibility with Pydantic 2.10+

#1176 by @Viicos

Set `defer_build` to models that we know will fail to build, and call
`model_rebuild`
in the `__init__.py` file.

Co-authored-by: knope-bot[bot] <152252888+knope-bot[bot]@users.noreply.github.com>
@johnthagen
Copy link
Collaborator

@dbanty Wanted to report that we upgraded to 0.23 and can confirm that this issue is fixed. Thanks! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants