-
Notifications
You must be signed in to change notification settings - Fork 30
Baseline snapshot test failures on macOS #91
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
Comments
Hi @varungandhi-src, We are taking a look at this issue to get However, there are some things that are unclear even in the expected test outputs.
Rather than
at line https://github.com/sourcegraph/scip-python/blob/scip/packages/pyright-scip/snapshots/output/nested_items/src/importer.py#L5C13-L5C13 in the expected output? I would expect a full identifier given that we resolve in Reproducing the macOs errorThe macOs error is easily reproduced, and we have pushed the output to https://github.com/Titou325/scip-python/blob/fix-91/packages/pyright-scip/snapshots/output/nested_item__macos/src/importer.py Deep diveTo get the test suite coherent on macOs (but it may be erroneous on other platforms?) we need to switch the Here are the things that we have noted: Incoherent init.py resolution for subfoldersOn macOs and given the current test input snapshots, the output leaves each and every
regardless of their position in the file tree. The only
Correct resolution if we remove the importsWhen we remove importer.py and long_importer.py, the
Correct resolution given relative import paths, wrong importIf we replace the imports contained in the There is still an issue with the imported reference, I.E. from .foo.bar import InitClass
# ^^^^^^^^ reference snapshot-util 0.1 `foo.bar`/__init__:
# ^^^^^^^^^ reference snapshot-util 0.1 `src.foo.bar`/InitClass# We would expect (note the from .foo.bar import InitClass
# ^^^^^^^^ reference snapshot-util 0.1 `src.foo.bar`/__init__:
# ^^^^^^^^^ reference snapshot-util 0.1 `src.foo.bar`/InitClass#
Correct resolution given fully qualified import pathsIf we replace the imports contained in the The imports are also correctly qualified (NB: however this still doesn't match the expected snapshot output due to from src.foo.bar import InitClass
# ^^^^^^^^^^^ reference snapshot-util 0.1 `src.foo.bar`/__init__:
# ^^^^^^^^^ reference snapshot-util 0.1 `src.foo.bar`/InitClass#
Moving forwardWith that out of the way, it seems that the relative imports are not properly resolving to the root namespace and would be the cause of this issue? Thanks for the hard work and sorry for such a long read! |
It seems to affect any relative imports, as also seen in the very simple demo at https://github.com/Titou325/scip-python/blob/fix-91/packages/pyright-scip/snapshots/output/relative_import_nested/src/bar.py From what I can tell, the For example, this: # Current module is src, package is snapshot-utils
from .foo.bar import Something Pyright will pass A possible workaround for relative imports is to fetch back the current module name to resolve the relative import, with something similar to (pseudo-code): resolveRelative(this.fileInfo!.moduleName as string, node.nameParts as string[]) as string;
resolveRelative("src.importer", ["foo", "bar", "mod"]); // src.foo.bar.mod Which doesn't seem like the best thing to do. For "absolute-relative" imports, there is no way to detect that the node nameParts need to be requalified other than fetching the module name of the destination file. I'm keen on hearing your inputs on this and if anything has already been considered regarding this issue. Have a nice day! |
Thanks for your diligence here, and apologies for not responding sooner.
I agree with your assessment, that seems like a bug. I've filed a new issue here: #133
I looked into this briefly. I suspect it's probably a bug in Pyright itself (or at least, an inconsistency across platforms, not technically a bug if it isn't affecting user-facing behavior in Pyright). I'm assuming Pyright isn't relying on the exact strings that we're relying on in its own cross-platform tests, causing this divergence. One potential way debug this would be to:
I think there are at least two different problems here:
This GitHub issue is about problem 2. I'm not 100% sure, but if I understand correctly, your second comment is describing part of the cause behind problem 1. Is that correct? If so, could you file a new issue for it (if it's not covered by #133) or mention it in #133? Let's keep this GitHub issue scoped to cross-platform differences, not to whether the output is correct or not. |
Hi @varungandhi-src, thanks for circling back on this. #133 indeed covers the seemingly only issue that affects all platforms. For the scope of #91, the question really boils down to why aren't imported members correctly qualified, if qualified at all, on macOS.
I think resolution of #133 may collaterally fix #91, but can't really be sure at this time, hence the report on this thread. I will focus on #133 for now. |
I have spent quite some time this afternoon debugging the existing code, and the root cause seems to be a wrong Here is a debugger screenshot, macOS runner on the left, Debian on the right. ![]() This comes from Thanks |
Yep, I got this far too, and I attempted to update the sync the changes from upstream earlier in an attempt to fix that. However, merging the changes didn't turn out to be as simple (I've pushed the status I had, with some unfixed merge conflicts in this PR: #137) Given the challenge there, my first instinct was to attempt to verify if this problem has been fixed upstream or not (and only go through the effort for fixing the merge conflicts if it was fixed). However, there doesn't seem to be any easy CLI flag to extract the AST with module names to verify if this was fixed. So I was going to add some extra logging to base Pyright to check if there was a difference in behavior between the one we're on vs latest. But I didn't have the time to figure out which parts of the code to instrument before I switched to focus on another project. If you have the time to look into merging the changes from upstream (regardless of whether that fixes the test issues or not), I'd be happy to review a PR. Even if the latest version of upstream still has this issue, submitting a patch upstream (and switching to that in scip-python) will be easier if we have already synced all the other recent changes. |
This reverts commit 514bf16.
This reverts commit 805a253.
Digged a bit further, it seems to all boil down to path casing. If the import cannot be found in strict resolution (not relative nor absolute, which is our case where we import without leading dot although it is not the fully qualified path), This seems to have been changed upstream to I have added a quick (dirty) patch for this, but merging the upstream would be good. I am short on time now, but I will take a look at the merges. |
Thanks for digging! It might just make sense to abandon my PR and attempt to merge the latest changes directly. I'd tried that merge a while back (Aug 22 is the commit date). I just put it up to show that there were some non-trivial merge conflicts due to code changes. |
When running
npm run check-snapshots
on macOS off 0834d92, I get the following failure:This is not reproducing on Ubuntu.
The text was updated successfully, but these errors were encountered: