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

Shouldn't App's __init__() method accept only keywords? #3140

Closed
nautics889 opened this issue Apr 22, 2024 · 1 comment
Closed

Shouldn't App's __init__() method accept only keywords? #3140

nautics889 opened this issue Apr 22, 2024 · 1 comment

Comments

@nautics889
Copy link
Contributor

nautics889 commented Apr 22, 2024

In short words

*args in App class are not used anywhere, except passing it to base __init__ (which in it's turns does not accept positional arguments)

Describe the bug

Here in the App class, the __init__() method accepts an arbitrary positional argument and then passes it to the base method. However, __init__() of Pydantic's BaseModel doesn't really accept any positional args (actually never has), only **kwargs. And I haven't seen any example where reflex App would be called with pos. args, so maybe it shouldn't be there.

Doesn't it make sense to remove passing positional args to the App class? It doesn't use them anywhere except pass it up to super()'s __init__ (i. e. BaseModel).

To Reproduce

>>> from reflex import App
>>> app = App('bar')
Traceback (most recent call last):
    ...
    super().__init__(*args, **kwargs)
TypeError: BaseModel.__init__() takes 1 positional argument but 2 were given

Expected behavior

An exception that it couldn't take pos. arguments is raised from the App class, not BaseModel.

Specifics (please complete the following information):

  • Python Version: 3.12 (doesn't really matter)
  • Reflex Version: v0.4.8.post1
  • OS: Win (doesn't really matter)
nautics889 added a commit to nautics889/reflex that referenced this issue Apr 22, 2024
* (fix): remove '*args' from '__init__()' method of 'App', update
  docstrings and .pyi accordingly
@picklelo
Copy link
Contributor

Merged in #3141

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

No branches or pull requests

2 participants