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

Feature: 为子依赖添加 PEP593 Annotated 支持 #1832

Merged
merged 7 commits into from
Mar 22, 2023

Conversation

mnixry
Copy link
Member

@mnixry mnixry commented Mar 22, 2023

Example

Before

@handler1.handle()
async def _(user:User=Depends(current_user), connection:Connection=Depends()):
	...

@handler1.handle()
async def _(user:User=Depends(current_user), connection:Connection=Depends()):
	...

@handler1.handle()
async def _(user:User=Depends(current_user), connection:Connection=Depends()):
	...

After

CurrentUser = Annotated[User, Depends(current_user)]
CurrentConnection = Annotated[Connection,Depends()]

@handler1.handle()
async def _(user:CurrentUser, connection:CurrentConnection):
	...

@handler1.handle()
async def _(user:CurrentUser, connection:CurrentConnection):
	...

@handler1.handle()
async def _(user:CurrentUser, connection:CurrentConnection):
	...

References:

@mnixry mnixry added the enhancement New feature or request label Mar 22, 2023
@mnixry mnixry requested a review from yanyongyu March 22, 2023 06:35
@codecov
Copy link

codecov bot commented Mar 22, 2023

Codecov Report

Merging #1832 (99fadb6) into master (9afaf3d) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1832      +/-   ##
==========================================
+ Coverage   88.22%   88.25%   +0.02%     
==========================================
  Files          44       44              
  Lines        3160     3168       +8     
==========================================
+ Hits         2788     2796       +8     
  Misses        372      372              
Flag Coverage Δ
unittests 88.25% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
nonebot/internal/params.py 99.31% <100.00%> (+0.03%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 22, 2023

🚀 Deployed on https://deploy-preview-1832--nonebot2.netlify.app

@github-actions github-actions bot temporarily deployed to pull request March 22, 2023 06:38 Inactive
@github-actions github-actions bot temporarily deployed to pull request March 22, 2023 06:48 Inactive
@github-actions github-actions bot temporarily deployed to pull request March 22, 2023 06:53 Inactive
@yanyongyu yanyongyu changed the title Add support for PEP-593 Annotated for specifying dependencies Feature: 为子依赖添加 PEP593 Annotated 支持 Mar 22, 2023
nonebot/internal/params.py Outdated Show resolved Hide resolved
@mnixry mnixry requested a review from yanyongyu March 22, 2023 11:09
@github-actions github-actions bot temporarily deployed to pull request March 22, 2023 11:11 Inactive
@yanyongyu yanyongyu merged commit 3e92fcc into master Mar 22, 2023
@yanyongyu yanyongyu deleted the feature/support-annotated branch March 22, 2023 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

2 participants