PyCQA / isort

A Python utility / library to sort imports.
https://pycqa.github.io/isort/
MIT License
6.53k stars 583 forks source link

isort breaks the code with sort_reexports = true #2268

Closed hwpang closed 5 months ago

hwpang commented 6 months ago

Thanks for making this amazing package!

I use isort to sort the following file with isort --sort-reexports <file/path>. The results break the file.

Original file:

from .agg import (
    Aggregation,
    AggregationRegistry,
    AttentiveAggregation,
    MeanAggregation,
    NormAggregation,
    SumAggregation,
)
from .loss import (
    BCELoss,
    BinaryDirichletLoss,
    BinaryMCCLoss,
    BoundedMSELoss,
    CrossEntropyLoss,
    DirichletMixin,
    EvidentialLoss,
    LossFunction,
    LossFunctionRegistry,
    MccMixin,
    MSELoss,
    MulticlassDirichletLoss,
    MulticlassMCCLoss,
    MVELoss,
    SIDLoss,
    WassersteinLoss,
)
from .message_passing import (
    AtomMessagePassing,
    BondMessagePassing,
    MessagePassing,
    MulticomponentMessagePassing,
)
from .metrics import (
    BCEMetric,
    BinaryAccuracyMetric,
    BinaryAUPRCMetric,
    BinaryAUROCMetric,
    BinaryF1Metric,
    BinaryMCCMetric,
    BoundedMAEMetric,
    BoundedMixin,
    BoundedMSEMetric,
    BoundedRMSEMetric,
    CrossEntropyMetric,
    MAEMetric,
    Metric,
    MetricRegistry,
    MSEMetric,
    MulticlassMCCMetric,
    R2Metric,
    RMSEMetric,
    SIDMetric,
    ThresholdedMixin,
    WassersteinMetric,
)
from .predictors import (
    BinaryClassificationFFN,
    BinaryClassificationFFNBase,
    BinaryDirichletFFN,
    EvidentialFFN,
    MulticlassClassificationFFN,
    MulticlassDirichletFFN,
    MveFFN,
    Predictor,
    PredictorRegistry,
    RegressionFFN,
    SpectralFFN,
)
from .transforms import UnscaleTransform
from .utils import Activation

__all__ = [
    "Aggregation",
    "AggregationRegistry",
    "MeanAggregation",
    "SumAggregation",
    "NormAggregation",
    "AttentiveAggregation",
    "LossFunction",
    "LossFunctionRegistry",
    "MSELoss",
    "BoundedMSELoss",
    "MVELoss",
    "EvidentialLoss",
    "BCELoss",
    "CrossEntropyLoss",
    "MccMixin",
    "BinaryMCCLoss",
    "MulticlassMCCLoss",
    "DirichletMixin",
    "BinaryDirichletLoss",
    "MulticlassDirichletLoss",
    "SIDLoss",
    "WassersteinLoss",
    "Metric",
    "MetricRegistry",
    "ThresholdedMixin",
    "MAEMetric",
    "MSEMetric",
    "RMSEMetric",
    "BoundedMixin",
    "BoundedMAEMetric",
    "BoundedMSEMetric",
    "BoundedRMSEMetric",
    "R2Metric",
    "BinaryAUROCMetric",
    "BinaryAUPRCMetric",
    "BinaryAccuracyMetric",
    "BinaryF1Metric",
    "BCEMetric",
    "CrossEntropyMetric",
    "BinaryMCCMetric",
    "MulticlassMCCMetric",
    "SIDMetric",
    "WassersteinMetric",
    "MessagePassing",
    "AtomMessagePassing",
    "BondMessagePassing",
    "MulticomponentMessagePassing",
    "Predictor",
    "PredictorRegistry",
    "RegressionFFN",
    "MveFFN",
    "EvidentialFFN",
    "BinaryClassificationFFNBase",
    "BinaryClassificationFFN",
    "BinaryDirichletFFN",
    "MulticlassClassificationFFN",
    "MulticlassDirichletFFN",
    "SpectralFFN",
    "Activation",
    "UnscaleTransform",
]

After sorting:

from .agg import (
    Aggregation,
    AggregationRegistry,
    AttentiveAggregat__all__ = ['Activation', 'Aggregation', 'AggregationRegistry', 'AtomMessagePassing', 'AttentiveAggregation',
 'BCELoss', 'BCEMetric', 'BinaryAUPRCMetric', 'BinaryAUROCMetric', 'BinaryAccuracyMetric',
 'BinaryClassificationFFN', 'BinaryClassificationFFNBase', 'BinaryDirichletFFN',
 'BinaryDirichletLoss', 'BinaryF1Metric', 'BinaryMCCLoss', 'BinaryMCCMetric', 'BondMessagePassing',
 'BoundedMAEMetric', 'BoundedMSELoss', 'BoundedMSEMetric', 'BoundedMixin', 'BoundedRMSEMetric',
 'CrossEntropyLoss', 'CrossEntropyMetric', 'DirichletMixin', 'EvidentialFFN', 'EvidentialLoss',
 'LossFunction', 'LossFunctionRegistry', 'MAEMetric', 'MSELoss', 'MSEMetric', 'MVELoss', 'MccMixin',
 'MeanAggregation', 'MessagePassing', 'Metric', 'MetricRegistry', 'MulticlassClassificationFFN',
 'MulticlassDirichletFFN', 'MulticlassDirichletLoss', 'MulticlassMCCLoss', 'MulticlassMCCMetric',
 'MulticomponentMessagePassing', 'MveFFN', 'NormAggregation', 'Predictor', 'PredictorRegistry',
 'R2Metric', 'RMSEMetric', 'RegressionFFN', 'SIDLoss', 'SIDMetric', 'SpectralFFN', 'SumAggregation',
 'ThresholdedMixin', 'UnscaleTransform', 'WassersteinLoss', 'WassersteinMetric']
classDirichletFFN,
    MveFFN,
    Predictor,
    PredictorRegistry,
    RegressionFFN,
    SpectralFFN,
)
from .transforms import UnscaleTransform
from .utils import Activation

__all__ = [

Any suggestions are appreciated!

JacksonBurns commented 5 months ago

Probable duplicate of https://github.com/PyCQA/isort/issues/2193

hwpang commented 5 months ago

Closing this as it's duplicate of https://github.com/PyCQA/isort/issues/2193