From c554194fb5ef1bb867fc0e36c09d2cdcca6eefb2 Mon Sep 17 00:00:00 2001 From: Finn Christiansen Date: Fri, 11 Oct 2024 22:31:28 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=9A=20Fix=20PEP8=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + app/__init__.py | 4 ---- app/resources/__init__.py | 1 - app/resources/impulses.py | 1 - app/schemas/namespacedSchema.py | 3 --- migrations/versions/925f94e2acd6_.py | 12 ++++++------ powermeter.py | 6 +++--- 7 files changed, 10 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index a137123..ac98241 100644 --- a/.gitignore +++ b/.gitignore @@ -70,3 +70,4 @@ pip-selfcheck.json # custom tags .env +.mypy_cache diff --git a/app/__init__.py b/app/__init__.py index 436b174..733da2c 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -3,12 +3,10 @@ from flask_smorest import Api from flask_marshmallow import Marshmallow from flask_sqlalchemy import SQLAlchemy from flask_migrate import Migrate -#from flask_jwt_extended import JWTManager db = SQLAlchemy() ma = Marshmallow() -#jwt = JWTManager() def create_app(cfg='default'): @@ -26,9 +24,7 @@ def create_app(cfg='default'): api.init_app(app) db.init_app(app) ma.init_app(app) - #jwt.init_app(app) Migrate(app, db) resources.register_blueprints(api) return app - diff --git a/app/resources/__init__.py b/app/resources/__init__.py index 3b2634e..688ddfe 100644 --- a/app/resources/__init__.py +++ b/app/resources/__init__.py @@ -11,4 +11,3 @@ def register_blueprints(api): api.register_blueprint(resource_blp, url_prefix=f'/{resource_blp.url_prefix}') - diff --git a/app/resources/impulses.py b/app/resources/impulses.py index 5ad747a..509ba4a 100644 --- a/app/resources/impulses.py +++ b/app/resources/impulses.py @@ -32,4 +32,3 @@ class ImpulseById(MethodView): impulse = Impulse.query.filter_by(id=impulse_id).first() db.session.delete(impulse) db.session.commit() - diff --git a/app/schemas/namespacedSchema.py b/app/schemas/namespacedSchema.py index a45b2c1..87aecda 100644 --- a/app/schemas/namespacedSchema.py +++ b/app/schemas/namespacedSchema.py @@ -1,7 +1,6 @@ from marshmallow import SchemaOpts from marshmallow import pre_load, post_dump from marshmallow_sqlalchemy import ModelSchemaOpts, ModelConverter, ModelSchema -from .. import ma from .. import db @@ -23,7 +22,6 @@ class NamespaceOpts(ModelSchemaOpts): self.include_relationships = True -#class NamespacedSchema(ma.SQLAlchemySchema): class NamespacedSchema(ModelSchema): OPTIONS_CLASS = NamespaceOpts @@ -42,4 +40,3 @@ class NamespacedSchema(ModelSchema): else: key = self.opts.plural_name if many else self.opts.name return {key: data} - diff --git a/migrations/versions/925f94e2acd6_.py b/migrations/versions/925f94e2acd6_.py index 4eeed14..886e3ba 100644 --- a/migrations/versions/925f94e2acd6_.py +++ b/migrations/versions/925f94e2acd6_.py @@ -1,7 +1,7 @@ """empty message Revision ID: 925f94e2acd6 -Revises: +Revises: Create Date: 2021-01-23 21:09:25.068512 """ @@ -19,11 +19,11 @@ depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('impulse', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('power', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.PrimaryKeyConstraint('id') - ) + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('power', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.PrimaryKeyConstraint('id') + ) # ### end Alembic commands ### diff --git a/powermeter.py b/powermeter.py index 4b8c68a..534414e 100755 --- a/powermeter.py +++ b/powermeter.py @@ -4,8 +4,8 @@ import time import datetime import requests -import influxdb_client, os -from influxdb_client import InfluxDBClient, Point, WritePrecision +import influxdb_client +import os from influxdb_client.client.write_api import SYNCHRONOUS @@ -42,7 +42,7 @@ def flaskapp(): def influxdb(): point = ( - Point("electricity") + influxdb_client.Point("electricity") .field("consumption", 2) ) write_api.write(bucket=bucket, org="finn", record=point)