aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Kramkowski <tomasz@kramkow.ski>2025-08-15 21:47:41 +0100
committerTomasz Kramkowski <tomasz@kramkow.ski>2025-08-15 21:47:41 +0100
commita961fbda426d79dc3c33a66848408e84b0737a98 (patch)
tree264ffa9a3be219cb4ec067f64030af64e67521ee
parente48c5758975756271ae4bf4b9eae538d0a411c21 (diff)
downloadkutter-a961fbda426d79dc3c33a66848408e84b0737a98.tar.gz
kutter-a961fbda426d79dc3c33a66848408e84b0737a98.tar.xz
kutter-a961fbda426d79dc3c33a66848408e84b0737a98.zip
Isort all klippy code
-rw-r--r--klippy/chelper/__init__.py5
-rw-r--r--klippy/clocksync.py3
-rw-r--r--klippy/configfile.py13
-rwxr-xr-xklippy/console.py13
-rw-r--r--klippy/extras/adc_temperature.py4
-rw-r--r--klippy/extras/ads1220.py1
-rw-r--r--klippy/extras/ads1x1x.py2
-rw-r--r--klippy/extras/adxl345.py9
-rw-r--r--klippy/extras/aht10.py1
-rw-r--r--klippy/extras/angle.py6
-rw-r--r--klippy/extras/axis_twist_compensation.py2
-rw-r--r--klippy/extras/bed_mesh.py6
-rw-r--r--klippy/extras/bed_tilt.py2
-rw-r--r--klippy/extras/bltouch.py1
-rw-r--r--klippy/extras/bme280.py1
-rw-r--r--klippy/extras/bulk_sensor.py4
-rw-r--r--klippy/extras/buttons.py1
-rw-r--r--klippy/extras/delta_calibrate.py6
-rw-r--r--klippy/extras/display/display.py7
-rw-r--r--klippy/extras/display/hd44780_spi.py1
-rw-r--r--klippy/extras/display/menu.py6
-rw-r--r--klippy/extras/display/st7920.py1
-rw-r--r--klippy/extras/display/uc1701.py1
-rw-r--r--klippy/extras/ds18b20.py1
-rw-r--r--klippy/extras/endstop_phase.py4
-rw-r--r--klippy/extras/exclude_object.py2
-rw-r--r--klippy/extras/extruder_stepper.py1
-rw-r--r--klippy/extras/fan.py2
-rw-r--r--klippy/extras/fan_generic.py1
-rw-r--r--klippy/extras/filament_motion_sensor.py1
-rw-r--r--klippy/extras/force_move.py4
-rw-r--r--klippy/extras/gcode_macro.py8
-rw-r--r--klippy/extras/heaters.py5
-rw-r--r--klippy/extras/homing.py3
-rw-r--r--klippy/extras/htu21d.py1
-rw-r--r--klippy/extras/hx71x.py1
-rw-r--r--klippy/extras/icm20948.py3
-rw-r--r--klippy/extras/input_shaper.py2
-rw-r--r--klippy/extras/ldc1612.py3
-rw-r--r--klippy/extras/led.py1
-rw-r--r--klippy/extras/lis2dw.py3
-rw-r--r--klippy/extras/lm75.py1
-rw-r--r--klippy/extras/load_cell.py7
-rw-r--r--klippy/extras/load_cell_probe.py7
-rw-r--r--klippy/extras/manual_probe.py3
-rw-r--r--klippy/extras/manual_stepper.py5
-rw-r--r--klippy/extras/motion_report.py2
-rw-r--r--klippy/extras/mpu9250.py3
-rw-r--r--klippy/extras/neopixel.py1
-rw-r--r--klippy/extras/output_pin.py5
-rw-r--r--klippy/extras/palette2.py6
-rw-r--r--klippy/extras/pca9533.py1
-rw-r--r--klippy/extras/pid_calibrate.py4
-rw-r--r--klippy/extras/probe.py2
-rw-r--r--klippy/extras/probe_eddy_current.py8
-rw-r--r--klippy/extras/quad_gantry_level.py1
-rw-r--r--klippy/extras/replicape.py8
-rw-r--r--klippy/extras/resonance_tester.py6
-rw-r--r--klippy/extras/save_variables.py5
-rw-r--r--klippy/extras/screws_tilt_adjust.py1
-rw-r--r--klippy/extras/shaper_calibrate.py7
-rw-r--r--klippy/extras/shaper_defs.py3
-rw-r--r--klippy/extras/sht3x.py1
-rw-r--r--klippy/extras/smart_effector.py1
-rw-r--r--klippy/extras/spi_temperature.py5
-rw-r--r--klippy/extras/statistics.py4
-rw-r--r--klippy/extras/sx1509.py1
-rw-r--r--klippy/extras/temperature_mcu.py2
-rw-r--r--klippy/extras/temperature_probe.py1
-rw-r--r--klippy/extras/thermistor.py4
-rw-r--r--klippy/extras/tmc.py6
-rw-r--r--klippy/extras/tmc2130.py4
-rw-r--r--klippy/extras/tmc2208.py3
-rw-r--r--klippy/extras/tmc2209.py2
-rw-r--r--klippy/extras/tmc2240.py4
-rw-r--r--klippy/extras/tmc2660.py4
-rw-r--r--klippy/extras/tmc5160.py4
-rw-r--r--klippy/extras/tmc_uart.py1
-rw-r--r--klippy/extras/tuning_tower.py3
-rw-r--r--klippy/extras/virtual_sdcard.py4
-rw-r--r--klippy/extras/z_tilt.py2
-rw-r--r--klippy/gcode.py6
-rw-r--r--klippy/kinematics/cartesian.py2
-rw-r--r--klippy/kinematics/corexy.py4
-rw-r--r--klippy/kinematics/corexz.py4
-rw-r--r--klippy/kinematics/delta.py7
-rw-r--r--klippy/kinematics/deltesian.py4
-rw-r--r--klippy/kinematics/extruder.py7
-rw-r--r--klippy/kinematics/generic_cartesian.py11
-rw-r--r--klippy/kinematics/hybrid_corexy.py2
-rw-r--r--klippy/kinematics/hybrid_corexz.py2
-rw-r--r--klippy/kinematics/idex_modes.py5
-rw-r--r--klippy/kinematics/kinematic_stepper.py7
-rw-r--r--klippy/kinematics/polar.py4
-rw-r--r--klippy/kinematics/rotary_delta.py8
-rw-r--r--klippy/kinematics/winch.py3
-rw-r--r--klippy/klippy.py22
-rw-r--r--klippy/mathutil.py7
-rw-r--r--klippy/mcu.py13
-rw-r--r--klippy/msgproto.py4
-rwxr-xr-xklippy/parsedump.py5
-rw-r--r--klippy/queuelogger.py7
-rw-r--r--klippy/reactor.py12
-rw-r--r--klippy/serialhdl.py10
-rw-r--r--klippy/stepper.py5
-rw-r--r--klippy/toolhead.py9
-rw-r--r--klippy/util.py8
-rw-r--r--klippy/webhooks.py8
108 files changed, 362 insertions, 108 deletions
diff --git a/klippy/chelper/__init__.py b/klippy/chelper/__init__.py
index 9bb2ebad..99baf7b1 100644
--- a/klippy/chelper/__init__.py
+++ b/klippy/chelper/__init__.py
@@ -3,9 +3,10 @@
# Copyright (C) 2016-2021 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import os, logging
-import cffi
+import logging
+import os
+import cffi
######################################################################
# c_helper.so compiling
diff --git a/klippy/clocksync.py b/klippy/clocksync.py
index 1e444381..fae9a392 100644
--- a/klippy/clocksync.py
+++ b/klippy/clocksync.py
@@ -3,7 +3,8 @@
# Copyright (C) 2016-2018 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import logging, math
+import logging
+import math
RTT_AGE = 0.000010 / (60.0 * 60.0)
DECAY = 1.0 / 30.0
diff --git a/klippy/configfile.py b/klippy/configfile.py
index 6860a964..879a7d63 100644
--- a/klippy/configfile.py
+++ b/klippy/configfile.py
@@ -3,7 +3,14 @@
# Copyright (C) 2016-2024 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import os, glob, re, time, logging, configparser, io, shutil
+import configparser
+import glob
+import io
+import logging
+import os
+import re
+import shutil
+import time
error = configparser.Error
@@ -450,7 +457,9 @@ class ConfigAutoSave:
backup_name = autosave_filename[:-4] + datestr + ".cfg"
temp_name = autosave_filename[:-4] + "_autosave.cfg"
# Create new config file with temporary name and swap with main config
- logging.info("SAVE_CONFIG to '%s' (backup in '%s')", autosave_filename, backup_name)
+ logging.info(
+ "SAVE_CONFIG to '%s' (backup in '%s')", autosave_filename, backup_name
+ )
try:
f = open(temp_name, "w")
f.write(autosave_data)
diff --git a/klippy/console.py b/klippy/console.py
index b0d0c965..3f9086d6 100755
--- a/klippy/console.py
+++ b/klippy/console.py
@@ -4,8 +4,17 @@
# Copyright (C) 2016-2021 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import sys, optparse, os, re, logging
-import util, reactor, serialhdl, msgproto, clocksync
+import logging
+import optparse
+import os
+import re
+import sys
+
+import clocksync
+import msgproto
+import reactor
+import serialhdl
+import util
help_txt = """
This is a debugging console for the Kutter micro-controller.
diff --git a/klippy/extras/adc_temperature.py b/klippy/extras/adc_temperature.py
index ef05c52b..2bad0349 100644
--- a/klippy/extras/adc_temperature.py
+++ b/klippy/extras/adc_temperature.py
@@ -3,8 +3,8 @@
# Copyright (C) 2016-2024 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import logging, bisect
-
+import bisect
+import logging
######################################################################
# Interface between MCU adc and heater temperature callbacks
diff --git a/klippy/extras/ads1220.py b/klippy/extras/ads1220.py
index d1ccc9c9..0e3e6bbb 100644
--- a/klippy/extras/ads1220.py
+++ b/klippy/extras/ads1220.py
@@ -4,6 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
from . import bulk_sensor, bus
#
diff --git a/klippy/extras/ads1x1x.py b/klippy/extras/ads1x1x.py
index 43bdea25..a76a14d9 100644
--- a/klippy/extras/ads1x1x.py
+++ b/klippy/extras/ads1x1x.py
@@ -4,7 +4,9 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
import pins
+
from . import bus
# Supported chip types
diff --git a/klippy/extras/adxl345.py b/klippy/extras/adxl345.py
index 7870bd4a..4d64ad14 100644
--- a/klippy/extras/adxl345.py
+++ b/klippy/extras/adxl345.py
@@ -3,8 +3,13 @@
# Copyright (C) 2020-2023 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import logging, time, collections, multiprocessing, os
-from . import bus, bulk_sensor
+import collections
+import logging
+import multiprocessing
+import os
+import time
+
+from . import bulk_sensor, bus
# ADXL345 registers
REG_DEVID = 0x00
diff --git a/klippy/extras/aht10.py b/klippy/extras/aht10.py
index f680004d..320ccb36 100644
--- a/klippy/extras/aht10.py
+++ b/klippy/extras/aht10.py
@@ -4,6 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
from . import bus
######################################################################
diff --git a/klippy/extras/angle.py b/klippy/extras/angle.py
index f2799543..c857a14f 100644
--- a/klippy/extras/angle.py
+++ b/klippy/extras/angle.py
@@ -3,8 +3,10 @@
# Copyright (C) 2021,2022 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import logging, math
-from . import bus, bulk_sensor
+import logging
+import math
+
+from . import bulk_sensor, bus
MIN_MSG_TIME = 0.100
TCODE_ERROR = 0xFF
diff --git a/klippy/extras/axis_twist_compensation.py b/klippy/extras/axis_twist_compensation.py
index ae3c9811..f0008e1b 100644
--- a/klippy/extras/axis_twist_compensation.py
+++ b/klippy/extras/axis_twist_compensation.py
@@ -5,8 +5,8 @@
# This file may be distributed under the terms of the GNU GPLv3 license.
import math
-from . import manual_probe, bed_mesh, probe
+from . import bed_mesh, manual_probe, probe
DEFAULT_SAMPLE_COUNT = 3
DEFAULT_SPEED = 50.0
diff --git a/klippy/extras/bed_mesh.py b/klippy/extras/bed_mesh.py
index 921b6296..9fb3701b 100644
--- a/klippy/extras/bed_mesh.py
+++ b/klippy/extras/bed_mesh.py
@@ -3,7 +3,11 @@
# Copyright (C) 2018-2019 Eric Callahan <arksine.code@gmail.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import logging, math, json, collections
+import collections
+import json
+import logging
+import math
+
from . import probe
PROFILE_VERSION = 1
diff --git a/klippy/extras/bed_tilt.py b/klippy/extras/bed_tilt.py
index 1bbce154..bb05343f 100644
--- a/klippy/extras/bed_tilt.py
+++ b/klippy/extras/bed_tilt.py
@@ -4,7 +4,9 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
import mathutil
+
from . import probe
diff --git a/klippy/extras/bltouch.py b/klippy/extras/bltouch.py
index 76823a25..d4206089 100644
--- a/klippy/extras/bltouch.py
+++ b/klippy/extras/bltouch.py
@@ -4,6 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
from . import probe
SIGNAL_PERIOD = 0.020
diff --git a/klippy/extras/bme280.py b/klippy/extras/bme280.py
index 44de9de3..e4c1f1ca 100644
--- a/klippy/extras/bme280.py
+++ b/klippy/extras/bme280.py
@@ -4,6 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
from . import bus
REPORT_TIME = 0.8
diff --git a/klippy/extras/bulk_sensor.py b/klippy/extras/bulk_sensor.py
index cd112e1a..e28bcbdc 100644
--- a/klippy/extras/bulk_sensor.py
+++ b/klippy/extras/bulk_sensor.py
@@ -3,7 +3,9 @@
# Copyright (C) 2020-2023 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import logging, threading, struct
+import logging
+import struct
+import threading
# This "bulk sensor" module facilitates the processing of sensor chip
# measurements that do not require the host to respond with low
diff --git a/klippy/extras/buttons.py b/klippy/extras/buttons.py
index 0b90f1a3..edb3adec 100644
--- a/klippy/extras/buttons.py
+++ b/klippy/extras/buttons.py
@@ -5,7 +5,6 @@
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
-
######################################################################
# Button state tracking
######################################################################
diff --git a/klippy/extras/delta_calibrate.py b/klippy/extras/delta_calibrate.py
index 342aa110..1a6ad8c8 100644
--- a/klippy/extras/delta_calibrate.py
+++ b/klippy/extras/delta_calibrate.py
@@ -3,8 +3,12 @@
# Copyright (C) 2017-2019 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import math, logging, collections
+import collections
+import logging
+import math
+
import mathutil
+
from . import probe
# A "stable position" is a 3-tuple containing the number of steps
diff --git a/klippy/extras/display/display.py b/klippy/extras/display/display.py
index c381cf09..be11ac43 100644
--- a/klippy/extras/display/display.py
+++ b/klippy/extras/display/display.py
@@ -5,8 +5,11 @@
# Copyright (C) 2018 Eric Callahan <arksine.code@gmail.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import logging, os, ast
-from . import aip31068_spi, hd44780, hd44780_spi, st7920, uc1701, menu
+import ast
+import logging
+import os
+
+from . import aip31068_spi, hd44780, hd44780_spi, menu, st7920, uc1701
# Normal time between each screen redraw
REDRAW_TIME = 0.500
diff --git a/klippy/extras/display/hd44780_spi.py b/klippy/extras/display/hd44780_spi.py
index dd46acd3..98a0c48d 100644
--- a/klippy/extras/display/hd44780_spi.py
+++ b/klippy/extras/display/hd44780_spi.py
@@ -6,6 +6,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
from .. import bus
LINE_LENGTH_DEFAULT = 20
diff --git a/klippy/extras/display/menu.py b/klippy/extras/display/menu.py
index 717b6084..230b9f97 100644
--- a/klippy/extras/display/menu.py
+++ b/klippy/extras/display/menu.py
@@ -4,8 +4,12 @@
# Copyright (C) 2020 Janar Sööt <janar.soot@gmail.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import os, logging, ast, re
+import ast
+import logging
+import os
+import re
from string import Template
+
from . import menu_keys
diff --git a/klippy/extras/display/st7920.py b/klippy/extras/display/st7920.py
index 9411a064..624d180b 100644
--- a/klippy/extras/display/st7920.py
+++ b/klippy/extras/display/st7920.py
@@ -4,6 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
from .. import bus
from . import font8x14
diff --git a/klippy/extras/display/uc1701.py b/klippy/extras/display/uc1701.py
index 7d4e4683..3129b7bc 100644
--- a/klippy/extras/display/uc1701.py
+++ b/klippy/extras/display/uc1701.py
@@ -5,6 +5,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
from .. import bus
from . import font8x14
diff --git a/klippy/extras/ds18b20.py b/klippy/extras/ds18b20.py
index e9c52fde..30750fd8 100644
--- a/klippy/extras/ds18b20.py
+++ b/klippy/extras/ds18b20.py
@@ -4,6 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
import mcu
DS18_REPORT_TIME = 3.0
diff --git a/klippy/extras/endstop_phase.py b/klippy/extras/endstop_phase.py
index 52d88681..58a627cb 100644
--- a/klippy/extras/endstop_phase.py
+++ b/klippy/extras/endstop_phase.py
@@ -3,7 +3,9 @@
# Copyright (C) 2016-2021 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import math, logging
+import logging
+import math
+
import stepper
TRINAMIC_DRIVERS = ["tmc2130", "tmc2208", "tmc2209", "tmc2240", "tmc2660", "tmc5160"]
diff --git a/klippy/extras/exclude_object.py b/klippy/extras/exclude_object.py
index 3043e8dd..eb8700b3 100644
--- a/klippy/extras/exclude_object.py
+++ b/klippy/extras/exclude_object.py
@@ -5,8 +5,8 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import logging
import json
+import logging
class ExcludeObject:
diff --git a/klippy/extras/extruder_stepper.py b/klippy/extras/extruder_stepper.py
index b5feddf1..8ed085fe 100644
--- a/klippy/extras/extruder_stepper.py
+++ b/klippy/extras/extruder_stepper.py
@@ -4,6 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
from kinematics import extruder
diff --git a/klippy/extras/fan.py b/klippy/extras/fan.py
index 081db642..ee52a101 100644
--- a/klippy/extras/fan.py
+++ b/klippy/extras/fan.py
@@ -3,7 +3,7 @@
# Copyright (C) 2016-2024 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-from . import pulse_counter, output_pin
+from . import output_pin, pulse_counter
class Fan:
diff --git a/klippy/extras/fan_generic.py b/klippy/extras/fan_generic.py
index 3a9b3791..4a400c03 100644
--- a/klippy/extras/fan_generic.py
+++ b/klippy/extras/fan_generic.py
@@ -4,6 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
from . import fan, output_pin
diff --git a/klippy/extras/filament_motion_sensor.py b/klippy/extras/filament_motion_sensor.py
index 71a01949..59f3c943 100644
--- a/klippy/extras/filament_motion_sensor.py
+++ b/klippy/extras/filament_motion_sensor.py
@@ -4,6 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
from . import filament_switch_sensor
CHECK_RUNOUT_TIMEOUT = 0.250
diff --git a/klippy/extras/force_move.py b/klippy/extras/force_move.py
index dfdc26f2..c43b3d0c 100644
--- a/klippy/extras/force_move.py
+++ b/klippy/extras/force_move.py
@@ -3,7 +3,9 @@
# Copyright (C) 2018-2019 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import math, logging
+import logging
+import math
+
import chelper
BUZZ_DISTANCE = 1.0
diff --git a/klippy/extras/gcode_macro.py b/klippy/extras/gcode_macro.py
index ddcdc7c9..017f8dd0 100644
--- a/klippy/extras/gcode_macro.py
+++ b/klippy/extras/gcode_macro.py
@@ -3,9 +3,13 @@
# Copyright (C) 2018-2021 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import traceback, logging, ast, copy, json
-import jinja2
+import ast
+import copy
+import json
+import logging
+import traceback
+import jinja2
######################################################################
# Template handling
diff --git a/klippy/extras/heaters.py b/klippy/extras/heaters.py
index ce06955e..f188bd23 100644
--- a/klippy/extras/heaters.py
+++ b/klippy/extras/heaters.py
@@ -3,8 +3,9 @@
# Copyright (C) 2016-2025 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import os, logging, threading
-
+import logging
+import os
+import threading
######################################################################
# Heater
diff --git a/klippy/extras/homing.py b/klippy/extras/homing.py
index 0a2b1f32..a98478b8 100644
--- a/klippy/extras/homing.py
+++ b/klippy/extras/homing.py
@@ -3,7 +3,8 @@
# Copyright (C) 2016-2024 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import logging, math
+import logging
+import math
HOMING_START_DELAY = 0.001
ENDSTOP_SAMPLE_TIME = 0.000015
diff --git a/klippy/extras/htu21d.py b/klippy/extras/htu21d.py
index d7104503..cf3b4c4a 100644
--- a/klippy/extras/htu21d.py
+++ b/klippy/extras/htu21d.py
@@ -4,6 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
from . import bus
######################################################################
diff --git a/klippy/extras/hx71x.py b/klippy/extras/hx71x.py
index ad3134f8..5c25689a 100644
--- a/klippy/extras/hx71x.py
+++ b/klippy/extras/hx71x.py
@@ -4,6 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
from . import bulk_sensor
#
diff --git a/klippy/extras/icm20948.py b/klippy/extras/icm20948.py
index c99224fa..5b1b137d 100644
--- a/klippy/extras/icm20948.py
+++ b/klippy/extras/icm20948.py
@@ -10,7 +10,8 @@
# 2016/06/DS-000189-ICM-20948-v1.3.pdf
import logging
-from . import bus, adxl345, bulk_sensor
+
+from . import adxl345, bulk_sensor, bus
ICM20948_ADDR = 0x68
diff --git a/klippy/extras/input_shaper.py b/klippy/extras/input_shaper.py
index 70a68fd1..90c168e5 100644
--- a/klippy/extras/input_shaper.py
+++ b/klippy/extras/input_shaper.py
@@ -5,7 +5,9 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import collections
+
import chelper
+
from . import shaper_defs
diff --git a/klippy/extras/ldc1612.py b/klippy/extras/ldc1612.py
index 1bec5c35..74330a02 100644
--- a/klippy/extras/ldc1612.py
+++ b/klippy/extras/ldc1612.py
@@ -4,7 +4,8 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
-from . import bus, bulk_sensor
+
+from . import bulk_sensor, bus
MIN_MSG_TIME = 0.100
diff --git a/klippy/extras/led.py b/klippy/extras/led.py
index b22ddf72..e1fe149e 100644
--- a/klippy/extras/led.py
+++ b/klippy/extras/led.py
@@ -4,6 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
from . import output_pin
diff --git a/klippy/extras/lis2dw.py b/klippy/extras/lis2dw.py
index a0d582bb..1a5506fd 100644
--- a/klippy/extras/lis2dw.py
+++ b/klippy/extras/lis2dw.py
@@ -5,7 +5,8 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
-from . import bus, adxl345, bulk_sensor
+
+from . import adxl345, bulk_sensor, bus
# LIS2DW registers
REG_LIS2DW_WHO_AM_I_ADDR = 0x0F
diff --git a/klippy/extras/lm75.py b/klippy/extras/lm75.py
index 10fbcb9f..444e650b 100644
--- a/klippy/extras/lm75.py
+++ b/klippy/extras/lm75.py
@@ -4,6 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
from . import bus
LM75_CHIP_ADDR = 0x48
diff --git a/klippy/extras/load_cell.py b/klippy/extras/load_cell.py
index 3481c06e..9b13cecd 100644
--- a/klippy/extras/load_cell.py
+++ b/klippy/extras/load_cell.py
@@ -4,10 +4,11 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-from . import hx71x
-from . import ads1220
+import collections
+import itertools
+
+from . import ads1220, hx71x
from .bulk_sensor import BatchWebhooksClient
-import collections, itertools
# We want either Python 3's zip() or Python 2's izip() but NOT 2's zip():
zip_impl = zip
diff --git a/klippy/extras/load_cell_probe.py b/klippy/extras/load_cell_probe.py
index de54792f..6407ccbf 100644
--- a/klippy/extras/load_cell_probe.py
+++ b/klippy/extras/load_cell_probe.py
@@ -3,9 +3,12 @@
# Copyright (C) 2025 Gareth Farrington <gareth@waves.ky>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import logging, math
+import logging
+import math
+
import mcu
-from . import probe, sos_filter, load_cell, hx71x, ads1220
+
+from . import ads1220, hx71x, load_cell, probe, sos_filter
np = None # delay NumPy import until configuration time
diff --git a/klippy/extras/manual_probe.py b/klippy/extras/manual_probe.py
index 176a97e5..48acf4f1 100644
--- a/klippy/extras/manual_probe.py
+++ b/klippy/extras/manual_probe.py
@@ -3,7 +3,8 @@
# Copyright (C) 2019 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import logging, bisect
+import bisect
+import logging
# Helper to lookup the Z stepper config section
diff --git a/klippy/extras/manual_stepper.py b/klippy/extras/manual_stepper.py
index eeba2e93..c4da3265 100644
--- a/klippy/extras/manual_stepper.py
+++ b/klippy/extras/manual_stepper.py
@@ -4,7 +4,10 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
-import stepper, chelper
+
+import chelper
+import stepper
+
from . import force_move
diff --git a/klippy/extras/motion_report.py b/klippy/extras/motion_report.py
index 4b4debcb..8819a12b 100644
--- a/klippy/extras/motion_report.py
+++ b/klippy/extras/motion_report.py
@@ -4,7 +4,9 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
import chelper
+
from . import bulk_sensor
diff --git a/klippy/extras/mpu9250.py b/klippy/extras/mpu9250.py
index 189f1f98..15103b9f 100644
--- a/klippy/extras/mpu9250.py
+++ b/klippy/extras/mpu9250.py
@@ -5,7 +5,8 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
-from . import bus, adxl345, bulk_sensor
+
+from . import adxl345, bulk_sensor, bus
MPU9250_ADDR = 0x68
diff --git a/klippy/extras/neopixel.py b/klippy/extras/neopixel.py
index 1bed21b4..eccec556 100644
--- a/klippy/extras/neopixel.py
+++ b/klippy/extras/neopixel.py
@@ -4,6 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
from . import led
BACKGROUND_PRIORITY_CLOCK = 0x7FFFFFFF00000000
diff --git a/klippy/extras/output_pin.py b/klippy/extras/output_pin.py
index 85a9e91c..2b3592a7 100644
--- a/klippy/extras/output_pin.py
+++ b/klippy/extras/output_pin.py
@@ -3,9 +3,10 @@
# Copyright (C) 2017-2025 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import logging, ast
-from .display import display
+import ast
+import logging
+from .display import display
######################################################################
# G-Code request queuing helper
diff --git a/klippy/extras/palette2.py b/klippy/extras/palette2.py
index 1679eec3..c0026886 100644
--- a/klippy/extras/palette2.py
+++ b/klippy/extras/palette2.py
@@ -6,14 +6,14 @@
import logging
import os
-import serial
+import serial
from serial import SerialException
try:
- from queue import Queue, Empty
+ from queue import Empty, Queue
except ImportError:
- from Queue import Queue, Empty
+ from Queue import Empty, Queue
COMMAND_HEARTBEAT = "O99"
COMMAND_CUT = "O10 D5"
diff --git a/klippy/extras/pca9533.py b/klippy/extras/pca9533.py
index c56ff71c..9048507d 100644
--- a/klippy/extras/pca9533.py
+++ b/klippy/extras/pca9533.py
@@ -4,6 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
from . import bus, led
BACKGROUND_PRIORITY_CLOCK = 0x7FFFFFFF00000000
diff --git a/klippy/extras/pid_calibrate.py b/klippy/extras/pid_calibrate.py
index a29f0b71..faf867e5 100644
--- a/klippy/extras/pid_calibrate.py
+++ b/klippy/extras/pid_calibrate.py
@@ -3,7 +3,9 @@
# Copyright (C) 2016-2018 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import math, logging
+import logging
+import math
+
from . import heaters
diff --git a/klippy/extras/probe.py b/klippy/extras/probe.py
index 3811f883..88b8ebe6 100644
--- a/klippy/extras/probe.py
+++ b/klippy/extras/probe.py
@@ -4,7 +4,9 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
import pins
+
from . import manual_probe
HINT_TIMEOUT = """
diff --git a/klippy/extras/probe_eddy_current.py b/klippy/extras/probe_eddy_current.py
index 529b097c..256f9d3a 100644
--- a/klippy/extras/probe_eddy_current.py
+++ b/klippy/extras/probe_eddy_current.py
@@ -3,9 +3,13 @@
# Copyright (C) 2021-2024 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import logging, math, bisect
+import bisect
+import logging
+import math
+
import mcu
-from . import ldc1612, probe, manual_probe
+
+from . import ldc1612, manual_probe, probe
OUT_OF_RANGE = 99.9
diff --git a/klippy/extras/quad_gantry_level.py b/klippy/extras/quad_gantry_level.py
index 4dbdc47e..5bbb356f 100644
--- a/klippy/extras/quad_gantry_level.py
+++ b/klippy/extras/quad_gantry_level.py
@@ -4,6 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
from . import probe, z_tilt
# Leveling code for XY rails that are controlled by Z steppers as in:
diff --git a/klippy/extras/replicape.py b/klippy/extras/replicape.py
index 8f62a959..cad70036 100644
--- a/klippy/extras/replicape.py
+++ b/klippy/extras/replicape.py
@@ -3,8 +3,12 @@
# Copyright (C) 2017-2019 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import logging, os
-import pins, mcu
+import logging
+import os
+
+import mcu
+import pins
+
from . import bus
REPLICAPE_MAX_CURRENT = 3.84
diff --git a/klippy/extras/resonance_tester.py b/klippy/extras/resonance_tester.py
index 85dac5ee..4d5f8b65 100644
--- a/klippy/extras/resonance_tester.py
+++ b/klippy/extras/resonance_tester.py
@@ -3,7 +3,11 @@
# Copyright (C) 2020-2024 Dmitry Butyugin <dmbutyugin@google.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import logging, math, os, time
+import logging
+import math
+import os
+import time
+
from . import shaper_calibrate
diff --git a/klippy/extras/save_variables.py b/klippy/extras/save_variables.py
index 043f1c6d..f949e58f 100644
--- a/klippy/extras/save_variables.py
+++ b/klippy/extras/save_variables.py
@@ -4,7 +4,10 @@
# Copyright (C) 2016-2020 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import os, logging, ast, configparser
+import ast
+import configparser
+import logging
+import os
class SaveVariables:
diff --git a/klippy/extras/screws_tilt_adjust.py b/klippy/extras/screws_tilt_adjust.py
index 6dacde87..f98dd75d 100644
--- a/klippy/extras/screws_tilt_adjust.py
+++ b/klippy/extras/screws_tilt_adjust.py
@@ -5,6 +5,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import math
+
from . import probe
diff --git a/klippy/extras/shaper_calibrate.py b/klippy/extras/shaper_calibrate.py
index 117409aa..5b440426 100644
--- a/klippy/extras/shaper_calibrate.py
+++ b/klippy/extras/shaper_calibrate.py
@@ -3,7 +3,12 @@
# Copyright (C) 2020-2024 Dmitry Butyugin <dmbutyugin@google.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import collections, importlib, logging, math, multiprocessing, traceback
+import collections
+import importlib
+import logging
+import math
+import multiprocessing
+import traceback
shaper_defs = importlib.import_module(".shaper_defs", "extras")
diff --git a/klippy/extras/shaper_defs.py b/klippy/extras/shaper_defs.py
index 1cd7aeed..080e21ea 100644
--- a/klippy/extras/shaper_defs.py
+++ b/klippy/extras/shaper_defs.py
@@ -3,7 +3,8 @@
# Copyright (C) 2020-2021 Dmitry Butyugin <dmbutyugin@google.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import collections, math
+import collections
+import math
SHAPER_VIBRATION_REDUCTION = 20.0
DEFAULT_DAMPING_RATIO = 0.1
diff --git a/klippy/extras/sht3x.py b/klippy/extras/sht3x.py
index d6acd987..030737da 100644
--- a/klippy/extras/sht3x.py
+++ b/klippy/extras/sht3x.py
@@ -5,6 +5,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
from . import bus
######################################################################
diff --git a/klippy/extras/smart_effector.py b/klippy/extras/smart_effector.py
index 2ddee5e9..3886dea7 100644
--- a/klippy/extras/smart_effector.py
+++ b/klippy/extras/smart_effector.py
@@ -5,6 +5,7 @@
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
from . import probe
# SmartEffector communication protocol implemented here originates from
diff --git a/klippy/extras/spi_temperature.py b/klippy/extras/spi_temperature.py
index 38d6b559..31b1f39c 100644
--- a/klippy/extras/spi_temperature.py
+++ b/klippy/extras/spi_temperature.py
@@ -4,9 +4,10 @@
# Copyright (C) 2018 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import math, logging
-from . import bus
+import logging
+import math
+from . import bus
######################################################################
# SensorBase
diff --git a/klippy/extras/statistics.py b/klippy/extras/statistics.py
index de7302e7..c4243618 100644
--- a/klippy/extras/statistics.py
+++ b/klippy/extras/statistics.py
@@ -3,7 +3,9 @@
# Copyright (C) 2018-2021 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import os, time, logging
+import logging
+import os
+import time
class PrinterSysStats:
diff --git a/klippy/extras/sx1509.py b/klippy/extras/sx1509.py
index 22a6c6a7..358ba8a2 100644
--- a/klippy/extras/sx1509.py
+++ b/klippy/extras/sx1509.py
@@ -4,6 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import pins
+
from . import bus
# Word registers
diff --git a/klippy/extras/temperature_mcu.py b/klippy/extras/temperature_mcu.py
index 1b4d983a..c79f16f8 100644
--- a/klippy/extras/temperature_mcu.py
+++ b/klippy/extras/temperature_mcu.py
@@ -4,7 +4,9 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
import mcu
+
from . import adc_temperature
SAMPLE_TIME = 0.001
diff --git a/klippy/extras/temperature_probe.py b/klippy/extras/temperature_probe.py
index 1d5327d7..e54f259f 100644
--- a/klippy/extras/temperature_probe.py
+++ b/klippy/extras/temperature_probe.py
@@ -4,6 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
from . import manual_probe
KELVIN_TO_CELSIUS = -273.15
diff --git a/klippy/extras/thermistor.py b/klippy/extras/thermistor.py
index db1288e5..cb9f639e 100644
--- a/klippy/extras/thermistor.py
+++ b/klippy/extras/thermistor.py
@@ -3,7 +3,9 @@
# Copyright (C) 2016-2019 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import math, logging
+import logging
+import math
+
from . import adc_temperature
KELVIN_TO_CELSIUS = -273.15
diff --git a/klippy/extras/tmc.py b/klippy/extras/tmc.py
index 4a7bcc9c..15d7fe0d 100644
--- a/klippy/extras/tmc.py
+++ b/klippy/extras/tmc.py
@@ -3,10 +3,12 @@
# Copyright (C) 2018-2020 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import logging, collections
+import collections
+import logging
+
import stepper
-from . import bulk_sensor
+from . import bulk_sensor
######################################################################
# Field helpers
diff --git a/klippy/extras/tmc2130.py b/klippy/extras/tmc2130.py
index 88c7fcf4..fbe0a969 100644
--- a/klippy/extras/tmc2130.py
+++ b/klippy/extras/tmc2130.py
@@ -3,7 +3,9 @@
# Copyright (C) 2018-2019 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import math, logging
+import logging
+import math
+
from . import bus, tmc
TMC_FREQUENCY = 13200000.0
diff --git a/klippy/extras/tmc2208.py b/klippy/extras/tmc2208.py
index fcf057ce..488b0b7f 100644
--- a/klippy/extras/tmc2208.py
+++ b/klippy/extras/tmc2208.py
@@ -4,7 +4,8 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
-from . import tmc, tmc_uart, tmc2130
+
+from . import tmc, tmc2130, tmc_uart
TMC_FREQUENCY = 12000000.0
diff --git a/klippy/extras/tmc2209.py b/klippy/extras/tmc2209.py
index 5fc3ae17..62cf4f74 100644
--- a/klippy/extras/tmc2209.py
+++ b/klippy/extras/tmc2209.py
@@ -3,7 +3,7 @@
# Copyright (C) 2019 Stephan Oelze <stephan.oelze@gmail.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-from . import tmc2208, tmc2130, tmc, tmc_uart
+from . import tmc, tmc2130, tmc2208, tmc_uart
TMC_FREQUENCY = 12000000.0
diff --git a/klippy/extras/tmc2240.py b/klippy/extras/tmc2240.py
index b6d13935..01163795 100644
--- a/klippy/extras/tmc2240.py
+++ b/klippy/extras/tmc2240.py
@@ -4,7 +4,9 @@
# Copyright (C) 2023 Alex Voinea <voinea.dragos.alexandru@gmail.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import math, logging
+import logging
+import math
+
from . import bus, tmc, tmc2130, tmc_uart
TMC_FREQUENCY = 12500000.0
diff --git a/klippy/extras/tmc2660.py b/klippy/extras/tmc2660.py
index 03b8c12c..8c6887ab 100644
--- a/klippy/extras/tmc2660.py
+++ b/klippy/extras/tmc2660.py
@@ -4,7 +4,9 @@
# Copyright (C) 2019-2021 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import math, logging
+import logging
+import math
+
from . import bus, tmc, tmc2130
Registers = {
diff --git a/klippy/extras/tmc5160.py b/klippy/extras/tmc5160.py
index 42161d8a..278f9cb2 100644
--- a/klippy/extras/tmc5160.py
+++ b/klippy/extras/tmc5160.py
@@ -3,7 +3,9 @@
# Copyright (C) 2018-2019 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import math, logging
+import logging
+import math
+
from . import bus, tmc, tmc2130
TMC_FREQUENCY = 12000000.0
diff --git a/klippy/extras/tmc_uart.py b/klippy/extras/tmc_uart.py
index 141b8965..541fabdc 100644
--- a/klippy/extras/tmc_uart.py
+++ b/klippy/extras/tmc_uart.py
@@ -5,7 +5,6 @@
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
-
######################################################################
# TMC uart analog mux support
######################################################################
diff --git a/klippy/extras/tuning_tower.py b/klippy/extras/tuning_tower.py
index 7d54cbb5..d15d7d1d 100644
--- a/klippy/extras/tuning_tower.py
+++ b/klippy/extras/tuning_tower.py
@@ -3,7 +3,8 @@
# Copyright (C) 2019 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import math, logging
+import logging
+import math
CANCEL_Z_DELTA = 2.0
diff --git a/klippy/extras/virtual_sdcard.py b/klippy/extras/virtual_sdcard.py
index 85dd3616..0d54d244 100644
--- a/klippy/extras/virtual_sdcard.py
+++ b/klippy/extras/virtual_sdcard.py
@@ -3,7 +3,9 @@
# Copyright (C) 2018-2024 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import os, logging, io
+import io
+import logging
+import os
VALID_GCODE_EXTS = ["gcode", "g", "gco"]
diff --git a/klippy/extras/z_tilt.py b/klippy/extras/z_tilt.py
index f000370c..14b39fb8 100644
--- a/klippy/extras/z_tilt.py
+++ b/klippy/extras/z_tilt.py
@@ -4,7 +4,9 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
import mathutil
+
from . import probe
diff --git a/klippy/gcode.py b/klippy/gcode.py
index 523a39c5..5781e9fb 100644
--- a/klippy/gcode.py
+++ b/klippy/gcode.py
@@ -3,7 +3,11 @@
# Copyright (C) 2016-2024 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import os, re, logging, collections, shlex
+import collections
+import logging
+import os
+import re
+import shlex
class CommandError(Exception):
diff --git a/klippy/kinematics/cartesian.py b/klippy/kinematics/cartesian.py
index 4d21c6e1..2d83e6e0 100644
--- a/klippy/kinematics/cartesian.py
+++ b/klippy/kinematics/cartesian.py
@@ -4,7 +4,9 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
import stepper
+
from . import idex_modes
diff --git a/klippy/kinematics/corexy.py b/klippy/kinematics/corexy.py
index a571b2f6..257dd72c 100644
--- a/klippy/kinematics/corexy.py
+++ b/klippy/kinematics/corexy.py
@@ -3,7 +3,9 @@
# Copyright (C) 2017-2021 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import logging, math
+import logging
+import math
+
import stepper
diff --git a/klippy/kinematics/corexz.py b/klippy/kinematics/corexz.py
index b75e00c0..94b12fef 100644
--- a/klippy/kinematics/corexz.py
+++ b/klippy/kinematics/corexz.py
@@ -3,7 +3,9 @@
# Copyright (C) 2020 Maks Zolin <mzolin@vorondesign.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import logging, math
+import logging
+import math
+
import stepper
diff --git a/klippy/kinematics/delta.py b/klippy/kinematics/delta.py
index 508a3331..5ce1841b 100644
--- a/klippy/kinematics/delta.py
+++ b/klippy/kinematics/delta.py
@@ -3,8 +3,11 @@
# Copyright (C) 2016-2021 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import math, logging
-import stepper, mathutil
+import logging
+import math
+
+import mathutil
+import stepper
# Slow moves once the ratio of tower to XY movement exceeds SLOW_RATIO
SLOW_RATIO = 3.0
diff --git a/klippy/kinematics/deltesian.py b/klippy/kinematics/deltesian.py
index c2aec720..94e2baa7 100644
--- a/klippy/kinematics/deltesian.py
+++ b/klippy/kinematics/deltesian.py
@@ -3,7 +3,9 @@
# Copyright (C) 2022 Fabrice Gallet <tircown@gmail.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import math, logging
+import logging
+import math
+
import stepper
# Slow moves once the ratio of tower to XY movement exceeds SLOW_RATIO
diff --git a/klippy/kinematics/extruder.py b/klippy/kinematics/extruder.py
index ae1604db..6b9e0712 100644
--- a/klippy/kinematics/extruder.py
+++ b/klippy/kinematics/extruder.py
@@ -3,8 +3,11 @@
# Copyright (C) 2016-2025 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import math, logging
-import stepper, chelper
+import logging
+import math
+
+import chelper
+import stepper
class ExtruderStepper:
diff --git a/klippy/kinematics/generic_cartesian.py b/klippy/kinematics/generic_cartesian.py
index a76e4a21..24cf6dcc 100644
--- a/klippy/kinematics/generic_cartesian.py
+++ b/klippy/kinematics/generic_cartesian.py
@@ -4,8 +4,15 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import copy, itertools, logging, math
-import gcode, mathutil, stepper
+import copy
+import itertools
+import logging
+import math
+
+import gcode
+import mathutil
+import stepper
+
from . import idex_modes
from . import kinematic_stepper as ks
diff --git a/klippy/kinematics/hybrid_corexy.py b/klippy/kinematics/hybrid_corexy.py
index 2562ba33..6a125928 100644
--- a/klippy/kinematics/hybrid_corexy.py
+++ b/klippy/kinematics/hybrid_corexy.py
@@ -4,7 +4,9 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
import stepper
+
from . import idex_modes
diff --git a/klippy/kinematics/hybrid_corexz.py b/klippy/kinematics/hybrid_corexz.py
index 6c3ae57d..79d31c36 100644
--- a/klippy/kinematics/hybrid_corexz.py
+++ b/klippy/kinematics/hybrid_corexz.py
@@ -4,7 +4,9 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+
import stepper
+
from . import idex_modes
diff --git a/klippy/kinematics/idex_modes.py b/klippy/kinematics/idex_modes.py
index 5910d5c0..6ff470c5 100644
--- a/klippy/kinematics/idex_modes.py
+++ b/klippy/kinematics/idex_modes.py
@@ -4,7 +4,10 @@
# Copyright (C) 2023-2025 Dmitry Butyugin <dmbutyugin@google.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import collections, logging, math
+import collections
+import logging
+import math
+
import chelper
INACTIVE = "INACTIVE"
diff --git a/klippy/kinematics/kinematic_stepper.py b/klippy/kinematics/kinematic_stepper.py
index 7d983ed1..bdf9641c 100644
--- a/klippy/kinematics/kinematic_stepper.py
+++ b/klippy/kinematics/kinematic_stepper.py
@@ -4,8 +4,11 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import logging, re
-import stepper, chelper
+import logging
+import re
+
+import chelper
+import stepper
def parse_carriages_string(carriages_str, printer_carriages, parse_error):
diff --git a/klippy/kinematics/polar.py b/klippy/kinematics/polar.py
index cd480a42..1ddec527 100644
--- a/klippy/kinematics/polar.py
+++ b/klippy/kinematics/polar.py
@@ -3,7 +3,9 @@
# Copyright (C) 2018-2021 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import logging, math
+import logging
+import math
+
import stepper
diff --git a/klippy/kinematics/rotary_delta.py b/klippy/kinematics/rotary_delta.py
index 7bc3a4d8..ac22c5e5 100644
--- a/klippy/kinematics/rotary_delta.py
+++ b/klippy/kinematics/rotary_delta.py
@@ -3,8 +3,12 @@
# Copyright (C) 2019-2021 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import math, logging
-import stepper, mathutil, chelper
+import logging
+import math
+
+import chelper
+import mathutil
+import stepper
class RotaryDeltaKinematics:
diff --git a/klippy/kinematics/winch.py b/klippy/kinematics/winch.py
index 290a7f27..6a67d8c4 100644
--- a/klippy/kinematics/winch.py
+++ b/klippy/kinematics/winch.py
@@ -3,7 +3,8 @@
# Copyright (C) 2018-2021 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import stepper, mathutil
+import mathutil
+import stepper
class WinchKinematics:
diff --git a/klippy/klippy.py b/klippy/klippy.py
index 7a875c28..7931bb10 100644
--- a/klippy/klippy.py
+++ b/klippy/klippy.py
@@ -4,9 +4,25 @@
# Copyright (C) 2016-2024 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import sys, os, gc, optparse, logging, time, collections, importlib
-import util, reactor, queuelogger, msgproto
-import gcode, configfile, pins, mcu, toolhead, webhooks
+import collections
+import gc
+import importlib
+import logging
+import optparse
+import os
+import sys
+import time
+
+import configfile
+import gcode
+import mcu
+import msgproto
+import pins
+import queuelogger
+import reactor
+import toolhead
+import util
+import webhooks
__version__ = "0.1.0-rc1"
diff --git a/klippy/mathutil.py b/klippy/mathutil.py
index 6de89c64..d413591b 100644
--- a/klippy/mathutil.py
+++ b/klippy/mathutil.py
@@ -3,9 +3,12 @@
# Copyright (C) 2018-2019 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import math, logging, multiprocessing, traceback
-import queuelogger
+import logging
+import math
+import multiprocessing
+import traceback
+import queuelogger
######################################################################
# Coordinate descent
diff --git a/klippy/mcu.py b/klippy/mcu.py
index 635128f4..8195c390 100644
--- a/klippy/mcu.py
+++ b/klippy/mcu.py
@@ -3,8 +3,17 @@
# Copyright (C) 2016-2025 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import sys, os, zlib, logging, math
-import serialhdl, msgproto, pins, chelper, clocksync
+import logging
+import math
+import os
+import sys
+import zlib
+
+import chelper
+import clocksync
+import msgproto
+import pins
+import serialhdl
class error(Exception):
diff --git a/klippy/msgproto.py b/klippy/msgproto.py
index a2151a68..5313fad6 100644
--- a/klippy/msgproto.py
+++ b/klippy/msgproto.py
@@ -3,7 +3,9 @@
# Copyright (C) 2016-2024 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import json, zlib, logging
+import json
+import logging
+import zlib
DefaultMessages = {
"identify_response offset=%u data=%.*s": 0,
diff --git a/klippy/parsedump.py b/klippy/parsedump.py
index 93d8d14e..6c4e0871 100755
--- a/klippy/parsedump.py
+++ b/klippy/parsedump.py
@@ -4,7 +4,10 @@
# Copyright (C) 2016 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import os, sys, logging
+import logging
+import os
+import sys
+
import msgproto
diff --git a/klippy/queuelogger.py b/klippy/queuelogger.py
index 2792d513..b8640527 100644
--- a/klippy/queuelogger.py
+++ b/klippy/queuelogger.py
@@ -3,7 +3,11 @@
# Copyright (C) 2016-2019 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import logging, logging.handlers, threading, queue, time
+import logging
+import logging.handlers
+import queue
+import threading
+import time
# Class to forward all messages through a queue to a background thread
@@ -22,6 +26,7 @@ class QueueHandler(logging.Handler):
except Exception:
self.handleError(record)
+
# Class to poll a queue in a background thread and log each message
class QueueListener(logging.StreamHandler):
def __init__(self):
diff --git a/klippy/reactor.py b/klippy/reactor.py
index c5979b40..2f76c89a 100644
--- a/klippy/reactor.py
+++ b/klippy/reactor.py
@@ -3,9 +3,17 @@
# Copyright (C) 2016-2020 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import os, gc, select, math, time, logging, queue
+import gc
+import logging
+import math
+import os
+import queue
+import select
+import time
+
+import chelper
import greenlet
-import chelper, util
+import util
_NOW = 0.0
_NEVER = 9999999999999999.0
diff --git a/klippy/serialhdl.py b/klippy/serialhdl.py
index 97169373..821d0a84 100644
--- a/klippy/serialhdl.py
+++ b/klippy/serialhdl.py
@@ -3,10 +3,14 @@
# Copyright (C) 2016-2021 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import logging, threading, os
-import serial
+import logging
+import os
+import threading
-import msgproto, chelper, util
+import chelper
+import msgproto
+import serial
+import util
class error(Exception):
diff --git a/klippy/stepper.py b/klippy/stepper.py
index 09b1b9e1..c340a44e 100644
--- a/klippy/stepper.py
+++ b/klippy/stepper.py
@@ -3,7 +3,10 @@
# Copyright (C) 2016-2025 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import math, logging, collections
+import collections
+import logging
+import math
+
import chelper
diff --git a/klippy/toolhead.py b/klippy/toolhead.py
index c0693d6f..bbdc930c 100644
--- a/klippy/toolhead.py
+++ b/klippy/toolhead.py
@@ -3,8 +3,13 @@
# Copyright (C) 2016-2025 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import math, logging, importlib
-import mcu, chelper, kinematics.extruder
+import importlib
+import logging
+import math
+
+import chelper
+import kinematics.extruder
+import mcu
# Common suffixes: _d is distance (in mm), _v is velocity (in
# mm/second), _v2 is velocity squared (mm^2/s^2), _t is time (in
diff --git a/klippy/util.py b/klippy/util.py
index 687c1435..c55c7995 100644
--- a/klippy/util.py
+++ b/klippy/util.py
@@ -3,10 +3,14 @@
# Copyright (C) 2016-2020 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import os, pty, fcntl, termios, signal, logging
+import fcntl
+import logging
+import os
+import pty
+import signal
+import termios
import traceback
-
######################################################################
# Low-level Unix commands
######################################################################
diff --git a/klippy/webhooks.py b/klippy/webhooks.py
index 21181e45..5902c4ef 100644
--- a/klippy/webhooks.py
+++ b/klippy/webhooks.py
@@ -3,7 +3,13 @@
# Copyright (C) 2020 Eric Callahan <arksine.code@gmail.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license
-import logging, socket, os, sys, errno, collections
+import collections
+import errno
+import logging
+import os
+import socket
+import sys
+
import gcode
try: