Skip to content
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
42 changes: 16 additions & 26 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,14 @@ python = "^3.8"
poetry-core = "1.6.1"
poetry-plugin-export = "^1.4.0"
build = "^0.10.0"
cachecontrol = { version = "^0.12.9", extras = ["filecache"] }
cachecontrol = { version = "^0.13.0", extras = ["filecache"] }
cleo = "^2.0.0"
crashtest = "^0.4.1"
dulwich = "^0.21.2"
filelock = "^3.8.0"
importlib-metadata = { version = ">=4.4", python = "<3.10" }
installer = "^0.7.0"
jsonschema = "^4.10.0"
keyring = "^23.9.0"
lockfile = "^0.12.2"
# packaging uses calver, so version is unclamped
packaging = ">=20.4"
pexpect = "^4.7.0"
Expand All @@ -60,7 +58,6 @@ tomlkit = ">=0.11.4,<1.0.0"
trove-classifiers = ">=2022.5.19"
virtualenv = "^20.22.0"
xattr = { version = "^0.10.0", markers = "sys_platform == 'darwin'" }
urllib3 = "^1.26.0"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

poetry still has a direct dependency on urllib3 -

from urllib3 import util
- so this should not be removed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Seemed really minor for me to be kept but I understand the reasoning, better to be safe than sorry!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Would you prefer to relax the constraint or pin it to ^2.0.2 to enforce the usage of a more recent version? I'd prefer the second but I also understand the Poetry direct dependency on urllib3 works ok with <2 too..

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

so far as I can see that import is only used to set up a Retry, which is configured to retry only for GETs; and the uploader never does a GET, it only POSTs.

So if that's right then that little pile of code could be deleted anyway. But double-check, I only skimmed it..!

Copy link
Copy Markdown
Contributor Author

@ralbertazzi ralbertazzi Jun 2, 2023

Choose a reason for hiding this comment

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

I think you are totally right. Wouldn't it be better to then fix it to "POST" if the original goal was to retry uploads?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

meh, if the code has been there for this long without anyone feeling the need to have working retries - I'd just delete it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was just writing that 😄 Makes sense


[tool.poetry.group.dev.dependencies]
pre-commit = "^2.6"
Expand Down Expand Up @@ -181,17 +178,14 @@ warn_unused_ignores = false

[[tool.mypy.overrides]]
module = [
'cachecontrol.*',
'deepdiff.*',
'httpretty.*',
'keyring.*',
'lockfile.*',
'pexpect.*',
'requests_toolbelt.*',
'shellingham.*',
'virtualenv.*',
'xattr.*',
'zipp.*',
]
ignore_missing_imports = true

Expand Down
18 changes: 0 additions & 18 deletions src/poetry/publishing/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@

from poetry.core.masonry.metadata import Metadata
from poetry.core.masonry.utils.helpers import distribution_name
from requests import adapters
from requests.exceptions import ConnectionError
from requests.exceptions import HTTPError
from requests_toolbelt import user_agent
from requests_toolbelt.multipart import MultipartEncoder
from requests_toolbelt.multipart import MultipartEncoderMonitor
from urllib3 import util

from poetry.__version__ import __version__
from poetry.utils.constants import REQUESTS_TIMEOUT
from poetry.utils.constants import STATUS_FORCELIST
from poetry.utils.patterns import wheel_file_re


Expand Down Expand Up @@ -63,18 +60,6 @@ def user_agent(self) -> str:
agent: str = user_agent("poetry", __version__)
return agent

@property
def adapter(self) -> adapters.HTTPAdapter:
retry = util.Retry(
connect=5,
total=10,
allowed_methods=["GET"],
respect_retry_after_header=True,
status_forcelist=STATUS_FORCELIST,
)

return adapters.HTTPAdapter(max_retries=retry)

@property
def files(self) -> list[Path]:
dist = self._poetry.file.path.parent / "dist"
Expand All @@ -97,9 +82,6 @@ def make_session(self) -> requests.Session:
session.auth = auth

session.headers["User-Agent"] = self.user_agent
for scheme in ("http://", "https://"):
session.mount(scheme, self.adapter)

return session

def get_auth(self) -> tuple[str, str] | None:
Expand Down
23 changes: 0 additions & 23 deletions src/poetry/utils/authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
from typing import TYPE_CHECKING
from typing import Any

import lockfile
import requests
import requests.auth
import requests.exceptions

from cachecontrol import CacheControlAdapter
from cachecontrol.caches import FileCache
from filelock import FileLock

from poetry.config.config import Config
from poetry.exceptions import PoetryException
Expand All @@ -37,26 +35,6 @@
logger = logging.getLogger(__name__)


class FileLockLockFile(lockfile.LockBase): # type: ignore[misc]
# The default LockFile from the lockfile package as used by cachecontrol can remain
# locked if a process exits ungracefully. See eg
# <https://github.com/python-poetry/poetry/issues/6030#issuecomment-1189383875>.
#
# FileLock from the filelock package does not have this problem, so we use that to
# construct something compatible with cachecontrol.
def __init__(
self, path: str, threaded: bool = True, timeout: float | None = None
) -> None:
super().__init__(path, threaded, timeout)
self.file_lock = FileLock(self.lock_file)

def acquire(self, timeout: float | None = None) -> None:
self.file_lock.acquire(timeout=timeout)

def release(self) -> None:
self.file_lock.release()


@dataclasses.dataclass(frozen=True)
class RepositoryCertificateConfig:
cert: Path | None = dataclasses.field(default=None)
Expand Down Expand Up @@ -148,7 +126,6 @@ def __init__(
/ (cache_id or "_default_cache")
/ "_http"
),
lock_class=FileLockLockFile,
)
if not disable_cache
else None
Expand Down