Skip to content

Commit

Permalink
[watchmedo] Lazy loading of the PyYAML module (#847)
Browse files Browse the repository at this point in the history
  • Loading branch information
BoboTiG committed Dec 15, 2021
1 parent 5f89548 commit fa3b3b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.rst
Expand Up @@ -10,6 +10,7 @@ Changelog

- Eliminate timeout in waiting on event queue. (`#861 <https://github.com/gorakhargosh/watchdog/pull/861>`_)
- [inotify] Fix ``not`` equality implementation for ``InotifyEvent``. (`#848 <https://github.com/gorakhargosh/watchdog/pull/848>`_)
- [watchmedo] ``PyYAML`` is loaded only when strictly necessary. Simple usages of ``watchmedo`` are possible without the module being installed. (`#847 <https://github.com/gorakhargosh/watchdog/pull/847>`_)
- Thanks to our beloved contributors: @sattlerc, @JanzenLiu, @BoboTiG

2.1.6
Expand Down
5 changes: 4 additions & 1 deletion src/watchdog/watchmedo.py
Expand Up @@ -31,7 +31,6 @@
from io import StringIO
from textwrap import dedent

import yaml
from watchdog.utils import WatchdogShutdown, load_class
from watchdog.version import VERSION_STRING

Expand Down Expand Up @@ -136,6 +135,8 @@ def load_config(tricks_file_pathname):
:returns:
A dictionary of configuration information.
"""
import yaml

with open(tricks_file_pathname, 'rb') as f:
return yaml.safe_load(f.read())

Expand Down Expand Up @@ -309,6 +310,8 @@ def tricks_generate_yaml(args):
"""
Command to generate Yaml configuration for tricks named on the command line.
"""
import yaml

python_paths = path_split(args.python_path)
add_to_sys_path(python_paths)
output = StringIO()
Expand Down

0 comments on commit fa3b3b5

Please sign in to comment.