1818 QWidget )
1919from scapy .all import ARP , Ether , get_if_addr , srp # pylint: disable=E0611
2020
21- import core . db as db
21+ from core import db
2222import core .networking as net
2323from core import vendor
2424from core .mitm import MitmThread
3737_RESOLVE_WORKERS = 20
3838
3939
40- class DeviceDetailsWindow (QMainWindow ):
40+ class DeviceDetailsWindow (QMainWindow ): # pylint: disable=too-many-instance-attributes
4141 """Window showing detailed information about a device, with MITM controls."""
4242
43- def __init__ (
43+ def __init__ ( # pylint: disable=too-many-arguments,too-many-positional-arguments
4444 self ,
4545 ip_address ,
4646 mac_address ,
@@ -260,7 +260,8 @@ def _save_pcap(self):
260260 wrpcap (path , self ._captured_packets )
261261 print (f"[MITM] Saved { len (self ._captured_packets )} packets to { path } " )
262262
263- def closeEvent (self , event ):
263+ def closeEvent (self , event ): # pylint: disable=invalid-name
264+ """Stop MITM thread when window closes."""
264265 if self ._mitm and self ._mitm .isRunning ():
265266 self ._mitm .stop ()
266267 # Don't wait — let the thread finish in the background and clean up
@@ -302,6 +303,7 @@ def __init__(self, interface, oui_url, timeout=1000, target_cidr=None, parent=No
302303 self .scanner_timer = None
303304 self .device_info = {}
304305 self .arp_scanner_thread = None
306+ self .device_details_window = None
305307
306308 self ._load_known_devices ()
307309
@@ -402,22 +404,24 @@ def start_scan(self):
402404 self .arp_scanner_thread .finished .connect (self .handle_scan_results )
403405 self .arp_scanner_thread .progressChanged .connect (self .update_progress )
404406 self .arp_scanner_thread .start ()
405- print (
406- f"Started ARP scan — timeout: { self .timeout } ms, target: { self .target_cidr or 'local network' } "
407- )
407+ target = self .target_cidr or 'local network'
408+ print (f"Started ARP scan — timeout: { self .timeout } ms, target: { target } " )
408409
409410 @Slot (int )
410411 def update_progress (self , progress ):
412+ """Update the progress bar value."""
411413 self .progress_bar .setValue (progress )
412414
413415 @Slot (list )
414416 def handle_partial_results (self , partial_results ):
417+ """Handle partial scan results as they arrive."""
415418 for ip_address , mac , hostname , device_vendor , _ in partial_results :
416419 status = self ._upsert_and_tag (ip_address , mac , hostname , device_vendor )
417420 self .add_device_to_list (ip_address , mac , hostname , device_vendor , status )
418421
419422 @Slot (list )
420423 def handle_scan_results (self , results ):
424+ """Handle the final list of scan results."""
421425 self ._last_results = results
422426 for ip_address , mac , hostname , device_vendor , packet in results :
423427 status = self ._upsert_and_tag (ip_address , mac , hostname , device_vendor )
@@ -462,6 +466,7 @@ def add_device_to_list(
462466 item .setForeground (QColor (Qt .white ))
463467
464468 def add_packet_if_new (self , packet_label ):
469+ """Add a packet summary to the responses list if not already present."""
465470 if not self ._ui .responses .findItems (packet_label , Qt .MatchExactly ):
466471 item = QListWidgetItem (packet_label )
467472 item .setBackground (QColor (Qt .black ))
@@ -474,6 +479,7 @@ def add_packet_if_new(self, packet_label):
474479
475480 @Slot (QListWidgetItem )
476481 def open_device_details (self , item ):
482+ """Open the DeviceDetailsWindow for the clicked list item."""
477483 self .device_info = self ._parse_device_details (item .text ())
478484 if self .device_info :
479485 ip = self .device_info ["ip_address" ]
@@ -482,7 +488,7 @@ def open_device_details(self, item):
482488 known = next ((d for d in db .get_all_devices () if d ["ip_address" ] == ip ), {})
483489 gateway_ip = netifaces .gateways ()["default" ][netifaces .AF_INET ][0 ]
484490 self .device_details_window = (
485- DeviceDetailsWindow ( # pylint: disable=attribute-defined-outside-init
491+ DeviceDetailsWindow (
486492 ip ,
487493 self .device_info ["mac" ],
488494 self .device_info ["hostname" ],
@@ -560,10 +566,12 @@ def export_results(self):
560566 # ------------------------------------------------------------------
561567
562568 def quit_application (self ):
569+ """Disable the quit button and shut down the application."""
563570 self ._ui .quit .setEnabled (False )
564571 self ._shutdown ()
565572
566- def closeEvent (self , event ):
573+ def closeEvent (self , event ): # pylint: disable=invalid-name
574+ """Shut down scanner thread when dialog closes."""
567575 self ._shutdown ()
568576 super ().closeEvent (event )
569577
@@ -598,6 +606,7 @@ def __init__(self, interface, mac_vendor_lookup, timeout=1, target_cidr=None):
598606 self .use_native = self .is_macos and NATIVE_ARP_AVAILABLE
599607
600608 def run (self ):
609+ """Determine the target network and start the ARP scan."""
601610 src_ip = get_if_addr (self .interface )
602611
603612 if self .target_cidr :
0 commit comments