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

ci: switch to ruff #795

Merged
merged 6 commits into from
Jun 17, 2024
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
4 changes: 0 additions & 4 deletions .flake8

This file was deleted.

22 changes: 9 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,23 @@ repos:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: local
hooks:
- id: system
name: black
entry: poetry run black
name: Lint with Ruff
entry: poetry run ruff check
types: [python]
language: system

- id: system
name: isort
entry: poetry run isort
name: Lint with Ruff format
entry: poetry run ruff format --check
types: [python]
language: system

- id: system
name: flake8
entry: poetry run flake8 peakina tests
types: [python]
language: system
- id: mypy
name: mypy
name: Lint with Mypy
entry: poetry run mypy
language: system
types: [python]
require_serial: true
verbose: true
language: system
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.DEFAULT_GOAL := all
black = poetry run black peakina tests
isort = poetry run isort peakina tests
# Commands
RUFF = poetry run ruff check peakina tests
FORMAT = poetry run ruff format peakina tests
MYPY = poetry run mypy peakina tests

.PHONY: install_system_deps
install_system_deps:
Expand All @@ -15,13 +17,14 @@ install:

.PHONY: format
format:
poetry run pre-commit run --all-files
${RUFF} --fix
${FORMAT}

.PHONY: lint
lint:
$(black) --diff --check
$(isort) --check-only
poetry run flake8 peakina tests
${RUFF}
${FORMAT} --check
${MYPY}

.PHONY: mypy
mypy:
Expand Down
4 changes: 3 additions & 1 deletion peakina/io/ftp/ftp_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ def ntransfercmd( # type: ignore[override]
conn, size = ftplib.FTP.ntransfercmd(self, cmd, rest)
if self._prot_p: # type: ignore[attr-defined]
conn = self.context.wrap_socket(
conn, server_hostname=self.host, session=self.sock.session # type: ignore[union-attr]
conn,
server_hostname=self.host,
session=self.sock.session, # type: ignore[union-attr]
) # this is the fix
return conn, size # type:ignore[return-value] # size could be None here

Expand Down
139 changes: 28 additions & 111 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 6 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,9 @@ geopandas = ">=0.11.1,<1"
pyarrow = ">=11,<17"
openpyxl = "^3.1.2"

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
aiobotocore = {extras = ["boto3"], version = "^2.3.4"}
black = "^24.4"
docker = "^7.1.0"
flake8 = "^7.1.0"
isort = "^5.13.2"
mkdocs = "^1.5.3"
mkdocs-material = "^9.5.18"
mypy = "^1.10"
Expand All @@ -50,6 +47,7 @@ pytest-mock = "^3.14.0"
pytest-rerunfailures = "^14.0"
pytest-sugar = ">=0.9.4,<2"
PyYAML = "^6.0"
ruff = "^0.4.9"

# types
types-chardet = "^5.0.4"
Expand All @@ -63,13 +61,11 @@ types-PyYAML = "^6.0.12"
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.black]
target-version = ["py310"]
[tool.ruff]
# Assume python 3.10
target-version = "py310"
line-length = 100

[tool.isort]
profile = "black"
combine_as_imports = true
exclude = ["__init__.py", ".git", ".direnv"]

[tool.mypy]
python_version = "3.10"
Expand Down
13 changes: 8 additions & 5 deletions tests/test_datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,14 @@ def test_basic_excel(path):
ds = DataSource(path("fixture-multi-sheet.xlsx"))
df = pd.DataFrame({"Month": [1], "Year": [2019]})
assert ds.get_df().equals(df)
assert ds.get_metadata() == {
"df_rows": 1,
"sheetnames": ["January", "February"],
"total_rows": 4, # we have for rows as total here because january sheet has 1 row and February sheet has 3 (1 + 3)
}
assert (
ds.get_metadata()
== {
"df_rows": 1,
"sheetnames": ["January", "February"],
"total_rows": 4, # we have for rows as total here because january sheet has 1 row and February sheet has 3 (1 + 3)
}
)

# On match datasources, no metadata is returned:
assert DataSource(path("fixture-multi-sh*t.xlsx"), match=MatchEnum.GLOB).get_metadata() == {}
Expand Down
Loading