38 Commits

Author SHA1 Message Date
Anthony Sottile
8f6152921e drop python3.6 support
python 3.6 reached end of life on 2021-12-23

Committed via https://github.com/asottile/all-repos
2022-01-15 19:24:05 -05:00
Mikhail Khvoinitsky
10c5e4e166 forbid-new-submodules: fix triggering failure when only a submodule is committed (without any other file); support --from-ref and --to-ref; fixes #609 2021-08-13 21:32:08 +03:00
Iago Alonso
fed8b6debb Rename file causing check-json to fail
- `mv duplicated_key_json.{json,notjson}`
- change reference to the file in `tests/check_json_test.py`

Fixes #600
2021-05-15 12:31:33 +02:00
Aditya Khursale
fe37451719 Report duplicate keys in check_json
Raise ValueError and return 1 if json contains duplicate keys
2021-02-18 13:53:57 -08:00
Anthony Sottile
f5c42a050b pre-commit-hooks: python3.6+ 2020-02-05 11:22:18 -08:00
Anthony Sottile
030bfac7e4 Apply typing to all of pre-commit-hooks 2019-01-31 20:09:15 -08:00
Anthony Sottile
6e2e83a409 Simplify debug-statemetns tests 2018-05-13 15:07:31 -07:00
Anthony Sottile
9b1b44e9c9 Remove write_file (now unnecessary) 2018-03-26 09:10:43 -07:00
Michał Sochoń
54c0f8c937 Open files as UTF-8 2018-03-26 12:00:48 +02:00
Pablo Vega
97d838f792 dding the file aws_config_without_secrets_with_spaces.ini for new test case 2018-01-26 15:22:32 -08:00
Ben Webber
d889840b88 check-builtin-literals: Appease flake8 with six 2017-12-01 03:04:46 +00:00
Ben Webber
775867626d check-builtin-literals: Ignore function attribute calls 2017-11-30 18:33:36 +00:00
Ben Webber
35996b7a25 Add check to enforce literal syntax for Python builtin types
This check requires authors to initialize empty or zero builtin types
using the literal syntax (e.g., `{}` instead of `dict()`).

Authors may ignore this requirement for certain builtins using the
`--ignore` option.

Authors may also forbid calling `dict()` with keyword arguments
(`dict(a=1, b=2)`) using the `--no-allow-dict-kwargs` flag.
2017-11-26 00:46:03 +00:00
Anthony Sottile
c5b7c35d81 Use fixtures for the symlink tests to fix appveyor 2017-09-08 08:35:13 -07:00
Anthony Sottile
1d7aaaaa1e Fix end of files 2017-07-02 21:22:35 -07:00
ushuz
10f8bd2f22 Add unit test for --no-ensure-ascii option 2017-03-20 20:19:01 +08:00
Daniel Roschka
b0d4cdb1ee Improve searching for configured AWS credentials
The previous approach for finding AWS credentials was pretty naive and
only covered contents of a single file (~/.aws/credentials by
default).

The AWS CLI documentation states various other ways to configure
credentials which weren't covered:
https://docs.aws.amazon.com/cli/latest/topic/config-vars.html#credentials
Even that aren't all ways, a look into the code shows:
https://github.com/boto/botocore/blob/develop/botocore/credentials.py

This commit changes the behavior so the hook will behave in a way
that if the AWS CLI is able to obtain credentials from local files,
the hook will find them as well.

The changes in detail are:
- detect AWS session tokens and handle them like secret keys.
- always search credentials in the default AWS CLI file locations
  ( ~/.aws/config, ~/.aws/credentials, /etc/boto.cfg and ~/.boto)
- detect AWS credentials configured via environment variables in
  AWS_SECRET_ACCESS_KEY, AWS_SECURITY_TOKEN and AWS_SESSION_TOKEN
- check additional configuration files configured via environment
  variables (AWS_CREDENTIAL_FILE, AWS_SHARED_CREDENTIALS_FILE and
  BOTO_CONFIG)
- print out the first four characters of each secret found in files to
  be checked in, to make it easier to figure out, what the secrets
  were, which were going to be checked in
- improve error handling for parsing ini-files
- improve tests

There is a major functional change introduced by this commit:
Locations the AWS CLI gets credentials from are always searched and
there is no way to disable them. --credentials-file is still there to
specify one or more additional files to search credentials in. It's
the purpose of this hook to find and check files for found
credentials, so it should work in any case. As this commit also
improves error handling for not-existing or malformed configuration
files, it should be no big deal.

Receiving credentials via the EC2 and ECS meta data services is not
covered intentionally, to not further increase the amount of changes
in this commit and as it's probably an edge case anyway to have this
hook running in such an environment.
2016-12-30 08:41:24 +01:00
Lucas Cimon
54e83f7ceb Displaying the filename when the check-json hook fails with a UnicodeDecodeError - fix #148 2016-11-12 09:15:10 +01:00
David Brown
e9e9c3d577 add test to show how it works a bit more 2016-11-03 18:05:43 -07:00
Anthony Sottile
cf3aabe9b1 Merge pull request #120 from sanmai-NL/JSON_arbitrary_indentation_separator
Refactor legacy `indent: int` -> `indent: str`
2016-06-12 10:25:59 -07:00
Sander Maijers
a5628863e8 Refactor legacy indent: int -> indent: str
The type of `indent` parameter is preferably `str`. See
http://simplejson.readthedocs.io/en/latest/index.html?highlight=dump#simplejson.dump
. This change allows to specify TABs as indentation delimiter to
`pretty_format_json`. Add input validator/converter for backward compat.
2016-06-12 19:19:07 +02:00
Anthony Sottile
a99475afa0 Simplify the tests 2016-05-27 14:09:50 -07:00
Anthony Sottile
b4e29b5e63 Use newline='' to avoid automatic newline translation 2016-05-26 11:45:28 -07:00
Anthony Sottile
4a01f64c8f Fix check-merge-conflict against binary files 2016-05-26 11:20:32 -07:00
mattclegg
d49f04c69e Adjust formatting for existing test_pretty_format_json 2016-04-14 10:41:39 +01:00
mattclegg
bd4e37c366 Add test for '--no-sort-keys' 2016-04-14 10:41:39 +01:00
Benjamin Chess
896c0cfdc0 new hook tests for broken symlinks 2016-01-14 15:25:46 -08:00
Anthony Sottile
99574324eb Merge pull request #60 from arahayrabedian/master
AWS credential checking
2015-06-17 11:46:15 -07:00
Ara Hayrabedian
02e8bdc9d8 add tests, test sample files and minor refactor of exit codes in actual hook in order to facilitate testing 2015-06-12 19:20:56 +04:00
Léo Cavaillé
55bf22dc4a Add new hook pretty-format-json
This new hook allows to standardize one's JSON files (sorted key/4
spaces indent).
By default it just fails if any file is not complying with the standard,
but you can also pass the arg `--autofix` and the hook will
pretty-format the file itself.

Good in use combined with the `check-json` hook.
2015-06-11 00:08:03 -04:00
Anthony Sottile
713fab4bc7 Remove dependency on plumbum 2015-03-20 14:15:30 -07:00
Anthony Sottile
ddc9208a5f Add check-xml hook. 2015-01-17 10:30:58 -08:00
gkisel
c682b50749 Add check_case_conflict hook #21 2015-01-12 15:38:22 -08:00
Anthony Sottile
243fe50bc1 Add a hook for checking parseable json. 2014-08-19 16:03:48 -07:00
Anthony Sottile
830ea6d8c8 Give a better message when ast is not parseable. 2014-06-19 17:44:40 -07:00
Anthony Sottile
8270d81308 Improve test coverage. 2014-04-13 22:21:42 -07:00
Anthony Sottile
b80ca9e84a Update project setup. 2014-04-13 22:09:26 -07:00
Anthony Sottile
3e45f53e68 Add a hook for yaml files. 2014-04-03 21:36:03 -07:00