Skip to content

Commit

Permalink
⚡ migrate to uv for packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgafni committed Aug 22, 2024
1 parent aff5ad4 commit 36090c1
Show file tree
Hide file tree
Showing 8 changed files with 180 additions and 252 deletions.
272 changes: 20 additions & 252 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,285 +1,53 @@
# ########################
# ##### PYRIGHT
# ########################

# [Docs root]
# https://github.com/microsoft/pyright/tree/main/docs
# [Config option reference]
# https://github.com/microsoft/pyright/blob/main/docs/configuration.md

# Pyright does not have a docs site, but the documentation (a collection of
# markdown files in the GH repo, linked above) is pretty thorough.
[tool.uv]
dev-dependencies = [ "ruff==0.5.5",]

[tool.pyright]

include = [
".buildkite/dagster-buildkite",
"docs/dagster-ui-screenshot",
"docs/sphinx/_ext/dagster-sphinx",
"python_modules",
"examples",
"integration_tests",
"scripts",
]

# Unfortunately pyright does not offer a way to extend the default exclusions, so we have to
# reiterate them here if we want to add anything else.
exclude = [
"**/node_modules",
"**/__pycache__",
"**/__generated__",
"**/vendor",
"**/_vendored",
"**/.tox",
".git",
"**/.venv*",
"**/build",
]

# These two settings point pyright to a python environment to resolve imports against. This virtual
# environment is defined in the `pyright` tox environment in the tox section below-- that
# environment must be built before pyright can run correctly.
include = [ ".buildkite/dagster-buildkite", "docs/dagster-ui-screenshot", "docs/sphinx/_ext/dagster-sphinx", "python_modules", "examples", "integration_tests", "scripts",]
exclude = [ "**/node_modules", "**/__pycache__", "**/__generated__", "**/vendor", "**/_vendored", "**/.tox", ".git", "**/.venv*", "**/build",]
venv = ".venv"
venvPath = "pyright/master"

# Set to false to help us during the transition from mypy to pyright. Mypy does
# not analyze unannotated functions by default, and so as of 2023-02 the codebase contains a large
# number of type errors in unannotated functions. Eventually we can turn off this setting.
analyzeUnannotatedFunctions = false

# Minimum version of Python on which code must run. This determines the standard library stubs used by
# pyright.
pythonVersion = "3.8"

# Use "basic" ruleset. This differs from strict in several ways, but most
# importantly it does not flag untyped code as an error.
typeCheckingMode = "basic"

# Disable reading type annotations from libraries that are not explicitly marked as typed (i.e. that
# include a py.typed file). All imports from these libraries are given the `Unknown` type (i.e.
# `Any`). This setting does not affect `py.typed` libraries.
useLibraryCodeForTypes = false

# We use ruff for this.
reportInvalidStringEscapeSequence = false

# As of 2023-02-02, there are still many `py.typed` libs that are not compliant with the standards
# for defining a public API.
reportPrivateImportUsage = false

# Since we only use pyright, there is no need to suppress type errors that pyright does not
# recognize.
reportUnnecessaryTypeIgnoreComment = "warning"

# ########################
# ##### PYTEST
# ########################

[tool.pytest.ini_options]

filterwarnings = [
"ignore::dagster.ExperimentalWarning",
"ignore::DeprecationWarning",
"ignore::UserWarning",
"ignore::pytest.PytestCollectionWarning",
]

# ########################
# ##### RUFF
# ########################

# [Docs root]
# https://beta.ruff.rs/docs/
# [Config option reference]
# https://beta.ruff.rs/docs/configuration/
#
# As of 2022-12-05, the entire documentation of Ruff is in its very long
# README.

[tool.ruff]

target-version = "py38"

# *.py, *.ipy are included by default
extend-include = ["*.ipynb"]

extend-exclude = [
"*/__generated__/*",
"*/dagster_airflow/vendor/*",
"*/_vendored/*",
"*/snapshots/*",
"python_modules/libraries/dagstermill/dagstermill_tests/notebooks/cli_test_scaffold.ipynb",
]

# Codebase-wide default line length. Override in package-specific pyproject.toml where a different
# length is desired.
extend-include = [ "*.ipynb",]
extend-exclude = [ "*/__generated__/*", "*/dagster_airflow/vendor/*", "*/_vendored/*", "*/snapshots/*", "python_modules/libraries/dagstermill/dagstermill_tests/notebooks/cli_test_scaffold.ipynb",]
line-length = 100

# Fail if Ruff is not running this version.
required-version = "0.5.5"

[tool.ruff.lint]

# we only want to format notebooks, not lint them
exclude = ["*.ipynb"]

ignore = [

# (missing public docstrings) These work off of the Python sense of "public", rather than our
# bespoke definition based off of `@public`. When ruff supports custom plugins then we can write
# appropriate rules to require docstrings for `@public`.
"D100",
"D101",
"D102",
"D103",
"D104",
"D105",
"D106",
"D107",

# (docstring imperative mood) Overly restrictive.
"D401",

# (module level import not at top) There are several places where we use e.g.
# warnings.filterwarings calls before imports.
"E402",

# (line too long): This fires for comments, which the ruff formatter won't auto-wrap. Disabling
# until there is an autoformat solution available for comments.
"E501",

# (no type comparison): There are a few places where we use `== type(None)` which are more clear
# than the equivalent `isinstance` check.
'E721',

# (bare exception): There are many places where we want to catch a maximally generic exception.
'E722',

# (no assign lambda): existing code assigns lambdas in a few places. With ruff formatting
# requiring extra empty lines between defs, disallowing lambda assignment can make code less
# readable.
"E731",

# (try-except-in-loop) we use this pattern in many places and the performance impact is negligible
"PERF203",

# (no concatenation) Existing codebase has many concatentations, no reason to disallow them.
"RUF005",

# (use ClassVar for attr declarations with defaults) This is a good rule for vanilla Python, but
# triggers false positives for many libs that have DSLs that make use of attr defaults.
"RUF012",

##### TEMPORARY DISABLES

# (assorted docstring rules) There are too many violations of these to enable
# right now, but we should enable after fixing the violations.
"D200", # (one-line docstring should fit)
"D205", # (blank line after summary)
"D417", # (missing arg in docstring)

# (assorted perf rules) We have a lot of violations, enable when autofix is available
"PERF401", # (manual-list-comprehension)
"PERF402", # (manual-list-copy)
]

# By default, ruff only uses all "E" (pycodestyle) and "F" (pyflakes) rules.
# Here we append to the defaults.
select = [

# (flake8-builtins) detect shadowing of python builtin symbols by variables and arguments.
# Attributes are OK (which is why A003) is not included here.
"A001",
"A002",

# (useless expression): Expressions that aren't assigned to anything are typically bugs.
"B018",

# (static key dict comprehension): Flag reuse of a key in dict comprehensions.
"B035",

# (pydocstyle) Docstring-related rules. A large subset of these are ignored by the
# "convention=google" setting, we set under tool.ruff.pydocstyle.
"D",

# (pycodestyle) pycodestyle rules
"E",

# (pyflakes) pyflakes rules
"F",

# (isort) detect improperly sorted imports
"I001",

# (performance) perflint rules
"PERF",

# (pylint) use all pylint rules from categories "Convention", "Error", and "Warning" (ruff
# currently implements only a subset of pylint's rules)
"PLE",
"PLW",

# (no commented out code) keep commented out code blocks out of the codebase
# "ERA001",

# (ruff-specific) Enable all ruff-specific checks (i.e. not ports of
# functionality from an existing linter).
"RUF",

# (private member access) Flag access to `_`-prefixed symbols. By default the various special
# methods on `NamedTuple` are ignored (e.g. `_replace`).
"SLF001",

# (flake8-type-checking) Auto-sort imports into TYPE_CHECKING blocks depending on whether
# they are runtime or type-only imports.
"TCH",

# (banned-api) Flag use of banned APIs. See tool.ruff.flake8-tidy-imports.banned-api for details.
"TID251",
[tool.dagster]
module_name = "dagster_test.toys.repo"

# (disallow print statements) keep debugging statements out of the codebase
"T20",
[tool.uv.workspace]
members = [ "python_modules/dagster-pipes",]

# (f-strings) use f-strings instead of .format()
"UP032",
[tool.ruff.lint]
exclude = [ "*.ipynb",]
ignore = [ "D100", "D101", "D102", "D103", "D104", "D105", "D106", "D107", "D401", "E402", "E501", "E721", "E722", "E731", "PERF203", "RUF005", "RUF012", "D200", "D205", "D417", "PERF401", "PERF402",]
select = [ "A001", "A002", "B018", "B035", "D", "E", "F", "I001", "PERF", "PLE", "PLW", "RUF", "SLF001", "TCH", "TID251", "T20", "UP032", "W605",]

# (invalid escape sequence) flag errant backslashes
"W605",
]
[tool.pytest.ini_options]
filterwarnings = [ "ignore::dagster.ExperimentalWarning", "ignore::DeprecationWarning", "ignore::UserWarning", "ignore::pytest.PytestCollectionWarning",]

[tool.ruff.lint.flake8-builtins]

# We use `id` in many places and almost never want to use the python builtin.
builtins-ignorelist = ["id"]

[tool.ruff.lint.flake8-tidy-imports.banned-api]

"__future__.annotations".msg = "Directly quote annotations instead."
builtins-ignorelist = [ "id",]

[tool.ruff.lint.isort]

# Combine multiple `from foo import bar as baz` statements with the same source
# (`foo`) into a single statement.
combine-as-imports = true

# In cases where imports are automatically removed, allows the imports to be automatically collapsed
split-on-trailing-comma = false

# Imports of the form `from foo import bar as baz` show one `import bar as baz`
# per line. Useful for __init__.py files that just re-export symbols.
force-wrap-aliases = true

[tool.ruff.lint.per-file-ignores]

# Don't format docstrings in alembic migrations.
"**/alembic/versions/*.py" = ["D"]
"**/alembic/versions/*.py" = [ "D",]

[tool.ruff.lint.pydocstyle]

# Enforce google-style docstrings. This is equivalent to ignoring a large number of pydocstyle (D)
# rules incompatible with google-style docstrings. See:
# https://google.github.io/styleguide/pyguide.html#383-functions-and-methods
convention = "google"

[tool.dagster]
module_name = "dagster_test.toys.repo"
[tool.ruff.lint.flake8-tidy-imports.banned-api."__future__.annotations"]
msg = "Directly quote annotations instead."
Empty file.
21 changes: 21 additions & 0 deletions python_modules/dagster-pipes/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[project]
name = "dagster-pipes"
version = "1!0+dev"
description = "Toolkit for Dagster integrations with transform logic outside of Dagster"
readme = "README.md"
requires-python = ">=3.8,<3.13"
dependencies = []
classifiers = [ "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9",]
[[project.authors]]
name = "Dagster Labs"
email = "hello@dagsterlabs.com"

[build-system]
requires = [ "hatchling",]
build-backend = "hatchling.build"

[project.license]
text = "Apache-2.0"

[project.urls]
Homepage = "https://github.com/dagster-io/dagster/tree/master/python_modules/dagster-pipes"
Loading

0 comments on commit 36090c1

Please sign in to comment.