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

Improve handling of circular and imported class bases #1497

merged 13 commits into from Sep 3, 2019


Copy link

commented Aug 30, 2019

Fixes #1495

  • Since we don't handle reassignments, improve handling of imported bases like
from Base import A, B

class A(A, B):
    def methodA(self, x):
        return x

class C(B): ...

class B(A):
    def methodB(self, x):
        return x

by declaring imported variables in regular collection as well as in special imported collection so they can be found when we need to resolve class base.

  • Decide on declaration or import depending on location
  • Implement deep filtering of circular base chains
  • Tests
Copy link

left a comment

if all the tests pass then looks fine, tests should handle majority of cases. Make sure to start VS Code as well just in case the multithreading issues come back

@@ -47,14 +47,23 @@ public void DeclareVariable(string name, IMember value, VariableSource source, N
=> DeclareVariable(name, value, source, GetLocationOfName(location), overwrite);

public void DeclareVariable(string name, IMember value, VariableSource source, Location location, bool overwrite = true) {
if (source == VariableSource.Import) {
// Duplicate declaration so if variable gets overwritten it can still be retrieved. Consider:
// from X import A

This comment has been minimized.

Copy link

CTrando Sep 3, 2019


Maybe update the comment now that it loses its old context:
Store declaration source so in case if variable gets overwritten...

@@ -60,23 +61,19 @@ internal partial class PythonClassType {
/// </summary>
public IPythonType CreateSpecificType(IArgumentSet args) {
lock (_genericParameterLock) {
var genericTypeParameters = GetTypeParameters();
var newGenericTypeParameters = GetTypeParameters();

This comment has been minimized.

Copy link

CTrando Sep 3, 2019


newGenericTypeParameters is not entirely accurate because GetTypeParameters just gets the parameters that need to be filled in for this class

Copy link

left a comment

LGTM, passes and VS Code works on my test projects, Cameron's command/variable naming feedback notwithstanding.

@MikhailArkhipov MikhailArkhipov merged commit 51ccb26 into master Sep 3, 2019

1 check passed

license/cla All CLA requirements met.

@MikhailArkhipov MikhailArkhipov deleted the 1495 branch Sep 3, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
4 participants
You can’t perform that action at this time.