Release: Autopep8 transformer

Today, we are happy to announce the release of a new Transformer – “Autopep8”.

As you might already know, auotpep8 automatically formats Python code to conform to the PEP 8 style guide.

Now, coupled with Transformers, you can transform all incoming code using autopep8 – Every time a new PR is raised, we’ll check if it conforms with autopep8 style output. If it does, yay! If it doesn’t, no sweat – we run it for you, and commit back the results to the original PR.

How to enable it?

Just add the following to your .deepsource.toml, and we’ll take care of the rest:

[[transformers]]
name = "autopep8"
enabled = true

Missed our post on Transformers? Here’s a summary:

A DeepSource Transformer automatically ‘transforms’ all incoming source code in a repository with popular code auto-formatters (for e.g., black , gofmt , etc.).

For all repositories which have at least one transformer enabled in config, if:

  • A Pull/Merge Request is raised with the default branch as base, a transforming commit is added to that branch.
  • A commit is created on the default branch, DeepSource raises a Pull/Merge Request with transforming changes.

Docs: https://deepsource.io/docs/transformer/
Release notes: Transformers: Automatically format all incoming code

1 Like

Are there hidden options for transformer exceptions? I could not find much documentation on the topic. All our developers use autopep8 in their IDEs and have the switch set to

--ignore=E501

to ignore line length.

Deepsource keep line wrapping all our code! Thanks.

Hey!

Autopep8 should respect its config setup in a setup.cfg or pyproject.toml file.

Here’s how you can ignore E501 by making a setup.cfg file:

[pycodestyle]
ignore = E501

Similarly using a pyproject.toml file:

[tool.autopep8]
ignore = ["E501"]

Once this is committed, DeepSource will start respecting those options. Let me know if it still doesn’t work.

Thanks for reaponding! Its a great feature, thanks!