Skip to content

Commit

Permalink
Add pyupgrade to pre-commit checks, change target version to Python 3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
jace committed Feb 2, 2024
1 parent d7068c4 commit 605862f
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ hasjob/static/gen
hasjob/assets/node_modules
hasjob/static/build
hasjob/static/service-worker.js
node_modules/
7 changes: 6 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
ci:
skip: ['yesqa', 'no-commit-to-branch']
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
args: ['--keep-runtime-typing', '--py311-plus']
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.14
rev: v0.2.0
hooks:
- id: ruff
args: ['--fix', '--exit-non-zero-on-fix']
Expand Down
108 changes: 79 additions & 29 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[tool.black]
line-length = 88
target_version = ['py37']
target-version = ['py311']
skip-string-normalization = true
include = '\.pyi?$'
exclude = '''
Expand Down Expand Up @@ -44,11 +44,11 @@ sections = [
'THIRDPARTY',
'FIRSTPARTY',
'REPO',
'LOCALFOLDER'
'LOCALFOLDER',
]

[tool.pytest.ini_options]
minversion = "6.1" # For config.rootpath
minversion = "6.1" # For config.rootpath
required_plugins = [
'pytest-cov',
'pytest-datadir',
Expand All @@ -61,8 +61,8 @@ required_plugins = [
addopts = [
'--cov-report=term-missing',
'--disable-socket',
'--allow-unix-socket', # Required for Selenium driver
'--allow-hosts=127.0.0.1,::1', # Add Docker IPs here
'--allow-unix-socket', # Required for Selenium driver
'--allow-hosts=127.0.0.1,::1', # Add Docker IPs here
'--strict-markers',
]
env = ['FLASK_ENV=testing', 'FLASK_TESTING=true']
Expand Down Expand Up @@ -96,31 +96,76 @@ select = ["E", "F"]
ignore = ["E402", "E501"]

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
fixable = [
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"I",
"N",
"Q",
"S",
"T",
"W",
"ANN",
"ARG",
"BLE",
"COM",
"DJ",
"DTZ",
"EM",
"ERA",
"EXE",
"FBT",
"ICN",
"INP",
"ISC",
"NPY",
"PD",
"PGH",
"PIE",
"PL",
"PT",
"PTH",
"PYI",
"RET",
"RSE",
"RUF",
"SIM",
"SLF",
"TCH",
"TID",
"TRY",
"UP",
"YTT",
]
unfixable = []

# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
".bzr",
".direnv",
".eggs",
".git",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
]

# Same as Black.
Expand All @@ -129,8 +174,8 @@ line-length = 88
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

# Target Python 3.7
target-version = "py37"
# Target Python 3.11
target-version = "py311"

[tool.ruff.mccabe]
# Unlike Flake8, default to a complexity level of 10.
Expand All @@ -144,7 +189,12 @@ split-on-trailing-comma = false
relative-imports-order = 'furthest-to-closest'
known-first-party = ['coaster']
section-order = [
'future', 'standard-library', 'third-party', 'first-party', 'repo', 'local-folder'
'future',
'standard-library',
'third-party',
'first-party',
'repo',
'local-folder',
]

[tool.ruff.isort.sections]
Expand Down

0 comments on commit 605862f

Please sign in to comment.