-
Notifications
You must be signed in to change notification settings - Fork 2k
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 NodeType
to its own file out of chia.server
#19203
base: main
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 13020383560Details
💛 - Coveralls |
chia/server/outbound_message.py
Outdated
from typing import Optional, SupportsBytes, Union | ||
|
||
from chia.protocols.protocol_message_types import ProtocolMessageTypes | ||
from chia.types.node_type import NodeType # TODO: remove this and change a lot of `import` statements |
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.
i believe this will indicate an explicit re-export to mypy so we don't have to maintain a __all__
.
from chia.types.node_type import NodeType # TODO: remove this and change a lot of `import` statements | |
from chia.types.node_type import NodeType as NodeType # TODO: remove this and change a lot of `import` statements |
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.
Unfortunately this change is giving me chia/server/outbound_message.py:7:34: PLC0414 Import alias does not rename original package
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.
this is already a thing we intend to correct (per the TODO:
) so i think an ignore is reasonable here.
from chia.types.node_type import NodeType # TODO: remove this and change a lot of `import` statements | |
# TODO: remove this and change a lot of `import` statements | |
from chia.types.node_type import NodeType as NodeType # noqa: PLC0414 |
i just really hate maintaining __all__
, which won't generally happen i don't think unless some check catches it being out of date. and i despise even more when it is leveraged (*
imports).
for example, i did:
# just disallow * importing so we don't have to maintain this repetitive list
__all__: Sequence[str] = []
3695062
to
c3a7f07
Compare
Purpose:
I've been trying out the
tach
tool, and it works really well. It's been helpful in finding files that are in the wrong place. This is another one.This patch moves
NodeType
tochia.types
which meanschia.util
no longer needs to depend uponchia.server
(which seems pretty obviously bad).Lots of other files import
NodeType
fromchia.server.outbound_message
(about 116). To keep this patch short, I've left the import inchia.server.outbound_message
so I don't have to make 116 changes at this point, which would be a distraction in evaluating the idea here.There are a couple other options: move the entire file
chia/server/outbound_message.py
tochia/types/outbound_message.py
. We could also split outMessage
into its own file and/or move it tochia/types
. What do you @arvidn @altendky think about these options?Current Behavior:
New Behavior:
Testing Notes: