diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 4e5e1d5..0000000 --- a/.flake8 +++ /dev/null @@ -1,4 +0,0 @@ -[flake8] -exclude = .git,venv -max-line-length = 80 -max-complexity = 12 diff --git a/.gitignore b/.gitignore index 6ca00d7..157226e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,10 +4,14 @@ __pycache__/ *$py.class # Environments -.env -!example.env venv/ +# Config +*.env +!example.env +*.tfvars +!example.tfvars + # Data *.csv diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e1a1cd3..35e579d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,6 +40,7 @@ repos: rev: 6.0.0 hooks: - id: flake8 + additional_dependencies: [Flake8-pyproject] # Lint code for types - repo: https://github.com/pre-commit/mirrors-mypy rev: v0.991 diff --git a/deployment/terraform/cloud_function.tf b/deployment/terraform/cloud_function.tf index 3a95020..f70e37e 100644 --- a/deployment/terraform/cloud_function.tf +++ b/deployment/terraform/cloud_function.tf @@ -11,7 +11,6 @@ data "archive_file" "zip_code_repo" { "venv", ".env", "example.env", - ".flake8", ".gitignore", ".pre-commit-config.yaml", "CONTRIBUTING.md", diff --git a/dqm.py b/dqm.py deleted file mode 100644 index bcd133f..0000000 --- a/dqm.py +++ /dev/null @@ -1,24 +0,0 @@ -""" -Copyright 2022 Google LLC - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on 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 -from flask_pydantic import validate - -from routes.process_column import process_column - -dqm = Flask(__name__) - -dqm.route('/process_column', methods=['POST'])(validate()(process_column)) diff --git a/main.py b/main.py index 0ce3b16..cbd6e16 100644 --- a/main.py +++ b/main.py @@ -13,6 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. """ +from flask import Flask +from flask_pydantic import validate from functions_wrapper import entrypoint from werkzeug.exceptions import HTTPException @@ -20,7 +22,11 @@ from core.http import handle_malformed_config from core.http import handle_server_error from core.http import MalformedConfigError -from dqm import dqm +from routes.process_column import process_column + +dqm = Flask(__name__) + +dqm.route('/process_column', methods=['POST'])(validate()(process_column)) dqm.register_error_handler(MalformedConfigError, handle_malformed_config) dqm.register_error_handler(HTTPException, handle_http_error) diff --git a/pyproject.toml b/pyproject.toml index b093055..fd813c2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,19 @@ +[tool.flake8] +exclude = [ + ".git/", + "venv/", +] +max-line-length = 80 +max-complexity = 12 + [tool.isort] profile = "google" [tool.mypy] python_version = "3.10" exclude = [ - '.git/', # git - 'venv/', # virtualenv + '.git/', + 'venv/', ] check_untyped_defs = true # Google libraries lack type hints diff --git a/requirements-dev.txt b/requirements-dev.txt index 4093c0d..c7e1a8e 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,6 @@ faker==15.3.4 flake8==5.0.4 +Flake8-pyproject==1.2.2 isort==5.10.1 mypy==0.971 mypy-extensions==0.4.3