Skip to content

Commit 1518597

Browse files
neha-sanseclaude
andcommitted
Fix all remaining lint: line length, too-many-arguments, protected-access, import-outside-toplevel
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 05fa517 commit 1518597

2 files changed

Lines changed: 35 additions & 24 deletions

File tree

percy/robot_library.py

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
_screenshot_module = None
3636

3737
def _get_screenshot_module():
38-
global _screenshot_module
38+
global _screenshot_module # pylint: disable=global-statement
3939
if _screenshot_module is None:
40-
from percy import screenshot as _mod
40+
from percy import screenshot as _mod # pylint: disable=import-outside-toplevel
4141
_screenshot_module = _mod
4242
return _screenshot_module
4343

@@ -125,12 +125,14 @@ def _get_page(self):
125125
# --------------------------------------------------------------
126126

127127
@keyword("Percy Snapshot")
128-
def percy_snapshot_keyword(self, name, widths=None, min_height=None,
129-
percy_css=None, scope=None, scope_options=None,
130-
enable_javascript=None, enable_layout=None,
131-
disable_shadow_dom=None, labels=None,
132-
test_case=None, sync=None, regions=None,
133-
responsive_snapshot_capture=None):
128+
def percy_snapshot_keyword( # pylint: disable=too-many-arguments,too-many-locals
129+
self, name, widths=None, min_height=None,
130+
percy_css=None, scope=None, scope_options=None,
131+
enable_javascript=None, enable_layout=None,
132+
disable_shadow_dom=None, labels=None,
133+
test_case=None, sync=None, regions=None,
134+
responsive_snapshot_capture=None,
135+
):
134136
"""Capture a Percy visual snapshot of the current page.
135137
136138
``name`` is the snapshot name shown in the Percy dashboard.
@@ -184,14 +186,16 @@ def percy_snapshot_keyword(self, name, widths=None, min_height=None,
184186
# --------------------------------------------------------------
185187

186188
@keyword("Create Percy Region")
187-
def create_percy_region_keyword(self, algorithm="ignore",
188-
bounding_box=None, element_xpath=None,
189-
element_css=None, padding=None,
190-
diff_sensitivity=None,
191-
image_ignore_threshold=None,
192-
carousels_enabled=None,
193-
banners_enabled=None, ads_enabled=None,
194-
diff_ignore_threshold=None):
189+
def create_percy_region_keyword( # pylint: disable=too-many-arguments
190+
self, algorithm="ignore",
191+
bounding_box=None, element_xpath=None,
192+
element_css=None, padding=None,
193+
diff_sensitivity=None,
194+
image_ignore_threshold=None,
195+
carousels_enabled=None,
196+
banners_enabled=None, ads_enabled=None,
197+
diff_ignore_threshold=None,
198+
):
195199
"""Create a region definition for Percy ignore/consider regions.
196200
197201
``algorithm`` is one of ``ignore``, ``standard``, or ``intelliignore``.
@@ -215,7 +219,9 @@ def create_percy_region_keyword(self, algorithm="ignore",
215219
padding=int(padding) if padding else None,
216220
algorithm=algorithm,
217221
diffSensitivity=int(diff_sensitivity) if diff_sensitivity else None,
218-
imageIgnoreThreshold=float(image_ignore_threshold) if image_ignore_threshold else None,
222+
imageIgnoreThreshold=(
223+
float(image_ignore_threshold) if image_ignore_threshold else None
224+
),
219225
carouselsEnabled=_parse_bool(carousels_enabled),
220226
bannersEnabled=_parse_bool(banners_enabled),
221227
adsEnabled=_parse_bool(ads_enabled),
@@ -233,11 +239,11 @@ def percy_is_running_keyword(self):
233239
Returns ``True`` if Percy is available, ``False`` otherwise.
234240
"""
235241
mod = _get_screenshot_module()
236-
return bool(mod._is_percy_enabled())
242+
return bool(mod._is_percy_enabled()) # pylint: disable=protected-access
237243

238244
else:
239-
class PercyLibrary: # pylint: disable=function-redefined
240-
"""Stub robotframework is not installed."""
245+
class PercyLibrary: # pylint: disable=function-redefined,too-few-public-methods
246+
"""Stub -- robotframework is not installed."""
241247
def __init__(self):
242248
raise ImportError(
243249
"robotframework is not installed. "

tests/test_robot_library.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
import sys
77
from unittest.mock import MagicMock, patch
88

9-
# Mock playwright before any percy imports
9+
# Mock playwright before any percy imports pylint: disable=protected-access
1010
_mock_playwright = MagicMock()
11-
_mock_playwright._repo_version.version = "1.50.0"
11+
_mock_playwright._repo_version.version = "1.50.0" # pylint: disable=protected-access
1212
_mock_playwright.sync_api.Error = Exception
1313
_mock_playwright.sync_api.TimeoutError = TimeoutError
1414
sys.modules.setdefault("playwright", _mock_playwright)
15-
sys.modules.setdefault("playwright._repo_version", _mock_playwright._repo_version)
15+
sys.modules.setdefault( # pylint: disable=protected-access
16+
"playwright._repo_version", _mock_playwright._repo_version
17+
)
1618
sys.modules.setdefault("playwright.sync_api", _mock_playwright.sync_api)
1719

1820
from percy.robot_library import ( # noqa: E402 pylint: disable=wrong-import-position
@@ -87,7 +89,10 @@ def test_percy_is_running(self, mock_get_mod):
8789
@patch("percy.robot_library._get_screenshot_module")
8890
def test_create_region(self, mock_get_mod):
8991
mock_mod = MagicMock()
90-
mock_mod.create_region.return_value = {"algorithm": "ignore", "elementSelector": {"elementCSS": ".ad"}}
92+
mock_mod.create_region.return_value = {
93+
"algorithm": "ignore",
94+
"elementSelector": {"elementCSS": ".ad"},
95+
}
9196
mock_get_mod.return_value = mock_mod
9297

9398
lib = PercyLibrary()

0 commit comments

Comments
 (0)