Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ jobs:
python -m pip install --upgrade pip setuptools wheel
pip install -e ./packages/python-ta-z3
if [ "${{ matrix.dependency }}" == "z3-solver" ]; then
pip install -e ./packages/python-ta[dev,cfg,z3]
pip install -e ./packages/python-ta[dev,cfg,watchdog,z3]
else
pip install -e ./packages/python-ta[dev,cfg]
pip install -e ./packages/python-ta[dev,cfg,watchdog]
fi
- name: Run python-ta tests
run: |
Expand Down Expand Up @@ -123,7 +123,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -e ./packages/python-ta-z3 ./packages/python-ta[dev,cfg,z3]
pip install -e ./packages/python-ta-z3 ./packages/python-ta[dev,cfg,z3,watchdog]
- name: Generate docs
run: sphinx-build -b html -W docs docs/_build
working-directory: packages/python-ta
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ For more information about the library, check out our [documentation website](ht
If you're developing PyTA:

1. First, clone this repository.
2. Open a terminal in this repo, and run `pip install -e "./packages/python-ta-z3" "./packages/python-ta[dev, cfg, z3]"` to install the dependencies.
2. Open a terminal in this repo, and run `pip install -e "./packages/python-ta-z3" "./packages/python-ta[dev, cfg, z3, watchdog]"` to install the dependencies.
3. Then run `pre-commit install` to install the pre-commit hooks (for automatically formatting and checking your code on each commit).

While not strictly necessary for debugging, some debugging tools require [graphviz](https://www.graphviz.org/download/) to be installed on your system.
Expand Down
1 change: 1 addition & 0 deletions packages/python-ta/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- Extended `RecursionTable` to handle mutual recursion by taking in a list of function names to trace. Updated table output format correspondingly to include a "function" key column.
- Extended `unnecessary_f_string_checker.py` to present an alternate message when the input is already a string.
- Extended `snapshot_to_json` behaviour to handle `type` instances and display the `repr` of the type.
- Make `watchdog` an optional dependency; users can opt in with `pip install python-ta[watchdog]`. This affects runs of `python_ta.check_all` with the `watch` config option set to `True`.

### 💫 New checkers

Expand Down
6 changes: 6 additions & 0 deletions packages/python-ta/docs/usage/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ For the **HTMLReporter**, this enables a persistent server that serves the PyTA

When `false` (default), PythonTA performs a one-time analysis and exits after generating the report.

> **Note:** This option requires the optional `watchdog` extra. Install it with:
>
> ```bash
> pip install python-ta[watchdog]
> ```

### `server-port` (default: `0`)

The server-port option specifies the port number to use when serving the PyTA HTML report. When set to 0 (the default),
Expand Down
4 changes: 3 additions & 1 deletion packages/python-ta/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ dependencies = [
"tabulate ~= 0.9.0",
"toml ~= 0.10.2",
"typeguard >= 4.1.0, < 5",
"watchdog ~= 6.0.0",
"wrapt >= 1.15.0, < 3"
]
requires-python = ">=3.10"
Expand All @@ -47,6 +46,9 @@ dev = [
cfg = [
"graphviz",
]
watchdog = [
"watchdog ~= 6.0.0",
]
z3 = [
"python-ta-z3 == 2.13.0.dev",
"z3-solver",
Expand Down
4 changes: 3 additions & 1 deletion packages/python-ta/src/python_ta/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
upload_linter_results,
verify_pre_check,
)
from .check.watch import watch_files

if TYPE_CHECKING:
from .reporters.core import PythonTaReporter
Expand Down Expand Up @@ -182,6 +181,9 @@ def _check(
if is_any_file_checked:
linter.generate_reports()
if linter.config.watch:
# import only when needed to avoid dragging in watchdog
from .check.watch import watch_files

watch_files(
file_paths=linted_files,
level=level,
Expand Down
11 changes: 9 additions & 2 deletions packages/python-ta/src/python_ta/check/watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@
from typing import Any, Optional, Union

from pylint.lint import PyLinter
from watchdog.events import FileSystemEventHandler
from watchdog.observers import Observer

# ``watchdog`` is an optional extra. If someone imports this module without
# installing the extra, we print an error message before raising the error.
try:
from watchdog.events import FileSystemEventHandler
from watchdog.observers import Observer
except ImportError: # pragma: no cover - impossible to trigger in CI since extra is installed
print("ERROR: watch mode requires python-ta[watchdog] to be installed.")
raise

from .helpers import check_file, upload_linter_results

Expand Down
8 changes: 8 additions & 0 deletions packages/python-ta/src/python_ta/config/.pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ allow-pylint-comments = no
# Set whether the default error messages by pylint should be overwritten by PythonTA's custom messages
use-pyta-error-messages = yes

# Watch mode automatically re-runs checks when your files change.
# To use watch mode install PythonTA with the `watchdog` extra:
#
# pip install python-ta[watchdog]
#
# The default is `no` (disabled).
watch = no

[REPORTS]
# The type of reporter to use to display results. Available PyTA options are
# pyta-plain, pyta-color, pyta-html, pyta-json.
Expand Down
8 changes: 5 additions & 3 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.