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:
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
@ -227,7 +227,7 @@ def app_with_ten_pages(
Yields:
an AppHarness instance
"""
root = tmp_path_factory.mktemp(f"app10")
root = tmp_path_factory.mktemp("app10")
yield AppHarness.create(
root=root,
app_source=functools.partial(
@ -249,7 +249,7 @@ def app_with_hundred_pages(
Yields:
an AppHarness instance
"""
root = tmp_path_factory.mktemp(f"app100")
root = tmp_path_factory.mktemp("app100")
yield AppHarness.create(
root=root,
@ -272,7 +272,7 @@ def app_with_thousand_pages(
Yields:
an AppHarness instance
"""
root = tmp_path_factory.mktemp(f"app1000")
root = tmp_path_factory.mktemp("app1000")
yield AppHarness.create(
root=root,
@ -295,7 +295,7 @@ def app_with_ten_thousand_pages(
Yields:
running AppHarness instance
"""
root = tmp_path_factory.mktemp(f"app10000")
root = tmp_path_factory.mktemp("app10000")
yield AppHarness.create(
root=root,

View File

@ -92,7 +92,7 @@ build-backend = "poetry.core.masonry.api"
[tool.ruff]
target-version = "py39"
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"
[tool.ruff.lint.per-file-ignores]

View File

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

View File

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

View File

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

View File

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

View File

@ -236,7 +236,7 @@ class Theme(RadixThemesComponent):
tag = super()._render(props)
tag.add_props(
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

View File

@ -78,7 +78,7 @@ class Reflex(SimpleNamespace):
# The root directory of the reflex library.
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):

View File

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

View File

@ -363,7 +363,7 @@ def _login() -> str:
access_token = hosting.authenticate_on_browser(invitation_code)
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)
console.print("Successfully logged in.")

View File

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

View File

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

View File

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

View File

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

View File

@ -153,7 +153,7 @@ def dynamic_route(
running AppHarness instance
"""
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_source=DynamicRoute, # type: ignore
) as harness:

View File

@ -171,7 +171,7 @@ def event_action(tmp_path_factory) -> Generator[AppHarness, None, None]:
running AppHarness instance
"""
with AppHarness.create(
root=tmp_path_factory.mktemp(f"event_action"),
root=tmp_path_factory.mktemp("event_action"),
app_source=TestEventAction, # type: ignore
) as 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)
with AppHarness.create(
root=tmp_path_factory.mktemp(f"large_state"),
root=tmp_path_factory.mktemp("large_state"),
app_source=large_state_rendered,
app_name="large_state",
) as large_state:

View File

@ -74,7 +74,7 @@ async def test_navigation_app(navigation_app: AppHarness):
with poll_for_navigation(driver):
internal_link.click()
assert urlsplit(driver.current_url).path == f"/internal/"
assert urlsplit(driver.current_url).path == "/internal/"
with poll_for_navigation(driver):
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):
"""Get an instance of the browser open to the server_side_event app.
Args:
server_side_event: harness for ServerSideEvent app

View File

@ -216,7 +216,7 @@ def state_inheritance(
running AppHarness instance
"""
with AppHarness.create(
root=tmp_path_factory.mktemp(f"state_inheritance"),
root=tmp_path_factory.mktemp("state_inheritance"),
app_source=StateInheritance, # type: ignore
) as 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}"
upload_box = driver.find_elements(By.XPATH, "//input[@type='file']")[1]
upload_button = driver.find_element(By.ID, f"upload_button_secondary")
cancel_button = driver.find_element(By.ID, f"cancel_button_secondary")
upload_button = driver.find_element(By.ID, "upload_button_secondary")
cancel_button = driver.find_element(By.ID, "cancel_button_secondary")
exp_name = "large.txt"
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) == (
str(Path(".web") / "styles" / "styles.css"),
f"@import url('./tailwind.css'); \n"
f"@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"
f"@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('./tailwind.css'); \n"
"@import url('https://fonts.googleapis.com/css?family=Sofia&effect=neon|outline|emboss|shadow-multiple'); \n"
"@import url('https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css'); \n"
"@import url('../public/styles.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):
"""Dummy on_change handler.
Args:
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
)
FORMATTED_TEST_VAR_DICT_OF_DICT = LiteralVar.create(
{"a": {"b": f"footestbar"}}
{"a": {"b": "footestbar"}}
)._replace(merge_var_data=TEST_VAR._var_data)
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(
filename=f"image1.jpg",
filename="image1.jpg",
file=bio,
)
file2 = UploadFile(
filename=f"image2.jpg",
filename="image2.jpg",
file=bio,
)
upload_fn = upload(app)

View File

@ -1558,7 +1558,7 @@ def test_error_on_state_method_shadow():
assert (
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:
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(

View File

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