Skip to content

Commit

Permalink
BUG: Fix bug with toml triage (#2774)
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner authored Mar 8, 2023
1 parent 8fa4167 commit ec0f41b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/codespell-private.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# For general usage in your repo, see the example in codespell.yml
# https://github.com/codespell-project/codespell
# Concurrency cancels an action on a given PR once a new commit is pushed
name: Test Codespell
name: Pytest
concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }}
cancel-in-progress: true
Expand All @@ -23,7 +23,12 @@ jobs:
- '3.9'
- '3.10'
- '3.11'
name: Python ${{ matrix.python-version }} test
no-toml:
- ''
include:
- python-version: '3.10'
no-toml: 'no-toml'
name: ${{ matrix.python-version }} ${{ matrix.no-toml }}
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -44,10 +49,14 @@ jobs:
- run: codespell --version
- run: make check
- uses: codecov/codecov-action@v3
- 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"
# tomli should not be required for the next two steps (and make sure it's not)
- run: pip uninstall -yq tomli
if: ${{ matrix.no-toml == 'no-toml' }}
- 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"
# this file has an error
- run: "! codespell codespell_lib/tests/test_basic.py"


make-check-dictionaries:
runs-on: ubuntu-latest
steps:
Expand Down
10 changes: 6 additions & 4 deletions codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,10 +563,12 @@ def parse_options(
f"tomllib or tomli are required to read pyproject.toml "
f"but could not be imported, got: {e}"
) from None
for toml_file in toml_files:
with open(toml_file, "rb") as f:
data = tomllib.load(f).get("tool", {})
config.read_dict(data)
tomllib = None
if tomllib is not None:
for toml_file in toml_files:
with open(toml_file, "rb") as f:
data = tomllib.load(f).get("tool", {})
config.read_dict(data)

# Collect which config files are going to be used
used_cfg_files = []
Expand Down

0 comments on commit ec0f41b

Please sign in to comment.