Skip to content

Commit

Permalink
move around hatch envs
Browse files Browse the repository at this point in the history
  • Loading branch information
emmyoop committed Jan 16, 2024
1 parent 67b8b89 commit 198b6ba
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 49 deletions.
20 changes: 11 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,17 @@ Once you're able to manually test that your code change is working as expected,

See the pyproject.toml for a complete list of custom commands. See the h[atch docs](https://hatch.pypa.io/latest/cli/reference/) for a description of built in commands and flags. These are the most useful custom commands to use while developing.

|Command|Description|
|---|---|
|`hatch run test`|run all tests|
|`hatch run lint-all`|run black, flake8 and mypy checks|
|`hatch run lint-black`|run black|
|`hatch run lint-flake8`|run flake8|
|`hatch run lint-mypy`|run mypy|
|`hatch run format`|run TODO|
|`hatch run proto`|regenerate protobuf definitions|
|Type|Command|Description|
|---|---|---|
|Utility|`hatch run proto`|regenerate protobuf definitions|
|Testing|`hatch run test:unit`|run all tests|
|Testing|`hatch shell test`|Drops you into a shell env set up for manual testing|
|Code Quality|`hatch run lint:all`|run black, flake8 and mypy checks|
|Code Quality|`hatch run lint:black`|run black|
|Code Quality|`hatch run lint:flake8`|run flake8|
|Code Quality|`hatch run lint:mypy`|run mypy|
|Testing|`hatch shell lint`|Drops you into a shell env set up for manualcode quality checks|
|Code Quality|`hatch fmt`|runs ruff on all code|

## Debugging

Expand Down
8 changes: 2 additions & 6 deletions dbt_common/semver.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ class VersionSpecification(dbtClassMixin):
(?P<major>{num_no_leading_zeros})\.
(?P<minor>{num_no_leading_zeros})\.
(?P<patch>{num_no_leading_zeros})
""".format(
num_no_leading_zeros=_NUM_NO_LEADING_ZEROS
)
""".format(num_no_leading_zeros=_NUM_NO_LEADING_ZEROS)

_VERSION_EXTRA_REGEX = r"""
(\-?
Expand All @@ -47,9 +45,7 @@ class VersionSpecification(dbtClassMixin):
(\+
(?P<build>
{alpha}(\.{alpha})*))?
""".format(
alpha_no_leading_zeros=_ALPHA_NO_LEADING_ZEROS, alpha=_ALPHA
)
""".format(alpha_no_leading_zeros=_ALPHA_NO_LEADING_ZEROS, alpha=_ALPHA)


_VERSION_REGEX_PAT_STR = r"""
Expand Down
75 changes: 41 additions & 34 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,6 @@ dependencies = [
"requests<3.0.0",
"typing-extensions~=4.4",
]
[project.optional-dependencies]
lint = [
"black~=23.3",
"flake8",
"Flake8-pyproject",
"mypy~=1.3",
"ruff==0.1.11",
"types-Jinja2~=2.11",
"types-jsonschema~=4.17",
"types-protobuf~=4.24.0",
"types-python-dateutil~=2.8",
"types-PyYAML~=6.0",
"types-requests<2.31.0" # types-requests 2.31.0.8 requires urllib3>=2, but we pin urllib3 ~= 1.0 because of openssl requirement for requests

]
test = [
"pytest~=7.3",
"pytest-xdist~=3.2",
"hypothesis~=6.87"
]
[[tool.hatch.envs.test.matrix]]
python = ["3.8","3.9","3.10", "3.11"]

[project.urls]
Homepage = "https://github.com/dbt-labs/dbt-common" # TODO: should this be dbt's homepage?
Expand Down Expand Up @@ -90,22 +68,51 @@ packages = ["dbt_common"]
path = "dbt_common/__about__.py"

[tool.hatch.envs.default]
description = "Env for running development commands like pytest & linting"
features = ["lint", "test"]
description = "Default environment with dependencies for running dbt-common"

# these are the commands that you run with `hatch run <cmd>` for local dev & CI
[tool.hatch.envs.default.scripts]
test = "- python -m pytest {args:tests/unit}"
lint-all = [
"- lint-black",
"- lint-flake8",
"- lint-mypy",
proto = "protoc -I=./dbt_common/events --python_out=./dbt_common/events ./dbt_common/events/types.proto"

[tool.hatch.envs.lint]
description = "Env for running development commands for linting"
extra-dependencies = [
"black~=23.3",
"flake8",
"Flake8-pyproject",
"mypy~=1.3",
"ruff==0.1.11",
"types-Jinja2~=2.11",
"types-jsonschema~=4.17",
"types-protobuf~=4.24.0",
"types-python-dateutil~=2.8",
"types-PyYAML~=6.0",
"types-requests<2.31.0" # types-requests 2.31.0.8 requires urllib3>=2, but we pin urllib3 ~= 1.0 because of openssl requirement for requests

]
lint-black = "python -m black ."
lint-flake8 = "python -m flake8 ."
lint-mypy = "python -m mypy ."

[tool.hatch.envs.lint.scripts]
all = [
"- black",
"- flake8",
"- mypy",
]
black = "python -m black ."
flake8 = "python -m flake8 ."
mypy = "python -m mypy ."
format = ["black {args:.}", "ruff --fix --exit-non-zero-on-fix {args:.}"]
proto = "protoc -I=./dbt_common/events --python_out=./dbt_common/events ./dbt_common/events/types.proto"

[tool.hatch.envs.test]
description = "Env for running development commands for testing"
extra-dependencies = [
"pytest~=7.3",
"pytest-xdist~=3.2",
"hypothesis~=6.87"
]
[[tool.hatch.envs.test.matrix]]
python = ["3.8","3.9","3.10", "3.11"]

[tool.hatch.envs.test.scripts]
unit = "- python -m pytest {args:tests/unit}"

# TODO: should ruff replace flake8?
[tool.ruff]
Expand Down

0 comments on commit 198b6ba

Please sign in to comment.