Skip to content

Commit

Permalink
Merge pull request #2892 from tdadela/rm-redundant-None-in-Any-None-a…
Browse files Browse the repository at this point in the history
…nnotations

Remove redundant None in Any | None annotations
  • Loading branch information
cyberw authored Sep 6, 2024
2 parents 68716e0 + c4f7d86 commit 8c63086
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
36 changes: 18 additions & 18 deletions locust/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
# Mypy underneath uses information from the https://github.com/python/typeshed repo.

class RequestKwargs(TypedDict, total=False):
params: Any | None # simplified signature
params: Any # simplified signature
headers: Mapping[str, str | bytes | None] | None
cookies: RequestsCookieJar | MutableMapping[str, str] | None
files: Any | None # simplified signature
auth: Any | None # simplified signature
files: Any # simplified signature
auth: Any # simplified signature
timeout: float | tuple[float, float] | tuple[float, None] | None
allow_redirects: bool
proxies: MutableMapping[str, str] | None
Expand Down Expand Up @@ -139,8 +139,8 @@ def request( # type: ignore[override]
catch_response: bool = False,
context: dict = {},
*,
data: Any | None = None,
json: Any | None = None,
data: Any = None,
json: Any = None,
**kwargs: Unpack[RequestKwargs],
):
"""
Expand Down Expand Up @@ -245,7 +245,7 @@ def _send_request_safe_mode(self, method, url, **kwargs) -> Response | LocustRes
return r

def get(
self, url: str | bytes, *, data: Any | None = None, json: Any | None = None, **kwargs: Unpack[RESTKwargs]
self, url: str | bytes, *, data: Any = None, json: Any = None, **kwargs: Unpack[RESTKwargs]
) -> ResponseContextManager | Response | LocustResponse:
"""Sends a GET request"""
kwargs.setdefault("allow_redirects", True)
Expand All @@ -255,8 +255,8 @@ def options(
self,
url: str | bytes,
*,
data: Any | None = None,
json: Any | None = None,
data: Any = None,
json: Any = None,
**kwargs: Unpack[RESTKwargs],
) -> ResponseContextManager | Response | LocustResponse:
"""Sends a OPTIONS request"""
Expand All @@ -267,8 +267,8 @@ def head(
self,
url: str | bytes,
*,
data: Any | None = None,
json: Any | None = None,
data: Any = None,
json: Any = None,
**kwargs: Unpack[RESTKwargs],
) -> ResponseContextManager | Response | LocustResponse:
"""Sends a HEAD request"""
Expand All @@ -278,8 +278,8 @@ def head(
def post(
self,
url: str | bytes,
data: Any | None = None,
json: Any | None = None,
data: Any = None,
json: Any = None,
**kwargs: Unpack[RESTKwargs],
) -> ResponseContextManager | Response | LocustResponse:
"""Sends a POST request"""
Expand All @@ -288,9 +288,9 @@ def post(
def put(
self,
url: str | bytes,
data: Any | None = None,
data: Any = None,
*,
json: Any | None = None,
json: Any = None,
**kwargs: Unpack[RESTKwargs],
) -> ResponseContextManager | Response | LocustResponse:
"""Sends a PUT request"""
Expand All @@ -299,9 +299,9 @@ def put(
def patch(
self,
url: str | bytes,
data: Any | None = None,
data: Any = None,
*,
json: Any | None = None,
json: Any = None,
**kwargs: Unpack[RESTKwargs],
) -> ResponseContextManager | Response | LocustResponse:
"""Sends a PATCH request"""
Expand All @@ -311,8 +311,8 @@ def delete(
self,
url: str | bytes,
*,
data: Any | None = None,
json: Any | None = None,
data: Any = None,
json: Any = None,
**kwargs: Unpack[RESTKwargs],
) -> ResponseContextManager | Response | LocustResponse:
"""Sends a DELETE request"""
Expand Down
10 changes: 5 additions & 5 deletions locust/contrib/fasthttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ class PostKwargs(TypedDict, total=False):
context: dict

class PutKwargs(PostKwargs, total=False):
json: Any | None
json: Any

class PatchKwargs(PostKwargs, total=False):
json: Any | None
json: Any

class RESTKwargs(PostKwargs, total=False):
data: str | dict | None
json: Any | None
json: Any


# Monkey patch geventhttpclient.useragent.CompatRequest so that Cookiejar works with Python >= 3.3
Expand Down Expand Up @@ -185,7 +185,7 @@ def request(
stream: bool = False,
headers: dict | None = None,
auth: tuple[str | bytes, str | bytes] | None = None,
json: Any | None = None,
json: Any = None,
allow_redirects: bool = True,
context: dict = {},
**kwargs,
Expand Down Expand Up @@ -316,7 +316,7 @@ def patch(
return self.request("PATCH", url, data=data, **kwargs)

def post(
self, url: str, data: str | dict | None = None, json: Any | None = None, **kwargs: Unpack[PostKwargs]
self, url: str, data: str | dict | None = None, json: Any = None, **kwargs: Unpack[PostKwargs]
) -> ResponseContextManager | FastResponse:
"""Sends a POST request"""
return self.request("POST", url, data=data, json=json, **kwargs)
Expand Down
4 changes: 2 additions & 2 deletions locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def start(
) -> None: ...

@abstractmethod
def send_message(self, msg_type: str, data: Any | None = None, client_id: str | None = None) -> None: ...
def send_message(self, msg_type: str, data: Any = None, client_id: str | None = None) -> None: ...

def start_shape(self) -> None:
"""
Expand Down Expand Up @@ -550,7 +550,7 @@ def stop(self) -> None:
return
super().stop()

def send_message(self, msg_type: str, data: Any | None = None, client_id: str | None = None) -> None:
def send_message(self, msg_type: str, data: Any = None, client_id: str | None = None) -> None:
"""
Emulates internodal messaging by calling registered listeners
Expand Down
2 changes: 1 addition & 1 deletion locust/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ def to_name(self) -> str:
return f"{self.method} {self.name}: {unwrapped_error}"

def serialize(self) -> StatsErrorDict:
def _getattr(obj: StatsError, key: str, default: Any | None) -> Any | None:
def _getattr(obj: StatsError, key: str, default: Any) -> Any:
value = getattr(obj, key, default)

if key in ["error"]:
Expand Down

0 comments on commit 8c63086

Please sign in to comment.