Merge branch 'master' into peternewman-hidden-subdir

This commit is contained in:
Peter Newman
2022-10-20 15:08:16 +01:00
committed by GitHub
6 changed files with 31 additions and 5 deletions

View File

@ -33,16 +33,16 @@ jobs:
run: |
python --version # just to check
pip install -U pip wheel # upgrade to latest pip find 3.5 wheels; wheel to avoid errors
pip install --upgrade codecov chardet "setuptools!=47.2.0" docutils setuptools_scm[toml]
pip install --upgrade chardet "setuptools!=47.2.0" docutils setuptools_scm[toml]
pip install aspell-python-py3
pip install -e ".[dev]" # install the codespell dev packages
- run: codespell --help
- 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/*"
# this file has an error
- run: "! codespell codespell_lib/tests/test_basic.py"
- run: codecov
make-check-dictionaries:
runs-on: ubuntu-latest

2
.gitignore vendored
View File

@ -9,3 +9,5 @@ codespell.egg-info
.mypy_cache/
.pytest_cache/
codespell_lib/_version.py
junit-results.xml
*.egg-info/

View File

@ -647,14 +647,22 @@ def parse_file(filename, colors, summary, misspellings, exclude_lines,
if not os.path.isfile(filename):
return bad_count
text = is_text_file(filename)
try:
text = is_text_file(filename)
except PermissionError as e:
print("WARNING: %s: %s" % (e.strerror, filename),
file=sys.stderr)
return bad_count
except OSError:
return bad_count
if not text:
if not options.quiet_level & QuietLevels.BINARY_FILE:
print("WARNING: Binary file: %s" % filename, file=sys.stderr)
return bad_count
try:
lines, encoding = file_opener.open(filename)
except Exception:
except OSError:
return bad_count
for i, line in enumerate(lines):

View File

@ -8023,6 +8023,8 @@ constracted->constructed
constractor->constructor
constractors->constructors
constraing->constraining, constraint,
constrainst->constraint, constraints,
constrainsts->constraints
constrainted->constrained
constraintes->constraints
constrainting->constraining

View File

@ -122,6 +122,20 @@ def test_basic(tmpdir, capsys):
assert cs.main(d) == 0
@pytest.mark.skipif(
not sys.platform == 'linux', reason='Only supported on Linux')
def test_permission_error(tmp_path, capsys):
"""Test permission error handling."""
d = tmp_path
with open(d / 'unreadable.txt', 'w') as f:
f.write('abandonned\n')
code, _, stderr = cs.main(f.name, std=True)
assert 'WARNING:' not in stderr
os.chmod(f.name, 0o000)
code, _, stderr = cs.main(f.name, std=True)
assert 'WARNING:' in stderr
def test_interactivity(tmpdir, capsys):
"""Test interaction"""
# Windows can't read a currently-opened file, so here we use

View File

@ -1,5 +1,5 @@
[tool:pytest]
addopts = --cov=codespell_lib -rs --cov-report= --tb=short
addopts = --cov=codespell_lib -rs --cov-report= --tb=short --junit-xml=junit-results.xml
[flake8]
exclude = build, ci-helpers