Skip to content

Commit

Permalink
[docs] Add typing info to quick start (#1082)
Browse files Browse the repository at this point in the history
* [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 <[email protected]>
  • Loading branch information
nhairs and BoboTiG authored Nov 1, 2024
1 parent d774fec commit 73d5612
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,22 @@ file system changes and simply print them to the console::
observer.join()

To stop the program, press Control-C.

Typing
------
If you are using type annotations it is important to note that
`watchdog.observers.Observer` is not actually a class; it is a variable that
hold the "best" observer class available on your platform.

In order to correctly type your own code your should use
`watchdog.observers.api.BaseObserver`. For example:

from watchdog.observers import Observer
from watchdog.observers.api import BaseObserver

def my_func(obs: BaseObserver) -> None:
# Do something with obs
pass

observer: BaseObserver = Observer()
my_func(observer)

0 comments on commit 73d5612

Please sign in to comment.