Skip to content

Commit

Permalink
refactor: Emit deprecation warning when accessing stats instead of …
Browse files Browse the repository at this point in the history
…`Stats`
  • Loading branch information
pawamoy committed Jun 9, 2024
1 parent b327b90 commit e5572d2
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/griffe/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

from __future__ import annotations

import warnings
from collections import defaultdict
from pathlib import Path
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any

from griffe.enumerations import Kind

Expand All @@ -13,6 +14,17 @@
from griffe.loader import GriffeLoader


def __getattr__(name: str) -> Any:
if name == "stats":
warnings.warn(
"The 'stats' function was made into a class and renamed 'Stats'.",
DeprecationWarning,
stacklevel=2,
)
return Stats
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")


class Stats:
"""Load statistics for a Griffe loader."""

Expand Down Expand Up @@ -138,7 +150,4 @@ def as_text(self) -> str:
return "\n".join(lines)


stats = Stats
"""Deprecated. Use `Stats` instead."""

__all__ = ["Stats"]

0 comments on commit e5572d2

Please sign in to comment.