pyright icon indicating copy to clipboard operation
pyright copied to clipboard

defineConstant not working

Open kidsang opened this issue 4 years ago • 4 comments

Describe the bug Configuration setting "defineConstant" not working. Pyright's reachability analysis dosent seen to be affect by it. image

To Reproduce

  1. Add following setting in pyrightconfig.json
"defineConstant": {
	"DEBUG": false,
}
  1. Add following code in projcect script file
DEBUG = False
if DEBUG:
	a = 1
	print(a)
  1. Pyright still think statments under "if DEBUG:" is rechable (color's not changed).

Expected behavior Statements under "if Debug:" become unreachable.

kidsang avatar Jul 18 '22 14:07 kidsang

Version of Pylance language server is 2022.7.30 image

kidsang avatar Jul 18 '22 14:07 kidsang

I'm able to repro the problem you're seeing with pylance. It didn't show up in any of our internal testing or with our unit tests because it works fine in in debug mode. It appears only in production mode, where we use background threads for processing. This will be fixed in the next release.

erictraut avatar Jul 18 '22 18:07 erictraut

I'm able to repro the problem you're seeing with pylance. It didn't show up in any of our internal testing or with our unit tests because it works fine in in debug mode. It appears only in production mode, where we use background threads for processing. This will be fixed in the next release.

Thx for the reply, cant wait to see it fixed!

kidsang avatar Jul 19 '22 01:07 kidsang

This is addressed in pyright 1.1.262, which I just published. It will also be included in a future version of pylance.

erictraut avatar Jul 20 '22 14:07 erictraut