basedpyright icon indicating copy to clipboard operation
basedpyright copied to clipboard

hover/inlay hint for functions that return `Never` is `NoReturn`

Open DetachHead opened this issue 1 year ago • 1 comments

image

it should be Never instead because NoReturn is deprecated (#356)

DetachHead avatar May 13 '24 05:05 DetachHead

looks like the code that does this is here

DetachHead avatar Sep 22 '24 04:09 DetachHead

May i take this issue? @DetachHead

peacewalker122 avatar Nov 19 '24 08:11 peacewalker122

sure, thanks!

DetachHead avatar Nov 19 '24 09:11 DetachHead

Hi @DetachHead. I've a few problems related to testing this project, since I'm not really familiar with js/ts environment and found difficulties with building the project and testing, I tried few commands in package.json that may related like run:cli:unix to run the project in cli, but still not able to run the cli. Also I ran npx tsc and run the pyright.js in ./out/basedpyright/dist and I found a bunch of error & warning messages. Would you guide me for this problem? Thanks in advance.

peacewalker122 avatar Nov 20 '24 06:11 peacewalker122

what error messages are you seeing exactly?

this project is set up in such a way that you don't have to manually install node or anything like that. this project is managed with uv and pyprojectx, so it's built the same way as many other python projects. see the contributing docs for more info

once everything is installed and your venv is activated, you should be able to run those npm scripts. let me know if you're still having issues and i'll try to help out

DetachHead avatar Nov 20 '24 07:11 DetachHead

what error messages are you seeing exactly?

from this command: node ./out/basedpyright/dist/pyright.js which is the result from npx tsc

...
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3131:34 - error: "type" is not defined (reportUndefinedVariable)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3131:46 - error: Expected class but received "_alias" (reportGeneralTypeIssues)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3131:63 - error: "str" is not defined (reportUndefinedVariable)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3145:28 - warning: Argument type is unknown
    Argument corresponds to parameter "tp" in function "is_protocol" (reportUnknownArgumentType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3146:19 - error: "TypeError" is not defined (reportUndefinedVariable)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3147:12 - error: "hasattr" is not defined (reportUndefinedVariable)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3148:20 - error: "frozenset" is not defined (reportUndefinedVariable)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3148:20 - warning: Return type is unknown (reportUnknownVariableType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3148:30 - warning: Type of "__protocol_attrs__" is unknown (reportUnknownMemberType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3149:16 - error: "frozenset" is not defined (reportUndefinedVariable)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3149:16 - warning: Return type is unknown (reportUnknownVariableType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3149:46 - warning: Argument type is unknown
    Argument corresponds to parameter "cls" in function "_get_protocol_attrs" (reportUnknownArgumentType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3152:4 - error: "hasattr" is not defined (reportUndefinedVariable)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3153:5 - warning: Type of "Doc" is partially unknown
    Type of "Doc" is "Unknown | type[Doc]" (reportUnknownVariableType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3153:11 - warning: Type of "Doc" is unknown (reportUnknownMemberType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3153:18 - error: "Doc" is not a known attribute of module "typing" (reportAttributeAccessIssue)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3172:13 - error: Method "__init__" does not call the method of the same name in parent class (reportMissingSuperCall)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3172:13 - warning: Return type is unknown (reportUnknownParameterType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3172:28 - warning: Type of parameter "documentation" is unknown (reportUnknownParameterType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3172:43 - error: "str" is not defined (reportUndefinedVariable)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3172:54 - error: Return type of "__init__" must be None (reportGeneralTypeIssues)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3173:13 - warning: Type of "documentation" is unknown (reportUnknownMemberType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3173:18 - warning: Type annotation for attribute `documentation` is required because this class is not decorated with `@final` (reportUnannotatedClassAttribute)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3175:13 - warning: Return type is unknown (reportUnknownParameterType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3175:31 - error: "str" is not defined (reportUndefinedVariable)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3176:20 - warning: Return type is unknown (reportUnknownVariableType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3176:27 - warning: Type of "documentation" is unknown (reportUnknownMemberType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3178:13 - warning: Return type is unknown (reportUnknownParameterType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3178:31 - error: "int" is not defined (reportUndefinedVariable)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3179:20 - error: "hash" is not defined (reportUndefinedVariable)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3179:20 - warning: Return type is unknown (reportUnknownVariableType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3179:25 - warning: Type of "documentation" is unknown (reportUnknownMemberType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3181:13 - warning: Return type is unknown (reportUnknownParameterType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3181:26 - warning: Type of parameter "other" is unknown (reportUnknownParameterType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3181:33 - error: "object" is not defined (reportUndefinedVariable)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3181:44 - error: "bool" is not defined (reportUndefinedVariable)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3182:20 - error: "isinstance" is not defined (reportUndefinedVariable)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3183:24 - error: "NotImplemented" is not defined (reportUndefinedVariable)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3183:24 - warning: Return type is unknown (reportUnknownVariableType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3184:20 - warning: Type of "documentation" is unknown (reportUnknownMemberType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3184:20 - warning: Return type is unknown (reportUnknownVariableType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3184:42 - warning: Type of "documentation" is unknown (reportUnknownMemberType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3225:1 - warning: Type of "cast" is partially unknown
    Type of "cast" is "(typ: Unknown, val: Unknown) -> Unknown" (reportUnknownVariableType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3225:8 - warning: Type of "cast" is partially unknown
    Type of "cast" is "(typ: Unknown, val: Unknown) -> Unknown" (reportUnknownMemberType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3226:1 - warning: Type of "no_type_check" is partially unknown
    Type of "no_type_check" is "(arg: Unknown) -> Unknown" (reportUnknownVariableType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3226:17 - warning: Type of "no_type_check" is partially unknown
    Type of "no_type_check" is "(arg: Unknown) -> Unknown" (reportUnknownMemberType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3227:1 - warning: Type of "no_type_check_decorator" is partially unknown
    Type of "no_type_check_decorator" is "(decorator: Unknown) -> ((...) -> Unknown)" (reportUnknownVariableType)
  /home/danielangrh/.local/lib/python3.10/site-packages/typing_extensions.py:3227:27 - warning: Type of "no_type_check_decorator" is partially unknown
    Type of "no_type_check_decorator" is "(decorator: Unknown) -> ((...) -> Unknown)" (reportUnknownMemberType)
1086 errors, 4089 warnings, 0 notes

once everything is installed and your venv is activated, you should be able to run those npm scripts. let me know if you're still having issues and i'll try to help out

Yes, I'm able to run the npm scripts, but I'm confused to build the code, i tried few command like npm run run:cli:unix but there's no program run on my terminal.

peacewalker122 avatar Nov 20 '24 08:11 peacewalker122

the run:cli:unix and run:cli:windows scripts compile and run the basedpyright cli. to run it on a specific file, you can run npm run run:cli:unix -- some_file.py

im not sure why it seems to be reporting errors in your site-packages directory though. make sure your venv is activated before running it?

DetachHead avatar Nov 20 '24 08:11 DetachHead

im not sure why it seems to be reporting errors in your site-packages directory though. make sure your venv is activated before running it?

Yes i can assure you it's already activated.

btw is this command npm run run:cli:unix -- some_file.py used for the lsp?

peacewalker122 avatar Nov 21 '24 09:11 peacewalker122

Yes i can assure you it's already activated.

you wouldn't happen to have your venv in a different location? the run:cli:unix scripts passes --pythonpath .venv/bin/python so if your venv isn't located in the project root you will have to change that

btw is this command npm run run:cli:unix -- some_file.py used for the lsp?

nah that's the basedpyright cli. to test the language server (basedpyright-langserver) the easiest way to do so is to use vscode and run the "Pyright extension" debug config:

image

this will launch a separate instance of vscode with the basedpyright extension installed.

if you want to run the language server without vscode, you can run npm run build:cli:dev && node ./packages/pyright/langserver.index.js -- --stdio though i personally don't do this so i can't guarantee you won't encounter issues with it.

DetachHead avatar Nov 21 '24 10:11 DetachHead

fixed in #895

DetachHead avatar Jan 30 '25 08:01 DetachHead