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

Reify object based on base type #22

Merged

Conversation

AlexanderGrooff
Copy link
Contributor

The currect assumption that object can be used to create a new object
is not always valid. One example is the issue I'm currently facing:

>>> reify(ast.Num(n=var('x')), {var('x'): 123})
...
     55 def _reify_object_dict(o, s):
---> 56     obj = object.__new__(type(o))
     57
     58     d = yield _reify(o.__dict__, s)

TypeError: object.__new__(Num) is not safe, use Num.__new__()

@brandonwillard
Copy link
Member

Looks like we need to set up GitHub Actions for this repo now.

@brandonwillard
Copy link
Member

All right, I just merged the CI changes. Rebase and the tests should register correctly. You'll need to install the new pre-commit hooks (i.e. pip install -r requirements.txt; pre-commit install), and those will likely require some new formatting changes (e.g. isort).

The currect assumption that `object` can be used to create a new object
is not always valid. One example is the issue I'm currently facing:
```
>>> reify(ast.Num(n=var('x')), {var('x'): 123})
...
     55 def _reify_object_dict(o, s):
---> 56     obj = object.__new__(type(o))
     57
     58     d = yield _reify(o.__dict__, s)

TypeError: object.__new__(Num) is not safe, use Num.__new__()
```
@AlexanderGrooff
Copy link
Contributor Author

AlexanderGrooff commented Jan 9, 2021

Hey @brandonwillard, thanks for having a look. I've rebased this PR but it doesn't look like any more linting is required.

I've added an extra commit to better reflect the changes made in the first commit.

Change from the previous commit only affects reifying nonstandard
objects, so this change better reflects the new situation.
Use the base `unify` and `reify` functions to test instead of the
private functions.
@brandonwillard brandonwillard merged commit 9fef36c into pythological:master Jan 9, 2021
@brandonwillard
Copy link
Member

Looks great; thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants