Skip to content

Commit f042e75

Browse files
authored
Merge pull request #233 from khaeru/fix/ci-2025-w25
Adjust expectation for test_request_preview_data()
2 parents abb42b5 + d3cb374 commit f042e75

File tree

14 files changed

+168
-126
lines changed

14 files changed

+168
-126
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/mirrors-mypy
3-
rev: v1.13.0
3+
rev: v1.16.1
44
hooks:
55
- id: mypy
66
pass_filenames: false
@@ -16,8 +16,8 @@ repos:
1616
- types-PyYAML
1717
- types-requests
1818
- repo: https://github.com/astral-sh/ruff-pre-commit
19-
rev: v0.8.3
19+
rev: v0.11.13
2020
hooks:
21-
- id: ruff
21+
- id: ruff-check
2222
- id: ruff-format
2323
args: [ --check ]

.readthedocs.yml renamed to .readthedocs.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
version: 2
22

33
build:
4-
os: ubuntu-22.04
4+
os: ubuntu-24.04
55
tools:
6-
python: "3"
6+
python: "3.13"
77

88
python:
99
install:

README.rst

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,45 @@ sdmx: Statistical data and metadata exchange
2121
`Source code @ Github <https://github.com/khaeru/sdmx/>`_ —
2222
`Authors <https://github.com/khaeru/sdmx/graphs/contributors>`_
2323

24-
``sdmx`` (`‘sdmx1’ on PyPI <https://pypi.org/project/sdmx1>`_) is a Python implementation of the `SDMX <http://www.sdmx.org>`_ 2.1 (`ISO 17369:2013 <https://www.iso.org/standard/52500.html>`_) and 3.0 standards for **statistical data and metadata exchange**.
24+
``sdmx`` (`‘sdmx1’ on PyPI <https://pypi.org/project/sdmx1>`_) is a Python implementation
25+
of the `SDMX <http://www.sdmx.org>`_ 2.1 (`ISO 17369:2013 <https://www.iso.org/standard/52500.html>`_) and 3.0 standards
26+
for **statistical data and metadata exchange**.
2527
The SDMX standards are developed and used by national statistical agencies, central banks, and international organisations.
2628

2729
``sdmx`` can be used to:
2830

29-
- Explore and retrieve data available from SDMX-REST `web services <https://sdmx1.rtfd.io/en/latest/sources.html>`_ operated by providers including the World Bank, International Monetary Fund, Eurostat, OECD, and United Nations;
31+
- Explore and retrieve data available from SDMX-REST `web services <https://sdmx1.rtfd.io/en/latest/sources.html>`_
32+
operated by providers including the World Bank, International Monetary Fund, Eurostat, OECD, and United Nations;
3033
- Read and write data and metadata in file formats including SDMX-ML (XML), SDMX-JSON, and SDMX-CSV;
31-
- Convert data and metadata into `pandas <https://pandas.pydata.org>`_ objects, for use with the analysis, plotting, and other tools in the Python data science ecosystem;
32-
- Apply the `SDMX information model <https://sdmx1.rtfd.io/en/latest/api.rst#api-model>`_ to structure and publish your own data;
34+
- Convert data and metadata into `pandas <https://pandas.pydata.org>`_ objects,
35+
for use with the analysis, plotting, and other tools in the Python data science ecosystem;
36+
- Apply the `SDMX information model <https://sdmx1.rtfd.io/en/latest/implementation.html#im>`_ to structure and publish your own data;
3337

3438
…and much more.
3539

3640

3741
Documentation
3842
-------------
3943

40-
See https://sdmx1.readthedocs.io/en/latest/ for the latest docs per the ``main`` branch, or https://sdmx1.readthedocs.io/en/stable/ for the most recent release.
44+
See https://sdmx1.readthedocs.io/en/latest/ for the latest docs per the ``main`` branch,
45+
or https://sdmx1.readthedocs.io/en/stable/ for the most recent release.
4146

4247

4348
License
4449
-------
4550

4651
Copyright 2014–2025, `sdmx1 developers <https://github.com/khaeru/sdmx/graphs/contributors>`_
4752

48-
Licensed under the Apache License, Version 2.0 (the “License”); you may not use these files except in compliance with the License.
53+
Licensed under the Apache License, Version 2.0 (the “License”);
54+
you may not use these files except in compliance with the License.
4955
You may obtain a copy of the License:
5056

5157
- from the file LICENSE included with the source code, or
5258
- at http://www.apache.org/licenses/LICENSE-2.0
5359

54-
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
60+
Unless required by applicable law or agreed to in writing,
61+
software distributed under the License is distributed on an “AS IS” BASIS,
62+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5563
See the License for the specific language governing permissions and limitations under the License.
5664

5765

doc/example.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ and :func:`.to_pandas` to convert to :class:`.pandas.Series`:
3131

3232
.. ipython:: python
3333
34-
for cl in "ESTAT:AGE(11.0)", "ESTAT:SEX(1.13)", "ESTAT:UNIT(59.0)":
34+
for cl in "ESTAT:AGE(11.0)", "ESTAT:SEX(1.13)", "ESTAT:UNIT(61.0)":
3535
print(sdmx.to_pandas(sm.get(cl)))
3636
3737
Next, we download a **data set** containing a portion of the data in this data flow, structured by this DSD.

doc/whatsnew.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
What's new?
44
***********
55

6-
.. _2.22.0:
6+
Next release
7+
============
8+
9+
- Correct a broken link to :ref:`im` in the README (:pull:`233`; thanks :gh-user:`econometricsfanboy` for :issue:`232`).
710

8-
.. Next release
9-
.. ============
11+
.. _2.22.0:
1012

1113
v2.22.0 (2025-03-25)
1214
====================

sdmx/client.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def _request_from_args(self, kwargs):
247247
"get", url.join(with_query=False), params=url.query, headers=headers
248248
)
249249

250-
def _request_from_url(self, kwargs):
250+
def _request_from_url(self, kwargs) -> "requests.Request":
251251
url = kwargs.pop("url")
252252
parameters = kwargs.pop("params", {})
253253
headers = kwargs.pop("headers", {})
@@ -455,26 +455,26 @@ def get(
455455
else:
456456
req = self._request_from_args(kwargs)
457457

458-
req = self.session.prepare_request(req)
458+
req_prepared = self.session.prepare_request(req)
459459

460460
# Now get the SDMX message via HTTP
461-
log.info(f"Request {req.url}")
462-
log.info(f"with headers {req.headers}")
461+
log.info(f"Request {req_prepared.url}")
462+
log.info(f"with headers {req_prepared.headers}")
463463

464464
# Try to get resource from memory cache if specified
465-
if use_cache:
465+
if use_cache and req_prepared.url:
466466
try:
467-
return self.cache[req.url]
467+
return self.cache[req_prepared.url]
468468
except KeyError:
469469
log.info("Not found in cache")
470470
pass
471471

472472
if dry_run:
473-
return req
473+
return req_prepared # type: ignore [return-value]
474474

475475
try:
476476
# Send the request
477-
response = self.session.send(req, **self._send_kwargs)
477+
response = self.session.send(req_prepared, **self._send_kwargs)
478478
response.raise_for_status()
479479
except requests.exceptions.ConnectionError as e:
480480
raise e from None

sdmx/model/v30.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,20 +236,23 @@ class SelectionValue(common.BaseSelectionValue):
236236
valid_to: Optional[str] = None
237237

238238

239-
class MemberValue(common.BaseMemberValue, SelectionValue):
239+
@dataclass
240+
class MemberValue(SelectionValue, common.BaseMemberValue):
240241
"""SDMX 3.0 MemberValue."""
241242

242243

243244
class TimeRangeValue(SelectionValue):
244245
"""SDMX 3.0 TimeRangeValue."""
245246

246247

248+
@dataclass
247249
class BeforePeriod(TimeRangeValue, common.Period):
248-
pass
250+
"""SDMX 3.0 BeforePeriod."""
249251

250252

253+
@dataclass
251254
class AfterPeriod(TimeRangeValue, common.Period):
252-
pass
255+
"""SDMX 3.0 AfterPeriod."""
253256

254257

255258
@dataclass

sdmx/testing/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import re
44
from collections import ChainMap
5+
from collections.abc import Generator
56
from pathlib import Path
67
from typing import TYPE_CHECKING, Union
78

@@ -321,7 +322,7 @@ def test_data_path(pytestconfig):
321322

322323

323324
@pytest.fixture(scope="class")
324-
def testsource(pytestconfig):
325+
def testsource(pytestconfig) -> Generator[str, None, None]:
325326
"""Fixture: the :attr:`.Source.id` of a temporary data source."""
326327
from sdmx.source import sources
327328

sdmx/testing/data.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
import pytest
1010

1111
if TYPE_CHECKING:
12-
from requests_cache import CachedSession
13-
12+
from sdmx.session import Session
1413
from sdmx.source import Source
1514

1615
log = logging.getLogger(__name__)
@@ -203,9 +202,7 @@ def parametrize(self, metafunc) -> None:
203202
metafunc.parametrize(mark.args[0], self.as_params(**mark.kwargs))
204203

205204

206-
def add_responses(
207-
session: "CachedSession", file_cache_path: Path, source: "Source"
208-
) -> None:
205+
def add_responses(session: "Session", file_cache_path: Path, source: "Source") -> None:
209206
"""Populate cached responses for `session`.
210207
211208
Two sources are used:

sdmx/tests/model/test_v21.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,7 @@ def test_hierarchy(self, msg: sdmx.message.StructureMessage) -> None:
767767
# The code has a child associated with a different code list
768768
c3 = c2.child[0]
769769
assert "6J" == c3.code
770+
assert c3.code and c3.code.parent and c3.code.parent.urn
770771
assert c3.code.parent.urn.endswith("Codelist=BIS:CL_BIS_IF_REF_AREA(1.0)")
771772

772773
def test_repr(self, obj: model.HierarchicalCodelist):

0 commit comments

Comments
 (0)