Skip to content

Commit

Permalink
fix: Fix flake8 style code problems
Browse files Browse the repository at this point in the history
  • Loading branch information
drorganvidez committed Mar 24, 2024
1 parent 847d26b commit dcfb764
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length = 120
2 changes: 1 addition & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
import importlib.util

from flask import Flask, render_template, Blueprint, flash, redirect, url_for
from flask import Flask, render_template, Blueprint
from flask_login import current_user
from flask_sqlalchemy import SQLAlchemy
from dotenv import load_dotenv
Expand Down
Empty file removed app/blueprints/__init__.py
Empty file.
1 change: 0 additions & 1 deletion app/blueprints/auth/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from flask import Blueprint

auth_bp = Blueprint('auth', __name__, template_folder='templates')

2 changes: 1 addition & 1 deletion app/blueprints/auth/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def login():
login_user(user, remember=form.remember_me.data)
return redirect(url_for('public.index'))
else:
error = f'Invalid credentials'
error = 'Invalid credentials'
return render_template("auth/login_form.html", form=form, error=error)

return render_template('auth/login_form.html', form=form)
Expand Down
1 change: 0 additions & 1 deletion app/blueprints/dataset/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ class DataSetForm(FlaskForm):
tags = StringField('Tags (separated by commas)')
authors = FieldList(FormField(AuthorForm))
submit = SubmitField('Submit')

19 changes: 15 additions & 4 deletions app/blueprints/dataset/models.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from collections import OrderedDict
from datetime import datetime

from flask import request

from app import db
from enum import Enum
from sqlalchemy import Enum as SQLAlchemyEnum, inspect
from sqlalchemy import Enum as SQLAlchemyEnum

import os


class PublicationType(Enum):
NONE = 'none'
ANNOTATION_COLLECTION = 'annotationcollection'
Expand Down Expand Up @@ -197,7 +198,12 @@ class DSDownloadRecord(db.Model):
download_cookie = db.Column(db.String(36), nullable=False) # Assuming UUID4 strings

def __repr__(self):
return f'<Download id={self.id} dataset_id={self.dataset_id} date={self.download_date} cookie={self.download_cookie}>'
return (
f'<Download id={self.id} '
f'dataset_id={self.dataset_id} '
f'date={self.download_date} '
f'cookie={self.download_cookie}>'
)


class DSViewRecord(db.Model):
Expand All @@ -219,7 +225,12 @@ class FileDownloadRecord(db.Model):
download_cookie = db.Column(db.String(36), nullable=False) # Assuming UUID4 strings

def __repr__(self):
return f'<FileDownload id={self.id} file_id={self.file_id} date={self.download_date} cookie={self.download_cookie}>'
return (
f'<FileDownload id={self.id} '
f'file_id={self.file_id} '
f'date={self.download_date} '
f'cookie={self.download_cookie}>'
)


def get_human_readable_size(size):
Expand Down
6 changes: 3 additions & 3 deletions app/blueprints/dataset/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def create_dataset():
deposition_doi = zenodo_get_doi(deposition_id)
dataset.ds_meta_data.dataset_doi = deposition_doi
app.db.session.commit()
except Exception as e:
except Exception:
pass

# move feature models permanently
Expand Down Expand Up @@ -478,7 +478,7 @@ def api_create_dataset():
PART 2: SAVE BASIC DATA
"""
ds_meta_data = _create_ds_meta_data(info=info)
authors = _create_authors(info=info, ds_meta_data=ds_meta_data)
_create_authors(info=info, ds_meta_data=ds_meta_data)
dataset = _create_dataset(user=user, ds_meta_data=ds_meta_data)

"""
Expand Down Expand Up @@ -713,4 +713,4 @@ def subdomain_index(doi):
# Por ejemplo, mostrar un error 404 o redirigir a una página de error
return "Dataset no encontrado", 404

abort(404)
abort(404)
2 changes: 1 addition & 1 deletion app/blueprints/profile/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ class UserProfile(db.Model):
def save(self):
if not self.id:
db.session.add(self)
db.session.commit()
db.session.commit()
2 changes: 1 addition & 1 deletion app/blueprints/profile/routes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask import request, render_template, flash, redirect, url_for, current_app
from flask import request, render_template
from flask_login import login_required

from app.blueprints.profile import profile_bp
Expand Down
2 changes: 0 additions & 2 deletions app/blueprints/profile/services.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from app.blueprints.profile.repositories import UserProfileRepository
from app.services.BaseService import BaseService

from flask import current_app


class UserProfileService(BaseService):
def __init__(self):
Expand Down
2 changes: 1 addition & 1 deletion app/blueprints/public/routes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import app

from flask import request, current_app, render_template, Blueprint
from flask import render_template
from app.blueprints.public import public_bp
from ..dataset.models import DataSet, DSMetaData

Expand Down
1 change: 0 additions & 1 deletion app/blueprints/team/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from flask import Blueprint

team_bp = Blueprint('team', __name__, template_folder='templates')

2 changes: 1 addition & 1 deletion app/services/BaseService.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ def handle_service_response(self, result, errors, success_url_redirect, success_
for error_field, error_messages in errors.items():
for error_message in error_messages:
flash(f'{error_field}: {error_message}', 'error')
return render_template(error_template, form=form)
return render_template(error_template, form=form)
2 changes: 1 addition & 1 deletion app/zenodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_full_zenodo_connection() -> Response:

# Create an empty file
file_path = os.path.join(current_app.root_path, "test_file.txt")
with open(file_path, 'w') as file:
with open(file_path, 'w'):
pass

messages = [] # List to store messages
Expand Down

0 comments on commit dcfb764

Please sign in to comment.