Skip to content

Commit

Permalink
[i3] Record our adjustments to the type stub files
Browse files Browse the repository at this point in the history
  • Loading branch information
ttrei committed Nov 30, 2022
1 parent 4388e8b commit 53e9cbd
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 0 deletions.
69 changes: 69 additions & 0 deletions i3/i3init/typings.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
diff -ruN typings/i3ipc/aio/__init__.pyi typings.patched/i3ipc/aio/__init__.pyi
--- typings/i3ipc/aio/__init__.pyi 2022-11-30 21:30:26.454203922 +0200
+++ typings.patched/i3ipc/aio/__init__.pyi 2022-11-30 21:30:25.458199758 +0200
@@ -3,3 +3,5 @@
"""

from .connection import Con, Connection
+
+__all__ = ["Con", "Connection"]
diff -ruN typings/i3ipc/con.pyi typings.patched/i3ipc/con.pyi
--- typings/i3ipc/con.pyi 2022-11-30 21:30:26.474204005 +0200
+++ typings.patched/i3ipc/con.pyi 2022-11-30 21:30:25.458199758 +0200
@@ -86,6 +86,11 @@
:vartype ipc_data: dict
"""

+ name: str
+ nodes: List[Con]
+ type: str
+ window_class: str
+
def __init__(self, data, parent, conn) -> None: ...
def __iter__(self): # -> Generator[Unknown, None, None]:
"""Iterate through the descendents of this node (breadth-first tree traversal)"""
diff -ruN typings/i3ipc/events.pyi typings.patched/i3ipc/events.pyi
--- typings/i3ipc/events.pyi 2022-11-30 21:30:26.478204021 +0200
+++ typings.patched/i3ipc/events.pyi 2022-11-30 21:30:25.458199758 +0200
@@ -4,6 +4,7 @@

from enum import Enum

+from .con import Con
from .replies import BarConfigReply

class IpcBaseEvent:
@@ -111,6 +112,7 @@
:vartype ipc_data: dict
"""

+ container: Con
def __init__(self, data, conn, _Con=...) -> None: ...

class BarconfigUpdateEvent(IpcBaseEvent, BarConfigReply):
diff -ruN typings/i3ipc/__init__.pyi typings.patched/i3ipc/__init__.pyi
--- typings/i3ipc/__init__.pyi 2022-11-30 21:30:26.462203956 +0200
+++ typings.patched/i3ipc/__init__.pyi 2022-11-30 21:30:25.458199758 +0200
@@ -2,16 +2,6 @@
This type stub file was generated by pyright.
"""

-from .__version__ import (
- __author__,
- __author_email__,
- __copyright__,
- __description__,
- __license__,
- __title__,
- __url__,
- __version__,
-)
from .con import Con
from .connection import Connection
from .events import (
@@ -39,3 +29,5 @@
VersionReply,
WorkspaceReply,
)
+
+__all__ = ["Con", "Event", "WindowEvent"]
18 changes: 18 additions & 0 deletions i3/i3init/util/create-typestub-diff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env sh

# Create a patch to record our changes of the pyright-generate type stubs.

SCRIPT_DIR=$(dirname "$(readlink -f "$0")")

cd "$SCRIPT_DIR/.." || exit

cp -r typings typings.patched
rm -rf typings
pyright --createstub i3ipc
isort typings
black typings

diff -ruN typings typings.patched > typings.patch

rm -rf typings.patched
git restore typings
18 changes: 18 additions & 0 deletions i3/i3init/util/regenerate-typestubs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env sh

# Re-generate type stubs with pyright and re-apply our adjustments.
# If the patch doesn't apply cleanly, consider skipping the "patch" step and
# using git resolve the conflicts. Don't forget to re-create the patch file with
# create-typestub-diff.sh.

SCRIPT_DIR=$(dirname "$(readlink -f "$0")")

cd "$SCRIPT_DIR/.." || exit

rm -rf typings
pyright --createstub i3ipc
isort typings
black typings

patch -s -p0 < typings.patch

0 comments on commit 53e9cbd

Please sign in to comment.