Skip to content

Commit

Permalink
ci: make sure to generate _version.py with version metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxdaemon committed Apr 16, 2024
1 parent d666578 commit 9c956e5
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 28 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,11 @@ Session.vim
.netrwhist
# auto-generated tag files
tags

asyncirc/_version.py

.mypy_cache/
.pytest_cache/
.ruff_cache/
coverage.*
.coverage.*
9 changes: 7 additions & 2 deletions asyncirc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Async IRC Interface Library
"""

__all__ = ("protocol", "server")
from asyncirc._version import (
__version__,
__version_tuple__,
version,
version_tuple,
)

__version__ = "0.1.8"
__all__ = ("version", "version_tuple", "__version__", "__version_tuple__")
10 changes: 5 additions & 5 deletions asyncirc/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from asyncio import AbstractEventLoop, Transport
from logging import Logger

from asyncirc.server import BaseServer, Server
from asyncirc.server import BaseServer


__all__ = ("SASLMechanism", "IrcProtocol")
Expand Down Expand Up @@ -161,7 +161,7 @@ async def _do_sasl(conn: "IrcProtocol", cap: Cap) -> None:

conn.send(f"AUTHENTICATE {auth_line}")
# Wait for SASL to complete
# TODO log SASL response
# TODO(linuxdaemon): log SASL response
await conn.wait_for(
"902", "903", "904", "905", "906", "907", "908", timeout=30
)
Expand Down Expand Up @@ -205,7 +205,7 @@ class IrcProtocol(Protocol):

def __init__(
self,
servers: Sequence["Server"],
servers: Sequence["BaseServer"],
nick: str,
user: Optional[str] = None,
realname: Optional[str] = None,
Expand Down Expand Up @@ -344,10 +344,10 @@ async def _connect(self, server: "BaseServer") -> bool:
)

return False
except (ConnectionError, socket.gaierror) as e:
except (ConnectionError, socket.gaierror):
if self.logger:
self.logger.exception(
"Error occurred while connecting to %s (%s)", self.server, e
"Error occurred while connecting to %s", self.server
)

return False
Expand Down
2 changes: 1 addition & 1 deletion asyncirc/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(
is_ssl: bool = False,
ssl_ctx: Optional[ssl.SSLContext] = None,
certpath: Optional[str] = None,
):
) -> None:
if is_ssl:
if ssl_ctx is None:
ssl_ctx = ssl.create_default_context()
Expand Down
20 changes: 6 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,8 @@ description = "A simple asyncio.Protocol implementation designed for IRC"
readme = "README.md"
license = "MIT"
requires-python = ">=3.8"
authors = [
{ name = "linuxdaemon", email = "[email protected]" },
]
keywords = [
"async-irc",
"asyncio",
"asyncirc",
"irc",
"irc-framework",
]
authors = [{ name = "linuxdaemon", email = "[email protected]" }]
keywords = ["async-irc", "asyncio", "asyncirc", "irc", "irc-framework"]
classifiers = [
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: MIT License",
Expand All @@ -29,10 +21,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dependencies = [
"py-irclib>=0.4.0",
"typing_extensions",
]
dependencies = ["py-irclib>=0.4.0", "typing_extensions"]

[project.urls]
Homepage = "https://github.com/TotallyNotRobots/async-irc"
Expand All @@ -46,6 +35,9 @@ exclude = ["/.github"]
[tool.hatch.build.targets.wheel]
packages = ["asyncirc"]

[tool.hatch.build.hooks.vcs]
version-file = "asyncirc/_version.py"

[tool.hatch.env]
requires = ["hatch-containers"]

Expand Down
11 changes: 5 additions & 6 deletions tests/test_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ def write(self, data: bytes) -> None:
self._server.send_line(Message.parse(":irc.example.com 903"))
elif msg.command == "QUIT":
self._protocol.connection_lost(None)
else:
print(f"unhandled command: {msg}")

if not self._registered:
if (
Expand Down Expand Up @@ -99,9 +97,10 @@ def __init__(
)
self.lines: List[Tuple[str, str]] = []
self.in_buffer = b""
self.transport = None
self.transport: Optional[MockTransport] = None

def send_line(self, msg: Message):
def send_line(self, msg: Message) -> None:
assert self.transport is not None
self.transport.get_protocol().data_received(str(msg).encode() + b"\r\n")

async def connect(
Expand All @@ -118,9 +117,9 @@ async def connect(


async def test_sasl() -> None:
fut = asyncio.Future()
fut: "asyncio.Future[None]" = asyncio.Future()

async def _on_001(conn, msg):
async def _on_001(_conn: "IrcProtocol", _msg: "Message") -> None:
fut.set_result(None)

server = MockServer()
Expand Down

0 comments on commit 9c956e5

Please sign in to comment.