Skip to content

Commit

Permalink
github action python test static checks
Browse files Browse the repository at this point in the history
  • Loading branch information
p1c2u committed Feb 1, 2023
1 parent 0c2feaf commit a34963e
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 61 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,44 @@ jobs:

- name: Upload coverage
uses: codecov/codecov-action@v1

static-checks:
name: "Static checks"
runs-on: ubuntu-latest
steps:
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v2

- name: "Setup Python"
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Get full Python version
id: full-python-version
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")

- name: Bootstrap poetry
run: |
curl -sL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python - -y
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Configure poetry
run: poetry config virtualenvs.in-project true

- name: Set up cache
uses: actions/cache@v2
id: cache
with:
path: .venv
key: venv-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}

- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: timeout 10s poetry run pip --version || rm -rf .venv

- name: Install dependencies
run: poetry install

- name: Run static checks
run: poetry run pre-commit run -a
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repos:
- id: check-hooks-apply

- repo: https://github.com/asottile/pyupgrade
rev: v2.19.0
rev: v2.38.4
hooks:
- id: pyupgrade
args: ["--py36-plus"]
Expand Down
2 changes: 1 addition & 1 deletion openapi_schema_validator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from openapi_schema_validator._format import oas31_format_checker
from openapi_schema_validator.shortcuts import validate
from openapi_schema_validator.validators import OAS30ReadValidator
from openapi_schema_validator.validators import OAS30WriteValidator
from openapi_schema_validator.validators import OAS30Validator
from openapi_schema_validator.validators import OAS30WriteValidator
from openapi_schema_validator.validators import OAS31Validator

__author__ = "Artur Maciag"
Expand Down
5 changes: 1 addition & 4 deletions openapi_schema_validator/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,7 @@ def read_required(
prop_schema = schema.get("properties", {}).get(property)
if prop_schema:
write_only = prop_schema.get("writeOnly", False)
if (
getattr(validator, "read", True)
and write_only
):
if getattr(validator, "read", True) and write_only:
continue
yield ValidationError(f"{property!r} is a required property")

Expand Down
2 changes: 1 addition & 1 deletion openapi_schema_validator/validators.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import warnings
from typing import Any
from typing import Type
import warnings

from jsonschema import _legacy_validators
from jsonschema import _utils
Expand Down
Loading

0 comments on commit a34963e

Please sign in to comment.