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

be carefull with **kwargs call #1625

Open
2 tasks
samsja opened this issue Jun 6, 2023 · 5 comments
Open
2 tasks

be carefull with **kwargs call #1625

samsja opened this issue Jun 6, 2023 · 5 comments

Comments

@samsja
Copy link
Member

samsja commented Jun 6, 2023

Context

we need to be carefull when using **kwargs in a function signature.

We should always raised an expectation when too many kwargs are passed.

Example:

if I define def f(hello='hello', **kwargs) but I call the function with f(heello='hey') it will not be called at runtime and it the typo will create confusion.

We should avoid this in a systematic manner maybe with a decorator

Context

  • think how to solve this problem in a general way
  • go over each **kwargs usage and verify that we handle it proprely
@samsja samsja changed the title # be carefull with **kwargs call be carefull with **kwargs call Jun 6, 2023
@JoanFM
Copy link
Member

JoanFM commented Jun 6, 2023

I do not understand this issue, this is a common Python problem, I do not think we can fix it, and it would be an overkill handling this

@samsja
Copy link
Member Author

samsja commented Jun 6, 2023

Well we can def'ly fixed it. I actually think this is one of the major blocker of Jina this kwargs things since we use it everywhere.

To me if we don't tackle this from the start we create a lot of pain for users. The whole pydantic / FastAPI idea is that we should be able to catch this kind of typo

@JoanFM
Copy link
Member

JoanFM commented Jun 6, 2023

what does FastAPI and Pydantic have to do with kwargs in methods?

@samsja
Copy link
Member Author

samsja commented Jun 6, 2023

They basically never expose kwargs in public API. And if they do it is only for special method that are tagged as behind dangerous or for internal method

@JoanFM
Copy link
Member

JoanFM commented Jun 6, 2023

But this is just what they do, it is not that it is their main value proposition

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

No branches or pull requests

2 participants