Skip to content
Open
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
7 changes: 7 additions & 0 deletions .chronus/changes/nextversion-2025-11-30-10-16-46.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@typespec/http-client-python"
---

internal dependency bump
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pyright==1.1.405
pylint==3.2.7
pyright==1.1.407
pylint==4.0.4
tox==4.16.0
mypy==1.18.1
mypy==1.19.1
colorama==0.4.6
debugpy==1.8.2
pytest==8.3.2
Expand Down
2 changes: 1 addition & 1 deletion packages/http-client-python/eng/scripts/ci/pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ enable=useless-suppression
# too-many-arguments: Due to the nature of the CLI many commands have large arguments set which reflect in large arguments set in corresponding methods.
# too-many-lines: Due to code generation many files end up with too many lines.
# Let's black deal with bad-continuation
disable=missing-docstring,locally-disabled,fixme,cyclic-import,too-many-arguments,invalid-name,duplicate-code,too-few-public-methods,consider-using-f-string,super-with-arguments,redefined-builtin,import-outside-toplevel,client-suffix-needed,unnecessary-dunder-call,unnecessary-ellipsis,disallowed-name,consider-using-max-builtin,unknown-option-value,file-needs-copyright-header
disable=missing-docstring,locally-disabled,fixme,cyclic-import,too-many-arguments,invalid-name,duplicate-code,too-few-public-methods,consider-using-f-string,super-with-arguments,redefined-builtin,import-outside-toplevel,client-suffix-needed,unnecessary-dunder-call,unnecessary-ellipsis,disallowed-name,consider-using-max-builtin,unknown-option-value,file-needs-copyright-header,too-many-positional-arguments

[FORMAT]
max-line-length=120
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def get_no_polling_method_path(async_mode: bool) -> str:

def get_no_polling_method(self, async_mode: bool) -> str:
"""Get the default no polling method"""
return self.get_no_polling_method_path(async_mode).split(".")[-1]
return self.get_no_polling_method_path(async_mode).rsplit(".", maxsplit=1)[-1]

@staticmethod
def get_base_polling_method_path(async_mode: bool) -> str:
Expand All @@ -242,7 +242,7 @@ def get_base_polling_method_path(async_mode: bool) -> str:

def get_base_polling_method(self, async_mode: bool) -> str:
"""Get the base polling method."""
return self.get_base_polling_method_path(async_mode).split(".")[-1]
return self.get_base_polling_method_path(async_mode).rsplit(".", maxsplit=1)[-1]

def type_annotation(self, **kwargs: Any) -> str:
return f"{self.get_poller(kwargs.get('async_mode', False))}[{super().type_annotation(**kwargs)}]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ __all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"]

TZ_UTC = timezone.utc
_T = typing.TypeVar("_T")
_NONE_TYPE = type(None)

{% if code_model.has_external_type %}
TYPE_HANDLER_REGISTRY = TypeHandlerRegistry()
Expand Down Expand Up @@ -916,16 +917,16 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur

# is it optional?
try:
if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore
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 to workaround unidiomatic-typecheck

if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore
if len(annotation.__args__) <= 2: # pyright: ignore
if_obj_deserializer = _get_deserialize_callable_from_annotation(
next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore
next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore
)

return functools.partial(_deserialize_with_optional, if_obj_deserializer)
# the type is Optional[Union[...]], we need to remove the None type from the Union
annotation_copy = copy.copy(annotation)
annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a != type(None)] # pyright: ignore
annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a is not _NONE_TYPE] # pyright: ignore
return _get_deserialize_callable_from_annotation(annotation_copy, module, rf)
except AttributeError:
pass
Expand Down
Loading