pwwang / datar

A Grammar of Data Manipulation in python

Home Page:https://pwwang.github.io/datar/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[ENH] Enable full compatibility with Pylance

GitHunter0 opened this issue · comments

Feature Type

  • Adding new functionality to datar

  • Changing existing functionality in datar

  • Removing existing functionality in datar

Problem Description

datar documentations are not fully discovered and displayed by Pylance as described in this issue microsoft/pylance-release#4603

Feature Description

For example, being able to hover on glimpse in the MWE below and have the function info and docstring displayed:

import datar.all as d
import pandas as pd
df = pd.DataFrame({'x':[1,2,4]})
d.glimpse(df)

Additional Context

No response

commented

Should be enhanced by v0.13.0

image

However, this still has limitations for the dynamically added functions or objects, for example, additional functions that are added by a backend, and conflict names (python reserved names, i.e. filter). One should use filter_ instead. One could use filter with options(allow_conflict_names=True). However, the IDE will still only have hints for filter_.

Hey @pwwang , this is great, thank you.

Just a couple of points:
When installing datar 0.13., I'm getting:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
datar-pandas 0.3.0 requires datar<0.13,>=0.12, but you have datar 0.13.0 which is incompatible.
datar-numpy 0.2.0 requires datar<0.13,>=0.12, but you have datar 0.13.0 which is incompatible.
Successfully installed datar-0.13.0

Also, when I run this

import datar.all as d
d.filter

I'm getting this error:

AttributeError: module 'datar.all' has no attribute 'filter'

However, d.filter_ runs fine.

python      : 3.10.4 | packaged by conda-forge | (main, Mar 30 2022, 08:38:02) [MSC v.1916 64 bit (AMD64)]
datar       : 0.13.0
simplug     : 0.3.2
executing   : 1.2.0
pipda       : 0.12.0
datar-numpy : 0.2.0
numpy       : 1.23.1
datar-pandas: 0.3.0
pandas      : 1.4.3
commented

Need to upgrade the backends as well.

d.filter to raise an error is by design, see: https://pwwang.github.io/datar/options/#allow_conflict_names

commented

The backends are now upgraded.

d.filter to raise an error is by design, see: https://pwwang.github.io/datar/options/#allow_conflict_names

Yes @pwwang , but if I'm importing datar as d and using filter as a function from source d like d.filter(), there should be no conflict of names at all, right?
In this situation, options(allow_conflict_names=True) should not be necessary, don't you agree?

commented

Done with v0.13.1.

Note that d.filter still doesn't have IDE hints, as it's added dynamically.

Note that d.filter still doesn't have IDE hints, as it's added dynamically.

It's a pity, I hope Pylance gets dynamic support some day, many packages suffer from that same issue...

Done with v0.13.1.

Thank you

commented

That's the best we can do. It's (almost) impossible to do it dynamically because that requires us to run the whole code, which will bring uncontrollable side effects.

I understand and I appreciate the feedback, that's why I hope Pylance gets smarter.