stop ignoring some lint rules (#4311)

* bump python packages version

* stop ignoring some lint rules that pass ruff check

* stop ignoring rule F541

* remove sneaky test file
This commit is contained in:
Thomas Brandého 2024-11-06 13:32:31 -08:00 committed by GitHub
parent 6ea797d0cd
commit 4c0b49135b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
29 changed files with 56 additions and 64 deletions

View File

@ -210,7 +210,7 @@ def app_with_one_page(
Yields: Yields:
an AppHarness instance an AppHarness instance
""" """
root = tmp_path_factory.mktemp(f"app1") root = tmp_path_factory.mktemp("app1")
yield AppHarness.create(root=root, app_source=AppWithOnePage) # type: ignore yield AppHarness.create(root=root, app_source=AppWithOnePage) # type: ignore
@ -227,7 +227,7 @@ def app_with_ten_pages(
Yields: Yields:
an AppHarness instance an AppHarness instance
""" """
root = tmp_path_factory.mktemp(f"app10") root = tmp_path_factory.mktemp("app10")
yield AppHarness.create( yield AppHarness.create(
root=root, root=root,
app_source=functools.partial( app_source=functools.partial(
@ -249,7 +249,7 @@ def app_with_hundred_pages(
Yields: Yields:
an AppHarness instance an AppHarness instance
""" """
root = tmp_path_factory.mktemp(f"app100") root = tmp_path_factory.mktemp("app100")
yield AppHarness.create( yield AppHarness.create(
root=root, root=root,
@ -272,7 +272,7 @@ def app_with_thousand_pages(
Yields: Yields:
an AppHarness instance an AppHarness instance
""" """
root = tmp_path_factory.mktemp(f"app1000") root = tmp_path_factory.mktemp("app1000")
yield AppHarness.create( yield AppHarness.create(
root=root, root=root,
@ -295,7 +295,7 @@ def app_with_ten_thousand_pages(
Yields: Yields:
running AppHarness instance running AppHarness instance
""" """
root = tmp_path_factory.mktemp(f"app10000") root = tmp_path_factory.mktemp("app10000")
yield AppHarness.create( yield AppHarness.create(
root=root, root=root,

View File

@ -92,7 +92,7 @@ build-backend = "poetry.core.masonry.api"
[tool.ruff] [tool.ruff]
target-version = "py39" target-version = "py39"
lint.select = ["B", "D", "E", "F", "I", "SIM", "W"] lint.select = ["B", "D", "E", "F", "I", "SIM", "W"]
lint.ignore = ["B008", "D203", "D205", "D213", "D401", "D406", "D407", "E501", "F403", "F405", "F541", "SIM115"] lint.ignore = ["B008", "D205", "E501", "F403", "SIM115"]
lint.pydocstyle.convention = "google" lint.pydocstyle.convention = "google"
[tool.ruff.lint.per-file-ignores] [tool.ruff.lint.per-file-ignores]

View File

@ -158,7 +158,6 @@ class ComponentNamespace(SimpleNamespace):
def __hash__(self) -> int: def __hash__(self) -> int:
"""Get the hash of the namespace. """Get the hash of the namespace.
Returns: Returns:
The hash of the namespace. The hash of the namespace.
""" """

View File

@ -110,7 +110,7 @@ class ConnectionToaster(Toaster):
individual_hooks = [ individual_hooks = [
f"const toast_props = {str(LiteralVar.create(props))};", f"const toast_props = {str(LiteralVar.create(props))};",
f"const [userDismissed, setUserDismissed] = useState(false);", "const [userDismissed, setUserDismissed] = useState(false);",
FunctionStringVar( FunctionStringVar(
"useEffect", "useEffect",
_var_data=VarData( _var_data=VarData(

View File

@ -26,49 +26,48 @@ from reflex.vars.sequence import StringVar, string_replace_operation
def copy_script() -> Any: def copy_script() -> Any:
"""Copy script for the code block and modify the child SVG element. """Copy script for the code block and modify the child SVG element.
Returns: Returns:
Any: The result of calling the script. Any: The result of calling the script.
""" """
return run_script( return run_script(
f""" """
// Event listener for the parent click // Event listener for the parent click
document.addEventListener('click', function(event) {{ document.addEventListener('click', function(event) {
// Find the closest button (parent element) // Find the closest button (parent element)
const parent = event.target.closest('button'); const parent = event.target.closest('button');
// If the parent is found // If the parent is found
if (parent) {{ if (parent) {
// Find the SVG element within the parent // Find the SVG element within the parent
const svgIcon = parent.querySelector('svg'); const svgIcon = parent.querySelector('svg');
// If the SVG exists, proceed with the script // If the SVG exists, proceed with the script
if (svgIcon) {{ if (svgIcon) {
const originalPath = svgIcon.innerHTML; const originalPath = svgIcon.innerHTML;
const checkmarkPath = '<polyline points="20 6 9 17 4 12"></polyline>'; // Checkmark SVG path const checkmarkPath = '<polyline points="20 6 9 17 4 12"></polyline>'; // Checkmark SVG path
function transition(element, scale, opacity) {{ function transition(element, scale, opacity) {
element.style.transform = `scale(${{scale}})`; element.style.transform = `scale(${scale})`;
element.style.opacity = opacity; element.style.opacity = opacity;
}} }
// Animate the SVG // Animate the SVG
transition(svgIcon, 0, '0'); transition(svgIcon, 0, '0');
setTimeout(() => {{ setTimeout(() => {
svgIcon.innerHTML = checkmarkPath; // Replace content with checkmark svgIcon.innerHTML = checkmarkPath; // Replace content with checkmark
svgIcon.setAttribute('viewBox', '0 0 24 24'); // Adjust viewBox if necessary svgIcon.setAttribute('viewBox', '0 0 24 24'); // Adjust viewBox if necessary
transition(svgIcon, 1, '1'); transition(svgIcon, 1, '1');
setTimeout(() => {{ setTimeout(() => {
transition(svgIcon, 0, '0'); transition(svgIcon, 0, '0');
setTimeout(() => {{ setTimeout(() => {
svgIcon.innerHTML = originalPath; // Restore original SVG content svgIcon.innerHTML = originalPath; // Restore original SVG content
transition(svgIcon, 1, '1'); transition(svgIcon, 1, '1');
}}, 125); }, 125);
}}, 600); }, 600);
}}, 125); }, 125);
}} else {{ } else {
// console.error('SVG element not found within the parent.'); // console.error('SVG element not found within the parent.');
}} }
}} else {{ } else {
// console.error('Parent element not found.'); // console.error('Parent element not found.');
}} }
}}) })
""" """
) )

View File

@ -58,7 +58,7 @@ class Icon(LucideIconComponent):
props["tag"] = format.to_title_case(format.to_snake_case(props["tag"])) + "Icon" props["tag"] = format.to_title_case(format.to_snake_case(props["tag"])) + "Icon"
props["alias"] = f"Lucide{props['tag']}" props["alias"] = f"Lucide{props['tag']}"
props.setdefault("color", f"var(--current-color)") props.setdefault("color", "var(--current-color)")
return super().create(*children, **props) return super().create(*children, **props)

View File

@ -382,7 +382,7 @@ class AccordionTrigger(AccordionComponent):
"background_color": color("accent", 4), "background_color": color("accent", 4),
}, },
"& > .AccordionChevron": { "& > .AccordionChevron": {
"transition": f"transform var(--animation-duration) var(--animation-easing)", "transition": "transform var(--animation-duration) var(--animation-easing)",
}, },
_inherited_variant_selector("classic"): { _inherited_variant_selector("classic"): {
"color": "var(--accent-contrast)", "color": "var(--accent-contrast)",
@ -485,11 +485,11 @@ to {
The style of the component. The style of the component.
""" """
slideDown = LiteralVar.create( slideDown = LiteralVar.create(
f"${{slideDown}} var(--animation-duration) var(--animation-easing)", "${slideDown} var(--animation-duration) var(--animation-easing)",
) )
slideUp = LiteralVar.create( slideUp = LiteralVar.create(
f"${{slideUp}} var(--animation-duration) var(--animation-easing)", "${slideUp} var(--animation-duration) var(--animation-easing)",
) )
return { return {

View File

@ -236,7 +236,7 @@ class Theme(RadixThemesComponent):
tag = super()._render(props) tag = super()._render(props)
tag.add_props( tag.add_props(
css=Var( css=Var(
_js_expr=f"{{...theme.styles.global[':root'], ...theme.styles.global.body}}" _js_expr="{...theme.styles.global[':root'], ...theme.styles.global.body}"
), ),
) )
return tag return tag

View File

@ -78,7 +78,7 @@ class Reflex(SimpleNamespace):
# The root directory of the reflex library. # The root directory of the reflex library.
ROOT_DIR = Path(__file__).parents[2] ROOT_DIR = Path(__file__).parents[2]
RELEASES_URL = f"https://api.github.com/repos/reflex-dev/templates/releases" RELEASES_URL = "https://api.github.com/repos/reflex-dev/templates/releases"
class ReflexHostingCLI(SimpleNamespace): class ReflexHostingCLI(SimpleNamespace):

View File

@ -779,8 +779,8 @@ def _validate_project_info():
) )
# PyPI only shows the first author. # PyPI only shows the first author.
author = project.get("authors", [{}])[0] author = project.get("authors", [{}])[0]
author["name"] = console.ask(f"Author Name", default=author.get("name", "")) author["name"] = console.ask("Author Name", default=author.get("name", ""))
author["email"] = console.ask(f"Author Email", default=author.get("email", "")) author["email"] = console.ask("Author Email", default=author.get("email", ""))
console.print(f'Current keywords are: {project.get("keywords") or []}') console.print(f'Current keywords are: {project.get("keywords") or []}')
keyword_action = console.ask( keyword_action = console.ask(
@ -923,7 +923,7 @@ def _get_file_from_prompt_in_loop() -> Tuple[bytes, str] | None:
image_file = file_extension = None image_file = file_extension = None
while image_file is None: while image_file is None:
image_filepath = console.ask( image_filepath = console.ask(
f"Upload a preview image of your demo app (enter to skip)" "Upload a preview image of your demo app (enter to skip)"
) )
if not image_filepath: if not image_filepath:
break break
@ -973,6 +973,6 @@ def install(
console.set_log_level(loglevel) console.set_log_level(loglevel)
if _pip_install_on_demand(package_name=".", install_args=["-e"]): if _pip_install_on_demand(package_name=".", install_args=["-e"]):
console.info(f"Package installed successfully!") console.info("Package installed successfully!")
else: else:
raise typer.Exit(code=1) raise typer.Exit(code=1)

View File

@ -363,7 +363,7 @@ def _login() -> str:
access_token = hosting.authenticate_on_browser(invitation_code) access_token = hosting.authenticate_on_browser(invitation_code)
if not access_token: if not access_token:
console.error(f"Unable to authenticate. Please try again or contact support.") console.error("Unable to authenticate. Please try again or contact support.")
raise typer.Exit(1) raise typer.Exit(1)
console.print("Successfully logged in.") console.print("Successfully logged in.")

View File

@ -191,7 +191,6 @@ def ask(
def progress(): def progress():
"""Create a new progress bar. """Create a new progress bar.
Returns: Returns:
A new progress bar. A new progress bar.
""" """

View File

@ -429,7 +429,7 @@ def output_system_info():
except Exception: except Exception:
config_file = None config_file = None
console.rule(f"System Info") console.rule("System Info")
console.debug(f"Config file: {config_file!r}") console.debug(f"Config file: {config_file!r}")
console.debug(f"Config: {config}") console.debug(f"Config: {config}")

View File

@ -189,7 +189,7 @@ def background_task(
running AppHarness instance running AppHarness instance
""" """
with AppHarness.create( with AppHarness.create(
root=tmp_path_factory.mktemp(f"background_task"), root=tmp_path_factory.mktemp("background_task"),
app_source=BackgroundTask, # type: ignore app_source=BackgroundTask, # type: ignore
) as harness: ) as harness:
yield harness yield harness

View File

@ -124,7 +124,7 @@ def computed_vars(
running AppHarness instance running AppHarness instance
""" """
with AppHarness.create( with AppHarness.create(
root=tmp_path_factory.mktemp(f"computed_vars"), root=tmp_path_factory.mktemp("computed_vars"),
app_source=ComputedVars, # type: ignore app_source=ComputedVars, # type: ignore
) as harness: ) as harness:
yield harness yield harness

View File

@ -153,7 +153,7 @@ def dynamic_route(
running AppHarness instance running AppHarness instance
""" """
with app_harness_env.create( with app_harness_env.create(
root=tmp_path_factory.mktemp(f"dynamic_route"), root=tmp_path_factory.mktemp("dynamic_route"),
app_name=f"dynamicroute_{app_harness_env.__name__.lower()}", app_name=f"dynamicroute_{app_harness_env.__name__.lower()}",
app_source=DynamicRoute, # type: ignore app_source=DynamicRoute, # type: ignore
) as harness: ) as harness:

View File

@ -171,7 +171,7 @@ def event_action(tmp_path_factory) -> Generator[AppHarness, None, None]:
running AppHarness instance running AppHarness instance
""" """
with AppHarness.create( with AppHarness.create(
root=tmp_path_factory.mktemp(f"event_action"), root=tmp_path_factory.mktemp("event_action"),
app_source=TestEventAction, # type: ignore app_source=TestEventAction, # type: ignore
) as harness: ) as harness:
yield harness yield harness

View File

@ -58,7 +58,7 @@ def test_large_state(var_count: int, tmp_path_factory, benchmark):
large_state_rendered = template.render(var_count=var_count) large_state_rendered = template.render(var_count=var_count)
with AppHarness.create( with AppHarness.create(
root=tmp_path_factory.mktemp(f"large_state"), root=tmp_path_factory.mktemp("large_state"),
app_source=large_state_rendered, app_source=large_state_rendered,
app_name="large_state", app_name="large_state",
) as large_state: ) as large_state:

View File

@ -74,7 +74,7 @@ async def test_navigation_app(navigation_app: AppHarness):
with poll_for_navigation(driver): with poll_for_navigation(driver):
internal_link.click() internal_link.click()
assert urlsplit(driver.current_url).path == f"/internal/" assert urlsplit(driver.current_url).path == "/internal/"
with poll_for_navigation(driver): with poll_for_navigation(driver):
driver.back() driver.back()

View File

@ -102,7 +102,6 @@ def server_side_event(tmp_path_factory) -> Generator[AppHarness, None, None]:
def driver(server_side_event: AppHarness): def driver(server_side_event: AppHarness):
"""Get an instance of the browser open to the server_side_event app. """Get an instance of the browser open to the server_side_event app.
Args: Args:
server_side_event: harness for ServerSideEvent app server_side_event: harness for ServerSideEvent app

View File

@ -216,7 +216,7 @@ def state_inheritance(
running AppHarness instance running AppHarness instance
""" """
with AppHarness.create( with AppHarness.create(
root=tmp_path_factory.mktemp(f"state_inheritance"), root=tmp_path_factory.mktemp("state_inheritance"),
app_source=StateInheritance, # type: ignore app_source=StateInheritance, # type: ignore
) as harness: ) as harness:
yield harness yield harness

View File

@ -359,8 +359,8 @@ async def test_cancel_upload(tmp_path, upload_file: AppHarness, driver: WebDrive
substate_token = f"{token}_{state_full_name}" substate_token = f"{token}_{state_full_name}"
upload_box = driver.find_elements(By.XPATH, "//input[@type='file']")[1] upload_box = driver.find_elements(By.XPATH, "//input[@type='file']")[1]
upload_button = driver.find_element(By.ID, f"upload_button_secondary") upload_button = driver.find_element(By.ID, "upload_button_secondary")
cancel_button = driver.find_element(By.ID, f"cancel_button_secondary") cancel_button = driver.find_element(By.ID, "cancel_button_secondary")
exp_name = "large.txt" exp_name = "large.txt"
target_file = tmp_path / exp_name target_file = tmp_path / exp_name

View File

@ -131,11 +131,11 @@ def test_compile_stylesheets(tmp_path, mocker):
assert compiler.compile_root_stylesheet(stylesheets) == ( assert compiler.compile_root_stylesheet(stylesheets) == (
str(Path(".web") / "styles" / "styles.css"), str(Path(".web") / "styles" / "styles.css"),
f"@import url('./tailwind.css'); \n" "@import url('./tailwind.css'); \n"
f"@import url('https://fonts.googleapis.com/css?family=Sofia&effect=neon|outline|emboss|shadow-multiple'); \n" "@import url('https://fonts.googleapis.com/css?family=Sofia&effect=neon|outline|emboss|shadow-multiple'); \n"
f"@import url('https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css'); \n" "@import url('https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css'); \n"
f"@import url('../public/styles.css'); \n" "@import url('../public/styles.css'); \n"
f"@import url('https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap-theme.min.css'); \n", "@import url('https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap-theme.min.css'); \n",
) )

View File

@ -41,7 +41,6 @@ class S(BaseState):
def on_change(self, v: str): def on_change(self, v: str):
"""Dummy on_change handler. """Dummy on_change handler.
Args: Args:
v: The changed value. v: The changed value.
""" """

View File

@ -1208,7 +1208,7 @@ TEST_VAR_DICT_OF_DICT = LiteralVar.create({"a": {"b": "test"}})._replace(
merge_var_data=TEST_VAR._var_data merge_var_data=TEST_VAR._var_data
) )
FORMATTED_TEST_VAR_DICT_OF_DICT = LiteralVar.create( FORMATTED_TEST_VAR_DICT_OF_DICT = LiteralVar.create(
{"a": {"b": f"footestbar"}} {"a": {"b": "footestbar"}}
)._replace(merge_var_data=TEST_VAR._var_data) )._replace(merge_var_data=TEST_VAR._var_data)
TEST_VAR_LIST_OF_LIST = LiteralVar.create([["test"]])._replace( TEST_VAR_LIST_OF_LIST = LiteralVar.create([["test"]])._replace(

View File

@ -787,11 +787,11 @@ async def test_upload_file(tmp_path, state, delta, token: str, mocker):
} }
file1 = UploadFile( file1 = UploadFile(
filename=f"image1.jpg", filename="image1.jpg",
file=bio, file=bio,
) )
file2 = UploadFile( file2 = UploadFile(
filename=f"image2.jpg", filename="image2.jpg",
file=bio, file=bio,
) )
upload_fn = upload(app) upload_fn = upload(app)

View File

@ -1558,7 +1558,7 @@ def test_error_on_state_method_shadow():
assert ( assert (
err.value.args[0] err.value.args[0]
== f"The event handler name `reset` shadows a builtin State method; use a different name instead" == "The event handler name `reset` shadows a builtin State method; use a different name instead"
) )

View File

@ -1318,7 +1318,7 @@ def test_unsupported_types_for_reverse(var):
""" """
with pytest.raises(TypeError) as err: with pytest.raises(TypeError) as err:
var.reverse() var.reverse()
assert err.value.args[0] == f"Cannot reverse non-list var." assert err.value.args[0] == "Cannot reverse non-list var."
@pytest.mark.parametrize( @pytest.mark.parametrize(

View File

@ -20,7 +20,6 @@ from reflex.vars.base import LiteralVar
def test_has_serializer(type_: Type, expected: bool): def test_has_serializer(type_: Type, expected: bool):
"""Test that has_serializer returns the correct value. """Test that has_serializer returns the correct value.
Args: Args:
type_: The type to check. type_: The type to check.
expected: The expected result. expected: The expected result.
@ -41,7 +40,6 @@ def test_has_serializer(type_: Type, expected: bool):
def test_get_serializer(type_: Type, expected: serializers.Serializer): def test_get_serializer(type_: Type, expected: serializers.Serializer):
"""Test that get_serializer returns the correct value. """Test that get_serializer returns the correct value.
Args: Args:
type_: The type to check. type_: The type to check.
expected: The expected result. expected: The expected result.
@ -195,7 +193,6 @@ class BaseSubclass(Base):
def test_serialize(value: Any, expected: str): def test_serialize(value: Any, expected: str):
"""Test that serialize returns the correct value. """Test that serialize returns the correct value.
Args: Args:
value: The value to serialize. value: The value to serialize.
expected: The expected result. expected: The expected result.