From 605862f73ba63bf9db9c93cc661672e01a3471ec Mon Sep 17 00:00:00 2001 From: Kiran Jonnalagadda Date: Fri, 2 Feb 2024 16:09:54 +0530 Subject: [PATCH] Add pyupgrade to pre-commit checks, change target version to Python 3.11 --- .gitignore | 1 + .pre-commit-config.yaml | 7 ++- pyproject.toml | 108 +++++++++++++++++++++++++++++----------- 3 files changed, 86 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index 38f335d1..524ed67f 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ hasjob/static/gen hasjob/assets/node_modules hasjob/static/build hasjob/static/service-worker.js +node_modules/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8de5ae9b..070fa414 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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'] diff --git a/pyproject.toml b/pyproject.toml index 45581da3..12c2a135 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ [tool.black] line-length = 88 -target_version = ['py37'] +target-version = ['py311'] skip-string-normalization = true include = '\.pyi?$' exclude = ''' @@ -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', @@ -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'] @@ -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. @@ -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. @@ -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]