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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ import fredq

# Observations come back as a typed, polars-backed frame.
obs = fredq.Series("DGS10").observations(observation_start="2024-01-01")
df = obs.to_polars() # or .to_pandas() / .to_arrow() (needs [pandas]) / .to_dicts()
print(obs.meta.units, obs.meta.count) # the response envelope, corpus-typed
df = obs.to_polars() # or .to_pandas() / .to_arrow() (needs [pandas]) / .to_dicts()
print(obs.meta.units, obs.meta.count) # the response envelope, corpus-typed

# Metadata calls return validated pydantic models with real fields.
info = fredq.Series("DGS10").info()
Expand Down
30 changes: 15 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -221,28 +221,28 @@ select = [
fixable = ["ALL"]
unfixable = []
ignore = [
"COM812",
"D105",
"D202",
"D203",
"D213",
"D413",
"missing-trailing-comma",
"undocumented-magic-method",
"blank-line-after-function",
"incorrect-blank-line-before-class",
"multi-line-summary-second-line",
"missing-blank-line-after-last-section",
]
preview = true

[tool.ruff.lint.per-file-ignores]
"tests/*" = [
"DOC201",
"DOC402",
"DOC501",
"PLC2701",
"S101",
"S404",
"SLF001",
"docstring-missing-returns",
"docstring-missing-yields",
"docstring-missing-exception",
"import-private-name",
"assert",
"suspicious-subprocess-import",
"private-member-access",
]
"tools/*" = [
"PLC2701",
"T201",
"import-private-name",
"print",
]

[tool.ruff.lint.pydocstyle]
Expand Down
3 changes: 2 additions & 1 deletion src/fredq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
from fredq.frames import Frame, FrameShapeError, Observations


def __getattr__(name: str) -> Any: # noqa: ANN401 - PEP 562 module __getattr__
# PEP 562 module __getattr__
def __getattr__(name: str) -> Any: # ruff: ignore[any-type]
"""Lazily import heavy public names on first access (PEP 562).

Returns:
Expand Down
2 changes: 1 addition & 1 deletion src/fredq/_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


def _ensure_loop() -> asyncio.AbstractEventLoop:
global _loop # noqa: PLW0603 - module-level singleton by design
global _loop # ruff: ignore[global-statement] - module-level singleton by design
with _lock:
if _loop is not None and not _loop.is_closed():
return _loop
Expand Down
4 changes: 2 additions & 2 deletions src/fredq/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def configure(


def _get_client() -> FredClient:
global _client # noqa: PLW0603 - module singleton by design
global _client # ruff: ignore[global-statement] - module singleton by design
with _client_lock:
if _client is None:
api_key = _client_options.get("api_key") or resolve_api_key()
Expand All @@ -159,7 +159,7 @@ def _get_client() -> FredClient:
def _reset_for_tests() -> None: # pyright: ignore[reportUnusedFunction]
"""Drop the shared client so tests can reconfigure. Test-only."""

global _client # noqa: PLW0603 - module singleton by design
global _client # ruff: ignore[global-statement] - module singleton by design
with _client_lock:
if _client is not None:
with contextlib.suppress(Exception):
Expand Down
52 changes: 33 additions & 19 deletions src/fredq/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ def info(
)
return SeriesInfo.model_validate(_unwrap_single(payload, "seriess"))

def observations( # noqa: PLR0913 - one keyword-only arg per wire param.
# one keyword-only arg per wire param.
def observations( # ruff: ignore[too-many-arguments]
self,
*,
observation_start: DateLike | None = None,
Expand Down Expand Up @@ -358,7 +359,8 @@ def related(
)
return CategoriesResult.model_validate(payload)

def series( # noqa: PLR0913 - one keyword-only arg per wire param.
# one keyword-only arg per wire param.
def series( # ruff: ignore[too-many-arguments]
self,
*,
realtime_start: DateLike | None = None,
Expand Down Expand Up @@ -396,7 +398,7 @@ def series( # noqa: PLR0913 - one keyword-only arg per wire param.
)
return SeriesListResult.model_validate(payload)

def tags( # noqa: PLR0913 - one keyword-only arg per wire param.
def tags( # ruff: ignore[too-many-arguments] - one keyword-only arg per wire param.
self,
*,
realtime_start: DateLike | None = None,
Expand Down Expand Up @@ -432,7 +434,8 @@ def tags( # noqa: PLR0913 - one keyword-only arg per wire param.
)
return TagsResult.model_validate(payload)

def related_tags( # noqa: PLR0913 - one keyword-only arg per wire param.
# one keyword-only arg per wire param.
def related_tags( # ruff: ignore[too-many-arguments]
self,
tag_names: list[str] | str,
*,
Expand Down Expand Up @@ -510,7 +513,8 @@ def info(
)
return ReleaseInfo.model_validate(_unwrap_single(payload, "releases"))

def dates( # noqa: PLR0913 - one keyword-only arg per wire param.
# one keyword-only arg per wire param.
def dates( # ruff: ignore[too-many-arguments]
self,
*,
realtime_start: DateLike | None = None,
Expand Down Expand Up @@ -540,7 +544,8 @@ def dates( # noqa: PLR0913 - one keyword-only arg per wire param.
)
return ReleaseDatesResult.model_validate(payload)

def series( # noqa: PLR0913 - one keyword-only arg per wire param.
# one keyword-only arg per wire param.
def series( # ruff: ignore[too-many-arguments]
self,
*,
realtime_start: DateLike | None = None,
Expand Down Expand Up @@ -600,7 +605,7 @@ def sources(
)
return ReleaseSourcesResult.model_validate(payload)

def tags( # noqa: PLR0913 - one keyword-only arg per wire param.
def tags( # ruff: ignore[too-many-arguments] - one keyword-only arg per wire param.
self,
*,
realtime_start: DateLike | None = None,
Expand Down Expand Up @@ -636,7 +641,8 @@ def tags( # noqa: PLR0913 - one keyword-only arg per wire param.
)
return TagsResult.model_validate(payload)

def related_tags( # noqa: PLR0913 - one keyword-only arg per wire param.
# one keyword-only arg per wire param.
def related_tags( # ruff: ignore[too-many-arguments]
self,
tag_names: list[str] | str,
*,
Expand Down Expand Up @@ -738,7 +744,8 @@ def info(
)
return SourceInfo.model_validate(_unwrap_single(payload, "sources"))

def releases( # noqa: PLR0913 - one keyword-only arg per wire param.
# one keyword-only arg per wire param.
def releases( # ruff: ignore[too-many-arguments]
self,
*,
realtime_start: DateLike | None = None,
Expand Down Expand Up @@ -769,7 +776,8 @@ def releases( # noqa: PLR0913 - one keyword-only arg per wire param.
return ReleasesResult.model_validate(payload)


def search_series( # noqa: PLR0913 - one keyword-only arg per wire param.
# one keyword-only arg per wire param.
def search_series( # ruff: ignore[too-many-arguments]
search_text: str,
*,
search_type: str | None = None,
Expand Down Expand Up @@ -810,7 +818,8 @@ def search_series( # noqa: PLR0913 - one keyword-only arg per wire param.
return SeriesListResult.model_validate(payload)


def search_series_tags( # noqa: PLR0913 - one keyword-only arg per wire param.
# one keyword-only arg per wire param.
def search_series_tags( # ruff: ignore[too-many-arguments]
series_search_text: str,
*,
realtime_start: DateLike | None = None,
Expand Down Expand Up @@ -847,7 +856,8 @@ def search_series_tags( # noqa: PLR0913 - one keyword-only arg per wire param.
return TagsResult.model_validate(payload)


def search_series_related_tags( # noqa: PLR0913 - one keyword-only arg per wire param.
# one keyword-only arg per wire param.
def search_series_related_tags( # ruff: ignore[too-many-arguments]
series_search_text: str,
tag_names: list[str] | str,
*,
Expand Down Expand Up @@ -886,7 +896,8 @@ def search_series_related_tags( # noqa: PLR0913 - one keyword-only arg per wire
return TagsResult.model_validate(payload)


def series_updates( # noqa: PLR0913 - one keyword-only arg per wire param.
# one keyword-only arg per wire param.
def series_updates( # ruff: ignore[too-many-arguments]
*,
realtime_start: DateLike | None = None,
realtime_end: DateLike | None = None,
Expand Down Expand Up @@ -920,7 +931,7 @@ def series_updates( # noqa: PLR0913 - one keyword-only arg per wire param.
return SeriesListResult.model_validate(payload)


def releases( # noqa: PLR0913 - one keyword-only arg per wire param.
def releases( # ruff: ignore[too-many-arguments] - one keyword-only arg per wire param.
*,
realtime_start: DateLike | None = None,
realtime_end: DateLike | None = None,
Expand Down Expand Up @@ -949,7 +960,8 @@ def releases( # noqa: PLR0913 - one keyword-only arg per wire param.
return ReleasesResult.model_validate(payload)


def release_calendar( # noqa: PLR0913 - one keyword-only arg per wire param.
# one keyword-only arg per wire param.
def release_calendar( # ruff: ignore[too-many-arguments]
*,
realtime_start: DateLike | None = None,
realtime_end: DateLike | None = None,
Expand Down Expand Up @@ -980,7 +992,7 @@ def release_calendar( # noqa: PLR0913 - one keyword-only arg per wire param.
return ReleaseDatesResult.model_validate(payload)


def sources( # noqa: PLR0913 - one keyword-only arg per wire param.
def sources( # ruff: ignore[too-many-arguments] - one keyword-only arg per wire param.
*,
realtime_start: DateLike | None = None,
realtime_end: DateLike | None = None,
Expand Down Expand Up @@ -1009,7 +1021,7 @@ def sources( # noqa: PLR0913 - one keyword-only arg per wire param.
return SourcesResult.model_validate(payload)


def tags( # noqa: PLR0913 - one keyword-only arg per wire param.
def tags( # ruff: ignore[too-many-arguments] - one keyword-only arg per wire param.
*,
realtime_start: DateLike | None = None,
realtime_end: DateLike | None = None,
Expand Down Expand Up @@ -1044,7 +1056,8 @@ def tags( # noqa: PLR0913 - one keyword-only arg per wire param.
return TagsResult.model_validate(payload)


def tag_series( # noqa: PLR0913 - one keyword-only arg per wire param.
# one keyword-only arg per wire param.
def tag_series( # ruff: ignore[too-many-arguments]
tag_names: list[str] | str,
*,
exclude_tag_names: list[str] | str | None = None,
Expand Down Expand Up @@ -1077,7 +1090,8 @@ def tag_series( # noqa: PLR0913 - one keyword-only arg per wire param.
return SeriesListResult.model_validate(payload)


def related_tags( # noqa: PLR0913 - one keyword-only arg per wire param.
# one keyword-only arg per wire param.
def related_tags( # ruff: ignore[too-many-arguments]
tag_names: list[str] | str,
*,
realtime_start: DateLike | None = None,
Expand Down
5 changes: 3 additions & 2 deletions src/fredq/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def _add_skills_targeting_options(parser: argparse.ArgumentParser) -> None:


def _add_skills_command_group(
subparsers: Any, # noqa: ANN401
subparsers: Any, # ruff: ignore[any-type]
) -> argparse.ArgumentParser:
"""Build the ``fredq skills {install,uninstall,list}`` subparser tree.

Expand Down Expand Up @@ -564,7 +564,8 @@ def _handle_parquet_output(
polars import cost.
"""

from fredq.parquet_writer import ( # noqa: PLC0415 - lazy import.
# lazy import.
from fredq.parquet_writer import ( # ruff: ignore[import-outside-top-level]
ObservationsContext,
write_observations_parquet,
)
Expand Down
6 changes: 3 additions & 3 deletions src/fredq/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _install_api_key_redact_filter() -> None:
are created.
"""

global _redact_filter_installed # noqa: PLW0603
global _redact_filter_installed # ruff: ignore[global-statement]
if _redact_filter_installed:
return

Expand Down Expand Up @@ -184,15 +184,15 @@ async def _request_or_raise(
url: str,
*,
context: str,
**kwargs: Any, # noqa: ANN401
**kwargs: Any, # ruff: ignore[any-type]
) -> httpx.Response:
attempt = 1
while True:
try:
response = await self._client.request(method, url, **kwargs)
if response.is_error:
response.raise_for_status()
except httpx.HTTPStatusError as exc: # noqa: PERF203
except httpx.HTTPStatusError as exc: # ruff: ignore[try-except-in-loop]
status_code = exc.response.status_code if exc.response else -1
if (
status_code in self._RETRYABLE_STATUS_CODES
Expand Down
8 changes: 6 additions & 2 deletions src/fredq/frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ def to_pandas(self) -> pd.DataFrame:
"""

try:
import pandas # noqa: F401, ICN001, PLC0415 - optional dependency probe # pyright: ignore[reportMissingImports, reportMissingTypeStubs, reportUnusedImport]
# optional dependency probe
# ruff: ignore[unused-import, unconventional-import-alias, import-outside-top-level]
import pandas # pyright: ignore[reportMissingImports, reportMissingTypeStubs, reportUnusedImport]
except ImportError as exc:
message = (
"to_pandas() requires the optional extra: pip install fredq[pandas]"
Expand All @@ -81,7 +83,9 @@ def to_arrow(self) -> pa.Table:
"""

try:
import pyarrow # noqa: F401, ICN001, PLC0415 - optional dependency probe # pyright: ignore[reportMissingImports, reportMissingTypeStubs, reportUnusedImport]
# optional dependency probe
# ruff: ignore[unused-import, unconventional-import-alias, import-outside-top-level]
import pyarrow # pyright: ignore[reportMissingImports, reportMissingTypeStubs, reportUnusedImport]
except ImportError as exc:
message = (
"to_arrow() requires the optional extra: pip install fredq[pandas]"
Expand Down
4 changes: 3 additions & 1 deletion src/fredq/models/observations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

from __future__ import annotations

from datetime import date # noqa: TC003 - pydantic needs runtime types
# pydantic needs runtime types
# ruff: ignore[typing-only-standard-library-import]
from datetime import date
from typing import Literal

from fredq.models._base import FredModel
Expand Down
4 changes: 3 additions & 1 deletion src/fredq/models/releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

from __future__ import annotations

from datetime import date # noqa: TC003 - pydantic needs runtime types
# pydantic needs runtime types
# ruff: ignore[typing-only-standard-library-import]
from datetime import date

from fredq.models._base import FredDatetime, FredModel

Expand Down
4 changes: 3 additions & 1 deletion src/fredq/models/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

from __future__ import annotations

from datetime import date # noqa: TC003 - pydantic needs runtime types
# pydantic needs runtime types
# ruff: ignore[typing-only-standard-library-import]
from datetime import date

from fredq.models._base import FredDatetime, FredModel

Expand Down
4 changes: 3 additions & 1 deletion src/fredq/models/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

from __future__ import annotations

from datetime import date # noqa: TC003 - pydantic needs runtime types
# pydantic needs runtime types
# ruff: ignore[typing-only-standard-library-import]
from datetime import date

from fredq.models._base import FredModel

Expand Down
4 changes: 3 additions & 1 deletion src/fredq/models/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

from __future__ import annotations

from datetime import date # noqa: TC003 - pydantic needs runtime types
# pydantic needs runtime types
# ruff: ignore[typing-only-standard-library-import]
from datetime import date

from fredq.models._base import FredDatetime, FredModel

Expand Down
Loading
Loading