Skip to content

Commit 0317753

Browse files
Fix linter issues; fix ValidCoordinates; add OptionalCoordinates (#511)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 164a48b commit 0317753

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2608
-2284
lines changed

.pre-commit-config.yaml

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,32 @@
11
# See https://pre-commit.com for more information
22
# See https://pre-commit.com/hooks.html for more hooks
33
ci:
4-
skip: ['yesqa', 'no-commit-to-branch']
4+
skip: ['no-commit-to-branch']
55
repos:
66
- repo: https://github.com/pre-commit-ci/pre-commit-ci-config
77
rev: v1.6.1
88
hooks:
99
- id: check-pre-commit-ci-config
10-
- repo: https://github.com/astral-sh/ruff-pre-commit
11-
rev: v0.9.1
12-
hooks:
13-
- id: ruff
14-
args: ['--fix', '--exit-non-zero-on-fix']
15-
# Extra args, only after removing flake8 and yesqa: '--extend-select', 'RUF100'
1610
- repo: https://github.com/asottile/pyupgrade
17-
rev: v3.19.1
11+
rev: v3.20.0
1812
hooks:
1913
- id: pyupgrade
2014
args: ['--keep-runtime-typing', '--py39-plus']
21-
- repo: https://github.com/asottile/yesqa
22-
rev: v1.5.0
15+
- repo: https://github.com/astral-sh/ruff-pre-commit
16+
rev: v0.12.2
2317
hooks:
24-
- id: yesqa
25-
additional_dependencies: &flake8deps
26-
- bandit
27-
- flake8-assertive
28-
- flake8-blind-except
29-
- flake8-bugbear
30-
- flake8-builtins
31-
- flake8-comprehensions
32-
- flake8-docstrings
33-
- flake8-isort
34-
- flake8-logging-format
35-
- flake8-mutable
36-
- flake8-plugin-utils
37-
- flake8-print
38-
- flake8-pytest-style
39-
- pep8-naming
40-
- toml
41-
- tomli
18+
- id: ruff-check
19+
args: ['--fix', '--exit-non-zero-on-fix']
20+
# Extra args, only after removing flake8 and yesqa: '--extend-select', 'RUF100'
21+
- id: ruff-format
4222
- repo: https://github.com/PyCQA/isort
43-
rev: 5.13.2
23+
rev: 6.0.1
4424
hooks:
4525
- id: isort
4626
additional_dependencies:
4727
- toml
48-
- repo: https://github.com/psf/black
49-
rev: 24.10.0
50-
hooks:
51-
- id: black
5228
- repo: https://github.com/pre-commit/mirrors-mypy
53-
rev: v1.14.1
29+
rev: v1.16.1
5430
hooks:
5531
- id: mypy
5632
# warn-unused-ignores is unsafe with pre-commit, see
@@ -65,13 +41,8 @@ repos:
6541
- types-pytz
6642
- types-requests
6743
- typing-extensions
68-
- repo: https://github.com/PyCQA/flake8
69-
rev: 7.1.1
70-
hooks:
71-
- id: flake8
72-
additional_dependencies: *flake8deps
7344
- repo: https://github.com/PyCQA/pylint
74-
rev: v3.3.3
45+
rev: v3.3.7
7546
hooks:
7647
- id: pylint
7748
args: [
@@ -82,15 +53,15 @@ repos:
8253
additional_dependencies:
8354
- tomli
8455
- repo: https://github.com/PyCQA/bandit
85-
rev: 1.8.2
56+
rev: 1.8.6
8657
hooks:
8758
- id: bandit
8859
language_version: python3
8960
args: ['-c', 'pyproject.toml']
9061
additional_dependencies:
9162
- 'bandit[toml]'
9263
- repo: https://github.com/pycontribs/mirrors-prettier
93-
rev: v3.4.2
64+
rev: v3.6.2
9465
hooks:
9566
- id: prettier
9667
- repo: https://github.com/ducminh-phan/reformat-gherkin

docs/baseframe/conf.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Sphinx configuration."""
2-
3-
# flake8: noqa
2+
# ruff: noqa: A001,INP001
43
#
54
# baseframe documentation build configuration file, created by
65
# sphinx-quickstart on Thu Nov 15 12:31:40 2012.
@@ -52,7 +51,7 @@
5251

5352
# General information about the project.
5453
project = 'baseframe'
55-
copyright = '2012-22, Hasgeek'
54+
copyright = '2012-25, Hasgeek'
5655

5756
# The version info for the project you're documenting, acts as replacement for
5857
# |version| and |release|, also used in various other places throughout the

pyproject.toml

Lines changed: 92 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,21 @@ disable = [
168168
]
169169

170170
[tool.bandit]
171-
exclude_dirs = ['node_modules']
171+
exclude_dirs = ['node_modules', 'build']
172+
skips = [
173+
'B113', # Handled by pylint; bandit incorrectly flags requests_mock for timeout
174+
]
172175

173176
[tool.bandit.assert_used]
174177
skips = ['*/*_test.py', '*/test_*.py']
175178

179+
[tool.bandit.markupsafe_xss]
180+
allowed_calls = [
181+
'flask.render_template',
182+
'coaster.utils.markdown',
183+
'render_field_options',
184+
]
185+
176186
[tool.ruff]
177187
# Exclude a variety of commonly ignored directories.
178188
exclude = [
@@ -209,21 +219,90 @@ docstring-code-format = true
209219
quote-style = "preserve"
210220

211221
[tool.ruff.lint]
212-
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
213-
select = ["E", "F"]
214-
ignore = ["E402", "E501"]
215-
222+
select = [
223+
"A", # flake8-builtins
224+
"ANN", # flake8-annotations
225+
"ARG", # flake8-unused-arguments
226+
"ASYNC", # flake8-async
227+
"ASYNC1", # flake8-trio
228+
"B", # flake8-bugbear
229+
"BLE", # flake8-blind-except
230+
"C", # pylint convention
231+
"C4", # flake8-comprehensions
232+
"D", # pydocstyle
233+
"E", # Error
234+
"EM", # flake8-errmsg
235+
"EXE", # flake8-executable
236+
"F", # pyflakes
237+
"FA", # flake8-future-annotations
238+
"FLY", # flynt
239+
"G", # flake8-logging-format
240+
"I", # isort
241+
"INP", # flake8-no-pep420
242+
"INT", # flake8-gettext
243+
"ISC", # flake8-implicit-str-concat
244+
"N", # pep8-naming
245+
"PERF", # Perflint
246+
"PGH", # pygrep-hooks
247+
"PIE", # flake8-pie
248+
"PL", # pylint
249+
"PT", # flake8-pytest-style
250+
"PYI", # flake8-pyi
251+
"RET", # flake8-return
252+
"RUF", # ruff
253+
"S", # flake8-bandit
254+
"SIM", # flake8-simplify
255+
"SLOT", # flake8-slots
256+
"T20", # flake8-print
257+
"UP", # pyupgrade
258+
"W", # Warnings
259+
"YTT", # flake8-2020
260+
]
261+
ignore = [
262+
"A005", # Shadowing a Python standard-library module is okay as they're namespaced
263+
"ANN002", # `*args` is implicit `Any`
264+
"ANN003", # `**kwargs` is implicit `Any`
265+
"ANN401", # Allow `Any` type
266+
"C901",
267+
"D101",
268+
"D102",
269+
"D103",
270+
"D105", # Magic methods don't need docstrings
271+
"D106", # Nested classes don't need docstrings
272+
"D107", # `__init__` doesn't need a docstring
273+
"D203", # No blank lines before class docstring
274+
"D212", # Allow multiline docstring to start on next line after quotes
275+
"D213", # But also allow multiline docstring to start right after quotes
276+
"E402", # Allow top-level imports after statements
277+
"E501", # Allow long lines if the formatter can't fix it
278+
"EM101", # Allow Exception("string")
279+
"EM102", # Allow Exception(f"string")
280+
"ISC001", # Allow implicitly concatenated string literals (required for formatter)
281+
"PLR2004", # Too many false positives
282+
"PLR0911", # Alow multiple return statements
283+
"PLR0912", # Some functions are complex
284+
"PLR0913", # Some functions need many args
285+
"PLR0915", # Too many statements are okay
286+
"RUF012", # Allow mutable ClassVar without annotation (conflicts with SQLAlchemy)
287+
"SLOT000", # Don't require `__slots__` for subclasses of str
288+
]
216289
# Allow autofix for all enabled rules (when `--fix`) is provided.
217290
fixable = ["ALL"]
218291
unfixable = []
219292

293+
# Allow these characters in strings
294+
allowed-confusables = ["", "", ""]
295+
220296
[tool.ruff.lint.extend-per-file-ignores]
221297
"__init__.py" = ["E402"] # Allow non-top-level imports
222298
"tests/**.py" = [
223-
"S101", # Allow assert
299+
"ARG001", # Context manager fixtures may not be used within a test
224300
"ANN001", # Args don't need types (usually fixtures)
301+
"D401", # Fixture docstrings shouldn't be imperative
225302
"N802", # Fixture returning a class may be named per class name convention
226303
"N803", # Args don't require naming convention (fixture could be a class)
304+
"N999", # Module name may have a CamelCased class name in it
305+
"S101", # Allow assert
227306
]
228307

229308
[tool.ruff.lint.isort]
@@ -251,3 +330,10 @@ mark-parentheses = false
251330

252331
[tool.ruff.lint.pyupgrade]
253332
keep-runtime-typing = true
333+
334+
[tool.ruff.lint.flake8-bandit]
335+
allowed-markup-calls = [
336+
'flask.render_template',
337+
'coaster.utils.markdown',
338+
'baseframe.filters.render_field_options',
339+
]

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def run(self) -> None:
1313
if not self._dry_run:
1414
curdir = os.getcwd()
1515
os.chdir(os.path.join(self.build_lib, 'baseframe'))
16-
os.system('make') # nosec
16+
os.system('make') # nosec B605 B607 # noqa: S605,S607
1717
os.chdir(curdir)
1818

1919

src/baseframe/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,19 @@
3636
# TODO: baseframe_js and baseframe_css are defined in deprecated.py
3737
# and pending removal after an audit of all apps
3838
__all__ = [
39+
'Bundle',
40+
'Version',
3941
'_',
4042
'__',
4143
'__version__',
4244
'__version_info__',
4345
'assets',
4446
'babel',
47+
'baseframe',
4548
'baseframe_css',
4649
'baseframe_js',
4750
'baseframe_translations',
48-
'baseframe',
4951
'blueprint',
50-
'Bundle',
5152
'cache',
5253
'ctx_has_locale',
5354
'deprecated',
@@ -62,6 +63,5 @@
6263
'signals',
6364
'statsd',
6465
'utils',
65-
'Version',
6666
'views',
6767
]

0 commit comments

Comments
 (0)