Skip to content

Commit f1337fe

Browse files
authored
Fix pypi version detection and rename some attributes (#429)
- Fix outputing sha1 and version in cli - Fix outputing version in pypi version detection - Rename `GuildAvailableEvent.guild_chunk_nocne` to `GuildAvailableEvent.chunk_nonce` - Revert `/documentation`. This will changed back when full version indexing is done
1 parent 719fec2 commit f1337fe

7 files changed

Lines changed: 37 additions & 29 deletions

File tree

hikari/api/rest.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -780,9 +780,9 @@ def fetch_messages(
780780
An iterator to fetch the messages.
781781
782782
!!! note
783-
This call is not a coroutine function, it returns a special type of
784-
lazy iterator that will perform API calls as you iterate across it.
785-
See `hikari.iterators` for the full API for this iterator type.
783+
This call is not a coroutine function, it returns a special type of
784+
lazy iterator that will perform API calls as you iterate across it.
785+
See `hikari.iterators` for the full API for this iterator type.
786786
787787
Raises
788788
------
@@ -1566,9 +1566,9 @@ def fetch_reactions_for_emoji(
15661566
An iterator to fetch the users.
15671567
15681568
!!! note
1569-
This call is not a coroutine function, it returns a special type of
1570-
lazy iterator that will perform API calls as you iterate across it.
1571-
See `hikari.iterators` for the full API for this iterator type.
1569+
This call is not a coroutine function, it returns a special type of
1570+
lazy iterator that will perform API calls as you iterate across it.
1571+
See `hikari.iterators` for the full API for this iterator type.
15721572
15731573
Raises
15741574
------
@@ -2464,9 +2464,9 @@ def fetch_my_guilds(
24642464
The token's associated guilds.
24652465
24662466
!!! note
2467-
This call is not a coroutine function, it returns a special type of
2468-
lazy iterator that will perform API calls as you iterate across it.
2469-
See `hikari.iterators` for the full API for this iterator type.
2467+
This call is not a coroutine function, it returns a special type of
2468+
lazy iterator that will perform API calls as you iterate across it.
2469+
See `hikari.iterators` for the full API for this iterator type.
24702470
24712471
Raises
24722472
------
@@ -2774,9 +2774,9 @@ def fetch_audit_log(
27742774
The guild's audit log.
27752775
27762776
!!! note
2777-
This call is not a coroutine function, it returns a special type of
2778-
lazy iterator that will perform API calls as you iterate across it.
2779-
See `hikari.iterators` for the full API for this iterator type.
2777+
This call is not a coroutine function, it returns a special type of
2778+
lazy iterator that will perform API calls as you iterate across it.
2779+
See `hikari.iterators` for the full API for this iterator type.
27802780
27812781
Raises
27822782
------
@@ -3763,9 +3763,9 @@ def fetch_members(
37633763
An iterator to fetch the members.
37643764
37653765
!!! note
3766-
This call is not a coroutine function, it returns a special type of
3767-
lazy iterator that will perform API calls as you iterate across it.
3768-
See `hikari.iterators` for the full API for this iterator type.
3766+
This call is not a coroutine function, it returns a special type of
3767+
lazy iterator that will perform API calls as you iterate across it.
3768+
See `hikari.iterators` for the full API for this iterator type.
37693769
37703770
Raises
37713771
------

hikari/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ def main() -> None:
3737
sourcefile = inspect.getsourcefile(_about)
3838
assert isinstance(sourcefile, str)
3939
path: typing.Final[str] = os.path.abspath(os.path.dirname(sourcefile))
40-
sha1: typing.Final[str] = _about.__git_sha1__
40+
sha1: typing.Final[str] = _about.__git_sha1__[:8]
4141
version: typing.Final[str] = _about.__version__
4242
py_impl: typing.Final[str] = platform.python_implementation()
4343
py_ver: typing.Final[str] = platform.python_version()
4444
py_compiler: typing.Final[str] = platform.python_compiler()
45-
sys.stderr.write(f"hikari v{version} {sha1}\n")
45+
sys.stderr.write(f"hikari ({version}) [{sha1}]\n")
4646
sys.stderr.write(f"located at {path}\n")
4747
sys.stderr.write(f"{py_impl} {py_ver} {py_compiler}\n")
4848
sys.stderr.write(" ".join(frag.strip() for frag in platform.uname() if frag and frag.strip()) + "\n")

hikari/events/guild_events.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ class GuildAvailableEvent(GuildVisibilityEvent):
214214
The voice states active in the guild.
215215
"""
216216

217-
guild_chunk_nonce: typing.Optional[str] = attr.ib(repr=False, default=None)
218-
"""Nonce used to request the guild chunks.
217+
chunk_nonce: typing.Optional[str] = attr.ib(repr=False, default=None)
218+
"""Nonce used to request the member chunks for this guild.
219219
220220
This will be `builtins.None` if no chunks were requested.
221221
@@ -225,7 +225,7 @@ class GuildAvailableEvent(GuildVisibilityEvent):
225225
Returns
226226
-------
227227
typing.Optional[builtins.str]
228-
The nonce used to request the guild chunks.
228+
The nonce used to request the member chunks.
229229
"""
230230

231231
@property

hikari/impl/event_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ async def on_guild_create(self, shard: gateway_shard.GatewayShard, payload: data
149149
if members_declared and (event.guild.is_large or not presences_declared):
150150
# We create a task here instead of awaiting the result to avoid any rate-limits from delaying dispatch.
151151
nonce = f"{shard.id}.{time.uuid()}"
152-
event.guild_chunk_nonce = nonce
152+
event.chunk_nonce = nonce
153153
coroutine = shard.request_guild_members(
154154
event.guild, include_presences=bool(presences_declared), nonce=nonce
155155
)

hikari/internal/ux.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,14 @@ def parse(self, vstring: str) -> None: # type: ignore[override]
275275
else:
276276
self.prerelease = None
277277

278+
def __str__(self) -> str:
279+
vstring = ".".join(map(str, self.version))
280+
281+
if self.prerelease:
282+
vstring = vstring + self.prerelease[0] + str(self.prerelease[1])
283+
284+
return vstring
285+
278286

279287
async def check_for_updates(http_settings: config.HTTPSettings, proxy_settings: config.ProxySettings) -> None:
280288
"""Perform a check for newer versions of the library, logging any found."""

pipelines/pages.nox.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ def pages(session: nox.Session) -> None:
7474
)
7575

7676
# Rename `hikari` into `documentation`
77-
print("Renaming output dir...")
78-
print(f"{config.ARTIFACT_DIRECTORY}/{config.MAIN_PACKAGE} -> {config.ARTIFACT_DIRECTORY}/documentation")
79-
shutil.rmtree(f"{config.ARTIFACT_DIRECTORY}/documentation", ignore_errors=True)
80-
shutil.move(f"{config.ARTIFACT_DIRECTORY}/{config.MAIN_PACKAGE}", f"{config.ARTIFACT_DIRECTORY}/documentation")
77+
# print("Renaming output dir...")
78+
# print(f"{config.ARTIFACT_DIRECTORY}/{config.MAIN_PACKAGE} -> {config.ARTIFACT_DIRECTORY}/documentation")
79+
# shutil.rmtree(f"{config.ARTIFACT_DIRECTORY}/documentation", ignore_errors=True)
80+
# shutil.move(f"{config.ARTIFACT_DIRECTORY}/{config.MAIN_PACKAGE}", f"{config.ARTIFACT_DIRECTORY}/documentation")
8181

8282
# Pre-generated indexes
8383
if shutil.which("npm") is None:

tests/hikari/impl/test_event_manager.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,15 @@ async def test_on_guild_create(self, event_manager, shard, app):
156156
members={"TestMember": 5678},
157157
presences={"TestPresence": 9012},
158158
voice_states={"TestState": 345},
159-
guild_chunk_nonce=None,
159+
chunk_nonce=None,
160160
)
161161

162162
event_manager._app.event_factory.deserialize_guild_create_event.return_value = event
163163
shard.request_guild_members = mock.AsyncMock()
164164

165165
await event_manager.on_guild_create(shard, payload)
166166

167-
assert event.guild_chunk_nonce is None
167+
assert event.chunk_nonce is None
168168
shard.request_guild_members.assert_not_called()
169169

170170
event_manager._cache.update_guild.assert_called_once_with(event.guild)
@@ -201,7 +201,7 @@ async def test_on_guild_create_when_request_chunks(self, event_manager, shard, a
201201
members={"TestMember": 5678},
202202
presences={"TestPresence": 9012},
203203
voice_states={"TestState": 345},
204-
guild_chunk_nonce=None,
204+
chunk_nonce=None,
205205
)
206206

207207
event_manager._app.event_factory.deserialize_guild_create_event.return_value = event
@@ -213,7 +213,7 @@ async def test_on_guild_create_when_request_chunks(self, event_manager, shard, a
213213

214214
uuid.assert_called_once_with()
215215
nonce = "987.uuid"
216-
assert event.guild_chunk_nonce == nonce
216+
assert event.chunk_nonce == nonce
217217
shard.request_guild_members.assert_called_once_with(event.guild, include_presences=True, nonce=nonce)
218218
create_task.assert_called_once_with(shard.request_guild_members(), name="987:123 guild create members request")
219219

0 commit comments

Comments
 (0)