You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This PR adds autoflake to the Python linting environment in py/tox.ini. It uses pyflakes, which is already run by flake8, but this uses a slightly different configuration and fixes errors in place (flake8 runs more linters but doesn't auto-fix any errors).
It is enabled in the linting and linting-ci tox environments, so it will run locally as well as CI.
The flake8 configuration should be in the tox.ini file or .flake8 file, not in pyproject.toml. The flake8-pyproject package is added as a dependency, but flake8 doesn't natively support configuration in pyproject.toml.
+# Either move this configuration to tox.ini or .flake8, or ensure flake8-pyproject is properly installed and configured
[tool.flake8]
exclude = "selenium/webdriver/common/devtools"
# Disable E501 once line length is better handled
extend-ignore = ["E501", "E203"]
# This does nothing for now as E501 is ignored
max-line-length = 120
min-python-version = "3.9"
Apply this suggestion
Suggestion importance[1-10]: 7
__
Why: This is a valid concern about flake8 configuration in pyproject.toml. The PR adds flake8-pyproject as a dependency in tox.ini, which is needed for flake8 to read from pyproject.toml. However, highlighting this potential issue is valuable to ensure proper configuration.
✅ Add missing autoflake optionSuggestion Impact:The suggestion was directly implemented in the commit by adding the 'remove-all-unused-imports = true' line to the autoflake configuration in pyproject.toml, exactly as suggested.
code diff:
+remove-all-unused-imports = true
Consider adding the remove-all-unused-imports option to the autoflake configuration to ensure all unused imports are removed, which aligns with the PR's goal of adding autoflake for linting.
Why: The suggestion adds the 'remove-all-unused-imports' option to autoflake configuration, which aligns with the PR's goal of enhancing linting capabilities. This is a relevant improvement that would make the autoflake tool more effective at removing unused imports.
Low
Fix inconsistent return type annotation
The return type annotation is incorrect. The function returns a callable that produces either a WebElement or False, but the Union order is reversed from the standard pattern used in other similar functions in this file.
Why: The suggestion correctly identifies an inconsistency in the return type annotation. Other similar functions in the file use Union[WebElement, Literal[False]] pattern, while this function uses the reverse order. Fixing this improves code consistency.
Low
✅ Suggestions up to commit ac67486
Category
Suggestion
Impact
Possible issue
Fix incorrect return type
The return type annotation is incorrect. The function returns a callable that produces either a WebElement or False, but the current type annotation uses a Literal[False] which is too restrictive. It should use a more general boolean type.
Why: The suggestion correctly identifies a type annotation issue. Using Union[bool, WebElement] is more accurate than Union[Literal[False], WebElement] since it better represents the function's actual return behavior.
Medium
✅ Fix flake8 configurationSuggestion Impact:The commit partially implemented the suggestion by adding quotes around the Python version value (3.9 -> "3.9"), but did not change the parameter name from hyphenated to underscore format
The flake8-pyproject package is added as a dependency in tox.ini, but the configuration in pyproject.toml might not work as expected. Flake8 traditionally doesn't read from pyproject.toml natively - it requires the flake8-pyproject plugin to be properly configured.
[tool.flake8]
exclude = "selenium/webdriver/common/devtools"
# Disable E501 once line length is better handled
extend-ignore = ["E501", "E203"]
# This does nothing for now as E501 is ignored
max-line-length = 120
-min-python-version = 3.9+min_python_version = "3.9"
[Suggestion has been applied]
Suggestion importance[1-10]: 5
__
Why: The suggestion correctly identifies a configuration issue with flake8 in pyproject.toml. The parameter should be min_python_version with an underscore instead of min-python-version with a hyphen, and the value should be a string "3.9" rather than a number.
✅ Remove only_modified isort optionSuggestion Impact:The suggestion to remove the 'only_modified = true' option was implemented. The line was removed as suggested, though additional changes were also made by adding 'quiet = true' and 'skip = "selenium/webdriver/common/devtools"' options.
The only_modified option in isort configuration will limit isort to only process modified files. This could lead to inconsistent formatting across the codebase. For a linting tool in a CI environment, it's better to ensure all files follow the same standard.
[tool.isort]
# isort is a common python tool for keeping imports nicely formatted.
# Automatically keep imports alphabetically sorted, on single lines in
# PEP recommended sections (https://peps.python.org/pep-0008/#imports)
# files or individual lines can be ignored via `# isort:skip|# isort:skip_file`.
force_single_line = true
profile = "black"
py_version = 39
-only_modified = true
Suggestion importance[1-10]: 8
__
Why: The suggestion correctly identifies a potential issue with the added "only_modified" option, which could lead to inconsistent formatting across the codebase. Removing this option would ensure consistent formatting standards are applied to all files.
Medium
Maintain original package versions
The PR is adding autoflake as a linter but also changing package versions in tox.ini. This contradicts the PR title which only mentions adding autoflake. Consider keeping the original package versions to maintain the focus of this PR.
Why: The suggestion correctly identifies that changing package versions is outside the scope of a PR focused on adding autoflake. Keeping the original versions would maintain the PR's focus and reduce potential issues from unrelated changes.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
💥 What does this PR do?
This PR adds
autoflake
to the Python linting environment inpy/tox.ini
. It usespyflakes
, which is already run byflake8
, but this uses a slightly different configuration and fixes errors in place (flake8
runs more linters but doesn't auto-fix any errors).It is enabled in the
linting
andlinting-ci
tox environments, so it will run locally as well as CI.More info: https://pypi.org/project/autoflake/
This PR also contains:
tox.ini
andpyproject.toml
flake8
configuration fromtox.ini
topyproject.toml
(using theflake8-pyproject
package)conftest.py
selenium/webdriver/support/expected_conditions.py
🔄 Types of changes
PR Type
Enhancement, Other
Description
Added
autoflake
to Python linting environment for unused imports/variables.Configured
autoflake
inpyproject.toml
with specific settings.Updated
tox.ini
to includeautoflake
in the linting and linting-ci tasks.Improved comments and formatting in
tox.ini
for clarity.Changes walkthrough 📝
pyproject.toml
Added autoflake configuration to pyproject.toml
py/pyproject.toml
autoflake
configuration section.ignore-pass-after-docstring
andremove-unused-variables
.autoflake
to operate recursively and in-place.tox.ini
Integrated autoflake into tox linting tasks
py/tox.ini
autoflake
to linting dependencies and commands.