Skip to content

Commit

Permalink
Use isort (#720)
Browse files Browse the repository at this point in the history
* Use isort

* lint

* exclude generated files

* black
  • Loading branch information
skearnes authored Jun 1, 2024
1 parent 471b729 commit 50a0501
Show file tree
Hide file tree
Showing 34 changed files with 54 additions and 78 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ jobs:
- name: Run black
run: |
black --check .
- name: Run isort
run: |
isort --check .
- name: Run pylint
run: |
pylint -j 0 -v examples ord_schema *.py
Expand Down
2 changes: 1 addition & 1 deletion badges/reactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"""
import glob
import os
import requests

import docopt
import requests

from ord_schema import message_helpers
from ord_schema.logging import get_logger
Expand Down
2 changes: 1 addition & 1 deletion ord_schema/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"""Generic helpers for ord_schema, including common message types."""
from typing import Union

from google.protobuf import descriptor
import google.protobuf.message # pytype: disable=import-error
from google.protobuf import descriptor

from ord_schema.proto import reaction_pb2

Expand Down
6 changes: 2 additions & 4 deletions ord_schema/frozen_message_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@

import pytest

from ord_schema import frozen_message
from ord_schema import message_helpers
from ord_schema.proto import reaction_pb2
from ord_schema.proto import test_pb2
from ord_schema import frozen_message, message_helpers
from ord_schema.proto import reaction_pb2, test_pb2


def _freeze(message) -> frozen_message.FrozenMessage:
Expand Down
2 changes: 1 addition & 1 deletion ord_schema/macros/solutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"""Macros for programmatic message creation."""
from typing import Optional, Union

from ord_schema.proto import reaction_pb2
from ord_schema import units
from ord_schema.proto import reaction_pb2

UNITS_RESOLVER = units.UnitResolver()
CONCENTRATION_RESOLVER = units.UnitResolver(units.CONCENTRATION_UNIT_SYNONYMS, forbidden_units={})
Expand Down
4 changes: 2 additions & 2 deletions ord_schema/macros/solutions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import pytest
from google.protobuf import text_format

from ord_schema.proto import reaction_pb2
from ord_schema.macros import solutions
from ord_schema import validations
from ord_schema.macros import solutions
from ord_schema.proto import reaction_pb2


def test_simple_solution():
Expand Down
2 changes: 1 addition & 1 deletion ord_schema/macros/workups.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
"""
from collections.abc import Iterable

from ord_schema.proto import reaction_pb2
from ord_schema import units
from ord_schema.proto import reaction_pb2

UNITS_RESOLVER = units.UnitResolver()
CONCENTRATION_RESOLVER = units.UnitResolver(units.CONCENTRATION_UNIT_SYNONYMS)
Expand Down
5 changes: 2 additions & 3 deletions ord_schema/message_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,15 @@
import pandas as pd
import requests
from google import protobuf # pytype: disable=import-error
from google.protobuf import json_format
from google.protobuf import text_format # pytype: disable=import-error
from google.protobuf import json_format
from rdkit import Chem
from rdkit.Chem import rdChemReactions
from werkzeug import security

import ord_schema
from ord_schema import units
from ord_schema.proto import dataset_pb2
from ord_schema.proto import reaction_pb2
from ord_schema.proto import dataset_pb2, reaction_pb2

_COMPOUND_IDENTIFIER_LOADERS = {
reaction_pb2.CompoundIdentifier.SMILES: Chem.MolFromSmiles,
Expand Down
6 changes: 2 additions & 4 deletions ord_schema/message_helpers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@

import pandas as pd
import pytest
from google.protobuf import json_format
from google.protobuf import text_format
from google.protobuf import json_format, text_format
from rdkit import Chem

from ord_schema import message_helpers
from ord_schema.proto import reaction_pb2
from ord_schema.proto import test_pb2
from ord_schema.proto import reaction_pb2, test_pb2

_BENZENE_MOLBLOCK = """241
-OEChem-07232015262D
Expand Down
4 changes: 2 additions & 2 deletions ord_schema/orm/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
# limitations under the License.

"""Functions for creating/managing the PostgreSQL database."""
import time
import os
import time
from unittest.mock import patch

from sqlalchemy import cast, delete, func, select, text, update
from sqlalchemy.dialects.postgresql import insert
from sqlalchemy.engine import Engine
from sqlalchemy.exc import OperationalError, NotSupportedError
from sqlalchemy.exc import NotSupportedError, OperationalError
from sqlalchemy.orm import Session

from ord_schema.logging import get_logger
Expand Down
6 changes: 2 additions & 4 deletions ord_schema/orm/mappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,15 @@
from google.protobuf.descriptor import Descriptor, FieldDescriptor
from google.protobuf.message import Message
from inflection import underscore
from sqlalchemy import Boolean, Column, Enum, Float, Integer, ForeignKey, LargeBinary, String, Text
from sqlalchemy import Boolean, Column, Enum, Float, ForeignKey, Integer, LargeBinary, String, Text
from sqlalchemy.dialects.postgresql import ARRAY
from sqlalchemy.orm import relationship

import ord_schema.orm.rdkit_mappers # pylint: disable=unused-import
from ord_schema import message_helpers
from ord_schema.logging import get_logger
from ord_schema.orm import Base
from ord_schema.proto import dataset_pb2
from ord_schema.proto import reaction_pb2

from ord_schema.proto import dataset_pb2, reaction_pb2

logger = get_logger(__name__)

Expand Down
1 change: 1 addition & 0 deletions ord_schema/orm/mappers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

"""Tests for ord_schema.orm.mappers."""
import os

import pytest

from ord_schema.message_helpers import load_message
Expand Down
1 change: 1 addition & 0 deletions ord_schema/orm/rdkit_mappers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import pytest
from sqlalchemy import select
from sqlalchemy.exc import ProgrammingError

from ord_schema.orm.mappers import Mappers
from ord_schema.orm.rdkit_mappers import FingerprintType, RDKitMol

Expand Down
2 changes: 1 addition & 1 deletion ord_schema/orm/scripts/add_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
"""
import os
import time
from concurrent.futures import ProcessPoolExecutor
from functools import partial
from glob import glob
from hashlib import md5
from concurrent.futures import ProcessPoolExecutor

from docopt import docopt
from rdkit import RDLogger
Expand Down
3 changes: 1 addition & 2 deletions ord_schema/proto/dataset_pb2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

import pytest

from ord_schema.proto import dataset_pb2
from ord_schema.proto import reaction_pb2
from ord_schema.proto import dataset_pb2, reaction_pb2


@pytest.fixture
Expand Down
4 changes: 2 additions & 2 deletions ord_schema/resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
"""Name/string resolution to structured messages or identifiers."""
import email.message
import re
import urllib.error
import urllib.parse
import urllib.request
import urllib.error

from rdkit import Chem

from ord_schema.logging import get_logger
from ord_schema import message_helpers
from ord_schema.logging import get_logger
from ord_schema.proto import reaction_pb2

logger = get_logger(__name__)
Expand Down
6 changes: 2 additions & 4 deletions ord_schema/scripts/build_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@

import docopt

from ord_schema import message_helpers, validations
from ord_schema.logging import get_logger
from ord_schema import message_helpers
from ord_schema import validations
from ord_schema.proto import dataset_pb2
from ord_schema.proto import reaction_pb2
from ord_schema.proto import dataset_pb2, reaction_pb2

logger = get_logger(__name__)

Expand Down
6 changes: 2 additions & 4 deletions ord_schema/scripts/build_dataset_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
import docopt
import pytest

from ord_schema import message_helpers
from ord_schema import validations
from ord_schema.proto import dataset_pb2
from ord_schema.proto import reaction_pb2
from ord_schema import message_helpers, validations
from ord_schema.proto import dataset_pb2, reaction_pb2
from ord_schema.scripts import build_dataset


Expand Down
3 changes: 1 addition & 2 deletions ord_schema/scripts/enumerate_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
"""
import docopt

from ord_schema import message_helpers, templating
from ord_schema.logging import get_logger
from ord_schema import message_helpers
from ord_schema import templating

logger = get_logger(__name__)

Expand Down
6 changes: 2 additions & 4 deletions ord_schema/scripts/enumerate_dataset_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
import pandas as pd
import pytest

from ord_schema import message_helpers
from ord_schema import validations
from ord_schema.proto import dataset_pb2
from ord_schema.proto import reaction_pb2
from ord_schema import message_helpers, validations
from ord_schema.proto import dataset_pb2, reaction_pb2
from ord_schema.scripts import enumerate_dataset


Expand Down
7 changes: 2 additions & 5 deletions ord_schema/scripts/parse_uspto.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,9 @@
from rdkit import RDLogger

import ord_schema
from ord_schema import message_helpers, units, validations
from ord_schema.logging import get_logger
from ord_schema import message_helpers
from ord_schema import units
from ord_schema import validations
from ord_schema.proto import dataset_pb2
from ord_schema.proto import reaction_pb2
from ord_schema.proto import dataset_pb2, reaction_pb2

logger = get_logger(__name__)
RDLogger.DisableLog("rdApp.*") # Disable RDKit logging.
Expand Down
4 changes: 1 addition & 3 deletions ord_schema/scripts/process_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,8 @@
import github
from rdkit import RDLogger

from ord_schema import message_helpers, updates, validations
from ord_schema.logging import get_logger
from ord_schema import message_helpers
from ord_schema import updates
from ord_schema import validations
from ord_schema.proto import dataset_pb2

logger = get_logger(__name__)
Expand Down
6 changes: 2 additions & 4 deletions ord_schema/scripts/process_dataset_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@
import pytest
from rdkit import RDLogger

from ord_schema import message_helpers, validations
from ord_schema.logging import get_logger
from ord_schema import message_helpers
from ord_schema import validations
from ord_schema.proto import dataset_pb2
from ord_schema.proto import reaction_pb2
from ord_schema.proto import dataset_pb2, reaction_pb2
from ord_schema.scripts import process_dataset

logger = get_logger(__name__)
Expand Down
3 changes: 1 addition & 2 deletions ord_schema/scripts/validate_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@
import docopt
from rdkit import RDLogger

from ord_schema import message_helpers, validations
from ord_schema.logging import get_logger
from ord_schema import message_helpers
from ord_schema import validations
from ord_schema.proto import dataset_pb2

logger = get_logger(__name__)
Expand Down
6 changes: 2 additions & 4 deletions ord_schema/scripts/validate_dataset_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
import docopt
import pytest

from ord_schema import message_helpers
from ord_schema import validations
from ord_schema.proto import dataset_pb2
from ord_schema.proto import reaction_pb2
from ord_schema import message_helpers, validations
from ord_schema.proto import dataset_pb2, reaction_pb2
from ord_schema.scripts import validate_dataset


Expand Down
4 changes: 1 addition & 3 deletions ord_schema/templating.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@

import ord_schema
from ord_schema import validations
from ord_schema.proto import dataset_pb2
from ord_schema.proto import reaction_pb2

from ord_schema.proto import dataset_pb2, reaction_pb2

# pylint: disable=too-many-branches

Expand Down
3 changes: 1 addition & 2 deletions ord_schema/templating_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
from rdkit import Chem

from ord_schema import templating
from ord_schema.proto import reaction_pb2
from ord_schema.proto import dataset_pb2
from ord_schema.proto import dataset_pb2, reaction_pb2


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion ord_schema/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"""Helpers for translating strings with units."""

import re
from typing import Optional, Type, Union, Tuple
from typing import Optional, Tuple, Type, Union

import numpy as np

Expand Down
3 changes: 1 addition & 2 deletions ord_schema/updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
import re
import uuid

from ord_schema.proto import dataset_pb2
from ord_schema.proto import reaction_pb2
from ord_schema.proto import dataset_pb2, reaction_pb2

_COMPOUND_STRUCTURAL_IDENTIFIERS = [
reaction_pb2.CompoundIdentifier.SMILES,
Expand Down
3 changes: 1 addition & 2 deletions ord_schema/updates_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
import pytest

from ord_schema import updates
from ord_schema.proto import reaction_pb2
from ord_schema.proto import dataset_pb2
from ord_schema.proto import dataset_pb2, reaction_pb2


class TestUpdateReaction:
Expand Down
7 changes: 3 additions & 4 deletions ord_schema/validations.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@
import re
import warnings
from collections.abc import Mapping
from typing import Any, Optional
from enum import IntEnum
from typing import Any, Optional

from dateutil import parser
from rdkit import Chem
from rdkit import __version__ as RDKIT_VERSION

import ord_schema
from ord_schema.logging import get_logger
from ord_schema import message_helpers
from ord_schema.proto import dataset_pb2
from ord_schema.proto import reaction_pb2
from ord_schema.logging import get_logger
from ord_schema.proto import dataset_pb2, reaction_pb2

logger = get_logger(__name__)

Expand Down
Loading

0 comments on commit 50a0501

Please sign in to comment.