Skip to content

Commit

Permalink
Enforce usage of isort
Browse files Browse the repository at this point in the history
Update the configuration for isort.

Enforce usage of isort via a pre-commit hook.
  • Loading branch information
fabcor-maxiv committed Oct 22, 2024
1 parent e646fb2 commit 9fdbcb5
Show file tree
Hide file tree
Showing 485 changed files with 2,358 additions and 1,716 deletions.
13 changes: 3 additions & 10 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
[settings]
; see https://github.com/psf/black
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
combine_as_imports=True
use_parentheses=True
line_length=88
sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
default_section=THIRDPARTY
ensure_newline_before_comments = True
profile=black
py_version=38
force_grid_wrap=2
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ repos:
- --remove-duplicate-keys
- --ignore-pass-after-docstring

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 24.8.0 # The following version (`24.10.0`) dropped support for Python 3.8.
hooks:
Expand Down
5 changes: 3 additions & 2 deletions deprecated/Command/Exporter/MDClient.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import sys
import time
import string
import sys
import threading
import time

from Command.exporter.ExporterClient import *

SERVER_ADDRESS = "localhost"
Expand Down
12 changes: 8 additions & 4 deletions deprecated/HardwareObjects/Camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
</object>
"""

from mxcubecore import BaseHardwareObjects
from mxcubecore import CommandContainer
import gevent
import logging
import os
import time
import sys
import time

import gevent

from mxcubecore import (
BaseHardwareObjects,
CommandContainer,
)

try:
from Qub.CTools.qttools import BgrImageMmap
Expand Down
6 changes: 3 additions & 3 deletions deprecated/HardwareObjects/EnhancedPopen.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import errno
import fcntl
import os
import select
import subprocess
import errno
import time
import select
import fcntl

PIPE = subprocess.PIPE

Expand Down
4 changes: 2 additions & 2 deletions deprecated/HardwareObjects/NamedState.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
# You should have received a copy of the GNU Lesser General Public License
# along with MXCuBE. If not, see <http://www.gnu.org/licenses/>.

import logging

from mxcubecore import HardwareRepository as HWR
from mxcubecore.BaseHardwareObjects import HardwareObject

import logging


class NamedState(HardwareObject):
def __init__(self, name):
Expand Down
2 changes: 1 addition & 1 deletion deprecated/HardwareObjects/Server/Daemonize.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
import os
import sys

"""This module is used to fork the current process into a daemon.
Almost none of this is necessary (or advisable) if your daemon
Expand Down
10 changes: 6 additions & 4 deletions deprecated/HardwareObjects/Server/SimpleXMLReadWriteSupport.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import sys
import io
import sys
from xml.sax import (
SAXParseException,
make_parser,
)
from xml.sax.handler import ContentHandler
from xml.sax.saxutils import XMLGenerator
from xml.sax import make_parser
from xml.sax import SAXParseException
from xml.sax.xmlreader import AttributesImpl
from xml.sax.handler import ContentHandler

_parser = make_parser()

Expand Down
6 changes: 4 additions & 2 deletions deprecated/HardwareObjects/Server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
from xml.sax import SAXParseException
from xml.sax.handler import ContentHandler

from SpecClient_gevent import SpecServer
from SpecClient_gevent import SpecMessage
import Daemonize
import SimpleXMLReadWriteSupport
from SpecClient_gevent import (
SpecMessage,
SpecServer,
)


class XMLNodesWithRolesReadingHandler(ContentHandler):
Expand Down
3 changes: 2 additions & 1 deletion deprecated/HardwareObjects/SpecMotor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from mxcubecore.BaseHardwareObjects import HardwareObject
from SpecClient_gevent.SpecMotor import SpecMotorA

from mxcubecore.BaseHardwareObjects import HardwareObject


class SpecMotor(HardwareObject, SpecMotorA):
(NOTINITIALIZED, UNUSABLE, READY, MOVESTARTED, MOVING, ONLIMIT) = (0, 1, 2, 3, 4, 5)
Expand Down
3 changes: 2 additions & 1 deletion deprecated/HardwareObjects/SpecMotorWPositions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from mxcubecore.HardwareObjects import SpecMotor
import logging

from mxcubecore.HardwareObjects import SpecMotor


class SpecMotorWPositions(SpecMotor.SpecMotor):
def init(self):
Expand Down
6 changes: 4 additions & 2 deletions deprecated/HardwareObjects/SpecScan.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
try:
from SpecClient_gevent import SpecEventsDispatcher
from SpecClient_gevent import SpecConnectionsManager
from SpecClient_gevent import (
SpecConnectionsManager,
SpecEventsDispatcher,
)
except ImportError:
from SpecClient import SpecEventsDispatcher
from SpecClient import SpecConnectionsManager
Expand Down
1 change: 1 addition & 0 deletions deprecated/HardwareObjects/SpecShell.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""

import logging

from mxcubecore.BaseHardwareObjects import HardwareObject

try:
Expand Down
1 change: 1 addition & 0 deletions deprecated/HardwareObjects/SpecState.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""

import logging

from mxcubecore.BaseHardwareObjects import Procedure

try:
Expand Down
7 changes: 4 additions & 3 deletions deprecated/HardwareObjects/TacoDevice_MTSafe.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# $Id: TacoDevice_MTSafe.py,v 1.5 2004/11/15 12:39:19 guijarro Exp $
from Taco import *
from threading import RLock
import weakref
import types
import weakref
from threading import RLock

from Taco import *

_global_lock = RLock()

Expand Down
6 changes: 4 additions & 2 deletions deprecated/HardwareObjects/mockup/CameraMockup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
"""Class for cameras connected to framegrabbers run by Taco Device Servers
"""

from mxcubecore import BaseHardwareObjects
import logging
import os
import gevent
import time

import gevent
import numpy
from PIL import Image

from mxcubecore import BaseHardwareObjects

try:
from cStringIO import StringIO
except ImportError:
Expand Down
3 changes: 2 additions & 1 deletion deprecated/HardwareObjects/mockup/MachInfoMockup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@
values['topup_remaining']
"""

import gevent
import time

import gevent

from mxcubecore import HardwareRepository as HWR
from mxcubecore.BaseHardwareObjects import HardwareObject

Expand Down
10 changes: 6 additions & 4 deletions deprecated/HardwareObjects/mockup/MultiCollectMockup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import logging
import os
import time

import gevent

from mxcubecore.BaseHardwareObjects import HardwareObject
from mxcubecore.HardwareObjects.abstract.AbstractMultiCollect import (
AbstractMultiCollect,
)
from mxcubecore.TaskUtils import task
import logging
import time
import os
import gevent


class MultiCollectMockup(AbstractMultiCollect, HardwareObject):
Expand Down
10 changes: 6 additions & 4 deletions deprecated/HardwareObjects/mockup/Oxford700Mockup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# pylint: skip-file

from mxcubecore.BaseHardwareObjects import HardwareObject
from mxcubecore import HardwareRepository as HWR
import gevent
import sys
import random
import sys

import gevent

from mxcubecore import HardwareRepository as HWR
from mxcubecore.BaseHardwareObjects import HardwareObject

CRYO_STATUS = ["OFF", "SATURATED", "READY", "WARNING", "FROZEN", "UNKNOWN"]
PHASE_ACTION = {
Expand Down
2 changes: 2 additions & 0 deletions deprecated/HardwareObjects/mockup/VideoMockup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

import os
import time

import gevent
from gui.utils.qt_import import QImage

from mxcubecore import BaseHardwareObjects
from mxcubecore.HardwareObjects.Camera import JpegType

Expand Down
39 changes: 26 additions & 13 deletions mxcubecore/BaseHardwareObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,50 @@

from __future__ import absolute_import

import typing
import ast
import enum
from collections import OrderedDict
import logging
from gevent import event, Timeout
from pydantic.v1 import create_model, Field
import typing
import warnings

from collections import OrderedDict
from typing import (
TYPE_CHECKING,
Callable,
Iterator,
Union,
Any,
Callable,
Dict,
Generator,
Iterator,
List,
Dict,
Optional,
)
from typing import OrderedDict as TOrderedDict
from typing import (
Tuple,
Type,
Optional,
OrderedDict as TOrderedDict,
Union,
)

from gevent import (
Timeout,
event,
)
from pydantic.v1 import (
Field,
create_model,
)
from typing_extensions import (
Literal,
Self,
)
from typing_extensions import Self, Literal

from mxcubecore.dispatcher import dispatcher
from mxcubecore.CommandContainer import CommandContainer
from mxcubecore.dispatcher import dispatcher

if TYPE_CHECKING:
from logging import Logger

from pydantic.v1 import BaseModel

from .CommandContainer import CommandObject

__copyright__ = """ Copyright © 2010-2020 by the MXCuBE collaboration """
Expand Down
8 changes: 5 additions & 3 deletions mxcubecore/Command/Epics.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with MXCuBE. If not, see <http://www.gnu.org/licenses/>.

import logging
import copy
import logging
import time

try:
Expand All @@ -28,9 +28,11 @@
logging.getLogger("HWR").warning("EPICS support not available.")

from mxcubecore import Poller
from mxcubecore.CommandContainer import (
ChannelObject,
CommandObject,
)
from mxcubecore.dispatcher import saferef
from mxcubecore.CommandContainer import CommandObject, ChannelObject


__copyright__ = """ Copyright © 2010 - 2020 by MXCuBE Collaboration """
__license__ = "LGPLv3+"
Expand Down
8 changes: 7 additions & 1 deletion mxcubecore/Command/Exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@

# from warnings import warn
import logging

import gevent
from gevent.queue import Queue
from mxcubecore.CommandContainer import CommandObject, ChannelObject

from mxcubecore.CommandContainer import (
ChannelObject,
CommandObject,
)

from .exporter import ExporterClient
from .exporter.StandardClient import PROTOCOL

Expand Down
6 changes: 4 additions & 2 deletions mxcubecore/Command/Mockup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
# import queue


from mxcubecore.CommandContainer import CommandObject, ChannelObject

from mxcubecore.CommandContainer import (
ChannelObject,
CommandObject,
)

__copyright__ = """ Copyright © 2010 - 2020 by MXCuBE Collaboration """
__license__ = "LGPLv3+"
Expand Down
4 changes: 2 additions & 2 deletions mxcubecore/Command/Pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@

import logging
import weakref

import qt

try:
import Queue as queue
except ImportError:
import queue


from mxcubecore.CommandContainer import (
CommandObject,
ChannelObject,
CommandObject,
ConnectionError,
)

Expand Down
Loading

0 comments on commit 9fdbcb5

Please sign in to comment.