Skip to content

Typetype clean #660

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

Merged
merged 3 commits into from
Mar 11, 2019
Merged

Typetype clean #660

merged 3 commits into from
Mar 11, 2019

Conversation

cthulahoops
Copy link
Collaborator

No description provided.

@codecov-io
Copy link

codecov-io commented Mar 11, 2019

Codecov Report

Merging #660 into master will decrease coverage by 0.05%.
The diff coverage is 55.84%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #660      +/-   ##
=========================================
- Coverage   40.75%   40.7%   -0.06%     
=========================================
  Files          77      77              
  Lines       17402   17410       +8     
  Branches     4528    4522       -6     
=========================================
- Hits         7093    7087       -6     
- Misses       8409    8429      +20     
+ Partials     1900    1894       -6
Impacted Files Coverage Δ
vm/src/pyobject.rs 57.61% <44.44%> (+0.39%) ⬆️
vm/src/obj/objtype.rs 39.93% <55.73%> (-1%) ⬇️
vm/src/obj/objobject.rs 39.72% <71.42%> (-4.93%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3d306fc...633a9b0. Read the comment docs.

@@ -1548,6 +1551,19 @@ pub trait PyValue: Any + fmt::Debug {
fn required_type(ctx: &PyContext) -> PyObjectRef;
}

impl FromPyObjectRef for PyRef<PyClass> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I was planning on deleting FromPyObjectRef since it overlaps considerably with TryFromObject - could you use the latter instead? Should be more or less the same, just with the unwrap/panic on the caller instead (which we will eventually be able to get rid of).

Copy link
Member

Choose a reason for hiding this comment

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

Get rid of by using !?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, from the trait's perspective, it can fail. I was referring to the fact that the mro could be a Vec of PyClassRef rather than PyObjectRef so that no downcasting is necessary.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought this might be the controversial bit.

I tried with TryFromObject but it required me to pass the VirtualMachine into a bunch of code that doesn't currently have a VM. The panic should never happen as an object's type should always be a type. I'd be happy with an interface that doesn't require VM but gives me an option/result to deal with?

Will I pass the VM through?

I suppose the alternative would be to make PyObject.typ a PyClassRef, but that's a pretty invasive change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I forget it takes a vm - we can work this out later then.

I'd be happy with an interface that doesn't require VM but gives me an option/result to deal with?

This will exist soon! (PyObjectRef::downcast in my prototype)

I suppose the alternative would be to make PyObject.typ a PyClassRef, but that's a pretty invasive change.

It is but I definitely think we should do this at some point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, I'll merge. Once we have PyClassRef everywhere this will go away anyway.

@cthulahoops cthulahoops merged commit 8ec1af5 into master Mar 11, 2019
@cthulahoops cthulahoops deleted the typetype_clean branch April 9, 2019 19:53
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.

6 participants