Skip to content
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

chore: update linters 2024 #2588

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hooks which we consume from the pre-commit project - they are not shipped automatically so we specify them like that.

hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -15,16 +15,16 @@ repos:
- id: check-executables-have-shebangs
- id: check-merge-conflict
- repo: https://github.com/psf/black
rev: 23.9.1
rev: 24.8.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
rev: v1.11.2
hooks:
- id: mypy
additional_dependencies: [types-pyOpenSSL==23.2.0.2, types-requests==2.31.0.10]
additional_dependencies: [types-pyOpenSSL==24.1.0.20240722, types-requests==2.32.0.20240914]
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
rev: 7.1.1
hooks:
- id: flake8
- repo: https://github.com/pycqa/isort
Expand All @@ -39,7 +39,7 @@ repos:
language: node
pass_filenames: false
types: [python]
additional_dependencies: ["[email protected].278"]
additional_dependencies: ["[email protected].384"]
- repo: local
hooks:
- id: check-license-header
Expand Down
2 changes: 1 addition & 1 deletion local-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mypy==1.11.2
objgraph==3.6.1
Pillow==10.4.0
pixelmatch==0.3.0
pre-commit==3.4.0
pre-commit==3.5.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this one? Why is it different from the previous file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pre-commit - like ESLint - and above are some rules we consume.

pyOpenSSL==24.2.1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one does not seem to match the previous file either.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In both cases the latest version. Seems like its like definitely-typed - so their version can differ.

pytest==8.3.3
pytest-asyncio==0.21.2
Expand Down
16 changes: 10 additions & 6 deletions playwright/_impl/_assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,11 @@ async def to_be_attached(
) -> None:
__tracebackhide__ = True
await self._expect_impl(
"to.be.attached"
if (attached is None or attached is True)
else "to.be.detached",
(
"to.be.attached"
if (attached is None or attached is True)
else "to.be.detached"
),
FrameExpectOptions(timeout=timeout),
None,
"Locator expected to be attached",
Expand All @@ -527,9 +529,11 @@ async def to_be_checked(
) -> None:
__tracebackhide__ = True
await self._expect_impl(
"to.be.checked"
if checked is None or checked is True
else "to.be.unchecked",
(
"to.be.checked"
if checked is None or checked is True
else "to.be.unchecked"
),
FrameExpectOptions(timeout=timeout),
None,
"Locator expected to be checked",
Expand Down
9 changes: 5 additions & 4 deletions playwright/_impl/_async_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import asyncio
from contextlib import AbstractAsyncContextManager
from types import TracebackType
from typing import Any, Callable, Generic, Optional, Type, TypeVar
from typing import Any, Callable, Generic, Optional, Type, TypeVar, Union

from playwright._impl._impl_to_api_mapping import ImplToApiMapping, ImplWrapper

Expand Down Expand Up @@ -68,7 +68,9 @@ def __init__(self, impl_obj: Any) -> None:
def __str__(self) -> str:
return self._impl_obj.__str__()

def _wrap_handler(self, handler: Any) -> Callable[..., None]:
def _wrap_handler(
self, handler: Union[Callable[..., Any], Any]
) -> Callable[..., None]:
if callable(handler):
return mapping.wrap_handler(handler)
return handler
Expand Down Expand Up @@ -100,5 +102,4 @@ async def __aexit__(
) -> None:
await self.close()

async def close(self) -> None:
...
async def close(self) -> None: ...
24 changes: 12 additions & 12 deletions playwright/_impl/_browser_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,21 +316,21 @@ async def clear_cookies(
{
"name": name if isinstance(name, str) else None,
"nameRegexSource": name.pattern if isinstance(name, Pattern) else None,
"nameRegexFlags": escape_regex_flags(name)
if isinstance(name, Pattern)
else None,
"nameRegexFlags": (
escape_regex_flags(name) if isinstance(name, Pattern) else None
),
"domain": domain if isinstance(domain, str) else None,
"domainRegexSource": domain.pattern
if isinstance(domain, Pattern)
else None,
"domainRegexFlags": escape_regex_flags(domain)
if isinstance(domain, Pattern)
else None,
"domainRegexSource": (
domain.pattern if isinstance(domain, Pattern) else None
),
"domainRegexFlags": (
escape_regex_flags(domain) if isinstance(domain, Pattern) else None
),
"path": path if isinstance(path, str) else None,
"pathRegexSource": path.pattern if isinstance(path, Pattern) else None,
"pathRegexFlags": escape_regex_flags(path)
if isinstance(path, Pattern)
else None,
"pathRegexFlags": (
escape_regex_flags(path) if isinstance(path, Pattern) else None
),
},
)

Expand Down
12 changes: 6 additions & 6 deletions playwright/_impl/_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ def cb(task: asyncio.Task) -> None:
if current_task:
current_task.add_done_callback(cb)
self.future.add_done_callback(
lambda _: current_task.remove_done_callback(cb)
if current_task
else None
lambda _: (
current_task.remove_done_callback(cb) if current_task else None
)
)


Expand Down Expand Up @@ -243,9 +243,9 @@ def __init__(
self._error: Optional[BaseException] = None
self.is_remote = False
self._init_task: Optional[asyncio.Task] = None
self._api_zone: contextvars.ContextVar[
Optional[ParsedStackTrace]
] = contextvars.ContextVar("ApiZone", default=None)
self._api_zone: contextvars.ContextVar[Optional[ParsedStackTrace]] = (
contextvars.ContextVar("ApiZone", default=None)
)
self._local_utils: Optional["LocalUtils"] = local_utils
self._tracing_count = 0
self._closed_error: Optional[Exception] = None
Expand Down
2 changes: 1 addition & 1 deletion playwright/_impl/_impl_to_api_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def to_impl(
except RecursionError:
raise Error("Maximum argument depth exceeded")

def wrap_handler(self, handler: Callable[..., None]) -> Callable[..., None]:
def wrap_handler(self, handler: Callable[..., Any]) -> Callable[..., None]:
def wrapper_func(*args: Any) -> Any:
arg_count = len(inspect.signature(handler).parameters)
return handler(
Expand Down
18 changes: 11 additions & 7 deletions playwright/_impl/_js_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,17 @@ def serialize_value(
return {
"e": {
"m": str(value),
"n": (value.name or "")
if isinstance(value, Error)
else value.__class__.__name__,
"s": (value.stack or "")
if isinstance(value, Error)
else "".join(
traceback.format_exception(type(value), value=value, tb=None)
"n": (
(value.name or "")
if isinstance(value, Error)
else value.__class__.__name__
),
"s": (
(value.stack or "")
if isinstance(value, Error)
else "".join(
traceback.format_exception(type(value), value=value, tb=None)
)
),
}
}
Expand Down
1 change: 0 additions & 1 deletion playwright/_impl/_json_pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def __init__(
Transport.__init__(self, loop)
self._stop_requested = False
self._pipe_channel = pipe_channel
self._loop: asyncio.AbstractEventLoop

def request_stop(self) -> None:
self._stop_requested = True
Expand Down
7 changes: 4 additions & 3 deletions playwright/_impl/_sync_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ def _sync(
asyncio._set_running_loop(self._loop)
return task.result()

def _wrap_handler(self, handler: Any) -> Callable[..., None]:
def _wrap_handler(
self, handler: Union[Callable[..., Any], Any]
) -> Callable[..., None]:
if callable(handler):
return mapping.wrap_handler(handler)
return handler
Expand Down Expand Up @@ -146,5 +148,4 @@ def __exit__(
) -> None:
self.close()

def close(self) -> None:
...
def close(self) -> None: ...
11 changes: 5 additions & 6 deletions playwright/async_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,19 @@ def set_options(self, timeout: Optional[float] = _unset) -> None:
self._timeout = timeout

@overload
def __call__(self, actual: Page, message: Optional[str] = None) -> PageAssertions:
...
def __call__(
self, actual: Page, message: Optional[str] = None
) -> PageAssertions: ...

@overload
def __call__(
self, actual: Locator, message: Optional[str] = None
) -> LocatorAssertions:
...
) -> LocatorAssertions: ...

@overload
def __call__(
self, actual: APIResponse, message: Optional[str] = None
) -> APIResponseAssertions:
...
) -> APIResponseAssertions: ...

def __call__(
self, actual: Union[Page, Locator, APIResponse], message: Optional[str] = None
Expand Down
Loading
Loading