Skip to content

Commit

Permalink
Sort imports with ruff isort (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
oerc0122 authored Sep 10, 2024
1 parent 50140ea commit c549089
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 36 deletions.
2 changes: 1 addition & 1 deletion castep_outputs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@

# pylint: disable=unused-import

from .parsers import * # noqa: F403
from .cli.castep_outputs_main import parse_single # noqa: F401
from .parsers import * # noqa: F403
3 changes: 1 addition & 2 deletions castep_outputs/cli/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
from collections.abc import Sequence
from pathlib import Path

from castep_outputs.parsers import CASTEP_FILE_FORMATS
from castep_outputs.parsers import CASTEP_OUTPUT_NAMES
from castep_outputs.parsers import CASTEP_FILE_FORMATS, CASTEP_OUTPUT_NAMES
from castep_outputs.utilities.dumpers import SUPPORTED_FORMATS

# pylint: disable=line-too-long
Expand Down
4 changes: 2 additions & 2 deletions castep_outputs/cli/castep_outputs_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
import io
import logging
import sys
from collections.abc import Sequence, Callable
from collections.abc import Callable, Sequence
from pathlib import Path
from typing import Any, TextIO

from .args import args_to_dict, parse_args
from ..parsers import PARSERS
from ..utilities.constants import OutFormats
from ..utilities.dumpers import get_dumpers
from ..utilities.utility import flatten_dict, json_safe, normalise
from .args import args_to_dict, parse_args


def parse_single(in_file: str | Path | TextIO,
Expand Down
10 changes: 7 additions & 3 deletions castep_outputs/parsers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@
from .hug_file_parser import parse_hug_file
from .magres_file_parser import parse_magres_file
from .md_geom_file_parser import parse_md_geom_file
from .parse_fmt_files import (parse_chdiff_fmt_file, parse_den_fmt_file,
parse_elf_fmt_file, parse_pot_fmt_file)
from .parse_fmt_files import (
parse_chdiff_fmt_file,
parse_den_fmt_file,
parse_elf_fmt_file,
parse_pot_fmt_file,
)
from .phonon_dos_file_parser import parse_phonon_dos_file
from .phonon_file_parser import parse_phonon_file
from .tddft_file_parser import parse_tddft_file
from .ts_file_parser import parse_ts_file
from .xrd_sf_file_parser import parse_xrd_sf_file
from .phonon_file_parser import parse_phonon_file

__all__ = ["parse_castep_file",
"parse_cell_param_file",
Expand Down
75 changes: 54 additions & 21 deletions castep_outputs/parsers/castep_file_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,69 @@
import re
from collections import defaultdict
from enum import Flag, auto
from typing import Any, cast, Dict, List, TextIO, Union
from typing import Any, Dict, List, TextIO, Union, cast

from ..utilities import castep_res as REs
from ..utilities.castep_res import (gen_table_re, get_numbers,
labelled_floats)
from ..utilities.castep_res import gen_table_re, get_numbers, labelled_floats
from ..utilities.constants import SHELLS
from ..utilities.datatypes import (AtomIndex, AtomPropBlock, BandStructure,
BondData, CellInfo, CharTable,
ConstraintsReport, DipoleTable,
ElasticProperties, FinalConfig, GeomTable,
InitialSpin, KPointsList, KPointsSpec,
MDInfo, MemoryEst, MullikenInfo,
Occupancies, PhononSymmetryReport,
PSPotEnergy, PSPotReport, PSPotStrInfo,
QData, RamanReport, SCFReport, SixVector,
SymmetryReport, TDDFTData, Thermodynamics,
ThreeByThreeMatrix, ThreeVector,
WvfnLineMin)
from ..utilities.datatypes import (
AtomIndex,
AtomPropBlock,
BandStructure,
BondData,
CellInfo,
CharTable,
ConstraintsReport,
DipoleTable,
ElasticProperties,
FinalConfig,
GeomTable,
InitialSpin,
KPointsList,
KPointsSpec,
MDInfo,
MemoryEst,
MullikenInfo,
Occupancies,
PhononSymmetryReport,
PSPotEnergy,
PSPotReport,
PSPotStrInfo,
QData,
RamanReport,
SCFReport,
SixVector,
SymmetryReport,
TDDFTData,
Thermodynamics,
ThreeByThreeMatrix,
ThreeVector,
WvfnLineMin,
)
from ..utilities.filewrapper import Block, FileWrapper
from ..utilities.utility import (add_aliases, atreg_to_index, determine_type,
fix_data_types, log_factory, normalise_key,
normalise_string, parse_int_or_float,
stack_dict, to_type)
from ..utilities.utility import (
add_aliases,
atreg_to_index,
determine_type,
fix_data_types,
log_factory,
normalise_key,
normalise_string,
parse_int_or_float,
stack_dict,
to_type,
)
from .bands_file_parser import parse_bands_file
from .cell_param_file_parser import _parse_devel_code_block
from .efield_file_parser import parse_efield_file
from .elastic_file_parser import parse_elastic_file
from .hug_file_parser import parse_hug_file
from .parse_fmt_files import (parse_chdiff_fmt_file, parse_den_fmt_file,
parse_elf_fmt_file, parse_pot_fmt_file)
from .parse_fmt_files import (
parse_chdiff_fmt_file,
parse_den_fmt_file,
parse_elf_fmt_file,
parse_pot_fmt_file,
)
from .phonon_dos_file_parser import parse_phonon_dos_file
from .xrd_sf_file_parser import parse_xrd_sf_file

Expand Down
3 changes: 1 addition & 2 deletions castep_outputs/parsers/cell_param_file_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

from ..utilities.datatypes import AtomIndex, ThreeByThreeMatrix, ThreeVector
from ..utilities.filewrapper import Block
from ..utilities.utility import (atreg_to_index, determine_type, log_factory,
to_type)
from ..utilities.utility import atreg_to_index, determine_type, log_factory, to_type


def parse_cell_param_file(cell_param_file: TextIO) -> list[dict[str, str | dict[str, str]]]:
Expand Down
3 changes: 1 addition & 2 deletions castep_outputs/parsers/ts_file_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
from collections import defaultdict
from typing import Any, TextIO

from ..utilities.castep_res import (ATDATTAG, TAG_RE, get_numbers,
labelled_floats)
from ..utilities.castep_res import ATDATTAG, TAG_RE, get_numbers, labelled_floats
from ..utilities.constants import FST_D, TAG_ALIASES, TS_TYPES
from ..utilities.filewrapper import Block
from ..utilities.utility import add_aliases, atreg_to_index, to_type
Expand Down
1 change: 0 additions & 1 deletion castep_outputs/utilities/castep_res.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

from .constants import FST_D, MINIMISERS, SHELLS


Pattern = Union[str, re.Pattern]


Expand Down
2 changes: 1 addition & 1 deletion castep_outputs/utilities/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
from __future__ import annotations

from typing import Literal, TypedDict, Tuple, Dict
from typing import Dict, Literal, Tuple, TypedDict

# General types

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ select = [
# "RET", # Flake8 return
"ARG", # Flake8 unused args
"PTH", # Flake8 use pathlib
# "I", # Isort
"I", # Isort
"RUF", # Ruff specific
"FURB",# Refurb
"PERF",# Perflint
Expand Down

0 comments on commit c549089

Please sign in to comment.