Skip to content

Commit

Permalink
Apply requests best practices (#8558)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakob-keller authored Oct 20, 2023
1 parent 611033a commit c41e213
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/poetry/publishing/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def auth(self, username: str | None, password: str | None) -> None:
self._password = password

def make_session(self) -> requests.Session:
session = requests.session()
session = requests.Session()
auth = self.get_auth()
if auth is not None:
session.auth = auth
Expand Down Expand Up @@ -106,10 +106,8 @@ def upload(
if client_cert:
session.cert = str(client_cert)

try:
with session:
self._upload(session, url, dry_run, skip_existing)
finally:
session.close()

def post_data(self, file: Path) -> dict[str, Any]:
meta = Metadata.from_package(self._package)
Expand Down
2 changes: 1 addition & 1 deletion src/poetry/repositories/pypi_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(
def search(self, query: str) -> list[Package]:
results = []

response = requests.session().get(
response = requests.get(
self._base_url + "search", params={"q": query}, timeout=REQUESTS_TIMEOUT
)
parser = SearchResultParser()
Expand Down

0 comments on commit c41e213

Please sign in to comment.