Skip to content

Commit 76b825a

Browse files
committed
Update README.md and Bump v0.1.5
1 parent 289905d commit 76b825a

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

README.md

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
# Fast Registry
2+
[![](https://img.shields.io/pypi/v/fast-registry.svg)](https://pypi.python.org/pypi/fast-registry/)
3+
[![](https://github.com/danialkeimasi/fast-registry/workflows/tests/badge.svg)](https://github.com/danialkeimasi/fast-registry/actions)
4+
[![](https://img.shields.io/github/license/danialkeimasi/fast-registry.svg)](https://github.com/danialkeimasi/fast-registry/blob/master/LICENSE)
5+
26
A generic class that can be used to register classes or functions, with type hints support.
7+
# Installation
8+
9+
```bash
10+
pip install fast-registry
11+
```
12+
13+
# Register Classes
14+
You can enforce types on your concrete classes, and also use type hints on your text editors:
315

4-
# Example
516
```py
617
from fast_registry import FastRegistry
718

@@ -11,7 +22,7 @@ class Animal:
1122
raise NotImplementedError
1223

1324

14-
# create a registry that requires registered items to implement the Animal interface.
25+
# create a registry that requires registered items to implement the Animal interface:
1526
animal_registry = FastRegistry(Animal)
1627

1728
@animal_registry("dog")
@@ -31,9 +42,25 @@ class Dog:
3142
'woof'
3243
```
3344

45+
# Register Functions
3446

35-
# Installation
47+
You can also use this tool to register functions:
48+
```py
49+
from fast_registry import FastRegistry
3650

37-
```bash
38-
pip install fast-registry
51+
52+
registry = FastRegistry()
53+
54+
55+
@registry("foo")
56+
def foo():
57+
return "bar"
58+
```
59+
60+
```sh
61+
>>> registry["foo"]
62+
<function foo at 0x7f803c989fc0>
63+
64+
>>> registry["foo"]()
65+
'bar'
3966
```

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "fast-registry"
3-
version = "0.1.3"
3+
version = "0.1.5"
44
description = "A generic class that can be used to register classes or functions."
55
authors = ["Danial Keimasi <danialkeimasi@gmail.com>"]
66
license = "MIT"

0 commit comments

Comments
 (0)