Skip to content

Commit ec0f41b

Browse files
authored
BUG: Fix bug with toml triage (#2774)
1 parent 8fa4167 commit ec0f41b

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

Diff for: .github/workflows/codespell-private.yml

+12-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# For general usage in your repo, see the example in codespell.yml
33
# https://github.com/codespell-project/codespell
44
# Concurrency cancels an action on a given PR once a new commit is pushed
5-
name: Test Codespell
5+
name: Pytest
66
concurrency:
77
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }}
88
cancel-in-progress: true
@@ -23,7 +23,12 @@ jobs:
2323
- '3.9'
2424
- '3.10'
2525
- '3.11'
26-
name: Python ${{ matrix.python-version }} test
26+
no-toml:
27+
- ''
28+
include:
29+
- python-version: '3.10'
30+
no-toml: 'no-toml'
31+
name: ${{ matrix.python-version }} ${{ matrix.no-toml }}
2732
steps:
2833
- uses: actions/checkout@v3
2934
with:
@@ -44,10 +49,14 @@ jobs:
4449
- run: codespell --version
4550
- run: make check
4651
- uses: codecov/codecov-action@v3
47-
- run: codespell --check-filenames --skip="./.git/*,*.pyc,./codespell_lib/tests/test_basic.py,./codespell_lib/data/*,./example/code.c,./build/lib/codespell_lib/tests/test_basic.py,./build/lib/codespell_lib/data/*,README.rst,*.egg-info/*,pyproject-codespell.precommit-toml"
52+
# tomli should not be required for the next two steps (and make sure it's not)
53+
- run: pip uninstall -yq tomli
54+
if: ${{ matrix.no-toml == 'no-toml' }}
55+
- run: codespell --check-filenames --skip="./.git/*,*.pyc,./codespell_lib/tests/test_basic.py,./codespell_lib/data/*,./example/code.c,./build/lib/codespell_lib/tests/test_basic.py,./build/lib/codespell_lib/data/*,README.rst,*.egg-info/*,pyproject-codespell.precommit-toml,./.mypy_cache"
4856
# this file has an error
4957
- run: "! codespell codespell_lib/tests/test_basic.py"
5058

59+
5160
make-check-dictionaries:
5261
runs-on: ubuntu-latest
5362
steps:

Diff for: codespell_lib/_codespell.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -563,10 +563,12 @@ def parse_options(
563563
f"tomllib or tomli are required to read pyproject.toml "
564564
f"but could not be imported, got: {e}"
565565
) from None
566-
for toml_file in toml_files:
567-
with open(toml_file, "rb") as f:
568-
data = tomllib.load(f).get("tool", {})
569-
config.read_dict(data)
566+
tomllib = None
567+
if tomllib is not None:
568+
for toml_file in toml_files:
569+
with open(toml_file, "rb") as f:
570+
data = tomllib.load(f).get("tool", {})
571+
config.read_dict(data)
570572

571573
# Collect which config files are going to be used
572574
used_cfg_files = []

0 commit comments

Comments
 (0)