Repository navigation
Bug and test fixes - #1322
Bug and test fixes#1322
Conversation
- Fixes microsoft#1151: Reliable way to determine final analysis of a module - Fixes microsoft#1201: NRE in SymbolCollector.AddProperty - Fixes microsoft#1228: NRE in TryFindMissingDependencies - Fixes microsoft#1294: Handle valid case for reloading AST - Fixes microsoft#1295: FindReferences doesn't work on package init members - Fixes microsoft#1296: DependencyResolver graph misses intermediate imports - Part of the fix for microsoft#1174: All references are not listed when using ms language server
- Fix microsoft#1318: PathUtils.IsNormalizedPath and PathUtils.NormalizePath work incorrectly with UNC - Fix microsoft#1320: Incorrect relative import handling in Python 2x - Fix microsoft#1321: If one user paths is part of the name of another, PathResolverSnapshot is built incorrectly - Fix paths in tests - Remove IModuleManagement.SetUserSearchPaths
|
|
||
| public static bool PathStartsWith(string s, string prefix) | ||
| => s != null && s.StartsWith(prefix, StringExtensions.PathsStringComparison) && | ||
| (s.Length == prefix.Length || IsDirectorySeparator(s[prefix.Length])); |
| private void LogCompleted(IDependencyChainNode<PythonAnalyzerEntry> node, IPythonModule module, Stopwatch stopWatch, TimeSpan startTime) { | ||
| if (_log != null) { | ||
| var completed = node != null && module.Analysis is LibraryAnalysis ? "completed" : "completed for library"; | ||
| var completed = node != null && module.Analysis is LibraryAnalysis ? "completed for library" : "completed "; |
There was a problem hiding this comment.
Correct logging
| } else if (firstModule != default && !string.IsNullOrEmpty(importNames[0])) { | ||
| var firstName = moduleImportExpression.Names[0]; | ||
| Eval.DeclareVariable(importNames[0], variableModule, VariableSource.Import, firstName); | ||
| Eval.DeclareVariable(importNames[0], firstModule, VariableSource.Import, firstName); |
There was a problem hiding this comment.
This is part of the fix for #1320. Name of the module may not match the name of the variable in Python 2x
|
|
||
| // If __all__ is present, take it, otherwise declare all members from the module that do not begin with an underscore. | ||
| var memberNames = variableModule.Analysis.StarImportMemberNames ?? variableModule.GetMemberNames().Where(s => !s.StartsWithOrdinal("_")); | ||
| var memberNames = variableModule.Analysis?.StarImportMemberNames ?? variableModule.GetMemberNames().Where(s => !s.StartsWithOrdinal("_")); |
There was a problem hiding this comment.
If variableModule represents implicit package, Analysis will be null.
There was a problem hiding this comment.
Kinda dangerous... Maybe have it attach empty analysis?
There was a problem hiding this comment.
Empty analysis requires IDocument but there is actually no document - it is an implicit package.
|
|
||
| // If __all__ is present, take it, otherwise declare all members from the module that do not begin with an underscore. | ||
| var memberNames = variableModule.Analysis.StarImportMemberNames ?? variableModule.GetMemberNames().Where(s => !s.StartsWithOrdinal("_")); | ||
| var memberNames = variableModule.Analysis?.StarImportMemberNames ?? variableModule.GetMemberNames().Where(s => !s.StartsWithOrdinal("_")); |
There was a problem hiding this comment.
Should module have at least empty analysis always? I think there is a lot of code that assumes that.
| return "\"{0}\"".FormatInvariant(arg); | ||
| } | ||
|
|
||
| public static bool PathStartsWith(this string s, string prefix) |
There was a problem hiding this comment.
Should we have it instead calling PathUtils.PathStartsWith ?
There was a problem hiding this comment.
We have a bit of a mess in our extensions. From my understanding, StringExtensions should have things that are applicable to any strings, PathUtils should have string operations that are related to paths only, and FileSystemExtensions should have things like FindFile.
- Fix microsoft#1314: NRE in HandleModuleImportStar bug - Fix microsoft#1318: PathUtils.IsNormalizedPath and PathUtils.NormalizePath work incorrectly with UNC - Fix microsoft#1320: Incorrect relative import handling in Python 2x - Fix microsoft#1321: If one user paths is part of the name of another, PathResolverSnapshot is built incorrectly - Fix paths in tests - Remove IModuleManagement.SetUserSearchPaths
IModuleManagement.SetUserSearchPaths