oracle / graalpython

A Python 3 implementation built on GraalVM
Other
1.21k stars 104 forks source link

Spurious ValueError #188

Closed oroppas closed 3 years ago

oroppas commented 3 years ago

GraalPython gives ValueError: '_path' in __slots__ conflicts with class variable for the following code:

from typing import Optional
from pathlib import Path

class Style:

    _path: Optional[Path]

    __slots__ = [
        "_path"
    ]

if __name__ == '__main__':
    Style()

CPython gives no error.

ppisl commented 3 years ago

Hello @oroppas, thank for the report. It looks that problem is that graalpython translate line _path: Option[Path] to somothing like _path: {type of Option[Path]} = None and createss _path variable in the class body. I will try to fix it.

Why you have here the line with _path: Optional[Path]?

oroppas commented 3 years ago

Hi @ppisl,

It's been a while since I submitted this bug report and my memory is a bit rusty but I think I found it when I tried rich (https://github.com/willmcgugan/rich). https://github.com/willmcgugan/rich/blob/master/rich/style.py#L63

ppisl commented 3 years ago

@oroppas Thanks for the response. The problem is clear to me. I'm working on it.

oroppas commented 3 years ago

@ppisl I can confirm the fix works. Thanks!

ppisl commented 3 years ago

@ppisl I can confirm the fix works. Thanks!

You are welcome and thanks for chacking it.