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

Sample code in README gives error because of a change 3 weeks ago of definition of Table #126

Closed
aekespong opened this issue Dec 27, 2023 · 6 comments

Comments

@aekespong
Copy link
Contributor

Error in sample code in README.

image

Sample code doesn't work.

Sample code gives Request Error:

image

@aekespong
Copy link
Contributor Author

I've solved this in PR #124

@aekespong aekespong changed the title Sample code doesn't work Sample code in README doesn't work Dec 27, 2023
@AliRn76
Copy link

AliRn76 commented Dec 27, 2023

Please add more detail about the error,
It works fine in my environment

@aekespong
Copy link
Contributor Author

aekespong commented Dec 28, 2023

Strange.

The error is

<class 'fastui.components.tables.Table'> cannot be parametrized because it does not inherit from typing.Generic.

The end of the error displayed on the terminal:

File "/root/FastUI/main/env310/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "/root/FastUI/main/env310/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "/root/FastUI/main/sample/main.py", line 38, in users_table
    c.Table[User](  # c.Table is a generic component parameterized with the model used for rows
  File "/root/FastUI/main/env310/lib/python3.10/site-packages/pydantic/main.py", line 634, in __class_getitem__
    raise TypeError(f'{cls} cannot be parametrized because it does not inherit from typing.Generic')
TypeError: <class 'fastui.components.tables.Table'> cannot be parametrized because it does not inherit from typing.Generic

the code in tables.py was changed three weeks ago by Samuel to this version:

class Table(pydantic.BaseModel, extra='forbid'):
    data: _t.Sequence[pydantic.SerializeAsAny[_types.DataModel]]
    columns: _t.Union[_t.List[display.DisplayLookup], None] = None
    data_model: _t.Union[_t.Type[pydantic.BaseModel], None] = pydantic.Field(default=None, exclude=True)

from this version:

class Table(pydantic.BaseModel, _t.Generic[DataModel], extra='forbid'):
    data: _t.List[DataModel]
    columns: _t.Union[_t.List[display.DisplayLookup], None] = None

The modification means that Table does not inherit from_t.Generic[DataModel] anymore. In the new version there is a new attribute "data_model" introduced. These changes are implemented in the new sample code in README in PR #124

@aekespong aekespong changed the title Sample code in README doesn't work Sample code in README gives error because of a change 3 weeks ago of definition of Table Dec 28, 2023
@AliRn76
Copy link

AliRn76 commented Dec 28, 2023

Yes you are right but the latest version is 0.3.0 and these changes have not been released yet, so maybe we can change the readme after the release of the new version 👍🏽

@hasansezertasan
Copy link
Contributor

@AliRn76 It's merged 😢 and now the README.md example doesn't work with the latest version.

@samuelcolvin
Copy link
Member

This project is a work in progress, code being wrong in readme for a few hours really isn't worth worrying about.

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

4 participants