Skip to content

Commit d758699

Browse files
committed
remove imports outside toplevel
1 parent 0b1c8b2 commit d758699

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

addon/ops/start_live_mode.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# pylint: disable=import-outside-toplevel
2-
31
import bpy
2+
import serial
3+
import websocket
44

55
from bpy.types import Operator
66
from ..utils.live_mode import LiveMode
@@ -65,8 +65,6 @@ def execute(self, context):
6565
return {'CANCELLED'}
6666

6767
def open_serial(self, _context):
68-
import serial
69-
7068
try:
7169
serial_connection = serial.Serial(self.serial_port, self.serial_baud)
7270
except (serial.SerialException, ValueError):
@@ -91,8 +89,6 @@ def open_serial(self, _context):
9189
return {'FINISHED'}
9290

9391
def open_socket(self, _context):
94-
import websocket
95-
9692
socket_url = f"ws://{self.socket_host}:{self.socket_port}{self.socket_path}"
9793
socket_connection = websocket.WebSocket()
9894
socket_connection.settimeout(1)

addon/utils/live_mode.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
# pylint: disable=import-outside-toplevel, broad-exception-caught
1+
# pylint: disable=broad-exception-caught
22

33
import time
44
import math
55
import bpy
6+
import serial
7+
import websocket
68

79
from ..utils.servo_settings import get_active_pose_bones
810
from ..utils.converter import calculate_position
11+
from serial.tools import list_ports
912

1013
class LiveMode:
1114
COMMAND_START = 0x3C
@@ -26,9 +29,6 @@ def set_connection(cls, connection):
2629

2730
@classmethod
2831
def is_connected(cls):
29-
import serial
30-
import websocket
31-
3232
method = bpy.context.window_manager.servo_animation.live_mode_method
3333

3434
if method == LiveMode.METHOD_SERIAL:
@@ -63,8 +63,6 @@ def disable_handler(cls):
6363

6464
@classmethod
6565
def get_serial_ports(cls):
66-
from serial.tools import list_ports
67-
6866
ports = []
6967

7068
for port in list_ports.comports():

0 commit comments

Comments
 (0)