Skip to content

Commit

Permalink
Fix some issues for Python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
peterallenwebb committed Aug 5, 2024
1 parent 1d3504c commit 00dc905
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dbt_common/clients/agate_helper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from codecs import BOM_UTF8

import agate # type: ignore
import agate
import datetime
import isodate
import json
Expand Down
2 changes: 2 additions & 0 deletions dbt_common/clients/jinja.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def new_context(
"shared or locals parameters."
)

vars = {} if vars is None else vars
parent = ChainMap(vars, self.globals) if self.globals else vars

return self.environment.context_class(self.environment, parent, self.name, self.blocks)
Expand Down Expand Up @@ -544,6 +545,7 @@ def render_template(template, ctx: Dict[str, Any], node=None) -> str:

def _get_blocks_hash(text: str, allowed_blocks: Optional[Set[str]], collect_raw_data: bool) -> int:
"""Provides a hash function over the arguments to extract_toplevel_blocks, in order to support caching."""
allowed_blocks = allowed_blocks or set()
allowed_tuple = tuple(sorted(allowed_blocks) or [])
return text.__hash__() + allowed_tuple.__hash__() + collect_raw_data.__hash__()

Expand Down
6 changes: 3 additions & 3 deletions dbt_common/contracts/config/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class Metadata(Enum):
@classmethod
def from_field(cls: Type[M], fld: Field[Any]) -> M:
def from_field(cls: Type[M], fld: Field) -> M:
default = cls.default_field()
key = cls.metadata_key()

Expand All @@ -28,7 +28,7 @@ def metadata_key(cls) -> str:
raise NotImplementedError("Not implemented")


def _get_meta_value(cls: Type[M], fld: Field[Any], key: str, default: Any) -> M:
def _get_meta_value(cls: Type[M], fld: Field, key: str, default: Any) -> M:
# a metadata field might exist. If it does, it might have a matching key.
# If it has both, make sure the value is valid and return it. If it
# doesn't, return the default.
Expand Down Expand Up @@ -65,5 +65,5 @@ def metadata_key(cls) -> str:
return "show_hide"

@classmethod
def should_show(cls, fld: Field[Any]) -> bool:
def should_show(cls, fld: Field) -> bool:
return cls.from_field(fld) == cls.Show
2 changes: 1 addition & 1 deletion dbt_common/dataclass_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class dbtClassMixin(DataClassMessagePackMixin):
against the schema
"""

_mapped_fields: ClassVar[Optional[Dict[Any, List[Tuple[Field[Any], str]]]]] = None
_mapped_fields: ClassVar[Optional[Dict[Any, List[Tuple[Field, str]]]]] = None

# Config class used by Mashumaro
class Config(dbtMashConfig):
Expand Down

0 comments on commit 00dc905

Please sign in to comment.