3333
3434inotify_add_watch = cast (
3535 Callable [[int , bytes , int ], WatchDescriptor ],
36- ctypes .CFUNCTYPE (c_int , c_int , c_char_p , c_uint32 , use_errno = True )(("inotify_add_watch" , libc )))
36+ ctypes .CFUNCTYPE (c_int , c_int , c_char_p , c_uint32 , use_errno = True )(("inotify_add_watch" , libc )),
37+ )
3738
3839inotify_rm_watch = cast (
3940 Callable [[int , WatchDescriptor ], int ],
40- ctypes .CFUNCTYPE (c_int , c_int , c_uint32 , use_errno = True )(("inotify_rm_watch" , libc )))
41+ ctypes .CFUNCTYPE (c_int , c_int , c_uint32 , use_errno = True )(("inotify_rm_watch" , libc )),
42+ )
4143
4244inotify_init = cast (Callable [[], int ], ctypes .CFUNCTYPE (c_int , use_errno = True )(("inotify_init" , libc )))
4345
@@ -124,9 +126,7 @@ class InotifyConstants:
124126
125127
126128def _get_mask_string (mask : int ) -> str :
127- return "|" .join (
128- name for name , c_val in INOTIFY_ALL_CONSTANTS .items () if mask & c_val
129- )
129+ return "|" .join (name for name , c_val in INOTIFY_ALL_CONSTANTS .items () if mask & c_val )
130130
131131
132132class InotifyEventStruct (ctypes .Structure ):
@@ -173,6 +173,7 @@ def on_watch_deleted(self, wd: WatchDescriptor) -> None:
173173@dataclass
174174class Watch :
175175 """Represents an inotify watch"""
176+
176177 wd : WatchDescriptor
177178 """the inotify watch descriptor"""
178179 mask : Mask
@@ -194,11 +195,13 @@ def is_used(self) -> bool:
194195 return bool (self .callbacks )
195196
196197 def short_str (self ) -> str :
197- contents = ", " .join ([
198- f"wd={ self .wd } " ,
199- f"mask={ _get_mask_string (self .mask )} " ,
200- f"_initial_creation_path={ self ._initial_creation_path !r} " ,
201- ])
198+ contents = ", " .join (
199+ [
200+ f"wd={ self .wd } " ,
201+ f"mask={ _get_mask_string (self .mask )} " ,
202+ f"_initial_creation_path={ self ._initial_creation_path !r} " ,
203+ ]
204+ )
202205 return f"<{ type (self ).__name__ } : { contents } >"
203206
204207
@@ -522,7 +525,7 @@ def _parse_event_buffer(event_buffer: bytes) -> Generator[tuple[WatchDescriptor,
522525 i = 0
523526 while i + 16 <= len (event_buffer ):
524527 wd , mask , cookie , length = struct .unpack_from ("iIII" , event_buffer , i )
525- name = event_buffer [i + 16 : i + 16 + length ].rstrip (b"\0 " )
528+ name = event_buffer [i + 16 : i + 16 + length ].rstrip (b"\0 " )
526529 i += 16 + length
527530 yield wd , mask , cookie , name
528531
@@ -533,8 +536,7 @@ def _parse_event_buffer(event_buffer: bytes) -> Generator[tuple[WatchDescriptor,
533536
534537@dataclass (unsafe_hash = True , frozen = True )
535538class InotifyEvent :
536- """Inotify event struct wrapper.
537- """
539+ """Inotify event struct wrapper."""
538540
539541 wd : WatchDescriptor
540542 """Watch descriptor"""
@@ -611,10 +613,12 @@ def is_directory(self) -> bool:
611613 return self .is_delete_self or self .is_move_self or self .mask & InotifyConstants .IN_ISDIR > 0
612614
613615 def __repr__ (self ) -> str :
614- contents = ", " .join ([
615- f"wd={ self .wd } " ,
616- f"mask={ _get_mask_string (self .mask )} " ,
617- f"cookie={ self .cookie } " ,
618- f"name={ os .fsdecode (self .name )!r} " ,
619- ])
616+ contents = ", " .join (
617+ [
618+ f"wd={ self .wd } " ,
619+ f"mask={ _get_mask_string (self .mask )} " ,
620+ f"cookie={ self .cookie } " ,
621+ f"name={ os .fsdecode (self .name )!r} " ,
622+ ]
623+ )
620624 return f"<{ type (self ).__name__ } : { contents } >"
0 commit comments