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

Context builder does not recognize field inits in python constructors #311

Open
JSAbrahams opened this issue May 27, 2022 · 0 comments
Open
Labels
bug: check Something in the type check module isn't working (as intended)

Comments

@JSAbrahams
Copy link
Owner

JSAbrahams commented May 27, 2022

Description of Bug

Context builder does not recognize field inits in python constructors.

How to Reproduce

Build context from following class written in Python:

class MyClass:
    def __init__(self, a: int):
        self.a = a

Expected behavior

It should produce a context with MyClass which has one field a: Int.
However, the class has no such field.

Additional context

We should traverse the constructor and make not of all assignments to self.

@JSAbrahams JSAbrahams added the bug: check Something in the type check module isn't working (as intended) label May 27, 2022
@JSAbrahams JSAbrahams added this to Needs triage in Fixing Language Bugs via automation May 27, 2022
@JSAbrahams JSAbrahams added this to To do in Implementing Language Features via automation May 27, 2022
JSAbrahams added a commit that referenced this issue May 27, 2022
JSAbrahams added a commit that referenced this issue May 28, 2022
* Don't include Python init in GenericClassDef

- Made note of #311

* Don't include Python init in GenericClassDef

- Made note of #314
- Made note of #315
- Made note of #316
- Made note of #317
- Made note of #318

* Check that typed assign with expr does have type

- Made note of #319

* Test functionality of class from AST

- Type definition (and aliases) have self argument
- Make self in class have class as type
- Remove args from GenericParent, it doesn't do
  anything.
- Function arguments from python source is
  mutable.

The application logic in class from AST is
currently very convoluted.
Could use a rewrite.

* Test that py and mamba class can have generics

TrueName now takes generic arguments from type.

Now context also stores class generics from Mamba
classes. It may very well be that this explains
some weird behaviour we had around generics (in
that they didn't work in most cases).

In a future release we should test this further
since I'm sure there are some cases we've missed.

- Made note of #320

* Add optional to Name in generate

Always print out generics in alphabetical order.
This ensures that the output is easy to predict,
we are not dependent on the whims of the iterator
over the set, possibly preventing flaky tests.

Make annotating output the default in tests as
well. As we start to implement new features and
debug the checking stage we should then
automatically see old tests failing as well.

* Make sorting of generics case-insensitive

Add new description to README

* Verify current unknown generic parent behaviour

Currently, no check is done that a parent generic
exists until the class is actually used.
Perhaps in future this behaviour should be
changed, however.
JSAbrahams added a commit that referenced this issue May 28, 2022
JSAbrahams added a commit that referenced this issue Jun 7, 2022
* Don't include Python init in GenericClassDef

- Made note of #311

* Don't include Python init in GenericClassDef

- Made note of #314
- Made note of #315
- Made note of #316
- Made note of #317
- Made note of #318

* Check that typed assign with expr does have type

- Made note of #319

* Test functionality of class from AST

- Type definition (and aliases) have self argument
- Make self in class have class as type
- Remove args from GenericParent, it doesn't do
  anything.
- Function arguments from python source is
  mutable.

The application logic in class from AST is
currently very convoluted.
Could use a rewrite.

* Test that py and mamba class can have generics

TrueName now takes generic arguments from type.

Now context also stores class generics from Mamba
classes. It may very well be that this explains
some weird behaviour we had around generics (in
that they didn't work in most cases).

In a future release we should test this further
since I'm sure there are some cases we've missed.

- Made note of #320

* Add optional to Name in generate

Always print out generics in alphabetical order.
This ensures that the output is easy to predict,
we are not dependent on the whims of the iterator
over the set, possibly preventing flaky tests.

Make annotating output the default in tests as
well. As we start to implement new features and
debug the checking stage we should then
automatically see old tests failing as well.

* Make sorting of generics case-insensitive

Add new description to README

* Verify current unknown generic parent behaviour

Currently, no check is done that a parent generic
exists until the class is actually used.
Perhaps in future this behaviour should be
changed, however.
JSAbrahams added a commit that referenced this issue Jun 7, 2022
* Don't include Python init in GenericClassDef

- Made note of #311

* Don't include Python init in GenericClassDef

- Made note of #314
- Made note of #315
- Made note of #316
- Made note of #317
- Made note of #318

* Check that typed assign with expr does have type

- Made note of #319

* Test functionality of class from AST

- Type definition (and aliases) have self argument
- Make self in class have class as type
- Remove args from GenericParent, it doesn't do
  anything.
- Function arguments from python source is
  mutable.

The application logic in class from AST is
currently very convoluted.
Could use a rewrite.

* Test that py and mamba class can have generics

TrueName now takes generic arguments from type.

Now context also stores class generics from Mamba
classes. It may very well be that this explains
some weird behaviour we had around generics (in
that they didn't work in most cases).

In a future release we should test this further
since I'm sure there are some cases we've missed.

- Made note of #320

* Add optional to Name in generate

Always print out generics in alphabetical order.
This ensures that the output is easy to predict,
we are not dependent on the whims of the iterator
over the set, possibly preventing flaky tests.

Make annotating output the default in tests as
well. As we start to implement new features and
debug the checking stage we should then
automatically see old tests failing as well.

* Make sorting of generics case-insensitive

Add new description to README

* Verify current unknown generic parent behaviour

Currently, no check is done that a parent generic
exists until the class is actually used.
Perhaps in future this behaviour should be
changed, however.
JSAbrahams added a commit that referenced this issue Jun 8, 2022
* Don't include Python init in GenericClassDef

- Made note of #311

* Don't include Python init in GenericClassDef

- Made note of #314
- Made note of #315
- Made note of #316
- Made note of #317
- Made note of #318

* Check that typed assign with expr does have type

- Made note of #319

* Test functionality of class from AST

- Type definition (and aliases) have self argument
- Make self in class have class as type
- Remove args from GenericParent, it doesn't do
  anything.
- Function arguments from python source is
  mutable.

The application logic in class from AST is
currently very convoluted.
Could use a rewrite.

* Test that py and mamba class can have generics

TrueName now takes generic arguments from type.

Now context also stores class generics from Mamba
classes. It may very well be that this explains
some weird behaviour we had around generics (in
that they didn't work in most cases).

In a future release we should test this further
since I'm sure there are some cases we've missed.

- Made note of #320

* Add optional to Name in generate

Always print out generics in alphabetical order.
This ensures that the output is easy to predict,
we are not dependent on the whims of the iterator
over the set, possibly preventing flaky tests.

Make annotating output the default in tests as
well. As we start to implement new features and
debug the checking stage we should then
automatically see old tests failing as well.

* Make sorting of generics case-insensitive

Add new description to README

* Verify current unknown generic parent behaviour

Currently, no check is done that a parent generic
exists until the class is actually used.
Perhaps in future this behaviour should be
changed, however.
@JSAbrahams JSAbrahams mentioned this issue Jun 17, 2022
Merged
@JSAbrahams JSAbrahams added this to the v0.5 | Import management milestone Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: check Something in the type check module isn't working (as intended)
Projects
No open projects
Development

No branches or pull requests

1 participant