Skip to content

Commit

Permalink
autodetect print/breakpoints (#4581)
Browse files Browse the repository at this point in the history
* catch stray breakpoints and prints

* autodetect debug prints and breakpoints in main code

* readd hacky print in pyi_generator?
  • Loading branch information
Lendemor authored Jan 3, 2025
1 parent 97fb157 commit 53f0975
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion benchmarks/benchmark_package_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_package_size(venv_path: Path, os_name):
ValueError: when venv does not exist or python version is None.
"""
python_version = get_python_version(venv_path, os_name)
print("Python version:", python_version)
print("Python version:", python_version) # noqa: T201
if python_version is None:
raise ValueError("Error: Failed to determine Python version.")

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ build-backend = "poetry.core.masonry.api"
target-version = "py39"
output-format = "concise"
lint.isort.split-on-trailing-comma = false
lint.select = ["B", "C4", "D", "E", "ERA", "F", "FURB", "I", "PERF", "PTH", "RUF", "SIM", "W"]
lint.select = ["B", "C4", "D", "E", "ERA", "F", "FURB", "I", "PERF", "PTH", "RUF", "SIM", "T", "W"]
lint.ignore = ["B008", "D205", "E501", "F403", "SIM115", "RUF006", "RUF012"]
lint.pydocstyle.convention = "google"

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]
"tests/*.py" = ["D100", "D103", "D104", "B018", "PERF"]
"tests/*.py" = ["D100", "D103", "D104", "B018", "PERF", "T"]
"reflex/.templates/*.py" = ["D100", "D103", "D104"]
"*.pyi" = ["D301", "D415", "D417", "D418", "E742"]
"*/blank.py" = ["I001"]
Expand Down
6 changes: 3 additions & 3 deletions reflex/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
StateManagerRedis,
reload_state_module,
)
from reflex.utils import console

try:
from selenium import webdriver # pyright: ignore [reportMissingImports]
Expand Down Expand Up @@ -385,7 +386,7 @@ def _wait_frontend(self):
)
if not line:
break
print(line) # for pytest diagnosis
print(line) # for pytest diagnosis #noqa: T201
m = re.search(reflex.constants.Next.FRONTEND_LISTENING_REGEX, line)
if m is not None:
self.frontend_url = m.group(1)
Expand All @@ -403,11 +404,10 @@ def consume_frontend_output():
)
# catch I/O operation on closed file.
except ValueError as e:
print(e)
console.error(str(e))
break
if not line:
break
print(line)

self.frontend_output_thread = threading.Thread(target=consume_frontend_output)
self.frontend_output_thread.start()
Expand Down
2 changes: 1 addition & 1 deletion reflex/utils/pyi_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1202,4 +1202,4 @@ def scan_all(self, targets, changed_files: list[Path] | None = None):
or "Var[Template]" in line
):
line = line.rstrip() + " # type: ignore\n"
print(line, end="")
print(line, end="") # noqa: T201
6 changes: 3 additions & 3 deletions scripts/wait_for_listening_port.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def _pid_exists(pid):

def _wait_for_port(port, server_pid, timeout) -> Tuple[bool, str]:
start = time.time()
print(f"Waiting for up to {timeout} seconds for port {port} to start listening.")
print(f"Waiting for up to {timeout} seconds for port {port} to start listening.") # noqa: T201
while True:
if not _pid_exists(server_pid):
return False, f"Server PID {server_pid} is not running."
Expand Down Expand Up @@ -56,9 +56,9 @@ def main():
for f in as_completed(futures):
ok, msg = f.result()
if ok:
print(f"OK: {msg}")
print(f"OK: {msg}") # noqa: T201
else:
print(f"FAIL: {msg}")
print(f"FAIL: {msg}") # noqa: T201
exit(1)


Expand Down

0 comments on commit 53f0975

Please sign in to comment.