Skip to content

Missing dataclasses module #2623

Closed
Closed

Description

@oroppas

Activity

  1. moreal commented on Aug 12, 2021

    @moreal
    Contributor

    This issue is not able to solve until #2869 solved.

    dataclasses module calls inspect._signature_from_callable and it compares __new__ built-in method.
    Though empty class doesn't have additional __new__ method definition but RustPython implementation always bind new bound method for each types.

    References

    pub fn add_slot_wrappers(&self, ty: &PyTypeRef) {
    if !ty.attributes.read().contains_key("__new__") {
    let new_wrapper =
    self.new_bound_method(self.tp_new_wrapper.clone(), ty.clone().into_object());
    ty.set_str_attr("__new__", new_wrapper);
    }
    }

    https://github.com/python/cpython/blob/fa919fdf2583bdfead1df00e842f24f30b2a34bf/Lib/inspect.py#L2367-L2368:

    # _signature_from_callable
                    if (obj.__init__ is object.__init__ and
                        obj.__new__ is object.__new__):
  2. moreal commented on Aug 14, 2021

    @moreal
    Contributor

    Sadly, though #2869 was resolved, it doesn't work because there #2410 is not resolved 😿

    Welcome to the magnificent Rust Python 0.1.2 interpreter 😱 🖖
    >>>>> import dataclasses
    >>>>> @dataclasses.dataclass
    ..... class A:
    .....   s: str
    ..... 
    Traceback (most recent call last):
      File "<stdin>", line 3, in <module>
      File "/home/moreal/github/RustPython/RustPython/vm/pylib-crate/Lib/dataclasses.py", line 1000, in dataclass
        return wrap(cls)
      File "/home/moreal/github/RustPython/RustPython/vm/pylib-crate/Lib/dataclasses.py", line 992, in wrap
        return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
      File "/home/moreal/github/RustPython/RustPython/vm/pylib-crate/Lib/dataclasses.py", line 972, in _process_class
        str(inspect.signature(cls)).replace(' -> None', ''))
      File "/home/moreal/github/RustPython/RustPython/vm/pylib-crate/Lib/inspect.py", line 3093, in signature
        return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
      File "/home/moreal/github/RustPython/RustPython/vm/pylib-crate/Lib/inspect.py", line 2843, in from_callable
        follow_wrapper_chains=follow_wrapped)
      File "/home/moreal/github/RustPython/RustPython/vm/pylib-crate/Lib/inspect.py", line 2370, in _signature_from_callable
        return sigcls.from_callable(object)
      File "/home/moreal/github/RustPython/RustPython/vm/pylib-crate/Lib/inspect.py", line 2843, in from_callable
        follow_wrapper_chains=follow_wrapped)
      File "/home/moreal/github/RustPython/RustPython/vm/pylib-crate/Lib/inspect.py", line 2297, in _signature_from_callable
        skip_bound_arg=skip_bound_arg)
      File "/home/moreal/github/RustPython/RustPython/vm/pylib-crate/Lib/inspect.py", line 2107, in _signature_from_builtin
        raise ValueError("no signature found for builtin {!r}".format(func))
    ValueError: no signature found for builtin <class 'object'>
    >>>>> 
    
  3. moreal commented on Aug 20, 2021

    @moreal
    Contributor

    Though #2410 was resolved by #2904, the new bug #2917, #2918 appeared. I started to work on them.

  4. moreal commented on Aug 22, 2021

    @moreal
    Contributor

    Though #2917 and #2918 seem resolved by #2633 and #2924, a new bug which <KEY> in <TYPE>.__dict__ try to find <KEY> even the base types. I'm trying to fix the bug through #2932.

  5. oroppas commented on Sep 7, 2021

    @oroppas
    Author

    It appears 2c34602 add enough dataclasses support such that we can run basic rich

    image

    This is really awesome! Thank you.

  6. Snowapril commented on Sep 7, 2021

    @Snowapril
    Contributor

    Cool! 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions