refactor: rename sessions submodule to _sessions to avoid shadowing sessions()
wabot/__init__.py defines def sessions(...) and also had a sessions.py submodule, so wabot.sessions (attribute) resolved to the function, shadowing the module for import wabot.sessions as m style access. This is the same class of collision that browser.py -> _browser.py already fixed. Renaming to _sessions.py removes the ambiguity and lets docs/api.rst drop the :no-index: Sphinx workaround in favor of plain autoclass directives on the public SessionRecord/SessionStore re-exports.
This commit is contained in:
@@ -36,6 +36,6 @@ def site_url():
|
||||
|
||||
@pytest.fixture
|
||||
def store(tmp_path):
|
||||
from wabot.sessions import SessionStore
|
||||
from wabot import SessionStore
|
||||
|
||||
return SessionStore(path=tmp_path / "sessions.json")
|
||||
|
||||
@@ -15,7 +15,7 @@ REATTACH_SCRIPT = textwrap.dedent(
|
||||
"""
|
||||
import json, sys
|
||||
import wabot
|
||||
from wabot.sessions import SessionStore
|
||||
from wabot import SessionStore
|
||||
|
||||
store = SessionStore(path=sys.argv[1])
|
||||
bot = wabot.browser(session=sys.argv[2], pacing=wabot.NoPacing(), store=store)
|
||||
|
||||
@@ -3,7 +3,7 @@ from unittest.mock import MagicMock
|
||||
import pytest
|
||||
|
||||
import wabot
|
||||
from wabot.sessions import SessionRecord, SessionStore
|
||||
from wabot import SessionRecord, SessionStore
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
from wabot.sessions import SessionRecord, SessionStore
|
||||
from wabot._sessions import SessionRecord, SessionStore
|
||||
|
||||
|
||||
def make_record(name="scraper1", created_at=None):
|
||||
@@ -63,7 +63,7 @@ class TestSessionStore:
|
||||
assert store.get("scraper1") is not None
|
||||
|
||||
def test_default_path_is_under_platformdirs(self):
|
||||
from wabot.sessions import default_store_path
|
||||
from wabot._sessions import default_store_path
|
||||
|
||||
assert default_store_path().name == "sessions.json"
|
||||
assert "wabot" in str(default_store_path())
|
||||
|
||||
Reference in New Issue
Block a user