Selaa lähdekoodia

enable REFURB rules in ruff (#4466)

Co-authored-by: Masen Furer <m_github@0x26.net>
Thomas Brandého 5 kuukautta sitten
vanhempi
säilyke
fd0fd2c6d4

+ 1 - 1
pyproject.toml

@@ -93,7 +93,7 @@ build-backend = "poetry.core.masonry.api"
 [tool.ruff]
 [tool.ruff]
 target-version = "py39"
 target-version = "py39"
 lint.isort.split-on-trailing-comma = false
 lint.isort.split-on-trailing-comma = false
-lint.select = ["B", "D", "E", "F", "I", "SIM", "W", "RUF"]
+lint.select = ["B", "D", "E", "F", "I", "SIM", "W", "RUF", "FURB"]
 lint.ignore = ["B008", "D205", "E501", "F403", "SIM115", "RUF006", "RUF012"]
 lint.ignore = ["B008", "D205", "E501", "F403", "SIM115", "RUF006", "RUF012"]
 lint.pydocstyle.convention = "google"
 lint.pydocstyle.convention = "google"
 
 

+ 1 - 1
reflex/utils/prerequisites.py

@@ -495,7 +495,7 @@ def initialize_requirements_txt():
     try:
     try:
         other_requirements_exist = False
         other_requirements_exist = False
         with open(fp, "r", encoding=encoding) as f:
         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
                 # Check if we have a package name that is reflex
                 if re.match(r"^reflex[^a-zA-Z0-9]", req):
                 if re.match(r"^reflex[^a-zA-Z0-9]", req):
                     console.debug(f"{fp} already has reflex as dependency.")
                     console.debug(f"{fp} already has reflex as dependency.")

+ 1 - 1
reflex/utils/pyi_generator.py

@@ -24,7 +24,7 @@ from reflex.vars.base import Var
 
 
 logger = logging.getLogger("pyi_generator")
 logger = logging.getLogger("pyi_generator")
 
 
-PWD = Path(".").resolve()
+PWD = Path.cwd()
 
 
 EXCLUDED_FILES = [
 EXCLUDED_FILES = [
     "app.py",
     "app.py",

+ 1 - 1
tests/units/conftest.py

@@ -206,7 +206,7 @@ class chdir(contextlib.AbstractContextManager):
 
 
     def __enter__(self):
     def __enter__(self):
         """Save current directory and perform chdir."""
         """Save current directory and perform chdir."""
-        self._old_cwd.append(Path(".").resolve())
+        self._old_cwd.append(Path.cwd())
         os.chdir(self.path)
         os.chdir(self.path)
 
 
     def __exit__(self, *excinfo):
     def __exit__(self, *excinfo):

+ 1 - 1
tests/units/utils/test_utils.py

@@ -298,7 +298,7 @@ def tmp_working_dir(tmp_path):
     Yields:
     Yields:
         subdirectory of tmp_path which is now the current working directory.
         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 = tmp_path / "working_dir"
     working_dir.mkdir()
     working_dir.mkdir()
     os.chdir(working_dir)
     os.chdir(working_dir)