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
9 changes: 4 additions & 5 deletions cachier/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from ._version import * # noqa: F403
from .core import (
cachier,
set_default_params,
get_default_params,
enable_caching,
disable_caching,
enable_caching,
get_default_params,
set_default_params,
)

from ._version import * # noqa: F403

__all__ = [
"cachier",
"set_default_params",
Expand Down
2 changes: 1 addition & 1 deletion cachier/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


def _get_git_sha() -> str:
from subprocess import check_output, DEVNULL
from subprocess import DEVNULL, check_output

out = check_output(["git", "rev-parse", "--short", "HEAD"], stderr=DEVNULL) # noqa: S603, S607
return out.decode("utf-8").strip()
Expand Down
13 changes: 6 additions & 7 deletions cachier/cores/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@
# http://www.opensource.org/licenses/MIT-license
# Copyright (c) 2016, Shay Palachy <shaypal5@gmail.com>

import sys # to make sure that pymongo was imported
import pickle # for serialization of python objects
from contextlib import suppress
from datetime import datetime
import sys # to make sure that pymongo was imported
import time # to sleep when waiting on Mongo cache\
import warnings # to warn if pymongo is missing
from contextlib import suppress
from datetime import datetime

with suppress(ImportError):
from pymongo import IndexModel, ASCENDING
from pymongo.errors import OperationFailure
from bson.binary import Binary # to save binary data to mongodb
from pymongo import ASCENDING, IndexModel
from pymongo.errors import OperationFailure

from .base import _BaseCore, RecalculationNeeded

from .base import RecalculationNeeded, _BaseCore

MONGO_SLEEP_DURATION_IN_SEC = 1

Expand Down
5 changes: 2 additions & 3 deletions cachier/cores/pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@
# Copyright (c) 2016, Shay Palachy <shaypal5@gmail.com>
import os
import pickle # for local caching
import threading
from contextlib import suppress
from datetime import datetime
import threading

import portalocker # to lock on pickle cache IO
from watchdog.observers import Observer
from watchdog.events import PatternMatchingEventHandler
from watchdog.observers import Observer

# Alternative: https://github.com/WoLpH/portalocker

from .base import _BaseCore


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ lint.select = [
"E",
"W", # see: https://pypi.org/project/pycodestyle
"F", # see: https://pypi.org/project/pyflakes
# "I", #see: https://pypi.org/project/isort/
"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
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
# Copyright (c) 2024, Jirka Borovec <***@gmail.com>

import os.path
from importlib.util import spec_from_file_location, module_from_spec
from setuptools import setup, find_packages
from importlib.util import module_from_spec, spec_from_file_location

from pkg_resources import parse_requirements
from setuptools import find_packages, setup

_PATH_HERE = os.path.dirname(__file__)

Expand Down
3 changes: 2 additions & 1 deletion tests/standalone_script.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import cachier
import time

import cachier


@cachier.cachier()
def _takes_3_seconds(label, value):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_memory_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from random import random
from time import sleep, time

import pytest
import pandas as pd
import pytest

from cachier import cachier

Expand Down
3 changes: 1 addition & 2 deletions tests/test_mongo_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
from time import sleep
from urllib.parse import quote_plus

from birch import Birch # type: ignore[import-not-found]
import pandas as pd
import pymongo
import pytest
from birch import Birch # type: ignore[import-not-found]
from pymongo.errors import OperationFailure
from pymongo.mongo_client import MongoClient
from pymongo_inmemory import MongoClient as InMemoryMongoClient
Expand All @@ -23,7 +23,6 @@
from cachier.cores.base import RecalculationNeeded
from cachier.cores.mongo import _MongoCore


# === Enables testing vs a real MongoDB instance ===


Expand Down