Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move version from const.py to __init__.py for Flit static introspection #70

Merged
merged 1 commit into from
Nov 27, 2023
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
3 changes: 2 additions & 1 deletion asyncprawcore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
TrustedAuthenticator,
UntrustedAuthenticator,
)
from .const import __version__
from .exceptions import * # noqa: F403
from .requestor import Requestor
from .sessions import Session, session

logging.getLogger(__package__).addHandler(logging.NullHandler())

__version__ = "2.4.1.dev0"
2 changes: 0 additions & 2 deletions asyncprawcore/const.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Constants for the asyncprawcore package."""
import os

__version__ = "2.4.1.dev0"

ACCESS_TOKEN_PATH = "/api/v1/access_token" # noqa: S105
AUTHORIZATION_PATH = "/api/v1/authorize" # noqa: S105
REVOKE_TOKEN_PATH = "/api/v1/revoke_token" # noqa: S105
Expand Down
5 changes: 4 additions & 1 deletion asyncprawcore/requestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import aiohttp
from aiohttp import ClientSession

from .const import TIMEOUT, __version__
from .const import TIMEOUT
from .exceptions import InvalidInvocation, RequestException

if TYPE_CHECKING:
Expand Down Expand Up @@ -48,6 +48,9 @@ def __init__(
giving up (default: ``asyncprawcore.const.TIMEOUT``).

"""
# Imported locally to avoid an import cycle, with __init__
from . import __version__

if user_agent is None or len(user_agent) < 7:
msg = "user_agent is not descriptive"
raise InvalidInvocation(msg)
Expand Down
6 changes: 3 additions & 3 deletions tools/set_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def handle_version(version):


def increment_development_version():
with open("asyncprawcore/const.py") as fp:
with open("asyncprawcore/__init__.py") as fp:
version = re.search('__version__ = "([^"]+)"', fp.read()).group(1)

parsed_version = valid_version(version)
Expand Down Expand Up @@ -89,15 +89,15 @@ def update_changelog(version):


def update_package(version):
with open("asyncprawcore/const.py") as fp:
with open("asyncprawcore/__init__.py") as fp:
content = fp.read()

updated = re.sub('__version__ = "([^"]+)"', f'__version__ = "{version}"', content)
if content == updated:
sys.stderr.write("Package version string not changed\n")
return False

with open("asyncprawcore/const.py", "w") as fp:
with open("asyncprawcore/__init__.py", "w") as fp:
fp.write(updated)

print(version)
Expand Down
Loading