Merge pull request #87 from alufers/pre-commit-ci-update-config

[pre-commit.ci] pre-commit autoupdate
pull/112/head
Albert Koczy 12 months ago committed by GitHub
commit fe504307ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3,7 +3,7 @@
exclude: ^(api_protobuf/.*|docs/protobuf_docs\.md|dhaul_openapi/messages/.*)$ exclude: ^(api_protobuf/.*|docs/protobuf_docs\.md|dhaul_openapi/messages/.*)$
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0 rev: v4.5.0
hooks: hooks:
- id: check-yaml - id: check-yaml
- id: end-of-file-fixer - id: end-of-file-fixer
@ -16,7 +16,7 @@ repos:
- id: check-merge-conflict - id: check-merge-conflict
- id: check-added-large-files - id: check-added-large-files
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 23.7.0 rev: 23.11.0
hooks: hooks:
- id: black - id: black
args: [--config=pyproject.toml] args: [--config=pyproject.toml]
@ -25,7 +25,7 @@ repos:
hooks: hooks:
- id: isort - id: isort
- repo: https://github.com/pre-commit/mirrors-mypy - repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.4.1" rev: "v1.7.1"
hooks: hooks:
- id: mypy - id: mypy
- repo: https://github.com/PyCQA/docformatter - repo: https://github.com/PyCQA/docformatter
@ -36,28 +36,28 @@ repos:
- --in-place - --in-place
- --config=pyproject.toml - --config=pyproject.toml
- repo: https://github.com/PyCQA/autoflake - repo: https://github.com/PyCQA/autoflake
rev: v2.2.0 rev: v2.2.1
hooks: hooks:
- id: autoflake - id: autoflake
- repo: https://github.com/pycqa/flake8 - repo: https://github.com/pycqa/flake8
rev: 6.0.0 rev: 6.1.0
hooks: hooks:
- id: flake8 - id: flake8
entry: pflake8 entry: pflake8
additional_dependencies: [pyproject-flake8] additional_dependencies: [pyproject-flake8]
- repo: https://github.com/netromdk/vermin - repo: https://github.com/netromdk/vermin
rev: v1.5.2 rev: v1.6.0
hooks: hooks:
- id: vermin - id: vermin
# specify your target version here, OR in a Vermin config file as usual: # specify your target version here, OR in a Vermin config file as usual:
args: ["-t=3.9-", "--violations"] args: ["-t=3.9-", "--violations"]
# (if your target is specified in a Vermin config, you may omit the 'args' entry entirely) # (if your target is specified in a Vermin config, you may omit the 'args' entry entirely)
- repo: https://github.com/adrienverge/yamllint.git - repo: https://github.com/adrienverge/yamllint.git
rev: v1.32.0 rev: v1.33.0
hooks: hooks:
- id: yamllint - id: yamllint
- repo: https://github.com/igorshubovych/markdownlint-cli - repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.35.0 rev: v0.37.0
hooks: hooks:
- id: markdownlint-fix - id: markdownlint-fix
- id: markdownlint - id: markdownlint

@ -111,22 +111,22 @@ def response_to_headers(headers):
def value_to_schema(value): def value_to_schema(value):
# check if value is a number # check if value is a number
if type(value) == int or type(value) == float: if isinstance(value, (int, float)):
return {"type": "number"} return {"type": "number"}
# check if value is a boolean # check if value is a boolean
elif type(value) == bool: elif isinstance(value, bool):
return {"type": "boolean"} return {"type": "boolean"}
# check if value is a string # check if value is a string
elif type(value) == str: elif isinstance(value, str):
return {"type": "string"} return {"type": "string"}
# check if value is a list # check if value is a list
elif type(value) == list: elif isinstance(value, list):
if len(value) == 0: if len(value) == 0:
return {"type": "array", "items": {}} return {"type": "array", "items": {}}
return {"type": "array", "items": value_to_schema(value[0])} return {"type": "array", "items": value_to_schema(value[0])}
# check if value is a dict # check if value is a dict
elif type(value) == dict: elif isinstance(value, dict):
return { return {
"type": "object", "type": "object",
"properties": {key: value_to_schema(value[key]) for key in value}, "properties": {key: value_to_schema(value[key]) for key in value},
@ -142,14 +142,14 @@ MAX_EXAMPLE_OBJECT_PROPERTIES = 150
# recursively scan an example value and limit the number of elements and properties # recursively scan an example value and limit the number of elements and properties
def limit_example_size(example): def limit_example_size(example):
if type(example) == list: if isinstance(example, list):
new_list = [] new_list = []
for element in example: for element in example:
if len(new_list) >= MAX_EXAMPLE_ARRAY_ELEMENTS: if len(new_list) >= MAX_EXAMPLE_ARRAY_ELEMENTS:
break break
new_list.append(limit_example_size(element)) new_list.append(limit_example_size(element))
return new_list return new_list
elif type(example) == dict: elif isinstance(example, dict):
new_dict = {} new_dict = {}
for key in example: for key in example:
if len(new_dict) >= MAX_EXAMPLE_OBJECT_PROPERTIES: if len(new_dict) >= MAX_EXAMPLE_OBJECT_PROPERTIES:

Loading…
Cancel
Save