Skip to content

Commit

Permalink
Add black, ruff, and isort to development toolchain. (#245)
Browse files Browse the repository at this point in the history
* Add black, ruff, and isort to development toolchain.

* Fix formatting.

* Simplify CI pipeline to use make.

* Fix order?

* Fix syntax for Makefile.

* Add some missing optional type hints.

* Add pre-commit config.

* Fix linting.

* Add .lift.toml.

* Some small formatting tweaks.

* Some tweaks for devx.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Tweaks to allow signed commits.

* Fix lintiing on docs.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
ivanklee86 and pre-commit-ci[bot] authored Apr 14, 2023
1 parent 1018068 commit 699ca31
Show file tree
Hide file tree
Showing 91 changed files with 1,788 additions and 1,434 deletions.
3 changes: 3 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ FROM mcr.microsoft.com/vscode/devcontainers/python:${VARIANT}
ARG NODE_VERSION="none"
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi

# Set up GPG
RUN apt-get update && apt-get install gnupg2 -y

# Update pip
RUN pip install -U pip
11 changes: 8 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"ritwickdey.LiveServer",
"ms-vscode.makefile-tools",
"bungcip.better-toml",
"ms-python.vscode-pylance"
"ms-python.vscode-pylance",
"ms-azuretools.vscode-docker"
]
}
},
Expand All @@ -60,6 +61,10 @@
},

// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
"remoteUser": "vscode",

// Merge .gitconfig
"remote": {

}
}

6 changes: 3 additions & 3 deletions .devcontainer/post_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ set -ex
sudo su - vscode bash -c "cd /workspaces/unleash-client-python; python -m venv .venv; source .venv/bin/activate; pip install -U -r requirements.txt; python setup.py install; ./get-spec.sh;"

# Install pre-config
# pip install pre-commit
# pre-commit install
# pre-commit
pip install pre-commit
pre-commit install
pre-commit

# Configure git
git config --global --add --bool push.autoSetupRemote true
Expand Down
1 change: 0 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[flake8]
ignore = E501
exclude = docs/source/conf.py,build,dist,__init__.py,tests/utilities/mocks/*

2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ Please describe the tests that you ran to verify your changes.
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
- [ ] Any dependent changes have been merged and published in downstream modules
16 changes: 4 additions & 12 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,13 @@ jobs:
python-version: "3.7"
- name: Install packages
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python setup.py install
make install
- name: Linting
run: |
mypy UnleashClient --install-types --non-interactive
pylint UnleashClient
- name: Unit tests
run: |
py.test tests/unit_tests
- name: Download test cases
run: git clone --depth 5 --branch v4.2.2 https://github.com/Unleash/client-specification.git tests/specification_tests/client-specification
- name: Specification tests
make lint
- name: Run tests
run: |
py.test --no-cov tests/specification_tests
make test
- name: Send coverage to Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_build/html
publish_dir: ./docs/_build/html
2 changes: 1 addition & 1 deletion .github/workflows/release-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.github_slack_token }}
SLACK_WEBHOOK_URL: ${{ secrets.slack_webhook }}
if: always()
if: always()
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ site
test_results
_static
_templates
tests/specification_tests/client-specification
tests/specification_tests/client-specification
1 change: 1 addition & 0 deletions .lift.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tools = ["shellcheck"]
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: 'v0.0.260'
hooks:
- id: ruff
args: [--fix]
1 change: 0 additions & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ 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.

11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ build-local: clean build-package

install:
pip install -U -r requirements.txt && \
./get-spec.sh && \
python setup.py install
python setup.py install && \
./get-spec.sh

#-----------------------------------------------------------------------
# Testing & Linting
#-----------------------------------------------------------------------
fmt:
black . && \
ruff UnleashClient tests --fix

lint:
pylint ${PROJECT_NAME} && \
black . --check && \
ruff UnleashClient tests docs && \
mypy ${PROJECT_NAME} --install-types --non-interactive;

pytest:
Expand Down
Loading

0 comments on commit 699ca31

Please sign in to comment.