Skip to content

Instantly share code, notes, and snippets.

@amcgregor
Created October 21, 2019 17:24
Show Gist options
  • Save amcgregor/90bc7ee3a76941b294856c6199eb38d2 to your computer and use it in GitHub Desktop.
Save amcgregor/90bc7ee3a76941b294856c6199eb38d2 to your computer and use it in GitHub Desktop.
Attempting to grok data descriptor contributions to Python annotations.
#!/usr/bin/env python3
from dataclasses import dataclass
class String:
def __get__(self, obj, cls=None) -> str:
return "I'm a string!"
class Sample:
stringy: str = String()
class Example:
stringy = String()
@dataclass
class Dataclass:
stringy: str = String()
if __name__ == '__main__':
help(Sample)
help(Example)
help(Dataclass)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment