Skip to content

Commit 73d5612

Browse files
nhairsBoboTiG
andauthored
[docs] Add typing info to quick start (#1082)
* [docs] Add typing info to quick start ref: #982 * Add to authors (including fixing ordering) * Fix base module --> api * Update docs/source/quickstart.rst --------- Co-authored-by: Mickaël Schoentgen <contact@tiger-222.fr>
1 parent d774fec commit 73d5612

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

docs/source/quickstart.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,22 @@ file system changes and simply print them to the console::
5252
observer.join()
5353

5454
To stop the program, press Control-C.
55+
56+
Typing
57+
------
58+
If you are using type annotations it is important to note that
59+
`watchdog.observers.Observer` is not actually a class; it is a variable that
60+
hold the "best" observer class available on your platform.
61+
62+
In order to correctly type your own code your should use
63+
`watchdog.observers.api.BaseObserver`. For example:
64+
65+
from watchdog.observers import Observer
66+
from watchdog.observers.api import BaseObserver
67+
68+
def my_func(obs: BaseObserver) -> None:
69+
# Do something with obs
70+
pass
71+
72+
observer: BaseObserver = Observer()
73+
my_func(observer)

0 commit comments

Comments
 (0)