Skip to content

Commit

Permalink
switch from watchgod to watchfiles (#332)
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin authored Aug 23, 2022
1 parent a5e6742 commit 1b5f863
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions arq/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def cli(*, worker_settings: str, burst: bool, check: bool, watch: str, verbose:

async def watch_reload(path: str, worker_settings: 'WorkerSettingsType') -> None:
try:
from watchgod import awatch
from watchfiles import awatch
except ImportError as e: # pragma: no cover
raise ImportError('watchgod not installed, use `pip install watchgod`') from e
raise ImportError('watchfiles not installed, use `pip install watchfiles`') from e

loop = asyncio.get_event_loop()
stop_event = asyncio.Event()
Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ You can also watch for changes and reload the worker when the source changes::

arq demo.WorkerSettings --watch path/to/src

This requires watchgod_ to be installed (``pip install watchgod``).
This requires watchfiles_ to be installed (``pip install watchfiles``).

For details on the *arq* CLI::

Expand Down Expand Up @@ -268,5 +268,5 @@ Reference
.. |license| image:: https://img.shields.io/pypi/l/arq.svg
:target: https://github.com/samuelcolvin/arq
.. _asyncio: https://docs.python.org/3/library/asyncio.html
.. _watchgod: https://pypi.org/project/watchgod/
.. _watchfiles: https://pypi.org/project/watchfiles/
.. _rq: http://python-rq.org/
4 changes: 0 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,3 @@ disallow_untyped_defs = true
# remaining arguments from `mypy --strict` which cause errors
#no_implicit_optional = true
#warn_return_any = true

[[tool.mypy.overrides]]
module = ['redis.asyncio.*', 'watchgod']
ignore_missing_imports = true
10 changes: 9 additions & 1 deletion requirements/setup.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
# This file is autogenerated by pip-compile with python 3.9
# To update, run:
#
# pip-compile --output-file=requirements/setup.txt setup.py
# pip-compile --extra=watch --output-file=requirements/setup.txt setup.py
#
anyio==3.6.1
# via watchfiles
async-timeout==4.0.2
# via redis
click==8.1.3
Expand All @@ -12,6 +14,8 @@ deprecated==1.2.13
# via redis
hiredis==2.0.0
# via redis
idna==3.3
# via anyio
packaging==21.3
# via redis
pydantic==1.9.2
Expand All @@ -20,9 +24,13 @@ pyparsing==3.0.9
# via packaging
redis[hiredis]==4.2.2
# via arq (setup.py)
sniffio==1.2.0
# via anyio
typing-extensions==4.3.0
# via
# arq (setup.py)
# pydantic
watchfiles==0.16.1
# via arq (setup.py)
wrapt==1.14.1
# via deprecated
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@
'typing-extensions>=4.1.0,<5.0.0',
],
extras_require={
'watch': ['watchgod>=0.8,<0.9'],
'watch': ['watchfiles<=1'],
}
)
3 changes: 1 addition & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ async def mock_awatch():
yield [1]


@pytest.mark.filterwarnings('ignore::DeprecationWarning')
def test_run_watch(mocker, cancel_remaining_task):
mocker.patch('watchgod.awatch', return_value=mock_awatch())
mocker.patch('watchfiles.awatch', return_value=mock_awatch())
runner = CliRunner()
result = runner.invoke(cli, ['tests.test_cli.WorkerSettings', '--watch', 'tests'])
assert result.exit_code == 0
Expand Down

0 comments on commit 1b5f863

Please sign in to comment.