Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring of black, isort, mypy tools usages into pyproject.toml #378

Merged
merged 1 commit into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ requires-dist = [
"pytest; extra == 'devel'",
"pytest-mock; extra == 'devel'",
"pytest-cov; extra == 'devel'",
"pytest-clarity; extra == 'devel'",
"pytest-timeout; extra == 'devel'",
"sphinx; extra == 'devel'",
"sphinx-rtd-theme; extra == 'devel'",
Expand Down
13 changes: 6 additions & 7 deletions python/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
.DEFAULT_GOAL := help

VENV := venv
PY_SOURCE_DIR := deltalake tests

MATURIN_VERSION := $(shell awk -F '[ ="]+' '$$1 == "requires" { print $$4 }' pyproject.toml)

.PHONY: setup-venv
setup-venv: ## Setup the virtualenv
Expand All @@ -12,7 +11,7 @@ setup-venv: ## Setup the virtualenv
.PHONY: setup
setup: ## Setup the requirements
$(info --- Setup dependencies ---)
pip install maturin==0.10.6
pip install maturin==$(MATURIN_VERSION)

.PHONY: develop
develop: setup ## Install Python binding of delta-rs
Expand All @@ -24,7 +23,7 @@ format: ## Format the code
$(info --- Rust format ---)
cargo fmt
$(info --- Python format ---)
black deltalake tests *.py
black
isort .

.PHONY: check-rust
Expand All @@ -37,11 +36,11 @@ check-rust: ## Run check on Rust
.PHONY: check-python
check-python: ## Run check on Python
$(info Check Python isort)
isort --diff --check-only $(PY_SOURCE_DIR)
isort --diff --check-only .
$(info Check Python black)
black --check $(PY_SOURCE_DIR)
black --check
$(info Check Python mypy)
mypy --config-file setup.cfg $(PY_SOURCE_DIR)
mypy

.PHONY: unit-test
unit-test: ## Run unit test
Expand Down
2 changes: 1 addition & 1 deletion python/deltalake/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .deltalake import RawDeltaTable, RawDeltaTableMetaData, rust_core_version
from .deltalake import RawDeltaTable, rust_core_version
from .schema import DataType, Field, Schema
from .table import DeltaTable, Metadata
2 changes: 1 addition & 1 deletion python/deltalake/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
if TYPE_CHECKING:
import pandas

from .deltalake import RawDeltaTable, RawDeltaTableMetaData
from .deltalake import RawDeltaTable
from .schema import Schema, pyarrow_schema_from_json


Expand Down
20 changes: 0 additions & 20 deletions python/mypy.ini

This file was deleted.

22 changes: 21 additions & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
[build-system]
requires = ["maturin==0.10.6"]
requires = ["maturin==0.11.2"]
build-backend = "maturin"

[tool.mypy]
files = "deltalake/*.py"
exclude = "^tests"
mypy_path = "./stubs"
disallow_any_generics = true
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
disallow_untyped_decorators = true
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_return_any = false
implicit_reexport = false
strict_equality = true

[tool.isort]
profile = "black"
src_paths = ["deltalake", "tests"]

[tool.black]
include = "deltalake,tests"
exclude = "venv"
5 changes: 0 additions & 5 deletions python/setup.cfg

This file was deleted.

3 changes: 3 additions & 0 deletions python/stubs/deltalake/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Any

RawDeltaTableMetadata: Any
4 changes: 4 additions & 0 deletions python/stubs/deltalake/deltalake.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from typing import Any

RawDeltaTable: Any
rust_core_version: Any
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could annotate this as a callable that returns a str

3 changes: 3 additions & 0 deletions python/stubs/pandas/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Any

DataFrame: Any
18 changes: 18 additions & 0 deletions python/stubs/pyarrow/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from typing import Any

Schema: Any
Table: Any
Field: Any
DataType: Any
schema: Any
map_: Any
list_: Any
field: Any
struct: Any
type_for_alias: Any
date32: Any
date64: Any
decimal128: Any
float16: Any
float32: Any
float64: Any
5 changes: 5 additions & 0 deletions python/stubs/pyarrow/dataset.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from typing import Any

Dataset: Any
dataset: Any
partitioning: Any