Skip to content
This repository was archived by the owner on Oct 14, 2024. It is now read-only.

Commit 8b61089

Browse files
Martin Lambertsenbaywet
Martin Lambertsen
andauthored
fix: avoid using default mutable parameters
* Do not use mutable default arguments Using mutable default arguments is a common Python problem, see e.g. https://docs.python-guide.org/writing/gotchas/#mutable-default-arguments In this specific case the default argument even tries to setup some infrastructure settings at import time, which can potentially fail. * chore: adds date to changelog entry * Update CHANGELOG.md --------- Co-authored-by: Vincent Biret <vincentbiret@hotmail.com>
1 parent 7fc8509 commit 8b61089

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.3.2] - 2024-07-09
9+
10+
### Added
11+
12+
### Changed
13+
- Do not use mutable default arguments for HttpxRequestAdapter.[#383](https://github.com/microsoft/kiota-http-python/pull/383)
14+
815
## [1.3.1] - 2024-02-13
916

1017
### Added

kiota_http/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION: str = '1.3.1'
1+
VERSION: str = '1.3.2'

kiota_http/httpx_request_adapter.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
"""HTTPX client request adapter."""
22
import re
3-
from collections.abc import AsyncIterable, Iterable
43
from datetime import datetime
54
from typing import Any, Dict, Generic, List, Optional, TypeVar, Union
65
from urllib import parse
7-
from urllib.parse import unquote
86

97
import httpx
108
from kiota_abstractions.api_client_builder import (
@@ -63,29 +61,29 @@ class HttpxRequestAdapter(RequestAdapter, Generic[ModelType]):
6361
def __init__(
6462
self,
6563
authentication_provider: AuthenticationProvider,
66-
parse_node_factory: ParseNodeFactory = ParseNodeFactoryRegistry(),
67-
serialization_writer_factory:
68-
SerializationWriterFactory = SerializationWriterFactoryRegistry(),
69-
http_client: httpx.AsyncClient = KiotaClientFactory.create_with_default_middleware(),
70-
base_url: str = "",
71-
observability_options=ObservabilityOptions(),
64+
parse_node_factory: Optional[ParseNodeFactory] = None,
65+
serialization_writer_factory: Optional[SerializationWriterFactory] = None,
66+
http_client: Optional[httpx.AsyncClient] = None,
67+
base_url: Optional[str] = None,
68+
observability_options: Optional[ObservabilityOptions] = None,
7269
) -> None:
7370
if not authentication_provider:
7471
raise TypeError("Authentication provider cannot be null")
7572
self._authentication_provider = authentication_provider
7673
if not parse_node_factory:
77-
raise TypeError("Parse node factory cannot be null")
74+
parse_node_factory = ParseNodeFactoryRegistry()
7875
self._parse_node_factory = parse_node_factory
7976
if not serialization_writer_factory:
80-
raise TypeError("Serialization writer factory cannot be null")
77+
serialization_writer_factory = SerializationWriterFactoryRegistry()
8178
self._serialization_writer_factory = serialization_writer_factory
8279
if not http_client:
83-
raise TypeError("Http Client cannot be null")
84-
if not observability_options:
85-
observability_options = ObservabilityOptions()
86-
80+
http_client = KiotaClientFactory.create_with_default_middleware()
8781
self._http_client = http_client
82+
if not base_url:
83+
base_url = ""
8884
self._base_url: str = base_url
85+
if not observability_options:
86+
observability_options = ObservabilityOptions()
8987
self.observability_options = observability_options
9088

9189
@property

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy