Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--watch is not working #91

Closed
grigoryvp opened this issue Apr 26, 2019 · 5 comments
Closed

--watch is not working #91

grigoryvp opened this issue Apr 26, 2019 · 5 comments
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working

Comments

@grigoryvp
Copy link
Contributor

If you execute pyright with --watch and a file name, it will not re-check the file.

This is due to the different file path handling. While adding files to the list, files are added as-is, so executing "pyright --watch foo.py" will add "foo.py" into the '_sourceFileMap':

https://github.com/Microsoft/pyright/blob/master/server/src/analyzer/program.ts#L814

But while subscribing to the filesystem watch, file paths are added to the '_executionRootPath':

https://github.com/Microsoft/pyright/blob/master/server/src/analyzer/service.ts#L444

So after the file change event as-is path in the '_sourceFileMap' will be compared to the absolute path concatenated with '_executionRootPath', resulting in file not found in the dict and no re-check. I don't know which file handling, as-is or relative to '_executionRootPath' is assumed to be correct, so I can't make a patch for it :(

@erictraut erictraut added the bug Something isn't working label Apr 26, 2019
@erictraut
Copy link
Collaborator

I'm not able to repro the reported problem. It works fine for me.

The code is not concatenating paths as described above. It's using the method combinePaths, which ignores the first parameter if the second parameter is absolute.

@erictraut
Copy link
Collaborator

If you're still able to repro and have well-defined repro steps, please re-open the bug.

@grigoryvp
Copy link
Contributor Author

grigoryvp commented Apr 28, 2019

Hello. I can't see any way to re-open the bug report, maybe such feature is disabled for me. Reproduction steps on my MacBook with latest OSX:

echo "def foo(bar: int): pass; foo('bar')" > foo.py
npx pyright --watch foo.py &
echo "def foo(bar: int): pass; foo('bar')" > foo.py

Changes are not detected. As you mentioned 'combinePaths' logic, if I change file path to be absolute, it will detect the change. But normally command-line tools are executed with something like "*.py" as a file spec, which is not absolute:

echo "def foo(bar: int): pass; foo('bar')" > foo.py
npx pyright --watch $(pwd)/foo.py &
echo "def foo(bar: int): pass; foo('bar')" > foo.py

@erictraut erictraut reopened this Apr 28, 2019
@erictraut
Copy link
Collaborator

Thanks for the additional details. Yes, I was testing it with absolute paths. I've added code that converts all relative paths to full paths (relative to the current working directory), and it's working now.

Thanks for the bug report.

erictraut pushed a commit that referenced this issue Apr 28, 2019
@erictraut erictraut added the addressed in next version Issue is fixed and will appear in next published version label Apr 28, 2019
@erictraut
Copy link
Collaborator

This is now fixed in 1.0.20, which I just published.

heejaechang added a commit to heejaechang/pyright that referenced this issue Feb 11, 2020
* fixed root directory issues broke by my previous refactoring.

added comments to show differences between pyrx and pyright on directory structures.
heejaechang added a commit to heejaechang/pyright that referenced this issue Nov 3, 2021
* fixed root directory issues broke by my previous refactoring.

added comments to show differences between pyrx and pyright on directory structures.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants