Skip to content

Commit

Permalink
fix requirements, update MAKEFILE to work with hatch
Browse files Browse the repository at this point in the history
  • Loading branch information
emmyoop committed Jan 5, 2024
1 parent 99b7843 commit 0443b52
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 deletions.
27 changes: 18 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
.DEFAULT_GOAL:=help

.PHONY: dev_req
dev_req: ## Installs dbt-* packages in develop mode along with only development dependencies.
@\
pip install -r dev-requirements.txt

.PHONY: dev
dev: dev_req ## Installs dbt-* packages in develop mode along with development dependencies and pre-commit.
@\
pre-commit install
.PHONY: run install-hatch overwrite-pre-commit install test lint json_schema

run:
export FORMAT_JSON_LOGS="1"

install-hatch:
pip3 install hatch

# This edits your local pre-commit hook file to use Hatch when executing.
overwrite-pre-commit:
hatch run dev-env:pre-commit install
hatch run dev-env:sed -i -e "s/exec /exec hatch run dev-env:/g" .git/hooks/pre-commit

test:
export FORMAT_JSON_LOGS="1" && hatch -v run dev-env:pytest -n auto tests

lint:
hatch run dev-env:pre-commit run --show-diff-on-failure --color=always --all-files

.PHONY: proto_types
proto_types: ## generates google protobuf python file from types.proto
Expand All @@ -20,4 +30,3 @@ help: ## Show this help message.
@echo
@echo 'targets:'
@grep -E '^[8+a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

12 changes: 12 additions & 0 deletions dbt/common/ui.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
import sys
import textwrap
from typing import Dict

import colorama

# Colorama is needed for colored logs on Windows because we're using logger.info
# intead of print(). If the Windows env doesn't have a TERM var set or it is set to None
# (i.e. in the case of Git Bash on Windows- this emulates Unix), then it's safe to initialize
# Colorama with wrapping turned on which allows us to strip ANSI sequences from stdout.
# You can safely initialize Colorama for any OS and the coloring stays the same except
# when piped to another process for Linux and MacOS, then it loses the coloring. To combat
# that, we will just initialize Colorama when needed on Windows using a non-Unix terminal.

if sys.platform == "win32" and (not os.getenv("TERM") or os.getenv("TERM") == "None"):
colorama.init(wrap=True)

COLORS: Dict[str, str] = {
"red": colorama.Fore.RED,
"green": colorama.Fore.GREEN,
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ classifiers = [
]
dependencies = [
"agate~=1.7.0",
"colorama>=0.3.9,<0.5", # TODO: major version 0 - should we use it?
"jsonschema~=4.0",
"Jinja2~=3.0",
"mashumaro[msgpack]~=3.9",
"protobuf>=4.0.0",
"python-dateutil~=2.0",
"requests<3.0.0",
"typing-extensions~=4.4",
]

Expand Down Expand Up @@ -106,4 +109,4 @@ disallow_untyped_defs = false
profile = "black"

[tool.black]
line-length = 120
line-length = 120
4 changes: 2 additions & 2 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

import dbt.exceptions
import dbt.common.exceptions
import dbt.common.utils


Expand Down Expand Up @@ -139,5 +139,5 @@ def test_trivial(self):
result = dbt.common.utils.deep_map_render(lambda x, _: x, case)
self.assertEqual(result, case)

with self.assertRaises(dbt.exceptions.DbtConfigError):
with self.assertRaises(dbt.common.exceptions.DbtConfigError):
dbt.common.utils.deep_map_render(lambda x, _: x, {"foo": object()})

0 comments on commit 0443b52

Please sign in to comment.