Update patterns to modern Python syntax and features. Drops unnecessary
legacy syntax that was required for Python 2 (removed in
9c3db1a5c5e02739eedba9e9915acd51736300b3).
Details on pyupgrade can be found at:
https://github.com/asottile/pyupgrade
The encoding detection code was trying to catch encoding-related
exceptions when the file is opened. This doesn't make sense, because
at this point no data has been read, therefore no encoding errors can be
detected. Instead, catch encoding-related exceptions when the file
contents are read.
Also avoid bailing out with `Exception('Unknown encoding')` on empty
files.
The list comprehension is shorter than the map() version.
I feel it is also simpler, although that is debatable.
This is consistent with the previous commit.
* Read options from config
* Fix assert in test
* Fix tests
* Fix readme to pass rst checks in Travis
* Also support .codespellrc config file
* Fix flake8 error
* CLI args override config args
* Rename tool:codespell to just codespell in config
* Fix typo in readme
* Remove unnecessary check for existance of config files (configparser already handles this case)
This is for issue #676, where typos are found in actually-okay URIs/emails. Because these are closer to names in context, this ignores them.
Mechanically, this erases the URI/email text before the word regex is applied.
* Disable 'BINARY file' warning by default
Currently codespell prints a warning if it finds binary files in the tree.
This is annoying as many projects contain .git/.svn blobs, images, etc.
Disable the warning by default and let users enable it if needed.
Co-authored-by: Waldir Pimenta <waldyrious@gmail.com>
* Improve help message for the --quiet-level option
* Update _codespell.py
Co-authored-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
* Add a test for checking the filename of an empty file
To test #1532
* Test an irregular file with a typo
* Fix the filename typo detection edge cases
* Split the irregular file test into a seperate test
Probably easier to skip and certainly makes the maths easier
* Skip the test if mkfifo is missing
* Add the missing import
* Fix the test skip logic
* Write in the right language!
* Test filename checking on a binary file
* Check errors don't exist as valid words in the aspell dictionary
* Install aspell on Travis
* Add some missing packages
* Remove a virtual package
* Just install the version of aspell-python we need
* Keep flake8 happy
* Switch to warnings and count them, so we can see all the aspell errors in one go
* Handle different encoding of the word and aspell
* Try and fix the encoding conversion
* Find out the encoding type
* Don't assert on number of warnings
* Don't record warnings for now
* Warn on all the encoding options
* pprint the encoding
* More warning work
* Use the actual encoding type
* Correct the logic
* ENH: Multi dict support
* FIX: Fixes after merge
* FIX: Better error check
* FIX: More thorough testing, locations
* FIX: Try newer aspell
* FIX: Move to new dict
* FIX: Move
* FIX: Restore removals from #1181
* FIX: One from #1362
* Add rare chack->check, cheque,
* Minor tidy of some dictionary check code
* Add some more suggestions.
* Fix the whitespace
* Really fix the whitespace
* FIX: Refactor requirement
* Log an error when aspell not found and not required
* Fix the error logging
* Test all variants of present and missing from aspell
* Undo some tuple tidying
* Fix the true/false values used
* Skip some flake8 tests
* Fix the test cases
* Correct the not in aspell test and fix some test cases
* Remove a duplicate test
* Use a test word that isn't a typo
* Set the ideal aspell detection logic for each dictionary
I suspect we'll have to relax this as more obscure words won't be in the aspell dictionary
* Be more realistic given the size of the dictionary
* Fix a flake8 error
* Fix another line length error
* FIX: Move
* FIX: Make visible, simplify
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
* Add context options: -A/-B/-C; Fixes#287
* Fix indentation of line continuation.
* Fix 'only before context' case.
* Add some tests for the new context options.
* Refactor context code (pass context tuple, instead of before/after variables)
* Get rid of 'remove temp file code' in context test.
* Fix reintroduced error (regarding 'only before context').