DetachHead / basedpyright

pyright fork with various type checking improvements, improved vscode support and pylance features built into the language server
http://docs.basedpyright.com/
Other
601 stars 12 forks source link

docstrings for compiled builtin modules #420

Closed DetachHead closed 2 weeks ago

DetachHead commented 2 weeks ago

fixes #160

a few things we need to address before merging tho:

github-actions[bot] commented 2 weeks ago

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

github-actions[bot] commented 2 weeks ago

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

github-actions[bot] commented 2 weeks ago

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

github-actions[bot] commented 2 weeks ago

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

github-actions[bot] commented 2 weeks ago

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

github-actions[bot] commented 2 weeks ago

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

github-actions[bot] commented 2 weeks ago

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

AThePeanut4 commented 2 weeks ago

@DetachHead python 3.8 has a few other minor issues besides just the libcst version, I've pushed a fix to support 3.8 fully. I think you missed 3.8 in based_build/generateAllDocstubs.sh.

I've also added a run function that accepts kwargs rather than a list of string arguments, for easier usage when running programmatically.

DetachHead commented 2 weeks ago

oh oops, nice catch. thanks!

fixed in #423

jfcherng commented 2 weeks ago

I think docstrings can be added to the whole stdlib. Current it seems to be only done with builtin.pyi?

DetachHead commented 2 weeks ago

yeah i did that on purpose. i only made it run on compiled builtins because i figured running it on the entire stdlib would unnecessarily make it slower to build and increase the risk of something going wrong. since pyright can already see docstrings from all the other stdlib modules anyway i didn't see the point.

feel free to raise an issue if you disagree. i'm open to changing this behavior in the future if that's what people want

jfcherng commented 2 weeks ago

Ah, got it. We only need it for compiled modules. NVM.

jfcherng commented 2 weeks ago

Ah, got it. We only need it for compiled modules. NVM.

Hmm... doesn't seem to be this case.

import re

if m := re.search('foo', 'foo'):
    aa = m.group()
    #      ^^^^^ no docstring for `group`
>>> import inspect, re; m = re.search('foo', 'foo'); inspect.getdoc(m.group)
'group([group1, ...]) -> str or tuple.\nReturn subgroup(s) of the match by indices or names.\nFor 0 returns the entire match.'

There can a lot of built-in things still implemented in C. So I would still consider that dosctrings should be generated for the whole stdlib typeshed-fallback.

DetachHead commented 2 weeks ago

oh man that's annoying, i didn't know there were modules that are only partially compiled. also it looks like pylance has the same issue

i opened #428 to track this