Skip to content

Can't exclude specified file from auto formatting when using autopep8 #17188

Closed

Description

Discussed in #17148

Originally posted by Iftakharpy August 28, 2021
Can anyone help me to ignore the "settings.py" file in a Django project to be formatted on save? I have tried for 2 hours but couldn't get it to work. I am using Windows 10.

My vscode configurations:

{
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "[python]": {
    "editor.defaultFormatter": "ms-python.python",
    "editor.tabSize": 4,
    "editor.insertSpaces": true,
    "editor.formatOnSave": true
  },
  "python.formatting.autopep8Args": ["--exclude=settings.py"]
}

I also tried:
- "python.formatting.autopep8Args": ["--exclude settings.py"]
- "python.formatting.autopep8Args": ["--exclude */settings.py"]
- "python.formatting.autopep8Args": ["--exclude", "settings.py"]
- "python.formatting.autopep8Args": ["--exclude", "*/settings.py"]

Activity

  1. Iftakharpy commented on Sep 2, 2021

    @Iftakharpy

    Can I get an idea of when this bug will be resolved?

  2. brettcannon commented on Sep 2, 2021

    @brettcannon
    MemberAuthor

    Iftakhar Husan (@Iftakharpy) no idea. We have to reproduce it and then figure out what's going on. It's quite possible that it's an issue with how we execute autopep8, which would mean a complete rewrite of our formatting code would be required.

  3. kimadeline commented on Nov 3, 2021

    @kimadeline

    Hi Iftakhar Husan (@Iftakharpy),

    This is not a bug with the extension, since running autopep8 in the terminal with the args combinations that you tried also fails.

    You can use the following autopep8 args array with the extension to exclude your settings.py file:

    "python.formatting.autopep8Args": [
            "--exclude=*settings.py",
        ],
  4. locked as resolved and limited conversation to collaborators on Dec 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-formattingbugIssue identified by VS Code Team member as probable bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions