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

Fix #2055: Add support for PEP 518 #2290

Merged
merged 9 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ This is equivalent to running::

codespell --quiet-level 3 --count --skip "*.po,*.ts,./src/3rdParty,./src/Test"

Now codespell also support ``pyproject.toml``::
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...via the --toml argument


[tool.codespell]
skip = '*.po,*.ts,./src/3rdParty,./src/Test'
count = ''
quiet-level = 3

Any options specified in the command line will *override* options from the
config file.

Expand Down
8 changes: 8 additions & 0 deletions codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,17 @@ def parse_options(args):

# Load config files and look for ``codespell`` options.
cfg_files = ['setup.cfg', '.codespellrc']
tomlfile = 'pyproject.toml'
if options.config:
cfg_files.append(options.config)
config = configparser.ConfigParser()

# Read toml before other config files.
if os.path.isfile(os.path.realpath(tomlfile)):
import tomli
with open(tomlfile, 'rb') as f:
data = tomli.load(f).get('tool', {})
config.read_dict(data)
config.read(cfg_files)

if config.has_section('codespell'):
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@
"dev": ["check-manifest", "flake8", "pytest", "pytest-cov",
"pytest-dependency"],
"hard-encoding-detection": ["chardet"],
"toml": ["tomli"],
}
)