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

Replace black with ruff-format #40

Merged
merged 2 commits into from
Apr 2, 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
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ repos:

- repo: local
hooks:
- id: black
name: black
entry: black
- id: ruff-format
name: ruff-format
entry: ruff format --force-exclude
language: python
types_or: [python, pyi]
require_serial: true
Expand Down
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ For docstrings, adhere to [numpydoc](https://numpydoc.readthedocs.io/en/latest/f

## Code style
We use the following tools for code style and quality:
- [Black](https://black.readthedocs.io/en/stable/) for formatting
- [Ruff](https://docs.astral.sh/ruff/) for linting
- [Ruff](https://docs.astral.sh/ruff/) for formatting and linting
- [mypy](https://mypy.readthedocs.io/en/stable/) for static type checking

The development environment includes these tools, so you can either run them individually or use pre-commit.
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Linting: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)


edfio is a Python package for reading and writing [EDF](https://www.edfplus.info/specs/edf.html) and [EDF+C](https://www.edfplus.info/specs/edfplus.html) files.
Expand Down
6 changes: 2 additions & 4 deletions edfio/_header_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,10 @@ def __init__(self, length: int, *, is_settable: bool) -> None:
self.is_settable = is_settable

@overload
def __get__(self, instance: None, owner: Any) -> RawHeaderField[T]:
...
def __get__(self, instance: None, owner: Any) -> RawHeaderField[T]: ...

@overload
def __get__(self, instance: Any, owner: Any) -> T:
...
def __get__(self, instance: Any, owner: Any) -> T: ...

def __get__(self, instance: Any, owner: Any = None) -> RawHeaderField[T] | T:
if instance is None:
Expand Down
4 changes: 2 additions & 2 deletions edfio/edf.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,8 @@ def starttime(self, starttime: datetime.time) -> None:
if maxlen % 2:
maxlen += 1
raw = b"".join(dr.ljust(maxlen, b"\x00") for dr in data_records)
timekeeping_signal._samples_per_data_record = EdfSignal.samples_per_data_record.encode( # type: ignore[attr-defined]
maxlen // 2
timekeeping_signal._samples_per_data_record = ( # type: ignore[attr-defined]
EdfSignal.samples_per_data_record.encode(maxlen // 2)
)
timekeeping_signal._sampling_frequency = (
maxlen // 2 * self.data_record_duration
Expand Down
18 changes: 8 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ numpy = ">=1.22.0"
pytest = "7.4.3"
pytest-cov = "4.1.0"
pre-commit = "3.5.0"
black = "23.11.0"
mypy = "1.6.1"
ruff = "0.1.5"
ruff = "0.3.4"
sphinx = "7.2.6"
myst-parser = "2.0.0"
pydata-sphinx-theme = "0.14.3"
Expand All @@ -32,10 +31,11 @@ style = "semver"
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.black]
target-version = ["py39", "py310", "py311", "py312"]

[tool.ruff]
target-version = "py39"
fix = true

[tool.ruff.lint]
select = [
"F",
"E",
Expand All @@ -59,17 +59,15 @@ select = [
"RUF",
]
ignore = ["E501", "E741", "B028", "D100", "D104", "D105", "PLR0913"]
target-version = "py39"
fix = true
fixable = ["I001"]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"tests/*" = ["S101", "PLR2004", "B018", "D"]

[tool.ruff.flake8-tidy-imports]
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"

[tool.ruff.pydocstyle]
[tool.ruff.lint.pydocstyle]
convention = "numpy"

[tool.mypy]
Expand Down