Skip to content

Commit

Permalink
Updates for pre-commit CI tests, add black, isort and other pre commi…
Browse files Browse the repository at this point in the history
…t configs

Signed-off-by: Ayush Dattagupta <[email protected]>
  • Loading branch information
ayushdg committed Mar 21, 2024
1 parent 2cd02f3 commit b3ed243
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 8 deletions.
47 changes: 47 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

default_language_version:
python: python3

ci:
autofix_prs: true
autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions'
autoupdate_schedule: quarterly

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
args: ['--maxkb=1000']
- id: check-case-conflict
- id: check-yaml
- id: detect-private-key
- id: end-of-file-fixer
- id: requirements-txt-fixer
- id: trailing-whitespace

- repo: https://github.com/psf/black
rev: 24.3.0
hooks:
- id: black
name: Format code

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
name: Format imports
exclude: docs/
3 changes: 0 additions & 3 deletions .style.yapf

This file was deleted.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ We use ``black`` as our style guide. To fix your format run `pip install pre-com
1. Minimize the use of ``**kwargs``.
1. ``RaiseError`` is preferred to ``assert``. Write: ```if X: raise Error``` instead of ```assert X```.
1. Classes are preferred to standalone methods.
1. Methods should be atomic. A method shouldn't be longer than 75 lines, e.g. can be fit into the computer screen without scrolling.
1. Methods should be atomic. A method shouldn't be longer than 88 lines, e.g. can be fit into the computer screen without scrolling.
1. If a method has arguments that don't fit into one line, each argument should be in its own line for readability.
1. Add ``__init__.py`` for every folder.
1. F-strings are prefered to formatted strings.
Expand Down
13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[tool.isort]
profile = "black" # black-compatible
line_length = 88 # should match black parameters
py_version = 38
extend_skip = ["setup.py"]

[tool.black]
line_length = 88

[tool.pytest.ini_options]
markers = [
"gpu: marks tests as GPU tests (deselect with '-m \"not gpu\"')"
]
4 changes: 0 additions & 4 deletions pytest.ini

This file was deleted.

0 comments on commit b3ed243

Please sign in to comment.