Skip to content

Commit fd60809

Browse files
authored
ci: Fix tests and add pre-commit (#1306)
* ci: Added app configs to test apps * ci: fix paths to test apps * ci: linter fix * ci: sync line length between isort & flake8 * ci: added pre-commit config * ci: Remove pyupgrade and django upgrade for now. * ci: Pre-commit ran for flake8 & isort * ci: linter fix
1 parent 6a4706d commit fd60809

File tree

21 files changed

+134
-90
lines changed

21 files changed

+134
-90
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
uses: actions/setup-python@v2
1414
with:
1515
python-version: 3.9
16-
- name: Install flate8
16+
- name: Install flake8
1717
run: pip install --upgrade flake8
1818
- name: Run flake8
1919
uses: liskin/gh-problem-matcher-wrap@v1

.pre-commit-config.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
ci:
2+
autofix_commit_msg: |
3+
ci: auto fixes from pre-commit hooks
4+
5+
for more information, see https://pre-commit.ci
6+
autofix_prs: false
7+
autoupdate_commit_msg: 'ci: pre-commit autoupdate'
8+
autoupdate_schedule: monthly
9+
10+
repos:
11+
# - repo: https://github.com/asottile/pyupgrade
12+
# rev: v2.37.3
13+
# hooks:
14+
# - id: pyupgrade
15+
# args: ["--py36-plus"]
16+
#
17+
# - repo: https://github.com/adamchainz/django-upgrade
18+
# rev: '1.7.0'
19+
# hooks:
20+
# - id: django-upgrade
21+
# args: [--target-version, "2.2"]
22+
23+
- repo: https://github.com/PyCQA/flake8
24+
rev: 5.0.2
25+
hooks:
26+
- id: flake8
27+
28+
- repo: https://github.com/asottile/yesqa
29+
rev: v1.3.0
30+
hooks:
31+
- id: yesqa
32+
33+
- repo: https://github.com/pre-commit/pre-commit-hooks
34+
rev: v4.3.0
35+
hooks:
36+
- id: check-merge-conflict
37+
- id: mixed-line-ending
38+
39+
- repo: https://github.com/pycqa/isort
40+
rev: 5.10.1
41+
hooks:
42+
- id: isort

aldryn_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class Form(forms.BaseForm):
55

66
def to_settings(self, data, settings):
77
from functools import partial
8+
89
from aldryn_addons.utils import boolean_ish, djsenv
910
from aldryn_django import storage
1011

docs/conf.py

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,21 @@
1414
import os
1515
import sys
1616

17+
1718
sys.path.append(os.path.abspath('../'))
1819

19-
from filer import __version__
20+
from filer import __version__ # NOQA
21+
2022

2123
# If extensions (or modules to document with autodoc) are in another directory,
2224
# add these directories to sys.path here. If the directory is relative to the
2325
# documentation root, use os.path.abspath to make it absolute, like shown here.
24-
#sys.path.append(os.path.abspath('.'))
26+
# sys.path.append(os.path.abspath('.'))
2527

2628
# -- General configuration -----------------------------------------------------
2729

2830
# If your documentation needs a minimal Sphinx version, state it here.
29-
#needs_sphinx = '1.0'
31+
# needs_sphinx = '1.0'
3032

3133
# Add any Sphinx extension module names here, as strings. They can be extensions
3234
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
@@ -48,7 +50,7 @@
4850
source_suffix = '.rst'
4951

5052
# The encoding of source files.
51-
#source_encoding = 'utf-8-sig'
53+
# source_encoding = 'utf-8-sig'
5254

5355
# The master toctree document.
5456
master_doc = 'index'
@@ -68,37 +70,37 @@
6870

6971
# The language for content autogenerated by Sphinx. Refer to documentation
7072
# for a list of supported languages.
71-
#language = None
73+
# language = None
7274

7375
# There are two options for replacing |today|: either, you set today to some
7476
# non-false value, then it is used:
75-
#today = ''
77+
# today = ''
7678
# Else, today_fmt is used as the format for a strftime call.
77-
#today_fmt = '%B %d, %Y'
79+
# today_fmt = '%B %d, %Y'
7880

7981
# List of patterns, relative to source directory, that match files and
8082
# directories to ignore when looking for source files.
8183
exclude_patterns = ['_build', '_images', 'README.rst']
8284

8385
# The reST default role (used for this markup: `text`) to use for all documents.
84-
#default_role = None
86+
# default_role = None
8587

8688
# If true, '()' will be appended to :func: etc. cross-reference text.
87-
#add_function_parentheses = True
89+
# add_function_parentheses = True
8890

8991
# If true, the current module name will be prepended to all description
9092
# unit titles (such as .. function::).
91-
#add_module_names = True
93+
# add_module_names = True
9294

9395
# If true, sectionauthor and moduleauthor directives will be shown in the
9496
# output. They are ignored by default.
95-
#show_authors = False
97+
# show_authors = False
9698

9799
# The name of the Pygments (syntax highlighting) style to use.
98100
pygments_style = 'sphinx'
99101

100102
# A list of ignored prefixes for module index sorting.
101-
#modindex_common_prefix = []
103+
# modindex_common_prefix = []
102104

103105

104106
# -- Options for HTML output ---------------------------------------------------
@@ -111,27 +113,27 @@
111113
# further. For a list of options available for each theme, see the
112114
# documentation.
113115
html_theme_options = {
114-
"navigation_with_keys": True,
116+
"navigation_with_keys": True,
115117
}
116118

117119
# Add any paths that contain custom themes here, relative to this directory.
118-
#html_theme_path = []
120+
# html_theme_path = []
119121

120122
# The name for this set of Sphinx documents. If None, it defaults to
121123
# "<project> v<release> documentation".
122-
#html_title = None
124+
# html_title = None
123125

124126
# A shorter title for the navigation bar. Default is the same as html_title.
125-
#html_short_title = None
127+
# html_short_title = None
126128

127129
# The name of an image file (relative to this directory) to place at the top
128130
# of the sidebar.
129-
#html_logo = None
131+
# html_logo = None
130132

131133
# The name of an image file (within the static path) to use as favicon of the
132134
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
133135
# pixels large.
134-
#html_favicon = None
136+
# html_favicon = None
135137

136138
# Add any paths that contain custom static files (such as style sheets) here,
137139
# relative to this directory. They are copied after the builtin static files,
@@ -140,44 +142,44 @@
140142

141143
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
142144
# using the given strftime format.
143-
#html_last_updated_fmt = '%b %d, %Y'
145+
# html_last_updated_fmt = '%b %d, %Y'
144146

145147
# If true, SmartyPants will be used to convert quotes and dashes to
146148
# typographically correct entities.
147-
#html_use_smartypants = True
149+
# html_use_smartypants = True
148150

149151
# Custom sidebar templates, maps document names to template names.
150-
#html_sidebars = {}
152+
# html_sidebars = {}
151153

152154
# Additional templates that should be rendered to pages, maps page names to
153155
# template names.
154-
#html_additional_pages = {}
156+
# html_additional_pages = {}
155157

156158
# If false, no module index is generated.
157-
#html_domain_indices = True
159+
# html_domain_indices = True
158160

159161
# If false, no index is generated.
160-
#html_use_index = True
162+
# html_use_index = True
161163

162164
# If true, the index is split into individual pages for each letter.
163-
#html_split_index = False
165+
# html_split_index = False
164166

165167
# If true, links to the reST sources are added to the pages.
166-
#html_show_sourcelink = True
168+
# html_show_sourcelink = True
167169

168170
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
169-
#html_show_sphinx = True
171+
# html_show_sphinx = True
170172

171173
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
172-
#html_show_copyright = True
174+
# html_show_copyright = True
173175

174176
# If true, an OpenSearch description file will be output, and all pages will
175177
# contain a <link> tag referring to it. The value of this option must be the
176178
# base URL from which the finished HTML is served.
177-
#html_use_opensearch = ''
179+
# html_use_opensearch = ''
178180

179181
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
180-
#html_file_suffix = ''
182+
# html_file_suffix = ''
181183

182184
# Output file base name for HTML help builder.
183185
htmlhelp_basename = 'django-filerdoc'
@@ -186,49 +188,47 @@
186188
# -- Options for LaTeX output --------------------------------------------------
187189

188190
# The paper size ('letter' or 'a4').
189-
#latex_paper_size = 'letter'
191+
# latex_paper_size = 'letter'
190192

191193
# The font size ('10pt', '11pt' or '12pt').
192-
#latex_font_size = '10pt'
194+
# latex_font_size = '10pt'
193195

194196
# Grouping the document tree into LaTeX files. List of tuples
195197
# (source start file, target name, title, author, documentclass [howto/manual]).
196198
latex_documents = [
197-
('index', 'django-filer.tex', 'django-filer Documentation',
198-
'Stefan Foulis', 'manual'),
199+
('index', 'django-filer.tex', 'django-filer Documentation', 'Stefan Foulis', 'manual'),
199200
]
200201

201202
# The name of an image file (relative to this directory) to place at the top of
202203
# the title page.
203-
#latex_logo = None
204+
# latex_logo = None
204205

205206
# For "manual" documents, if this is true, then toplevel headings are parts,
206207
# not chapters.
207-
#latex_use_parts = False
208+
# latex_use_parts = False
208209

209210
# If true, show page references after internal links.
210-
#latex_show_pagerefs = False
211+
# latex_show_pagerefs = False
211212

212213
# If true, show URL addresses after external links.
213-
#latex_show_urls = False
214+
# latex_show_urls = False
214215

215216
# Additional stuff for the LaTeX preamble.
216-
#latex_preamble = ''
217+
# latex_preamble = ''
217218

218219
# Documents to append as an appendix to all manuals.
219-
#latex_appendices = []
220+
# latex_appendices = []
220221

221222
# If false, no module index is generated.
222-
#latex_domain_indices = True
223+
# latex_domain_indices = True
223224

224225

225226
# -- Options for manual page output --------------------------------------------
226227

227228
# One entry per manual page. List of tuples
228229
# (source start file, name, description, authors, manual section).
229230
man_pages = [
230-
('index', 'django-filer', u'django-filer Documentation',
231-
[u'Stefan Foulis'], 1)
231+
('index', 'django-filer', 'django-filer Documentation', ['Stefan Foulis'], 1)
232232
]
233233

234234

@@ -237,4 +237,4 @@
237237

238238
images_config = {
239239
'override_image_directive': True,
240-
}
240+
}

filer/admin/folderadmin.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@
2323
from django.utils.translation import ngettext_lazy
2424

2525
from .. import settings
26-
from ..models import (
27-
File, Folder, FolderPermission, FolderRoot, ImagesWithMissingData,
28-
UnsortedImages, tools,
29-
)
26+
from ..models import File, Folder, FolderPermission, FolderRoot, ImagesWithMissingData, UnsortedImages, tools
3027
from ..settings import FILER_IMAGE_MODEL, FILER_PAGINATE_BY
3128
from ..thumbnail_processors import normalize_subject_location
3229
from ..utils.compatibility import get_delete_permission
@@ -37,9 +34,8 @@
3734
from .patched.admin_utils import get_deleted_objects
3835
from .permissions import PrimitivePermissionAwareModelAdmin
3936
from .tools import (
40-
AdminContext, admin_url_params_encoded, check_files_edit_permissions,
41-
check_files_read_permissions, check_folder_edit_permissions,
42-
check_folder_read_permissions, popup_status, userperms_for_request,
37+
AdminContext, admin_url_params_encoded, check_files_edit_permissions, check_files_read_permissions,
38+
check_folder_edit_permissions, check_folder_read_permissions, popup_status, userperms_for_request,
4339
)
4440

4541

filer/thumbnail_processors.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
from easy_thumbnails import processors
44

5-
from .settings import (
6-
FILER_SUBJECT_LOCATION_IMAGE_DEBUG, FILER_WHITESPACE_COLOR,
7-
)
5+
from .settings import FILER_SUBJECT_LOCATION_IMAGE_DEBUG, FILER_WHITESPACE_COLOR
86

97

108
try:

filer/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
urlpatterns = [
88
re_path(
9-
filer_settings.FILER_CANONICAL_URL + r'(?P<uploaded_at>[0-9]+)/(?P<file_id>[0-9]+)/$', # flake8: noqa
9+
filer_settings.FILER_CANONICAL_URL + r'(?P<uploaded_at>[0-9]+)/(?P<file_id>[0-9]+)/$',
1010
views.canonical,
1111
name='canonical'
1212
),

filer/utils/compatibility.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ def truncate_words(s, num, end_text='...'):
1616

1717

1818
def get_delete_permission(opts):
19-
from django.contrib.auth import get_permission_codename # noqa
19+
from django.contrib.auth import get_permission_codename
2020
return '%s.%s' % (opts.app_label, get_permission_codename('delete', opts))
2121

2222

2323
try:
24-
from PIL import ExifTags as PILExifTags # noqa
25-
from PIL import Image as PILImage # noqa
26-
from PIL import ImageDraw as PILImageDraw # noqa
24+
from PIL import ExifTags as PILExifTags
25+
from PIL import Image as PILImage
26+
from PIL import ImageDraw as PILImageDraw
2727
except ImportError:
2828
try:
2929
import ExifTags as PILExifTags # noqa

filer/utils/files.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import mimetypes
22
import os
33

4-
from django.http.multipartparser import (
5-
ChunkIter, SkipFile, StopFutureHandlers, StopUpload, exhaust,
6-
)
4+
from django.http.multipartparser import ChunkIter, SkipFile, StopFutureHandlers, StopUpload, exhaust
75
from django.template.defaultfilters import slugify as slugify_django
86
from django.utils.encoding import force_str
97
from django.utils.text import get_valid_filename as get_valid_filename_django

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ exclude =
1818
ignore = E251,E128,E501,W503
1919

2020
[isort]
21-
line_length = 79
21+
line_length = 119
2222
skip = manage.py, *migrations*, .tox, .eggs, data, .env, .venv
2323
include_trailing_comma = true
2424
multi_line_output = 5

0 commit comments

Comments
 (0)