Skip to content

Commit dc9d644

Browse files
committed
Switch to ruff instead of black and isort
1 parent f10b8c7 commit dc9d644

File tree

5 files changed

+18
-21
lines changed

5 files changed

+18
-21
lines changed

.github/workflows/python-test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ jobs:
5656
run: |
5757
source .venv/bin/activate
5858
mypy
59-
isort . --check
60-
black . --check
59+
ruff check .
60+
ruff format . --check --diff
6161
6262
- name: Run tests
6363
run: |

python/conftest.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import fsspec
66
import pytest
7+
78
from hdfs_native import Client
89
from hdfs_native.fsspec import HdfsFileSystem
910

@@ -35,7 +36,7 @@ def minidfs():
3536

3637
try:
3738
child.communicate(input="\n", timeout=30)
38-
except:
39+
except: # noqa: E722
3940
child.kill()
4041

4142

python/hdfs_native/__init__.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import io
22
import os
3-
from typing import Dict, Iterator, Optional
3+
from typing import TYPE_CHECKING, Dict, Iterator, Optional
44

55
# For some reason mypy doesn't think this exists
66
from typing_extensions import Buffer # type: ignore
77

8-
from ._internal import *
8+
from ._internal import RawClient, WriteOptions
99

10+
if TYPE_CHECKING:
11+
from ._internal import ContentSummary, FileStatus, RawFileReader, RawFileWriter
1012

11-
class FileReader(io.RawIOBase):
1213

14+
class FileReader(io.RawIOBase):
1315
def __init__(self, inner: "RawFileReader"):
1416
self.inner = inner
1517

@@ -64,7 +66,6 @@ def close(self) -> None:
6466

6567

6668
class FileWriter(io.RawIOBase):
67-
6869
def __init__(self, inner: "RawFileWriter"):
6970
self.inner = inner
7071

@@ -87,7 +88,6 @@ def __exit__(self, *_args):
8788

8889

8990
class Client:
90-
9191
def __init__(
9292
self,
9393
url: Optional[str] = None,

python/pyproject.toml

+6-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ dependencies = [
2020

2121
[project.optional-dependencies]
2222
devel = [
23-
"mypy~=1.8.0",
24-
"ruff~=0.4.8",
25-
"pytest~=7.4",
26-
"black~=24.4",
27-
"isort~=5.13"
23+
"mypy~=1.13.0",
24+
"ruff~=0.7.2",
25+
"pytest~=8.3",
2826
]
2927

3028
[project.urls]
@@ -53,3 +51,6 @@ testpaths = [
5351
"tests",
5452
"hdfs_native",
5553
]
54+
55+
[tool.ruff.lint]
56+
extend-select = ["I"]

python/tests/test_fsspec.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,24 @@
22

33
import fsspec
44
import pytest
5+
56
from hdfs_native.fsspec import HdfsFileSystem
67

78

89
def test_dirs(fs: HdfsFileSystem):
910
fs.mkdir("/testdir")
1011
assert fs.info("/testdir")["type"] == "directory"
1112

12-
try:
13+
with pytest.raises(FileExistsError):
1314
fs.makedirs("/testdir", exist_ok=False)
14-
assert False, '"/testdir" already exists, should fail'
15-
except:
16-
pass
1715

1816
fs.makedirs("/testdir", exist_ok=True)
1917

2018
fs.mkdir("/testdir/nested/dir")
2119
assert fs.info("/testdir/nested/dir")["type"] == "directory"
2220

23-
try:
21+
with pytest.raises(FileExistsError):
2422
fs.mkdir("/testdir/nested2/dir", create_parents=False)
25-
assert False, "Should fail to make dir because parent doesn't exist"
26-
except:
27-
pass
2823

2924
with pytest.raises(RuntimeError):
3025
fs.rm("/testdir", recursive=False)

0 commit comments

Comments
 (0)