-
-
Notifications
You must be signed in to change notification settings - Fork 15
Closed
Description
Description
What do you think about API like this:
from patchy import patch
from typing import Callable
class Patch:
target: Callable
def __init_subclass__(cls) -> None:
diff_u = cls.__doc__.strip("\n")
patch(cls.target, diff_u)
And usage example:
class PatchHandleUpdates(Patch):
"""
@@ -1,8 +1,8 @@
async def handle_updates(self, updates):
if isinstance(updates, (raw.types.Updates, raw.types.UpdatesCombined)):
is_min = any((
- await self.fetch_peers(updates.users),
- await self.fetch_peers(updates.chats),
+ await self.fetch_peers__users(updates.users),
+ await self.fetch_peers__chats(updates.chats),
))
users = {u.id: u for u in updates.users}
"""
target = Client.handle_updates
TODO:
- Maybe add explicit patch apply / rollback
-
- It would require explicit methods
apply
androllback
instead of my implementation
- It would require explicit methods
- Maybe something else?
-
- Yes. Ability to add any name into globals. It require API change
Metadata
Metadata
Assignees
Labels
No labels