Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
pydocstringformatter
Advanced tools
A tool to automatically format Python docstrings that tries to follow recommendations from PEP 8 and PEP 257.
A tool to automatically format Python docstrings to follow recommendations from
PEP 8
and
PEP 257
(or other supported style
guides.)
See What it does for currently supported auto-formatting.
This project is heavily inspired by
docformatter
.
When this project was started docformatter
did not meet all of the requirements the
pylint
project had for its docstring formatter and
was no longer actively maintained (this has changed since then). Therefore, some
contributors of pylint
got together and started working on our own formatter to
fulfill our needs.
When asked we defined the objective of the tool as:
"A docstring formatter that follows PEP8 and PEP257 but makes some of the more 'controversial' elements of the PEPs optional"
See the original answer.
As such, the biggest difference between the two is that pydocstringformatter
fixes
some of the open issues we found in docformatter
. In general, the output of both
formatters (and any other docstring formatter) should be relatively similar.
pip install pydocstringformatter
Click here
for a
full Usage overview.
Pydocstringformatter will also read any configuration added to the
[tool.pydocstringformatter]
section of a pyproject.toml
file.
For example:
[tool.pydocstringformatter]
write = true
exclude = "**/my_dir/**,**/my_other_dir/**"
# Or:
exclude = ["**/my_dir/**", "**/my_other_dir/**"]
strip-whitespaces = true
split-summary-body = false
numpydoc-section-hyphen-length = false
Pydocstringformatter can be configured to use a specific style. The default is pep257
but we support other styles as well. These can also be used at the same time. For
example with:
pydocstringformatter --style=pep257 --style=numpydoc myfile.py
Pydocstringformatter can also be used as a pre-commit hook.
Add the following to your .pre-commit-config.yaml
file:
- repo: https://github.com/DanielNoord/pydocstringformatter
rev: SPECIFY VERSION HERE
hooks:
- id: pydocstringformatter
The following examples show some of the changes pydocstringformatter will apply. For a
full overview of all potential changes you can check out the
Usage
page which
shows an up to date list of all formatters and their description.
# Bad
'''
my docstring'''
""" my
multi-line docstring """
"""my title
===========
my docstring
"""
# Good
"""My docstring."""
"""My
multi-line docstring.
"""
"""My title
===========
My docstring
"""
# With --summary-quotes-same-line
# Bad
"""
My
multi-line docstring
"""
# Good
"""My
multi-line docstring
"""
For development and contributing guidelines please see
Development
.
FAQs
A tool to automatically format Python docstrings that tries to follow recommendations from PEP 8 and PEP 257.
We found that pydocstringformatter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.