Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
chore: Add isort to organize imports (#538)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgwerner committed Mar 22, 2021
1 parent 4ac5301 commit 0c8ac4d
Show file tree
Hide file tree
Showing 57 changed files with 180 additions and 200 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Expand Up @@ -6,4 +6,4 @@ docs
.git
dist
build
env.*
env.*
4 changes: 2 additions & 2 deletions .flake8
@@ -1,7 +1,7 @@

[flake8]
# Explicitly ignore rules to maintain better compatibility with black.
#
#
# F403: import *
# F811: redefinition of unused `name` from line `N`
# F841: local variable assigned but never used
Expand All @@ -11,7 +11,7 @@
# D400: first line should end with a period.
# E203: colons should not have any space before them.
# E231: missing whitespace after ','
# E501: line lengths are recommended to be no greater than 79 characters.
# E501: line lengths are recommended to be no greater than 79 characters.
# E503: there is no need for backslashes between brackets.
# W293: line break before binary operator
# W293: blank line contains whitespace
Expand Down
2 changes: 1 addition & 1 deletion .gitattributes
@@ -1 +1 @@
* text=auto eol=lf
* text=auto eol=lf
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Expand Up @@ -8,7 +8,7 @@ assignees: ''
---

**Describe the bug**
There are projects in production being created with the root user and group.
There are projects in production being created with the root user and group.

**To Reproduce**
Steps to reproduce the behavior:
Expand Down
3 changes: 1 addition & 2 deletions .github/config.yml
Expand Up @@ -6,7 +6,7 @@
newIssueWelcomeComment: >
Thanks for opening your first issue here! We would like to help you as efficiently as possible
so would very much appreciate if you use one of the provided Issue templates to document your feature,
o but report.
o but report.
# Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome

Expand All @@ -22,4 +22,3 @@ newPRWelcomeComment: >
# Comment to be posted to on pull requests merged by a first time user
firstPRMergeComment: >
Congrats on merging your first pull request! You are now an official IllumiDesk contributor :smile:!
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -36,4 +36,4 @@ share/jupyterhub/static/components
share/jupyterhub/static/css/style.min.css
share/jupyterhub/static/css/style.min.css.map
src/build*
venv
venv
8 changes: 8 additions & 0 deletions .isort.cfg
@@ -0,0 +1,8 @@
[settings]
profile=black
src_paths=src,test
known_illumidesk=illumidesk
sections=FUTURE,STDLIB,FIRSTPARTY,THIRDPARTY,ILLUMIDESK,LOCALFOLDER
known_third_party = Crypto,filelock,flask,flask_sqlalchemy,josepy,jupyterhub,jwcrypto,jwt,kubernetes,kubespawner,lti,ltiauthenticator,nbgrader,oauthenticator,oauthlib,pem,pytest,setuptools,sqlalchemy,sqlalchemy_utils,tornado,traitlets
multi_line_output=7
force_single_line=True
25 changes: 20 additions & 5 deletions .pre-commit-config.yaml
@@ -1,18 +1,33 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: check-yaml

- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
hooks:
- id: seed-isort-config

- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.7.0
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: stable
rev: 20.8b1
hooks:
- id: black
language_version: python3.8

- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.9
rev: 3.9.0
hooks:
- id: flake8

- repo: https://github.com/jazzband/pip-tools
rev: 5.3.1
rev: 6.0.1
hooks:
- id: pip-compile
files: ^requirements\.(in|txt)$
args: [--generate-hashes]
args: [--generate-hashes]
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -7,7 +7,7 @@ branches:
- production
notifications:
email: false

matrix:
include:
- language: python
Expand All @@ -20,4 +20,4 @@ matrix:
script:
- bash .travis/script.sh
after_success:
- bash .travis/after_success.sh
- bash .travis/after_success.sh
2 changes: 1 addition & 1 deletion .travis/after_success.sh
Expand Up @@ -11,4 +11,4 @@ main() {
upload_codecov
}

main
main
2 changes: 1 addition & 1 deletion .travis/before_install.sh
Expand Up @@ -26,4 +26,4 @@ main() {
setup_dependencies
}

main
main
2 changes: 1 addition & 1 deletion .travis/install.sh
Expand Up @@ -22,4 +22,4 @@ main() {
install_illumidesk_package
}

main
main
2 changes: 1 addition & 1 deletion .travis/script.sh
Expand Up @@ -27,4 +27,4 @@ main () {
run_coverage_report
}

main
main
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -323,4 +323,4 @@ All notable changes to this project will be documented in this file. See [standa

### Bug Fixes

* Update standard launch url for LTI 11 ([#6](https://github.com/IllumiDesk/illumidesk/issues/6)) ([736132a](https://github.com/IllumiDesk/illumidesk/commit/736132a971fcb7a7df2b77ee2392a07e0d39ea4a))
* Update standard launch url for LTI 11 ([#6](https://github.com/IllumiDesk/illumidesk/issues/6)) ([736132a](https://github.com/IllumiDesk/illumidesk/commit/736132a971fcb7a7df2b77ee2392a07e0d39ea4a))
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Expand Up @@ -83,6 +83,8 @@ For the most part, contributors do not need to worry about commit message format

### For Maintainers

#### Commits and merges

When squashing and merging to the `main` branch, use the following format to provide consistent updates to the `CHANGELOG.md` file:

<Commit Type>(scope): <Merge Description>
Expand Down Expand Up @@ -129,6 +131,16 @@ Examples:
BREAKING CHANGE: `extends` key in config file is now used for extending other config files
```

#### Pre-commit hooks

This repo includes the `pre-commit` setup with:

- black: code formatting
- flake8: python linter
- isort: imports organizer

To enable the pre-commit hook in your local environment,

**Updating the Changelog Format**

Refer to the official [`standard-version`](https://github.com/conventional-changelog/standard-version) docs to update the `CHANGELOG.md` template with additional options.
Expand Down
1 change: 1 addition & 0 deletions README.md
@@ -1,6 +1,7 @@
[![Build Status](https://travis-ci.com/IllumiDesk/illumidesk.svg?branch=main)](https://travis-ci.com/IllumiDesk/illumidesk)
[![codecov](https://codecov.io/gh/IllumiDesk/illumidesk/branch/main/graph/badge.svg)](https://codecov.io/gh/IllumiDesk/illumidesk)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
[![Code style black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

# IllumiDesk
Expand Down
6 changes: 3 additions & 3 deletions codecov.yml
Expand Up @@ -5,7 +5,7 @@ coverage:
tests:
target: 100%
paths: "src/tests/"
branches:
branches:
- main
if_not_found: success
if_ci_failed: error
Expand All @@ -15,9 +15,9 @@ coverage:
target: auto
threshold: 0%
base: auto
paths:
paths:
- "!src/tests/"
branches:
branches:
- main
if_not_found: success
if_ci_failed: error
Expand Down
1 change: 1 addition & 0 deletions dev-requirements.in
Expand Up @@ -5,6 +5,7 @@ flake8==3.8.4
flask==1.1.2
flask-sqlalchemy==2.5.1
gunicorn==20.0.4
isort==5.7.0
kubernetes==12.0.1
mock==4.0.2
pip-tools==5.4.0
Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Expand Up @@ -4,7 +4,6 @@ line-length = 119
target-version = ['py38']
include = '\.pyi?$'
exclude = '''
(
/(
\.eggs
Expand All @@ -16,9 +15,9 @@ exclude = '''
| \.vscode
| \.venv
| _build
| ansible
| build
| dist
)
)/
| pyproject.toml
)
'''
4 changes: 2 additions & 2 deletions pytest.ini
@@ -1,7 +1,7 @@
[pytest]
testpaths =
testpaths =
src/illumidesk/tests
python_files = test_*.py
markers =
group: mark as a test for groups
user: mark as a test for a users
user: mark as a test for a users
5 changes: 2 additions & 3 deletions src/grader-service/grader-service/__init__.py
Expand Up @@ -9,12 +9,11 @@
# 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.

from flask import Flask

import os

from .models import db
from flask import Flask

from .models import db

project_dir = os.path.dirname(os.path.abspath(__file__))
database_file = "sqlite:///{}".format(os.path.join(project_dir, "gradersetup.db.sqlite3"))
Expand Down
8 changes: 3 additions & 5 deletions src/grader-service/grader-service/grader_service.py
Expand Up @@ -13,18 +13,16 @@
import os
import shutil
import sys

from datetime import datetime
from pathlib import Path
from secrets import token_hex

from kubernetes import client
from kubernetes import config
from kubernetes.config import ConfigException

from pathlib import Path
from secrets import token_hex
from .constants import NBGRADER_HOME_CONFIG_TEMPLATE
from .constants import NBGRADER_COURSE_CONFIG_TEMPLATE

from .constants import NBGRADER_HOME_CONFIG_TEMPLATE

logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
logger = logging.getLogger(__name__)
Expand Down
13 changes: 5 additions & 8 deletions src/grader-service/grader-service/main.py
Expand Up @@ -13,22 +13,19 @@
import os
import shutil
import sys

from pathlib import Path
from secrets import token_hex

from flask import jsonify

from pathlib import Path

from illumidesk.grades.senders import LTIGradesSenderControlFile

from . import create_app
from .models import db
from .models import GraderService
from .grader_service import GraderServiceLauncher
from .grader_service import NB_UID
from .grader_service import NB_GID

from .grader_service import NB_UID
from .grader_service import GraderServiceLauncher
from .models import GraderService
from .models import db

logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
logger = logging.getLogger(__name__)
Expand Down
3 changes: 1 addition & 2 deletions src/grader-service/setup.py
@@ -1,9 +1,8 @@
import os
import sys

from setuptools import setup
from setuptools import find_packages

from setuptools import setup

v = sys.version_info
if v[:2] < (3, 6):
Expand Down
6 changes: 2 additions & 4 deletions src/illumidesk/illumidesk/apis/jupyterhub_api.py
@@ -1,15 +1,13 @@
import json
import os
from typing import Any
from typing import Awaitable

from tornado.httpclient import AsyncHTTPClient
from tornado.httpclient import HTTPClientError
from tornado.httpclient import HTTPResponse # noqa: F401

from traitlets.config import LoggingConfigurable

from typing import Any
from typing import Awaitable


class JupyterHubAPI(LoggingConfigurable):
"""
Expand Down
6 changes: 2 additions & 4 deletions src/illumidesk/illumidesk/apis/nbgrader_service.py
@@ -1,16 +1,14 @@
import logging
import os

from illumidesk.authenticators.utils import LTIUtils

from nbgrader.api import Assignment
from nbgrader.api import Course
from nbgrader.api import Gradebook
from nbgrader.api import InvalidEntry

from sqlalchemy_utils import database_exists
from sqlalchemy_utils import create_database
from sqlalchemy_utils import database_exists

from illumidesk.authenticators.utils import LTIUtils

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
Expand Down
2 changes: 0 additions & 2 deletions src/illumidesk/illumidesk/apis/setup_course_service.py
Expand Up @@ -3,10 +3,8 @@

from tornado.httpclient import AsyncHTTPClient
from tornado.httpclient import HTTPError

from traitlets.traitlets import Bool


# course setup service name
INTENAL_SERVICE_NAME = os.environ.get('SETUP_COURSE_SERVICE_NAME') or 'grader-setup-service'
# course setup service port
Expand Down

0 comments on commit 0c8ac4d

Please sign in to comment.