-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cruft and ruff updates #60
Changes from 8 commits
db62e15
087af2c
bd2a218
d51b2d6
00a0f7a
acd65c8
4748b0e
e1261c9
4291f26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022-2024 Perry Goy | ||
Copyright (c) 2022-2025 Perry Goy | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Happy new year! 🎉 |
||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
|
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ extend-exclude = ''' | |
[tool.ruff] | ||
target-version = "py38" # minimum supported version | ||
line-length = 88 # same as Black. | ||
output-format = "concise" | ||
extend-exclude = [ | ||
"docs", | ||
] | ||
|
@@ -86,8 +87,6 @@ ignore = [ | |
"D107", # missing __init__ docstring, we do that in the class docstring. | ||
"D203", # one blank line before class docstring, no thanks! | ||
"D212", # multi line summary first line, we want a one line summary. | ||
"ANN101", # missing self annotation, we only annotate self when we return it. | ||
"ANN102", # missing cls annotation, we only annotate cls when we return it. | ||
] | ||
|
||
extend-safe-fixes = [ | ||
|
@@ -122,13 +121,16 @@ split-on-trailing-comma = false | |
"D", # we don't need public-API-polished docstrings in tests. | ||
"FBT", # using a boolean as a test object is useful! | ||
"PLR", # likewise using specific numbers and strings in tests. | ||
"A", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. newer versions of ruff include more rules, which were triggering on tests. This ignores them. |
||
] | ||
"__version__.py" = ["D"] | ||
|
||
|
||
################################################################################ | ||
# END OF BOILERPLATE ScreenPyHQ CONFIGURATIONS # | ||
################################################################################ | ||
[tool.ruff.lint.flake8-builtins] | ||
builtins-allowed-modules = ["select"] | ||
|
||
[tool.poetry] | ||
name = "screenpy_selenium" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
ScreenPy Selenium is an extension for ScreenPy, enabling interaction with | ||
Selenium. | ||
|
||
:copyright: (c) 2022-2024, Perry Goy. | ||
:copyright: (c) 2022-2025, Perry Goy. | ||
:license: MIT, see LICENSE for more details. | ||
""" | ||
|
||
|
@@ -29,9 +29,9 @@ | |
__all__ = [ | ||
"BrowsingError", | ||
"Chainable", | ||
"settings", | ||
"Target", | ||
"TargetingError", | ||
"settings", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ruff wants these in slightly different alphabetical order. it considers this "isort-style" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense, since |
||
] | ||
|
||
__all__ += abilities.__all__ + actions.__all__ + questions.__all__ + resolutions.__all__ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
from typing import TYPE_CHECKING | ||
|
||
from selenium.webdriver import Chrome, Firefox, Remote, Safari | ||
from selenium.webdriver.common.options import ArgOptions | ||
|
||
from ..exceptions import BrowsingError | ||
|
||
|
@@ -67,18 +68,23 @@ def using_ios(cls) -> Self: | |
capabilities. Default is "iPhone Simulator" | ||
""" | ||
hub_url = os.getenv("APPIUM_HUB_URL", DEFAULT_APPIUM_HUB_URL) | ||
IOS_CAPABILITIES = { | ||
"platformName": "iOS", | ||
"platformVersion": os.getenv("IOS_DEVICE_VERSION"), | ||
"deviceName": os.getenv("IOS_DEVICE_NAME", "iPhone Simulator"), | ||
"automationName": "xcuitest", | ||
"browserName": "Safari", | ||
} | ||
|
||
opts = ArgOptions() | ||
opts.set_capability("platformName", "iOS") | ||
opts.set_capability("platformVersion", os.getenv("IOS_DEVICE_VERSION")) | ||
opts.set_capability( | ||
"deviceName", os.getenv("IOS_DEVICE_NAME", "iPhone Simulator") | ||
) | ||
opts.set_capability("automationName", "xcuitest") | ||
opts.set_capability("browserName", "Safari") | ||
|
||
IOS_CAPABILITIES = opts.to_capabilities() | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm more than a little surprised mypy didn't complain about this sooner. For sure selenium 4.18 would have triggered it. Perhaps it's just been that long since we updated? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps! Either way, thanks for updating it. |
||
if IOS_CAPABILITIES["platformVersion"] is None: | ||
msg = "IOS_DEVICE_VERSION Environment variable must be set." | ||
raise BrowsingError(msg) | ||
|
||
return cls.using(browser=Remote(hub_url, IOS_CAPABILITIES)) | ||
return cls.using(browser=Remote(hub_url, options=opts)) | ||
|
||
@classmethod | ||
def using_android(cls) -> Self: | ||
|
@@ -100,18 +106,23 @@ def using_android(cls) -> Self: | |
capabilities. Default is "Android Emulator" | ||
""" | ||
hub_url = os.getenv("APPIUM_HUB_URL", DEFAULT_APPIUM_HUB_URL) | ||
ANDROID_CAPABILITIES = { | ||
"platformName": "Android", | ||
"platformVersion": os.getenv("ANDROID_DEVICE_VERSION"), | ||
"deviceName": os.getenv("ANDROID_DEVICE_NAME", "Android Emulator"), | ||
"automationName": "UIAutomator2", | ||
"browserName": "Chrome", | ||
} | ||
|
||
opts = ArgOptions() | ||
opts.set_capability("platformName", "Android") | ||
opts.set_capability("platformVersion", os.getenv("ANDROID_DEVICE_VERSION")) | ||
opts.set_capability( | ||
"deviceName", os.getenv("ANDROID_DEVICE_NAME", "Android Emulator") | ||
) | ||
opts.set_capability("automationName", "UIAutomator2") | ||
opts.set_capability("browserName", "Chrome") | ||
|
||
ANDROID_CAPABILITIES = opts.to_capabilities() | ||
|
||
if ANDROID_CAPABILITIES["platformVersion"] is None: | ||
msg = "ANDROID_DEVICE_VERSION environment variable must be set." | ||
raise BrowsingError(msg) | ||
|
||
return cls.using(browser=Remote(hub_url, ANDROID_CAPABILITIES)) | ||
return cls.using(browser=Remote(hub_url, options=opts)) | ||
|
||
@classmethod | ||
def using(cls, browser: WebDriver) -> Self: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,7 @@ def not_raises(ExpectedException: type[Exception]) -> Generator: | |
msg = f"Incorrectly Raised {error}" | ||
raise AssertionError(msg) from error | ||
|
||
except Exception as error: # noqa: BLE001 | ||
except Exception as error: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: Did There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It did! There have been a few rules over the past several months that got updated in a similar fashion. |
||
msg = f"Unexpected exception {error}" | ||
raise AssertionError(msg) from error | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, dang, i guess it's been a while. 😅