From 17c0a1723527e423791c34663590823fd7b20389 Mon Sep 17 00:00:00 2001 From: Lendemor Date: Tue, 3 Dec 2024 14:56:42 +0100 Subject: [PATCH] enable REFURB rules in ruff --- pyproject.toml | 2 +- reflex/utils/prerequisites.py | 2 +- reflex/utils/pyi_generator.py | 2 +- tests/units/conftest.py | 2 +- tests/units/utils/test_utils.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 619c4ff47..6934691e3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -93,7 +93,7 @@ build-backend = "poetry.core.masonry.api" [tool.ruff] target-version = "py39" lint.isort.split-on-trailing-comma = false -lint.select = ["B", "D", "E", "F", "I", "SIM", "W"] +lint.select = ["B", "D", "E", "F", "I", "SIM", "W", "FURB"] lint.ignore = ["B008", "D205", "E501", "F403", "SIM115"] lint.pydocstyle.convention = "google" diff --git a/reflex/utils/prerequisites.py b/reflex/utils/prerequisites.py index ec79b3297..961658942 100644 --- a/reflex/utils/prerequisites.py +++ b/reflex/utils/prerequisites.py @@ -496,7 +496,7 @@ def initialize_requirements_txt(): try: other_requirements_exist = False with open(fp, "r", encoding=encoding) as f: - for req in f.readlines(): + for req in f: # Check if we have a package name that is reflex if re.match(r"^reflex[^a-zA-Z0-9]", req): console.debug(f"{fp} already has reflex as dependency.") diff --git a/reflex/utils/pyi_generator.py b/reflex/utils/pyi_generator.py index fb0a8f8c5..29ef1fae6 100644 --- a/reflex/utils/pyi_generator.py +++ b/reflex/utils/pyi_generator.py @@ -24,7 +24,7 @@ from reflex.vars.base import Var logger = logging.getLogger("pyi_generator") -PWD = Path(".").resolve() +PWD = Path.cwd() EXCLUDED_FILES = [ "app.py", diff --git a/tests/units/conftest.py b/tests/units/conftest.py index 2f619a941..fb6229aca 100644 --- a/tests/units/conftest.py +++ b/tests/units/conftest.py @@ -206,7 +206,7 @@ class chdir(contextlib.AbstractContextManager): def __enter__(self): """Save current directory and perform chdir.""" - self._old_cwd.append(Path(".").resolve()) + self._old_cwd.append(Path.cwd()) os.chdir(self.path) def __exit__(self, *excinfo): diff --git a/tests/units/utils/test_utils.py b/tests/units/utils/test_utils.py index dd1a3b3ef..20bad4146 100644 --- a/tests/units/utils/test_utils.py +++ b/tests/units/utils/test_utils.py @@ -298,7 +298,7 @@ def tmp_working_dir(tmp_path): Yields: subdirectory of tmp_path which is now the current working directory. """ - old_pwd = Path(".").resolve() + old_pwd = Path.cwd() working_dir = tmp_path / "working_dir" working_dir.mkdir() os.chdir(working_dir)