Skip to content

Commit

Permalink
Change config files to use Hatch.
Browse files Browse the repository at this point in the history
  • Loading branch information
plypaul committed May 24, 2023
1 parent dadd45f commit 5b02b59
Show file tree
Hide file tree
Showing 3 changed files with 226 additions and 106 deletions.
42 changes: 30 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
files: ^metricflow/
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: black
verbose: true
- repo: https://github.com/PyCQA/flake8
rev: 3.8.3
- id: check-json
- id: trailing-whitespace
exclude_types:
- "markdown"
- id: end-of-file-fixer
- id: check-case-conflict

# Faster version of flake8 / isort / etc.
# Uses ruff.toml for configuration.
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.260'
hooks:
- id: flake8
additional_dependencies: [flake8-docstrings==1.5.0]
verbose: true
- id: ruff
verbose: true
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
verbose: true
args: ["--line-length", "120"]

- repo: https://github.com/pre-commit/mirrors-mypy # configured via mypy.ini
# Uses mypy.ini for configuration.
- repo: https://github.com/pre-commit/mirrors-mypy
# Note: with "language: system", this version is unrelated to what's run.
rev: v1.3.0
hooks:
- id: mypy
name: mypy_metricflow
args: [--show-error-codes]
verbose: true
# Keep mypy environment packages consistent with the local environment.
# "system" means that the current environment will be used to run the hook, not the environment installed by
# pre-commit. This is set for mypy to use the specified package dependencies in Hatch (assuming pre-commit is
# run with hatch run ...). Seems like pre-commit calls the mypy on the command line with this settings.
language: system
207 changes: 113 additions & 94 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,107 +1,126 @@
[tool.poetry]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "metricflow"
version = "0.200.0.dev0"
description = "Translates a simple metric definition into reusable SQL and executes it against the SQL engine of your choice."
authors = ["Transform <hello@transformdata.io>"]
license = "AGPL-3.0-or-later"
readme = "README.md"
homepage = "https://transform.co/metricflow"
repository = "https://github.com/transform-data/metricflow"

[tool.poetry.dependencies]
python = ">=3.8,<3.10"
typing_extensions = ">=4.0.0"

dbt_semantic_interfaces = "0.1.0.dev1"

croniter = "^1.3.4"
pycron = "^3.0.0"
pydantic = "^1.9.0"
rapidfuzz= "3.0.0"
jsonschema = "3.2.0"
SQLAlchemy = "^1.4.42"
snowflake-sqlalchemy = "^1.4.3"
sqlalchemy-redshift = "0.8.1"
numpy = ">=1.22.2"
pandas = "^1.3.0"
Jinja2 = ">=2.11.3"
PyYAML = "^6.0"
snowflake-connector-python = ">=2.7.8"
mo-sql-parsing = "^9.328.23003"
tabulate = "0.8.9"
more-itertools = "8.10.0"
graphviz = "0.18.2"
sqlalchemy2-stubs = "^0.0.2-alpha.21"
sqlalchemy-bigquery = "^1.4.3"
python-dateutil = "2.8.2"
requests = "^2.27.1"
MarkupSafe = "2.0.1"
psycopg2 = "^2.9.3"
google-auth = "^2.13.0"
google-cloud-bigquery = "^3.4.2"
halo = "^0.0.31"
update-checker = "^0.18.0"
"ruamel.yaml" = "^0.17.21"
rudder-sdk-python = "^1.0.3"
duckdb-engine = "^0.1.8"
duckdb = "0.3.4"
click = ">=7.1.2"
GitPython = ">=3.1.27,<3.1.31"
databricks-sql-connector = "2.0.3"
dbt-snowflake = {version="1.4.2", optional=true}
dbt-redshift = {version="1.4.0", optional=true}
dbt-postgres = {version="1.4.0", optional=true}
dbt-bigquery = {version="1.4.3", optional=true}
dbt-metadata-client = {version="^0.1.0", optional=true}
cryptography = "^39.0.1" # This is a pinned transitive dependencies that was done to patch a vulnerability
pyopenssl = "^23.0.0" # This is a pinned transitive dependencies that was done to patch a vulnerability
pytest-xdist = "^3.2.1"
mypy = "^1.3.0"
requires-python = ">=3.8,<3.10"
license = "AGPL-3.0-or-later"
keywords = []
authors = [
{name = "Transform", email = "hello@transformdata.io"}
]

[tool.poetry.dev-dependencies]
dbt-core = "1.4.0"
pytest-mock = "^3.7.0"
pytest = "^7.1.1"
pre-commit = "^2.18.0"
mypy = "1.3.0"
types-python-dateutil = "*"
types-jsonschema = "*"
types-PyYAML = "*"
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
dependencies = [
"GitPython>=3.1.27,<3.1.31",
"Jinja2>=2.11.3",
"MarkupSafe==2.0.1",
"PyYAML~=6.0",
"SQLAlchemy~=1.4.42",
"click>=7.1.2",
"croniter~=1.3.4",
"databricks-sql-connector==2.0.3",
"dbt_semantic_interfaces==0.1.0.dev1",
"duckdb-engine~=0.1.8",
"duckdb==0.3.4",
"google-auth~=2.13.0",
"google-cloud-bigquery~=3.4.2",
"graphviz==0.18.2",
"halo~=0.0.31",
"jsonschema==3.2.0",
"mo-sql-parsing~=9.328.23003",
"more-itertools==8.10.0",
"numpy>=1.22.2",
"pandas~=1.3.0",
"psycopg2~=2.9.3",
"pycron~=3.0.0",
"pydantic~=1.9.0",
"python-dateutil==2.8.2",
"rapidfuzz==3.0.0",
"requests~=2.27.1",
"ruamel.yaml~=0.17.21",
"rudder-sdk-python~=1.0.3",
"snowflake-connector-python>=2.7.8",
"snowflake-sqlalchemy~=1.4.3",
"sqlalchemy-bigquery~=1.6.1",
"sqlalchemy-redshift==0.8.1",
"sqlalchemy2-stubs~=0.0.2a21",
"tabulate==0.8.9",
"typing_extensions>=4.0.0",
"update-checker~=0.18.0",
# Below are pinned transitive dependencies that was done to patch a vulnerability"
"cryptography~=39.0.1",
"pyopenssl~=23.0.0",
]

[project.urls]
Documentation = "https://transform.co/metricflow"
"Source Code" = "https://github.com/transform-data/metricflow"

[tool.poetry.extras]
dbt-snowflake = ["dbt-snowflake"]
dbt-redshift = ["dbt-redshift"]
dbt-postgres = ["dbt-postgres"]
dbt-bigquery = ["dbt-bigquery"]
dbt-cloud = ["dbt-metadata-client"]
[project.scripts]
mf = 'metricflow.cli.main:cli'

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[project.optional-dependencies]
dbt-snowflake = [
"dbt-snowflake==1.4.2"
]
dbt-redshift = [
"dbt-redshift==1.4.0"
]
dbt-postgres = [
"dbt-postgres==1.4.0"
]
dbt-bigquery = [
"dbt-bigquery==1.4.3"
]
dbt-metadata-client = [
"dbt-metadata-client~=0.1.0"
]
dev-packages = [
"dbt-core==1.4.0",
"mypy~=1.3.0",
"pre-commit~=3.2.2",
"pytest-mock~=3.7.0",
"pytest-xdist~=3.2.1",
"pytest~=7.1.1",
"types-PyYAML",
"types-jsonschema",
"types-python-dateutil",
]

[tool.poetry.scripts]
mf = 'metricflow.cli.main:cli'
[tool.hatch.build.targets.sdist]
exclude = [
"/.github",
"/.changes",
".changie.yaml",
".gitignore",
".pre-commit-config.yaml",
"CONTRIBUTING.md",
"MAKEFILE",
"/tests",
]

[tool.black]
line-length = 120
target-version = ['py36', 'py37', 'py38']
force-exclude = '''
(
/(
\.eggs # exclude a few common directories in the
| \.git # root of the project
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
)
'''
[tool.hatch.envs.dev-env]
description = "Environment for development."
features = [
"dbt-redshift",
"dbt-snowflake",
"dbt-bigquery",
"dbt-metadata-client",
"dbt-postgres",
"dev-packages",
]

# Many deprecation warnings come from 3rd-party libraries and make the
# output of pytest noisy. Since no action is going to be taken, hide those
Expand Down
83 changes: 83 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
select = [
# Pyflakes
"F",
# Pycodestyle
"E",
"W",
# flake8-docstrings
"D",
# isort
"I",
]
ignore = [
# TODO: Fix these.
# Lines longer than line-length. This is generally handled by Black.
"E501",
# Missing docstring in public module
"D100",
# Missing docstring in public package
"D104",
# no-blank-line-before-class
"D211",
# First line should end with a period
"D400",
# First word of the docstring should not be "This"
"D404",
# First line of docstring should be in imperative mood
"D401",
# Missing argument descriptions in the docstring
"D417",

]

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = [
"A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM",
"ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF",
"SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"
]
unfixable = []

# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
]

line-length = 120

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

# Assume Python 3.8, the lowest version that MF supports.
target-version = "py38"

[mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10

[pydocstyle]
convention = "google"

[isort]
required-imports = ["from __future__ import annotations"]

0 comments on commit 5b02b59

Please sign in to comment.