Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: aio-libs/yarl
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 96a1c984797be369898aef42c1729d757e990dee
Choose a base ref
..
head repository: aio-libs/yarl
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5c977b52a33bf58f016e5968934c3fcb8b49b239
Choose a head ref
Showing with 127 additions and 49 deletions.
  1. +1 −1 .github/workflows/ci.yml
  2. +1 −0 CHANGES/862.bugfix.rst
  3. +1 −0 CHANGES/871.bugfix.rst
  4. +1 −1 CHANGES/876.bugfix.rst
  5. +2 −0 CHANGES/886.misc.rst
  6. +1 −0 CHANGES/890.misc.rst
  7. +4 −1 pyproject.toml
  8. +1 −1 requirements/dev.txt
  9. +1 −1 requirements/towncrier.txt
  10. +79 −1 setup.cfg
  11. +0 −40 setup.py
  12. +31 −0 tests/test_url.py
  13. +4 −3 yarl/_url.py
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -226,7 +226,7 @@ jobs:
run: |
make cythonize
- name: Build wheels
uses: pypa/cibuildwheel@v2.13.0
uses: pypa/cibuildwheel@v2.13.1
env:
CIBW_ARCHS_MACOS: x86_64 arm64 universal2
- uses: actions/upload-artifact@v3
1 change: 1 addition & 0 deletions CHANGES/862.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Stopped dropping trailing slashes in ``URL.joinpath``.
1 change: 1 addition & 0 deletions CHANGES/871.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Accept string subclasses in truediv operations (``URL / segment``)
2 changes: 1 addition & 1 deletion CHANGES/876.bugfix.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Fixed the human representation of URLs with square brackets in usernames and passwords,
Fixed the human representation of URLs with square brackets in usernames and passwords.
2 changes: 2 additions & 0 deletions CHANGES/886.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Declared modern ``setuptools.build_meta`` as the :pep:`517` build
backend in ``pyproject.toml`` explicitly.
1 change: 1 addition & 0 deletions CHANGES/890.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Converted most of the packaging setup into a declarative ``setup.cfg`` config.
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[build-system]
requires = ["setuptools>=40", "wheel"]
requires = [
"setuptools>=40",
]
build-backend = "setuptools.build_meta"

[tool.towncrier]
package = "yarl"
2 changes: 1 addition & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
-r ci.txt
towncrier==22.12.0
towncrier==23.6.0
2 changes: 1 addition & 1 deletion requirements/towncrier.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
towncrier==22.12.0
towncrier==23.6.0
80 changes: 79 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,83 @@
[bdist_wheel]
# wheels should be OS-specific:
# their names must contain macOS/manulinux1/2010/2014/Windows identifiers
universal = 0

[metadata]
license_file = LICENSE
name = yarl
version = attr: yarl.__version__
url = https://github.com/aio-libs/yarl
project_urls =
Chat: Matrix = https://matrix.to/#/#aio-libs-space:matrix.org
CI: GitHub Workflows = https://github.com/aio-libs/yarl/actions?query=branch:master
Code of Conduct = https://github.com/aio-libs/.github/blob/master/CODE_OF_CONDUCT.md
Coverage: codecov = https://codecov.io/github/aio-libs/yarl
Docs: Changelog = https://github.com/aio-libs/yarl/blob/master/CHANGES.rst#changelog
Docs: RTD = https://yarl.aio-libs.org
GitHub: issues = https://github.com/aio-libs/yarl/issues
GitHub: repo = https://github.com/aio-libs/yarl
description = Yet another URL library
# long_description = file: README.rst, CHANGES.rst
long_description_content_type = text/x-rst
author = Andrew Svetlov
author_email = andrew.svetlov@gmail.com
maintainer = aiohttp team <team@aiohttp.org>
maintainer_email = team@aiohttp.org
license = Apache-2.0
license_files =
LICENSE
classifiers =
Development Status :: 5 - Production/Stable

Intended Audience :: Developers

License :: OSI Approved :: Apache Software License

Programming Language :: Cython
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11

Topic :: Internet :: WWW/HTTP
Topic :: Software Development :: Libraries :: Python Modules
keywords =
cython
cext
yarl

[options]
python_requires = >=3.7
# Ref:
# https://setuptools.readthedocs.io/en/latest/setuptools.html#using-a-src-layout
# (`src/` layout)
# package_dir =
# = src
packages =
yarl
# https://setuptools.readthedocs.io/en/latest/setuptools.html#setting-the-zip-safe-flag
zip_safe = False
include_package_data = True

install_requires =
idna >= 2.0
multidict >= 4.0
typing-extensions >= 3.7.4; python_version < "3.8"

[options.package_data]
# Ref:
# https://setuptools.readthedocs.io/en/latest/setuptools.html#options
# (see notes for the asterisk/`*` meaning)
* =
*.so

[exclude_package_data]
* =
*.c
*.h


[tool:pytest]
40 changes: 0 additions & 40 deletions setup.py
Original file line number Diff line number Diff line change
@@ -12,24 +12,9 @@


extensions = [Extension("yarl._quoting_c", ["yarl/_quoting_c.c"])]
# extra_compile_args=["-g"],
# extra_link_args=["-g"],


here = pathlib.Path(__file__).parent
fname = here / "yarl" / "__init__.py"

with fname.open(encoding="utf8") as fp:
try:
version = re.findall(r'^__version__ = "([^"]+)"$', fp.read(), re.M)[0]
except IndexError:
raise RuntimeError("Unable to determine version.")

install_requires = [
"multidict>=4.0",
"idna>=2.0",
'typing-extensions>=3.7.4;python_version<"3.8"',
]


def read(name):
@@ -48,34 +33,9 @@ def sanitize_rst_roles(rst_source_text: str) -> str:


args = dict(
name="yarl",
version=version,
description=("Yet another URL library"),
long_description="\n\n".join(
[read("README.rst"), sanitize_rst_roles(read("CHANGES.rst"))]
),
long_description_content_type="text/x-rst",
classifiers=[
"License :: OSI Approved :: Apache Software License",
"Intended Audience :: Developers",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Internet :: WWW/HTTP",
],
author="Andrew Svetlov",
author_email="andrew.svetlov@gmail.com",
url="https://github.com/aio-libs/yarl/",
license="Apache-2.0",
packages=["yarl"],
install_requires=install_requires,
python_requires=">=3.7",
include_package_data=True,
exclude_package_data={"": ["*.c"]},
)


31 changes: 31 additions & 0 deletions tests/test_url.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from enum import Enum
from urllib.parse import SplitResult

import pytest
@@ -713,6 +714,18 @@ def test_div_path_starting_from_slash_is_forbidden():
url / "/to/others"


class StrEnum(str, Enum):
spam = "ham"

def __str__(self):
return self.value


def test_div_path_srting_subclass():
url = URL("http://example.com/path/") / StrEnum.spam
assert str(url) == "http://example.com/path/ham"


def test_div_bad_type():
url = URL("http://example.com/path/")
with pytest.raises(TypeError):
@@ -791,6 +804,21 @@ def test_div_with_dots():
"http://example.com/path/to",
id="cleanup-query-and-fragment",
),
pytest.param("", ("path/",), "http://example.com/path/", id="trailing-slash"),
pytest.param(
"", ("path/", "to/"), "http://example.com/path/to/", id="duplicate-slash"
),
pytest.param("", (), "http://example.com", id="empty-segments"),
pytest.param(
"/", ("path/",), "http://example.com/path/", id="base-slash-trailing-slash"
),
pytest.param(
"/",
("path/", "to/"),
"http://example.com/path/to/",
id="base-slash-duplicate-slash",
),
pytest.param("/", (), "http://example.com", id="base-slash-empty-segments"),
],
)
def test_joinpath(base, to_join, expected):
@@ -805,6 +833,9 @@ def test_joinpath(base, to_join, expected):
pytest.param(URL("a"), ("b",), ("a", "b"), id="relative-path"),
pytest.param(URL("a"), ("b", "", "c"), ("a", "b", "c"), id="empty-element"),
pytest.param(URL("/a"), ("b"), ("/", "a", "b"), id="absolute-path"),
pytest.param(URL(), ("a/",), ("a", ""), id="trailing-slash"),
pytest.param(URL(), ("a/", "b/"), ("a", "b", ""), id="duplicate-slash"),
pytest.param(URL(), (), ("",), id="empty-segments"),
],
)
def test_joinpath_relative(url, to_join, expected):
7 changes: 4 additions & 3 deletions yarl/_url.py
Original file line number Diff line number Diff line change
@@ -341,9 +341,9 @@ def __gt__(self, other):
return self._val > other._val

def __truediv__(self, name):
if not type(name) is str:
if not isinstance(name, str):
return NotImplemented
return self._make_child((name,))
return self._make_child((str(name),))

def __mod__(self, query):
return self.update_query(query)
@@ -713,7 +713,8 @@ def _validate_authority_uri_abs_path(host, path):

def _make_child(self, segments, encoded=False):
"""add segments to self._val.path, accounting for absolute vs relative paths"""
parsed = []
# keep the trailing slash if the last segment ends with /
parsed = [""] if segments and segments[-1][-1:] == "/" else []
for seg in reversed(segments):
if not seg:
continue