Skip to content

Commit

Permalink
fix: cache of decimal and float
Browse files Browse the repository at this point in the history
  • Loading branch information
hgrecco committed Mar 9, 2024
1 parent 37e43f7 commit 8819917
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pint/delegates/base_defparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
import itertools
import numbers
import pathlib
from dataclasses import dataclass, field
from dataclasses import dataclass
from typing import Any

from pint import errors
from pint.facets.plain.definitions import NotNumeric
Expand Down Expand Up @@ -72,22 +73,26 @@ class PintParsedStatement(fp.ParsedStatement[ParserConfig]):


@functools.lru_cache
def build_disk_cache_class(non_int_type: type):
def build_disk_cache_class(chosen_non_int_type: type):
"""Build disk cache class, taking into account the non_int_type."""

@dataclass(frozen=True)
class PintHeader(fc.InvalidateByExist, fc.NameByFields, fc.BasicPythonHeader):
from .. import __version__

pint_version: str = __version__
non_int_type: str = field(default_factory=lambda: non_int_type.__qualname__)
non_int_type: str = chosen_non_int_type.__qualname__

@dataclass(frozen=True)
class PathHeader(fc.NameByFileContent, PintHeader):
pass

@dataclass(frozen=True)
class ParsedProjecHeader(fc.NameByHashIter, PintHeader):
@classmethod
def from_parsed_project(cls, pp: fp.ParsedProject, reader_id):
def from_parsed_project(
cls, pp: fp.ParsedProject[Any, ParserConfig], reader_id: str
):
tmp = (
f"{stmt.content_hash.algorithm_name}:{stmt.content_hash.hexdigest}"
for stmt in pp.iter_statements()
Expand Down

0 comments on commit 8819917

Please sign in to comment.