-
-
Notifications
You must be signed in to change notification settings - Fork 107
Partial Implementation of fixing the typing of tests. #2563
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
Open
mplatypus
wants to merge
37
commits into
hikari-py:master
Choose a base branch
from
mplatypus:fix/partial-typing-tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
46a3b40
Most functions typed (the ones that have been left, have been left du…
mplatypus 85b4897
replace object() with mock.Mock()
mplatypus 81c7897
replace object() with mock.Mock()
mplatypus 2b06574
Use Snowflake() instead of bare number.
mplatypus cedfab7
Add pyright test for tests in nox and to github workflows.
mplatypus 656ef3c
Mass update of all test files (no specific error was targeted, just f…
mplatypus 70fd372
formatting
mplatypus 9a6a152
Added a few more FIXME's to look at, and fixed a few more tests.
mplatypus 7e9a562
Renaming of test, and updated workflow.
mplatypus c14246c
Remove unnecessary fixtures
davfsa 643f351
Add pipelines folder to pytest norecursedirs
davfsa b86a135
Fix CI
davfsa 72ba12f
Fix tests leaking their context
davfsa f9a72bc
Merge branch 'master' into fix/typing-tests
davfsa c21d8e8
Reformat code
davfsa c4ecd29
Update pyright-tests pipeline to use new format
davfsa 0536325
Fix failing tests
davfsa f0c664c
Remove duplicate mocked applications (traits.RESTAware) and move to c…
mplatypus 0948635
Add license.
mplatypus ae44409
Merge branch 'master' into fix/typing-tests
davfsa bc8eb98
Merge branch 'master' into fix/typing-tests
davfsa 26618df
Switch uses of MutableMapping and Mapping to dict
davfsa 07c0ed2
Merge branch 'master' into fix/typing-tests
davfsa 0b24f6a
Add missing dependencies
davfsa b975075
Merge branch 'master' into fix/typing-tests
mplatypus 3e7f901
Removal of errors. Almost passing tests.
mplatypus 0302010
Add pyright configuration for tests
davfsa 4584aec
Make the pyright tests config more restrictive
davfsa b569258
Even more restrictive
davfsa 7de7ee0
Cleanup MockedUser class
davfsa 9f2331e
Use executionEnvironments for split config
davfsa ba71098
Fix failing tests and some more types
davfsa 9fd4888
Fix rest of failing tests
davfsa f49d111
Merge branch 'fix/typing-tests' of https://github.com/mplatypus/hikar…
mplatypus fb4a613
Merge branch 'master' into fix/typing-tests
mplatypus e4dfc34
Merge branch 'master' into fix/typing-tests
mplatypus 4d121ce
Fix workflows
mplatypus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,16 @@ | |
| NoxCallbackSigT = typing.Callable[[nox.Session], None] | ||
|
|
||
| # Default sessions should be defined here | ||
| nox.options.sessions = ["reformat-code", "codespell", "pytest", "ruff", "slotscheck", "mypy", "verify-types"] | ||
| nox.options.sessions = [ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dont want it to run by default if its not something that is expected to pass as of right now |
||
| "reformat-code", | ||
| "codespell", | ||
| "pytest", | ||
| "pyright-tests", | ||
| "ruff", | ||
| "slotscheck", | ||
| "mypy", | ||
| "verify-types", | ||
| ] | ||
| nox.options.default_venv_backend = "uv" | ||
|
|
||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| # Copyright (c) 2020 Nekokatt | ||
| # Copyright (c) 2021-present davfsa | ||
| # | ||
| # Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| # of this software and associated documentation files (the "Software"), to deal | ||
| # in the Software without restriction, including without limitation the rights | ||
| # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| # copies of the Software, and to permit persons to whom the Software is | ||
| # furnished to do so, subject to the following conditions: | ||
| # | ||
| # The above copyright notice and this permission notice shall be included in all | ||
| # copies or substantial portions of the Software. | ||
| # | ||
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| # SOFTWARE. | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import datetime | ||
|
|
||
| import mock | ||
| import pytest | ||
|
|
||
| from hikari import channels | ||
| from hikari import emojis | ||
| from hikari import guilds | ||
| from hikari import messages | ||
| from hikari import snowflakes | ||
| from hikari import stickers | ||
| from hikari import traits | ||
| from hikari import users | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def hikari_app() -> traits.RESTAware: | ||
| return mock.Mock(spec=traits.RESTAware, rest=mock.AsyncMock()) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def hikari_partial_guild() -> guilds.PartialGuild: | ||
| return guilds.PartialGuild( | ||
| app=mock.Mock(), id=snowflakes.Snowflake(123), icon_hash="partial_guild_icon_hash", name="partial_guild" | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def hikari_guild_text_channel() -> channels.GuildTextChannel: | ||
| return channels.GuildTextChannel( | ||
| app=mock.Mock(), | ||
| id=snowflakes.Snowflake(4560), | ||
| name="guild_text_channel_name", | ||
| type=channels.ChannelType.GUILD_TEXT, | ||
| guild_id=mock.Mock(), # FIXME: Can this be pulled from the actual fixture? | ||
| parent_id=mock.Mock(), # FIXME: Can this be pulled from the actual fixture? | ||
| position=0, | ||
| is_nsfw=False, | ||
| permission_overwrites={}, | ||
| topic=None, | ||
| last_message_id=None, | ||
| rate_limit_per_user=datetime.timedelta(seconds=10), | ||
| last_pin_timestamp=None, | ||
| default_auto_archive_duration=datetime.timedelta(seconds=10), | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def hikari_user() -> users.User: | ||
| return users.UserImpl( | ||
| id=snowflakes.Snowflake(789), | ||
| app=mock.Mock(), | ||
| discriminator="0", | ||
| username="user_username", | ||
| global_name="user_global_name", | ||
| avatar_decoration=users.AvatarDecoration( | ||
| asset_hash="avatar_decoration_asset_hash", sku_id=snowflakes.Snowflake(999), expires_at=None | ||
| ), | ||
| avatar_hash="user_avatar_hash", | ||
| banner_hash="user_banner_hash", | ||
| accent_color=None, | ||
| is_bot=False, | ||
| is_system=False, | ||
| flags=users.UserFlag.NONE, | ||
| primary_guild=None, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def hikari_message() -> messages.Message: | ||
| return messages.Message( | ||
| id=snowflakes.Snowflake(101), | ||
| app=mock.Mock(), | ||
| channel_id=snowflakes.Snowflake(456), | ||
| guild_id=None, | ||
| author=mock.Mock(), | ||
| member=mock.Mock(), | ||
| content=None, | ||
| timestamp=datetime.datetime.fromtimestamp(6000), | ||
| edited_timestamp=None, | ||
| is_tts=False, | ||
| user_mentions={}, | ||
| role_mention_ids=[], | ||
| channel_mentions={}, | ||
| mentions_everyone=False, | ||
| attachments=[], | ||
| embeds=[], | ||
| poll=None, | ||
| reactions=[], | ||
| is_pinned=False, | ||
| webhook_id=snowflakes.Snowflake(432), | ||
| type=messages.MessageType.DEFAULT, | ||
| activity=None, | ||
| application=None, | ||
| message_reference=None, | ||
| flags=messages.MessageFlag.NONE, | ||
| stickers=[], | ||
| nonce=None, | ||
| referenced_message=None, | ||
| message_snapshots=[], | ||
| application_id=None, | ||
| components=[], | ||
| thread=None, | ||
| interaction_metadata=None, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def hikari_partial_sticker() -> stickers.PartialSticker: | ||
| return stickers.PartialSticker( | ||
| id=snowflakes.Snowflake(222), name="sticker_name", format_type=stickers.StickerFormatType.PNG | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def hikari_guild_sticker() -> stickers.GuildSticker: | ||
| return stickers.GuildSticker( | ||
| id=snowflakes.Snowflake(2220), | ||
| name="guild_sticker_name", | ||
| format_type=stickers.StickerFormatType.PNG, | ||
| description="guild_sticker_description", | ||
| guild_id=snowflakes.Snowflake(123), | ||
| is_available=True, | ||
| tag="guild_sticker_tag", | ||
| user=None, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def hikari_custom_emoji() -> emojis.CustomEmoji: | ||
| return emojis.CustomEmoji(id=snowflakes.Snowflake(444), name="custom_emoji_name", is_animated=False) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def hikari_unicode_emoji() -> emojis.UnicodeEmoji: | ||
| return emojis.UnicodeEmoji("🙂") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets revert the changes in this file for now.
We can enable it in the future when it doesnt cause the pipeline to be marked as failed