Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorting imports wrong way #447

Closed
samirbr opened this issue Oct 26, 2018 · 3 comments
Closed

Sorting imports wrong way #447

samirbr opened this issue Oct 26, 2018 · 3 comments
Assignees

Comments

@samirbr
Copy link

samirbr commented Oct 26, 2018

I have the following imports in a file.

import os
import os.path as P
import sys
import cv2
import math
import time
import numpy as np
import tensorflow as tf
import matplotlib
from matplotlib import pyplot as plt
from scipy.sparse import coo_matrix
from scipy.ndimage.filters import maximum_filter

sys.path.insert(0, P.abspath(P.join(P.dirname(__file__), "../job/")))

from configuration import Configuration
from personLabNetworkFunctions import get_personlab
from helper import (
    add_circle_to_matrix,
    circle_of_digits,
    circle_of_x_offsets,
    circle_of_y_offsets,
    circle_of_mid_range_x_offsets,
    circle_of_mid_range_y_offsets,
    transform,
    display_mid_range_offsets,
    display_short_range_offsets,
    display_heatmaps,
    show_computed_heatmaps,
)
from constants import (
    KEYPOINTS,
    EDGES,
    IM_WIDTH,
    IM_HEIGHT,
    IN_WIDTH,
    IN_HEIGHT,
    RADIUS,
    PEAK_THRESH,
    DATA_DIR,
    NUM_EDGES,
    NUM_KP,
)

When I run autopep8 test.py it wrongly reorders the imports.

from constants import (
    from helper import (
        from personLabNetworkFunctions import get_personlab
        from configuration import Configuration
        import os
        import os.path as P
        import sys
        import cv2
        import math
        import time
        import numpy as np
        import tensorflow as tf
        import matplotlib
        from matplotlib import pyplot as plt
        from scipy.sparse import coo_matrix
        from scipy.ndimage.filters import maximum_filter

        sys.path.insert(0, P.abspath(P.join(P.dirname(__file__), "../job/")))

        add_circle_to_matrix,
        circle_of_digits,
        circle_of_x_offsets,
        circle_of_y_offsets,
        circle_of_mid_range_x_offsets,
        circle_of_mid_range_y_offsets,
        transform,
        display_mid_range_offsets,
        display_short_range_offsets,
        display_heatmaps,
        show_computed_heatmaps,
    )
    KEYPOINTS,
    EDGES,
    IM_WIDTH,
    IM_HEIGHT,
    IN_WIDTH,
    IN_HEIGHT,
    RADIUS,
    PEAK_THRESH,
    DATA_DIR,
    NUM_EDGES,
    NUM_KP,
)

If there is no line breaks between parentheses it works fine.
I'm using autopep8 1.4.2 (pycodestyle: 2.4.0) with Python 3.6.6.

@hhatto
Copy link
Owner

hhatto commented Oct 30, 2018

Thanks for bug report.
fix in latest master 4343c41

We are planning to release version 1.4.3.

If you do not want to apply the fix of E402 after sys.path.insert(... line please add NOQA: E402 comment.

for example:

  :
sys.path.insert(0, P.abspath(P.join(P.dirname(__file__), "../job/")))

from configuration import Configuration  # NOQA: E402
from personLabNetworkFunctions import get_personlab  # NOQA: E402
from helper import (
    add_circle_to_matrix,
    circle_of_digits,
    circle_of_x_offsets,
    circle_of_y_offsets,
    circle_of_mid_range_x_offsets,
    circle_of_mid_range_y_offsets,
    transform,
    display_mid_range_offsets,
    display_short_range_offsets,
    display_heatmaps,
    show_computed_heatmaps,
)  # NOQA: E402
from constants import (
    KEYPOINTS,
    EDGES,
    IM_WIDTH,
    IM_HEIGHT,
    IN_WIDTH,
    IN_HEIGHT,
    RADIUS,
    PEAK_THRESH,
    DATA_DIR,
    NUM_EDGES,
    NUM_KP,
)  # NOQA: E402

@samirbr
Copy link
Author

samirbr commented Oct 30, 2018

Thanks.

@hhatto
Copy link
Owner

hhatto commented Nov 12, 2018

version 1.4.3 released
https://pypi.org/project/autopep8/1.4.3/

@hhatto hhatto closed this as completed Nov 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants