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

autopep8 is destroying my code everytime I save it #17245

Closed
HiltzM opened this issue Dec 7, 2024 · 3 comments
Closed

autopep8 is destroying my code everytime I save it #17245

HiltzM opened this issue Dec 7, 2024 · 3 comments
Labels
bug 🐛 not-this-repo For any issues that are not for this repository requires triaging maintainers need to do initial inspection of issue

Comments

@HiltzM
Copy link

HiltzM commented Dec 7, 2024

Problem Description
When I use "ctrl" + "s", to save my code autopep8 is rearranging my code and adding a comment in an import statement. The import statement that gets broken up with comment is always the third import statement. Which effectively means I can't save my code in running order, because autopep8 keeps breaking it. I know it is autopep8 that is causing it, because when I turn off autopep8 it stops happening. This is pretty frustrating because my code is both useless and I can't structure it the way I want to.

I should also mention I have not adding anything to my setting.json file in regards to autopep8. The only thing I have added to my settings.json file is:
"flake8.args": ["--max-line-length","160"],

Since the last attempt I made to get help with this issue flagged my issue as "not-this-repo". I should clarify that I am posting my code show the effects of the bug with in autopep8. I am not looking for help with the code itself. But I am looking for help with the bug that autopep8 has where it rearranges the code and destroys the code after saving the document. When it auto-formats the code, it SHOULD NOT be adding in comments into import statements.

Before autopep8

import os
import numpy as np
from skimage.feature import hog
from PIL import Image, ImageFilter
from sklearn.decomposition import PCA
from sklearn.preprocessing import StandardScaler
from numpy import asarray
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import cross_val_score
from sklearn.metrics import confusion_matrix, accuracy_score


"""
Set folders and define classes
"""
# Set file location for Training and Testing
folder_training = 'Lego_dataset_2/training/' 
folder_testing = 'Lego_dataset_2/testing/' 

# Class labels for LEGO categories
classes = {
    '2b1': 0,  # 2x1 brick
    'rec': 1,  # Rectangle
    'cir': 2,  # Circle
    'squ': 3   # Square
}

After autopep8

# Set file location for Training and Testing
import os
import numpy as np
from skimage.fea  # ture import hog
from PIL import Image, ImageFilter
from sklearn.decomposition import PCA
from sklearn.preprocessing import StandardScaler
from numpy import asarray
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import cross_val_score
from sklearn.metrics import confusion_matrix, accuracy_score
folder_training = 'Lego_dataset_2/training/' 
folder_testing = 'Lego_dataset_2/testing/'  



"""
Set folders and define classes
"""
# Class labels for LEGO categories
classes = {
    '2b1': 0,  # 2x1 brick
    'rec': 1,  # Rectangle
    'cir': 2,  # Circle
    'squ': 3   # Square
}

My Set Up
VS Code: 1.95.3
autopep8: 2.3.1
Flake8: 7.1.1
tomli: 2.2.1
mccabe: 0.7.0
pycodestyle: 2.12.1
pyflakes: 3.2.0

@HiltzM HiltzM added bug 🐛 requires triaging maintainers need to do initial inspection of issue labels Dec 7, 2024
@miketheman
Copy link
Member

Since the last attempt I made to get help with this issue flagged my issue as "not-this-repo". I should clarify that I am posting my code show the effects of the bug with in autopep8. I am not looking for help with the code itself. But I am looking for help with the bug that autopep8 has where it rearranges the code and destroys the code after saving the document. When it auto-formats the code, it SHOULD NOT be adding in comments into import statements.

This is still not the autopep8 project repository, please report it there instead.

@miketheman miketheman added the not-this-repo For any issues that are not for this repository label Dec 7, 2024
Copy link
Contributor

github-actions bot commented Dec 7, 2024

Hi, this issue tracker is for issues with the codebase behind pypi.org itself, not the projects hosted on PyPI.
You should report this issue to the tracker for the project in question instead.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 7, 2024
@HiltzM
Copy link
Author

HiltzM commented Dec 7, 2024

Since the last attempt I made to get help with this issue flagged my issue as "not-this-repo". I should clarify that I am posting my code show the effects of the bug with in autopep8. I am not looking for help with the code itself. But I am looking for help with the bug that autopep8 has where it rearranges the code and destroys the code after saving the document. When it auto-formats the code, it SHOULD NOT be adding in comments into import statements.

This is still not the autopep8 project repository, please report it there instead.

Where is that, this is the github that the link on the autopep8 website sent me to

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 not-this-repo For any issues that are not for this repository requires triaging maintainers need to do initial inspection of issue
Projects
None yet
Development

No branches or pull requests

2 participants