Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 13 additions & 42 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,56 +1,32 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
ci:
skip: ['yesqa', 'no-commit-to-branch']
skip: ['no-commit-to-branch']
repos:
- repo: https://github.com/pre-commit-ci/pre-commit-ci-config
rev: v1.6.1
hooks:
- id: check-pre-commit-ci-config
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.1
hooks:
- id: ruff
args: ['--fix', '--exit-non-zero-on-fix']
# Extra args, only after removing flake8 and yesqa: '--extend-select', 'RUF100'
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.1
rev: v3.20.0
hooks:
- id: pyupgrade
args: ['--keep-runtime-typing', '--py39-plus']
- repo: https://github.com/asottile/yesqa
rev: v1.5.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.2
hooks:
- id: yesqa
additional_dependencies: &flake8deps
- bandit
- flake8-assertive
- flake8-blind-except
- flake8-bugbear
- flake8-builtins
- flake8-comprehensions
- flake8-docstrings
- flake8-isort
- flake8-logging-format
- flake8-mutable
- flake8-plugin-utils
- flake8-print
- flake8-pytest-style
- pep8-naming
- toml
- tomli
- id: ruff-check
args: ['--fix', '--exit-non-zero-on-fix']
# Extra args, only after removing flake8 and yesqa: '--extend-select', 'RUF100'
- id: ruff-format
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
rev: 6.0.1
hooks:
- id: isort
additional_dependencies:
- toml
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.14.1
rev: v1.16.1
hooks:
- id: mypy
# warn-unused-ignores is unsafe with pre-commit, see
Expand All @@ -65,13 +41,8 @@ repos:
- types-pytz
- types-requests
- typing-extensions
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
additional_dependencies: *flake8deps
- repo: https://github.com/PyCQA/pylint
rev: v3.3.3
rev: v3.3.7
hooks:
- id: pylint
args: [
Expand All @@ -82,15 +53,15 @@ repos:
additional_dependencies:
- tomli
- repo: https://github.com/PyCQA/bandit
rev: 1.8.2
rev: 1.8.6
hooks:
- id: bandit
language_version: python3
args: ['-c', 'pyproject.toml']
additional_dependencies:
- 'bandit[toml]'
- repo: https://github.com/pycontribs/mirrors-prettier
rev: v3.4.2
rev: v3.6.2
hooks:
- id: prettier
- repo: https://github.com/ducminh-phan/reformat-gherkin
Expand Down
5 changes: 2 additions & 3 deletions docs/baseframe/conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Sphinx configuration."""

# flake8: noqa
# ruff: noqa: A001,INP001
#
# baseframe documentation build configuration file, created by
# sphinx-quickstart on Thu Nov 15 12:31:40 2012.
Expand Down Expand Up @@ -52,7 +51,7 @@

# General information about the project.
project = 'baseframe'
copyright = '2012-22, Hasgeek'
copyright = '2012-25, Hasgeek'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down
98 changes: 92 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,21 @@ disable = [
]

[tool.bandit]
exclude_dirs = ['node_modules']
exclude_dirs = ['node_modules', 'build']
skips = [
'B113', # Handled by pylint; bandit incorrectly flags requests_mock for timeout
]

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

[tool.bandit.markupsafe_xss]
allowed_calls = [
'flask.render_template',
'coaster.utils.markdown',
'render_field_options',
]

[tool.ruff]
# Exclude a variety of commonly ignored directories.
exclude = [
Expand Down Expand Up @@ -209,21 +219,90 @@ docstring-code-format = true
quote-style = "preserve"

[tool.ruff.lint]
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
select = ["E", "F"]
ignore = ["E402", "E501"]

select = [
"A", # flake8-builtins
"ANN", # flake8-annotations
"ARG", # flake8-unused-arguments
"ASYNC", # flake8-async
"ASYNC1", # flake8-trio
"B", # flake8-bugbear
"BLE", # flake8-blind-except
"C", # pylint convention
"C4", # flake8-comprehensions
"D", # pydocstyle
"E", # Error
"EM", # flake8-errmsg
"EXE", # flake8-executable
"F", # pyflakes
"FA", # flake8-future-annotations
"FLY", # flynt
"G", # flake8-logging-format
"I", # isort
"INP", # flake8-no-pep420
"INT", # flake8-gettext
"ISC", # flake8-implicit-str-concat
"N", # pep8-naming
"PERF", # Perflint
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PL", # pylint
"PT", # flake8-pytest-style
"PYI", # flake8-pyi
"RET", # flake8-return
"RUF", # ruff
"S", # flake8-bandit
"SIM", # flake8-simplify
"SLOT", # flake8-slots
"T20", # flake8-print
"UP", # pyupgrade
"W", # Warnings
"YTT", # flake8-2020
]
ignore = [
"A005", # Shadowing a Python standard-library module is okay as they're namespaced
"ANN002", # `*args` is implicit `Any`
"ANN003", # `**kwargs` is implicit `Any`
"ANN401", # Allow `Any` type
"C901",
"D101",
"D102",
"D103",
"D105", # Magic methods don't need docstrings
"D106", # Nested classes don't need docstrings
"D107", # `__init__` doesn't need a docstring
"D203", # No blank lines before class docstring
"D212", # Allow multiline docstring to start on next line after quotes
"D213", # But also allow multiline docstring to start right after quotes
"E402", # Allow top-level imports after statements
"E501", # Allow long lines if the formatter can't fix it
"EM101", # Allow Exception("string")
"EM102", # Allow Exception(f"string")
"ISC001", # Allow implicitly concatenated string literals (required for formatter)
"PLR2004", # Too many false positives
"PLR0911", # Alow multiple return statements
"PLR0912", # Some functions are complex
"PLR0913", # Some functions need many args
"PLR0915", # Too many statements are okay
"RUF012", # Allow mutable ClassVar without annotation (conflicts with SQLAlchemy)
"SLOT000", # Don't require `__slots__` for subclasses of str
]
# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow these characters in strings
allowed-confusables = ["‘", "’", "–"]

[tool.ruff.lint.extend-per-file-ignores]
"__init__.py" = ["E402"] # Allow non-top-level imports
"tests/**.py" = [
"S101", # Allow assert
"ARG001", # Context manager fixtures may not be used within a test
"ANN001", # Args don't need types (usually fixtures)
"D401", # Fixture docstrings shouldn't be imperative
"N802", # Fixture returning a class may be named per class name convention
"N803", # Args don't require naming convention (fixture could be a class)
"N999", # Module name may have a CamelCased class name in it
"S101", # Allow assert
]

[tool.ruff.lint.isort]
Expand Down Expand Up @@ -251,3 +330,10 @@ mark-parentheses = false

[tool.ruff.lint.pyupgrade]
keep-runtime-typing = true

[tool.ruff.lint.flake8-bandit]
allowed-markup-calls = [
'flask.render_template',
'coaster.utils.markdown',
'baseframe.filters.render_field_options',
]
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def run(self) -> None:
if not self._dry_run:
curdir = os.getcwd()
os.chdir(os.path.join(self.build_lib, 'baseframe'))
os.system('make') # nosec
os.system('make') # nosec B605 B607 # noqa: S605,S607
os.chdir(curdir)


Expand Down
6 changes: 3 additions & 3 deletions src/baseframe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@
# TODO: baseframe_js and baseframe_css are defined in deprecated.py
# and pending removal after an audit of all apps
__all__ = [
'Bundle',
'Version',
'_',
'__',
'__version__',
'__version_info__',
'assets',
'babel',
'baseframe',
'baseframe_css',
'baseframe_js',
'baseframe_translations',
'baseframe',
'blueprint',
'Bundle',
'cache',
'ctx_has_locale',
'deprecated',
Expand All @@ -62,6 +63,5 @@
'signals',
'statsd',
'utils',
'Version',
'views',
]
Loading