Skip to content
This repository has been archived by the owner on Apr 14, 2022. It is now read-only.

Handle named tuples #339

Merged
merged 22 commits into from
Nov 5, 2018
Merged

Handle named tuples #339

merged 22 commits into from
Nov 5, 2018

Conversation

MikhailArkhipov
Copy link

@MikhailArkhipov MikhailArkhipov commented Nov 2, 2018

Fixes #15

  • Requires Fix processing of forward references #304 so it is included here
  • Adds handling of generic Type[T] from typing to typeinfo and the AST analysis
  • Adds handling of namedtuple from collections via typeshed annotations
  • Adds fetching of tuple members and handling assignment of tuple to sequence
  • Adds specific 'class' flag to the Python type telling that function returns class rather than instance and hence calling it creates instance of the class rather than invoking on instance.
  • Filters function overloads preferring annotated definitions to plain ones
  • Relevant tests

Implement wrapper over tuple so we can expose declared members in completion - separate item in #343

}

[TestMethod, Priority(0)]
public async Task AstForwardRefFunction2() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be a parameterized test.

=> klass.Contains(ProjectState.ClassInfos[BuiltinTypeId.Function]) || klass.Contains(ProjectState.ClassInfos[BuiltinTypeId.BuiltinFunction]);

public override IAnalysisSet Call(Node node, AnalysisUnit unit, IAnalysisSet[] args, NameExpression[] keywordArgNames) {
var returnTypes = GetFunctionOverloads().Where(o => o.ReturnType != null).SelectMany(o => o.ReturnType);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need .Distinct() here?

Use builtin types from interpreter
@@ -140,8 +135,7 @@ public static class AnalysisValueSetExtensions {
/// Performs a delete index operation propagating the index types into
/// the provided object.
/// </summary>
public static void DeleteIndex(this IAnalysisSet self, Node node, AnalysisUnit unit, IAnalysisSet index) {
}
public static void DeleteIndex(this IAnalysisSet self, Node node, AnalysisUnit unit, IAnalysisSet index) { }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty static method?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently it is called from DDG... Let's leave this alone until we decide fate of the DDG.

@MikhailArkhipov MikhailArkhipov merged commit d3c895d into microsoft:master Nov 5, 2018
@MikhailArkhipov MikhailArkhipov deleted the 15-2 branch November 5, 2018 20:35
jakebailey pushed a commit to jakebailey/python-language-server that referenced this pull request Nov 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants