Skip to content

Commit

Permalink
Update README.md (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
antonagestam authored Sep 25, 2022
1 parent 3642aad commit ce916c0
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

Abstract class attributes for ABCs.

### Examples

```python
import abc
from abcattrs import abstractattrs, Abstract
Expand All @@ -20,15 +22,24 @@ class A(abc.ABC):
foo: Abstract[int]


# Abstract subclasses can add more required attributes
@abstractattrs
# Abstract subclasses can add more required attributes.
class B(A, abc.ABC):
bar: Abstract[str]


class C(B):
# C must define both of these attributes to not raise an error
# C must assign values to both of these attributes to not raise an error.
foo = 1
bar = "str"


# This raises an error.
class MissingBar(B):
foo = 1


# This raises an error.
class MissingFoo(B):
bar = "str"
```

Expand Down

0 comments on commit ce916c0

Please sign in to comment.