Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit suggestions #224

Merged
merged 5 commits into from
Jul 16, 2024
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
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repos:
- id: detect-private-key

- repo: https://github.com/crate-ci/typos
rev: v1.20.7
rev: v1.22.9
hooks:
- id: typos
# empty to do not write fixes
Expand Down Expand Up @@ -60,7 +60,7 @@ repos:
# - id: mypy

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.5
rev: v0.5.0
hooks:
# use black formatting
- id: ruff-format
Expand All @@ -71,11 +71,11 @@ repos:
args: ["--fix"]

- repo: https://github.com/tox-dev/pyproject-fmt
rev: 1.7.0
rev: 2.1.3
hooks:
- id: pyproject-fmt
additional_dependencies: [tox]
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.16
rev: v0.18
hooks:
- id: validate-pyproject
193 changes: 104 additions & 89 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[build-system]
requires = [
"setuptools",
"wheel",
]

[project]
name = "cachier"
description = "Persistent, stale-free, local and cross-machine caching for Python functions."
Expand All @@ -12,15 +18,15 @@ keywords = [
"mongo",
"persistent",
]
license = {file = "LICENSE"}
license = { file = "LICENSE" }
authors = [
{name = "Shay Palachy Affek", email = '[email protected]'},
{ name = "Shay Palachy Affek", email = '[email protected]' },
]
classifiers = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand All @@ -39,123 +45,132 @@ dependencies = [
"portalocker>=2.3.2",
"watchdog>=2.3.1",
]
[project.urls]
Source = "https://github.com/python-cachier/cachier"
[project.scripts]
cachier = "cachier.__naim__:cli"
urls.Source = "https://github.com/python-cachier/cachier"
scripts.cachier = "cachier.__naim__:cli"

[tool.setuptools]
include-package-data = true

[tool.setuptools.dynamic]
version = {attr = "cachier._version.__version__"}
version = { attr = "cachier._version.__version__" }

[tool.setuptools.packages.find]
where = ["src"] # list of folders that contain the packages (["."] by default)
include = ["cachier*"] # package names should match these glob patterns (["*"] by default)
namespaces = false # to disable scanning PEP 420 namespaces (true by default)

[build-system]
requires = [
"setuptools",
"wheel",
]

[tool.pytest.ini_options]
testpaths = ["cachier", "tests"]
norecursedirs=["dist", "build"]
addopts = [
"--color=yes",
"--cov=cachier",
"--cov-report=term",
"--cov-report=xml:cov.xml",
"-r a",
"-v",
"-s",
]
markers = [
"mongo: test the MongoDB core",
"memory: test the memory core",
"pickle: test the pickle core"
]

[tool.docformatter]
recursive = true
# some docstring start with r"""
wrap-summaries = 79
wrap-descriptions = 79
blank = true
where = [
"src",
] # list of folders that contain the packages (["."] by default)
include = [
"cachier*",
] # package names should match these glob patterns (["*"] by default)
namespaces = false # to disable scanning PEP 420 namespaces (true by default)

[tool.ruff]
target-version = "py38"
line-length = 79
# Exclude a variety of commonly ignored directories.
exclude = [
".eggs",
".git",
".ruff_cache",
"__pypackages__",
"_build",
"build",
"dist",
]
# Enable Pyflakes `E` and `F` codes by default.
lint.select = [
"E",
"W", # see: https://pypi.org/project/pycodestyle
"F", # see: https://pypi.org/project/pyflakes
"I", #see: https://pypi.org/project/isort/
"D", # see: https://pypi.org/project/pydocstyle
#"N", # see: https://pypi.org/project/pep8-naming
"S", # see: https://pypi.org/project/flake8-bandit
"SIM",
"RUF100" # alternative to yesqa
"D", # see: https://pypi.org/project/pydocstyle
"E",
"F", # see: https://pypi.org/project/pyflakes
"I", #see: https://pypi.org/project/isort/
"RUF100", # alternative to yesqa
#"N", # see: https://pypi.org/project/pep8-naming
"S", # see: https://pypi.org/project/flake8-bandit
"SIM",
"W", # see: https://pypi.org/project/pycodestyle
]
lint.extend-select = [
"A", # see: https://pypi.org/project/flake8-builtins
"B", # see: https://pypi.org/project/flake8-bugbear
"C4", # see: https://pypi.org/project/flake8-comprehensions
"A", # see: https://pypi.org/project/flake8-builtins
"B", # see: https://pypi.org/project/flake8-bugbear
"C4", # see: https://pypi.org/project/flake8-comprehensions
]
lint.ignore = [
"E203",
"C901",
"C901",
"E203",
]
# Exclude a variety of commonly ignored directories.
exclude = [
".eggs",
".git",
".ruff_cache",
"__pypackages__",
"_build",
"build",
"dist",
]
lint.ignore-init-module-imports = true
lint.unfixable = ["F401"]

[tool.ruff.lint.per-file-ignores]
"src/**/__init__.py" = ["D104"]
"src/cachier/config.py" = ["D100"]
"tests/**" = [
"S101", "S311", "S105", "S603",
"D100", "D101", "D103", "D104", "D401"
lint.per-file-ignores."src/**/__init__.py" = [
"D104",
]
lint.per-file-ignores."src/cachier/config.py" = [
"D100",
]
lint.per-file-ignores."tests/**" = [
"D100",
"D101",
"D103",
"D104",
"D401",
"S101",
"S105",
"S311",
"S603",
]
lint.unfixable = [
"F401",
]

#[tool.ruff.pydocstyle]
## Use Google-style docstrings.
#convention = "google"

#[tool.ruff.pycodestyle]
#ignore-overlong-task-comments = true

[tool.ruff.lint.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10
lint.mccabe.max-complexity = 10

[tool.docformatter]
recursive = true
# some docstring start with r"""
wrap-summaries = 79
wrap-descriptions = 79
blank = true

[tool.pytest.ini_options]
testpaths = [
"cachier",
"tests",
]
norecursedirs = [
"dist",
"build",
]
addopts = [
"--color=yes",
"--cov=cachier",
"--cov-report=term",
"--cov-report=xml:cov.xml",
"-r a",
"-v",
"-s",
]
markers = [
"mongo: test the MongoDB core",
"memory: test the memory core",
"pickle: test the pickle core",
]

[tool.coverage.run]
branch = true
dynamic_context = "test_function"
omit = [
"tests/*",
"cachier/_version.py",
"cachier/__init__.py",
"**/scripts/**",
"tests/*",
"cachier/_version.py",
"cachier/__init__.py",
"**/scripts/**",
]
[tool.coverage.report]
show_missing = true
# Regexes for lines to exclude from consideration
exclude_lines = [
"pragma: no cover", # Have to re-enable the standard pragma
"raise NotImplementedError", # Don't complain if tests don't hit defensive assertion code:
"if TYPE_CHECKING:", # Is only true when running mypy, not tests
"pragma: no cover", # Have to re-enable the standard pragma
"raise NotImplementedError", # Don't complain if tests don't hit defensive assertion code:
"if TYPE_CHECKING:", # Is only true when running mypy, not tests
]
10 changes: 2 additions & 8 deletions tests/test_pickle_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,7 @@ def _helper_bad_cache_file(sleeptime, separate_files):
if not isinstance(res1, float):
return False
res2 = res_queue.get()
if res2 is not None or isinstance(res2, KeyError):
return False
return True
return res2 is None


# we want this to succeed at least once
Expand Down Expand Up @@ -483,11 +481,7 @@ def _helper_delete_cache_file(sleeptime, separate_files):
if not isinstance(res1, float):
return False
res2 = res_queue.get()
if not ((isinstance(res2, KeyError)) or (res2 is None)):
return False
return True
# print(res2)
# print(type(res2))
return isinstance(res2, KeyError) or (res2 is None)


@pytest.mark.pickle
Expand Down
Loading