Skip to content

Commit

Permalink
refactor!: Restructure package to accomodate both RPC and REST clients
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Sep 20, 2023
1 parent 3323ab9 commit 3c6645c
Show file tree
Hide file tree
Showing 10 changed files with 2,071 additions and 1,925 deletions.
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,11 @@ convention = "google"
max-args = 10

[tool.pytest.ini_options]
addopts = ["-vvv", "-W error"]
addopts = ["-vvv"]
filterwarnings = [
"error",
"always::citric._compat.CitricDeprecationWarning",
]
markers = [
"integration_test: Integration and end-to-end tests",
"xfail_mysql: Mark a test as expected to fail on MySQL",
Expand Down
24 changes: 22 additions & 2 deletions src/citric/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,33 @@

from __future__ import annotations

import typing as t
import warnings
from importlib import metadata

from citric.client import Client
from citric._compat import CitricDeprecationWarning
from citric.rpc.client import RPC

if t.TYPE_CHECKING:
from citric.rpc.client import RPC as Client # noqa: N811, F401


__version__ = metadata.version(__package__)
"""Package version"""

del annotations, metadata

__all__ = ["Client"]
__all__ = ["RPC"]


def __getattr__(name: str) -> t.Any: # noqa: ANN401
if name == "Client":
warnings.warn(
"citric.Client is deprecated, use citric.RPC instead",
CitricDeprecationWarning,
stacklevel=2,
)
return RPC

message = f"module {__name__!r} has no attribute {name!r}"
raise AttributeError(message)
4 changes: 4 additions & 0 deletions src/citric/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def _warning_message(next_version: str) -> tuple[str, ...]:
)


class CitricDeprecationWarning(DeprecationWarning):
"""Warning for deprecated APIs in Citric."""


class FutureVersionWarning(UserWarning):
"""Warning for features only available in an unreleased version of LimeSurvey."""

Expand Down
Loading

0 comments on commit 3c6645c

Please sign in to comment.