migrate to use black as opinionated auto formater

This commit is contained in:
Christoph Ladurner
2022-05-10 10:10:37 +02:00
committed by Mojib Wali
parent 4fd0501c58
commit 903498185f
7 changed files with 22 additions and 54 deletions

View File

@@ -15,15 +15,6 @@ insert_final_newline = true
trim_trailing_whitespace = true trim_trailing_whitespace = true
charset = utf-8 charset = utf-8
# Python files
[*.py]
indent_size = 4
# isort plugin configuration
known_first_party = invenio_theme_tugraz
multi_line_output = 2
default_section = THIRDPARTY
skip = .eggs
# RST files (used by sphinx) # RST files (used by sphinx)
[*.rst] [*.rst]
indent_size = 4 indent_size = 4

View File

@@ -44,9 +44,9 @@ source_suffix = ".rst"
master_doc = "index" master_doc = "index"
# General information about the project. # General information about the project.
project = u"invenio-theme-tugraz" project = "invenio-theme-tugraz"
copyright = u"2020, Graz University of Technology" copyright = "2020, Graz University of Technology"
author = u"Graz University of Technology" author = "Graz University of Technology"
# The version info for the project you're documenting, acts as replacement for # The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the # |version| and |release|, also used in various other places throughout the
@@ -241,8 +241,8 @@ latex_documents = [
( (
master_doc, master_doc,
"invenio-theme-tugraz.tex", "invenio-theme-tugraz.tex",
u"invenio-theme-tugraz Documentation", "invenio-theme-tugraz Documentation",
u"Graz University of Technology", "Graz University of Technology",
"manual", "manual",
), ),
] ]
@@ -276,7 +276,7 @@ man_pages = [
( (
master_doc, master_doc,
"invenio-theme-tugraz", "invenio-theme-tugraz",
u"invenio-theme-tugraz Documentation", "invenio-theme-tugraz Documentation",
[author], [author],
1, 1,
) )
@@ -295,7 +295,7 @@ texinfo_documents = [
( (
master_doc, master_doc,
"invenio-theme-tugraz", "invenio-theme-tugraz",
u"invenio-theme-tugraz Documentation", "invenio-theme-tugraz Documentation",
author, author,
"invenio-theme-tugraz", "invenio-theme-tugraz",
"invenio module for TUGRAZ theme.", "invenio module for TUGRAZ theme.",

View File

@@ -16,9 +16,7 @@ INVENIO_THEME_TUGRAZ_DEFAULT_VALUE = _("TU Graz Repository")
INVENIO_THEME_TUGRAZ_BASE_TEMPLATE = "invenio_theme_tugraz/base.html" INVENIO_THEME_TUGRAZ_BASE_TEMPLATE = "invenio_theme_tugraz/base.html"
"""TU Graz Default base template""" """TU Graz Default base template"""
INVENIO_THEME_TUGRAZ_ACCOUNT_BASE = ( INVENIO_THEME_TUGRAZ_ACCOUNT_BASE = "invenio_theme_tugraz/accounts/accounts_base.html"
"invenio_theme_tugraz/accounts/accounts_base.html"
)
"""TU Graz Default account base template""" """TU Graz Default account base template"""
INVENIO_THEME_TUGRAZ_ICON = "images/icon_use.png" INVENIO_THEME_TUGRAZ_ICON = "images/icon_use.png"
@@ -75,9 +73,7 @@ THEME_SITENAME = _("Repository")
SECURITY_LOGIN_USER_TEMPLATE = "invenio_theme_tugraz/accounts/login_user.html" SECURITY_LOGIN_USER_TEMPLATE = "invenio_theme_tugraz/accounts/login_user.html"
"""Login template""" """Login template"""
SECURITY_REGISTER_USER_TEMPLATE = ( SECURITY_REGISTER_USER_TEMPLATE = "invenio_theme_tugraz/accounts/register_user.html"
"invenio_theme_tugraz/accounts/register_user.html"
)
"""Sigup template""" """Sigup template"""
# Invenio-app-rdm # Invenio-app-rdm

View File

@@ -20,5 +20,6 @@ class FrontpageRecordsSearch(RecordsSearch):
index = "rdmrecords-records" index = "rdmrecords-records"
default_filter = Q( default_filter = Q(
"query_string", query=( "query_string",
"access.record:public " "AND versions.is_latest:true")) query=("access.record:public " "AND versions.is_latest:true"),
)

View File

@@ -51,7 +51,9 @@ def records_serializer(records=None):
"""Serialize list of records.""" """Serialize list of records."""
record_list = [] record_list = []
for record in records: for record in records:
record_list.append(UIJSONSerializer().serialize_object_to_dict(record.to_dict())) record_list.append(
UIJSONSerializer().serialize_object_to_dict(record.to_dict())
)
return record_list return record_list
@@ -60,8 +62,7 @@ def index():
records = FrontpageRecordsSearch()[:5].sort("-created").execute() records = FrontpageRecordsSearch()[:5].sort("-created").execute()
return render_template( return render_template(
"invenio_theme_tugraz/index.html", "invenio_theme_tugraz/index.html", records=records_serializer(records)
records=records_serializer(records)
) )

View File

@@ -1,12 +0,0 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2020-2021 Graz University of Technology.
#
# invenio-theme-tugraz is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see LICENSE file for more
# details.
[pytest]
addopts = --isort --pydocstyle --pycodestyle --doctest-glob="*.rst" --doctest-modules --cov=invenio_theme_tugraz --cov-report=term-missing tests invenio_theme_tugraz
testpaths = tests invenio_theme_tugraz
live_server_scope = module

View File

@@ -44,6 +44,7 @@ install_requires =
[options.extras_require] [options.extras_require]
tests = tests =
pytest-black>=0.3.0,<0.3.10
sphinx>=4.2.0,<5 sphinx>=4.2.0,<5
pytest-invenio>=1.4.7 pytest-invenio>=1.4.7
invenio-app>=1.3.0,<2.0.0 invenio-app>=1.3.0,<2.0.0
@@ -94,20 +95,10 @@ output-dir = invenio_theme_tugraz/translations/
[update_catalog] [update_catalog]
input-file = invenio_theme_tugraz/translations/messages.pot input-file = invenio_theme_tugraz/translations/messages.pot
output-dir = invenio_theme_tugraz/translations/ output-dir = invenio_theme_tugraz/translations/
[flake8]
max-line-length = 88
extend-ignore = E203
select = C,E,F,W,B,B950
ignore = E501
[isort] [isort]
multi_line_output = 3 profile=black
include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True
ensure_newline_before_comments = True
line_length = 88
[pycodestyle] [tool:pytest]
ignore = E203,E501 addopts = --black --isort --pydocstyle --doctest-glob="*.rst" --doctest-modules --cov=invenio_theme_tugraz --cov-report=term-missing tests invenio_theme_tugraz
testpaths = tests invenio_theme_tugraz
live_server_scope = module