dash-bootstrap-components icon indicating copy to clipboard operation
dash-bootstrap-components copied to clipboard

Question for `dbc.Table.from_dataframe` definition

Open stdedos opened this issue 3 years ago • 10 comments

Hello there!

I am wondering, why is dbc.Table.from_dataframe declared like this?

https://github.com/facultyai/dash-bootstrap-components/blob/fb8c3c72c50f343f4d0c74164ed61f2c5afc5b2b/dash_bootstrap_components/init.py#L37-L39

It seems to cause some issues on my pylint checking:

sa.py:116:11: E1101: Class 'Table' has no 'from_dataframe' member (no-member)

Is there ... some issue declaring it "normally"? Like

    @classmethod
    def from_dataframe(...): ...

Maybe that would help pylint in identifying it properly.

PS: Not a pylint connoisseur, YMMV since idk if my configuration "makes sense" or not

stdedos avatar Jan 05 '23 14:01 stdedos

Hey @stdedos

Good question. It's because Table is defined and generated from this JavaScript file (this is how Dash components are generated in general). Modifying / intercepting this component generation pipeline is too complicated, so we simply define from_dataframe inside __init__.py. You'll notice that nowhere in the source code do we define class Table.

That's interesting that this causes pylint issues, I hadn't seen this before. Perhaps it could be resolved by dropping the sys.modules[__name__] and simply doing Table.from_dataframe = .... That might help pylint realise that we're modifying the same Table class that you end up using.

tcbegley avatar Jan 05 '23 14:01 tcbegley

I asked the same question un-off on pylint too (https://discord.com/channels/825463413634891776/825463413634891779/1060572384609980446)

stdedos avatar Jan 05 '23 14:01 stdedos

That link doesn't appear to be working for me, but let me know if you get any interesting answers. When I get a moment I'll try implementing the change I mentioned above and see if it resolves the issue.

tcbegley avatar Jan 05 '23 15:01 tcbegley

You first have to join on the Discord community (invitation URL at least on isort's repo)

stdedos avatar Jan 05 '23 15:01 stdedos

You can use the 'generated-members' option to tell pylint about this kind of thing. (Check the documentation for no-member for details). Invite link to the discord server: https://discord.com/invite/Egy6P8AMB5

Pierre-Sassoulas avatar Jan 05 '23 16:01 Pierre-Sassoulas

Oh - so, "library cannot do anything about that"?

It's so sad to have to add exceptions locally 😢

stdedos avatar Jan 05 '23 21:01 stdedos

Thanks for the pointers and the invite @Pierre-Sassoulas! Good to know about generated-members.

@stdedos I just made a pre-release that fixes this issue on our side. It's working locally for me without any additional configuration of Pylint. Please try it out and let me know if you still have issues. All being well this will make it into a full release in the near future.

pip install dash-bootstrap-components==1.3.1rc1

tcbegley avatar Jan 05 '23 21:01 tcbegley

@stdedos I just made a pre-release that fixes this issue on our side. It's working locally for me without any additional configuration of Pylint. Please try it out and let me know if you still have issues. All being well this will make it into a full release in the near future.

pip install dash-bootstrap-components==1.3.1rc1

That's weird that "it fixes it from your side, since I thought that

That's interesting that this causes pylint issues, I hadn't seen this before.

😅

You didn't have to make a full pre-release to test it (I could've just git+https), but it seems it's the correct way forward! So now pylint does not complain anymore 🥳

You can go ahead and release this as a proper minor version, I guess - if you feel that's safe for you to do so.

Thank you both @tcbegley @Pierre-Sassoulas for chiming in 😊

stdedos avatar Jan 06 '23 08:01 stdedos

That's weird that "it fixes it from your side", since I thought that [you hadn't seen this before]

Yes, that's more to do with the fact that I tend to use flake8 for linting rather than Pylint which is less comprehensive in the checks that it does. So I hadn't seen the error because I was using a different tool, not because the error didn't occur on my system.

You can go ahead and release this as a proper minor version, I guess

That's the plan, just a couple of other things I want to include in that too, but will probably make the release in the next couple of days.

tcbegley avatar Jan 06 '23 09:01 tcbegley

FYI: At least the latest version (2025.7.1) of the vscode pylance extension does not find the from_database classmethod as well.

Image

I'm ignoring this error as it caused by the special import situation with the generated dash components.

Zoraiyo avatar Aug 21 '25 13:08 Zoraiyo