Skip to content

Commit

Permalink
Make a package (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinchuby authored Nov 13, 2022
1 parent 59b5584 commit 2524f42
Show file tree
Hide file tree
Showing 51 changed files with 3,131 additions and 165 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ jobs:
python-version: "3.10"
- name: Install dependencies
run: |
pip install -r requirements.txt
lintrunner init
pipx install poetry
poetry install
poetry run lintrunner init
- name: Run lintrunner on all files
run: |
set +e
if ! lintrunner --force-color --all-files --tee-json=lint.json; then
if ! poetry run lintrunner --force-color --all-files --tee-json=lint.json; then
echo ""
echo -e "\e[1m\e[36mYou can reproduce these results locally by using \`lintrunner\`.\e[0m"
exit 1
Expand All @@ -39,7 +40,7 @@ jobs:
- name: Produce SARIF
if: always()
run: |
python tools/convert_to_sarif.py --input lint.json --output lintrunner.sarif
poetry run python -m lintrunner_adapters to-sarif lint.json lintrunner.sarif
- name: Upload SARIF file
if: always()
continue-on-error: true
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ jobs:
python-version: "3.10"
- name: Install dependencies
run: |
pip install -r requirements.txt
lintrunner init
pipx install poetry
poetry install
poetry run lintrunner init
- name: Run pytest
run: |
pytest --doctest-modules
PY_IGNORE_IMPORTMISMATCH=1 poetry run pytest --doctest-modules
60 changes: 48 additions & 12 deletions .lintrunner.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ include_patterns = [
exclude_patterns = []
command = [
'python3',
'adapters/pytorch/flake8_linter.py',
'-m',
'lintrunner_adapters',
'run',
'flake8_linter',
'--',
'@{{PATHSFILE}}'
]
init_command = [
'python3',
'adapters/pytorch/pip_init.py',
'-m',
'lintrunner_adapters',
'run',
'pip_init',
'--dry-run={{DRYRUN}}',
'flake8==5.0.4',
'flake8-bugbear==22.10.27',
Expand All @@ -35,14 +41,20 @@ exclude_patterns = [
]
command = [
'python3',
'adapters/pytorch/mypy_linter.py',
'-m',
'lintrunner_adapters',
'run',
'mypy_linter',
'--config=pyproject.toml',
'--',
'@{{PATHSFILE}}'
]
init_command = [
'python3',
'adapters/pytorch/pip_init.py',
'-m',
'lintrunner_adapters',
'run',
'pip_init',
'--dry-run={{DRYRUN}}',
'mypy==0.990',
]
Expand All @@ -53,7 +65,10 @@ include_patterns = ['**/*.py', '**/*.pyi']
exclude_patterns = []
command = [
'python3',
'adapters/pytorch/grep_linter.py',
'-m',
'lintrunner_adapters',
'run',
'grep_linter',
'--pattern=# noqa([^:]|$)',
'--linter-name=NOQA',
'--error-name=unqualified noqa',
Expand All @@ -71,7 +86,10 @@ include_patterns=['**']
exclude_patterns=[]
command = [
'python3',
'adapters/pytorch/newlines_linter.py',
'-m',
'lintrunner_adapters',
'run',
'newlines_linter',
'--',
'@{{PATHSFILE}}',
]
Expand All @@ -83,7 +101,10 @@ include_patterns = ['**']
exclude_patterns = []
command = [
'python3',
'adapters/pytorch/grep_linter.py',
'-m',
'lintrunner_adapters',
'run',
'grep_linter',
'--pattern=[[:blank:]]$',
'--linter-name=SPACES',
'--error-name=trailing spaces',
Expand All @@ -103,7 +124,10 @@ exclude_patterns = [
]
command = [
'python3',
'adapters/pytorch/grep_linter.py',
'-m',
'lintrunner_adapters',
'run',
'grep_linter',
# @lint-ignore TXT2
'--pattern= ',
'--linter-name=TABS',
Expand All @@ -124,13 +148,19 @@ include_patterns = [
exclude_patterns = []
command = [
'python3',
'adapters/pytorch/black_isort_linter.py',
'-m',
'lintrunner_adapters',
'run',
'black_isort_linter',
'--',
'@{{PATHSFILE}}'
]
init_command = [
'python3',
'adapters/pytorch/pip_init.py',
'-m',
'lintrunner_adapters',
'run',
'pip_init',
'--dry-run={{DRYRUN}}',
'black==22.10.0',
'isort==5.10.1',
Expand All @@ -146,14 +176,20 @@ exclude_patterns = [
]
command = [
'python3',
'adapters/pylint_linter.py',
'-m',
'lintrunner_adapters',
'run',
'pylint_linter',
'--rcfile=pyproject.toml',
'--',
'@{{PATHSFILE}}'
]
init_command = [
'python3',
'adapters/pytorch/pip_init.py',
'-m',
'lintrunner_adapters',
'run',
'pip_init',
'--dry-run={{DRYRUN}}',
'pylint==2.15.5',
]
81 changes: 81 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,84 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

----------
PyTorch LICENSE

From PyTorch:

Copyright (c) 2016- Facebook, Inc (Adam Paszke)
Copyright (c) 2014- Facebook, Inc (Soumith Chintala)
Copyright (c) 2011-2014 Idiap Research Institute (Ronan Collobert)
Copyright (c) 2012-2014 Deepmind Technologies (Koray Kavukcuoglu)
Copyright (c) 2011-2012 NEC Laboratories America (Koray Kavukcuoglu)
Copyright (c) 2011-2013 NYU (Clement Farabet)
Copyright (c) 2006-2010 NEC Laboratories America (Ronan Collobert, Leon Bottou, Iain Melvin, Jason Weston)
Copyright (c) 2006 Idiap Research Institute (Samy Bengio)
Copyright (c) 2001-2004 Idiap Research Institute (Ronan Collobert, Samy Bengio, Johnny Mariethoz)

From Caffe2:

Copyright (c) 2016-present, Facebook Inc. All rights reserved.

All contributions by Facebook:
Copyright (c) 2016 Facebook Inc.

All contributions by Google:
Copyright (c) 2015 Google Inc.
All rights reserved.

All contributions by Yangqing Jia:
Copyright (c) 2015 Yangqing Jia
All rights reserved.

All contributions by Kakao Brain:
Copyright 2019-2020 Kakao Brain

All contributions by Cruise LLC:
Copyright (c) 2022 Cruise LLC.
All rights reserved.

All contributions from Caffe:
Copyright(c) 2013, 2014, 2015, the respective contributors
All rights reserved.

All other contributions:
Copyright(c) 2015, 2016 the respective contributors
All rights reserved.

Caffe2 uses a copyright model similar to Caffe: each contributor holds
copyright over their contributions to Caffe2. The project versioning records
all such contribution and copyright details. If a contributor wants to further
mark their specific copyright on a particular contribution, they should
indicate their copyright solely in the commit message of the change when it is
committed.

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3. Neither the names of Facebook, Deepmind Technologies, NYU, NEC Laboratories America
and IDIAP Research Institute nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# lintrunner-adapters

[![Test](https://github.com/justinchuby/lintrunner-adapters/actions/workflows/test.yml/badge.svg)](https://github.com/justinchuby/lintrunner-adapters/actions/workflows/test.yml) [![Lint](https://github.com/justinchuby/lintrunner-adapters/actions/workflows/lint.yml/badge.svg)](https://github.com/justinchuby/lintrunner-adapters/actions/workflows/lint.yml) [![PyPI version](https://badge.fury.io/py/lintrunner-adapters.svg)](https://badge.fury.io/py/lintrunner-adapters)

Adapters for [lintrunner](https://github.com/suo/lintrunner)

## Usage

```text
Usage: python -m lintrunner_adapters [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
run Run an adapter.
to-sarif Convert the output of lintrunner json (INPUT) to SARIF (OUTPUT).
```
77 changes: 0 additions & 77 deletions adapters/pytorch/LICENSE

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# PyTorch LICENSE. See LICENSE file in the root directory of this source tree.

import argparse
import concurrent.futures
import json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Format file with black and isort."""

# PyTorch LICENSE. See LICENSE file in the root directory of this source tree.

import argparse
import concurrent.futures
import json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# PyTorch LICENSE. See LICENSE file in the root directory of this source tree.

import argparse
import concurrent.futures
import json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Checks that the configuration in .circleci/config.yml has been properly regenerated."""

# PyTorch LICENSE. See LICENSE file in the root directory of this source tree.

import argparse
import json
import logging
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# PyTorch LICENSE. See LICENSE file in the root directory of this source tree.

import argparse
import concurrent.futures
import json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# PyTorch LICENSE. See LICENSE file in the root directory of this source tree.

import argparse
import concurrent.futures
import json
Expand Down
Loading

0 comments on commit 2524f42

Please sign in to comment.