Skip to content

Commit b72dcc0

Browse files
committed
use ruff, remove pylint config
1 parent 0277e66 commit b72dcc0

5 files changed

Lines changed: 54 additions & 55 deletions

File tree

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.2.2
3+
rev: v0.3.3
44
hooks:
55
- id: ruff
66
args: [ --fix ]
77
- id: ruff-format
88

99
- repo: https://github.com/RobertCraigie/pyright-python
10-
rev: v1.1.351
10+
rev: v1.1.354
1111
hooks:
1212
- id: pyright
1313

documentation/reference/mutablezip/index.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
## MutableZipFile
1515

16-
[Show source in __init__.py:13](../../../mutablezip/__init__.py#L13)
16+
[Show source in __init__.py:14](../../../mutablezip/__init__.py#L14)
1717

1818
Add delete (via remove_file) and update (via writestr and write methods)
1919
To enable update features use MutableZipFile with the 'with statement',
@@ -35,9 +35,9 @@ class MutableZipFile(ZipFile):
3535

3636
### MutableZipFile()._closeAllTempFiles
3737

38-
[Show source in __init__.py:121](../../../mutablezip/__init__.py#L121)
38+
[Show source in __init__.py:118](../../../mutablezip/__init__.py#L118)
3939

40-
close all temporary files
40+
Close all temporary files
4141

4242
#### Signature
4343

@@ -47,9 +47,9 @@ def _closeAllTempFiles(self): ...
4747

4848
### MutableZipFile().removeFile
4949

50-
[Show source in __init__.py:127](../../../mutablezip/__init__.py#L127)
50+
[Show source in __init__.py:124](../../../mutablezip/__init__.py#L124)
5151

52-
flag a file with a delete marker
52+
Flag a file with a delete marker
5353

5454
#### Signature
5555

@@ -59,7 +59,7 @@ def removeFile(self, path: str | PathLike[str]): ...
5959

6060
### MutableZipFile().write
6161

62-
[Show source in __init__.py:74](../../../mutablezip/__init__.py#L74)
62+
[Show source in __init__.py:73](../../../mutablezip/__init__.py#L73)
6363

6464
#### Signature
6565

@@ -75,7 +75,7 @@ def write(
7575

7676
### MutableZipFile().writestr
7777

78-
[Show source in __init__.py:45](../../../mutablezip/__init__.py#L45)
78+
[Show source in __init__.py:44](../../../mutablezip/__init__.py#L44)
7979

8080
#### Signature
8181

mutablezip/__init__.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
""" mutable zip file """
1+
"""mutable zip file"""
2+
23
from __future__ import annotations
34

45
from os import PathLike
@@ -28,9 +29,7 @@ def __init__(
2829
compression: int = ZIP_STORED,
2930
allowZip64: bool = False,
3031
):
31-
super().__init__(
32-
file, mode=mode, compression=compression, allowZip64=allowZip64
33-
)
32+
super().__init__(file, mode=mode, compression=compression, allowZip64=allowZip64)
3433
# track file to override in zip
3534
self._replace = {}
3635
# Whether the with statement was called
@@ -83,9 +82,7 @@ def write(
8382
# mark the entry, and create a temp-file for it
8483
# we allow this only if the with statement is used
8584
if self._allowUpdates and arcname in self.namelist():
86-
tempFile = self._replace[arcname] = self._replace.get(
87-
arcname, TemporaryFile()
88-
)
85+
tempFile = self._replace[arcname] = self._replace.get(arcname, TemporaryFile())
8986
with open(filename, "rb") as source:
9087
copyfileobj(source, tempFile)
9188
# Behave normally
@@ -119,13 +116,13 @@ def __exit__(
119116
self._allowUpdates = False
120117

121118
def _closeAllTempFiles(self):
122-
"""close all temporary files"""
119+
"""Close all temporary files"""
123120
for tempFile in self._replace.values():
124121
if hasattr(tempFile, "close"):
125122
tempFile.close()
126123

127124
def removeFile(self, path: str | PathLike[str]):
128-
"""flag a file with a delete marker"""
125+
"""Flag a file with a delete marker"""
129126
self._replace[path] = self.DeleteMarker()
130127

131128
def _rebuildZip(self):

pyproject.toml

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,47 +22,52 @@ readme = "README.md"
2222
[tool.poetry.dependencies]
2323
python = "^3.8"
2424

25-
2625
[tool.poetry.group.dev.dependencies]
27-
pytest = "^8.0.2"
26+
pytest = "^8.1.1"
2827
pylint = "^3.1.0"
2928
handsdown = "^2.1.0"
30-
coverage = "^7.4.3"
31-
32-
[tool.ruff.format]
33-
indent-style = "tab"
34-
docstring-code-format = true
35-
line-ending = "lf"
36-
37-
38-
[tool.isort]
39-
profile = "black"
40-
indent = "Tab"
41-
42-
[tool.pydocstyle]
43-
convention = "google"
44-
ignore = "D205,D415"
29+
coverage = "^7.4.4"
4530

4631
[build-system]
4732
requires = ["poetry-core"]
4833
build-backend = "poetry.core.masonry.api"
4934

50-
[tool.pylint.basic]
51-
argument-naming-style = "camelCase"
52-
attr-naming-style = "camelCase"
53-
function-naming-style = "camelCase"
54-
method-naming-style = "camelCase"
55-
variable-naming-style = "camelCase"
35+
[tool.ruff]
36+
line-length = 100
37+
indent-width = 4
38+
target-version = "py38"
5639

57-
[tool.pylint.format]
58-
indent-string = "\t"
40+
[tool.ruff.lint]
41+
select = ["ALL"]
42+
ignore = [
43+
"ANN101", # type annotation for self in method
44+
"COM812", # enforce trailing comma
45+
"D2", # pydocstyle formatting
46+
"ISC001",
47+
"N", # pep8 naming
48+
"PLR09", # pylint refactor too many
49+
"TCH", # type check blocks
50+
"W191" # ignore this to allow tabs
51+
]
52+
fixable = ["ALL"]
53+
54+
[tool.ruff.lint.per-file-ignores]
55+
"**/{tests,docs,tools}/*" = ["D", "S101", "E402"]
56+
57+
[tool.ruff.lint.flake8-tidy-imports]
58+
ban-relative-imports = "all" # Disallow all relative imports.
59+
60+
[tool.ruff.format]
61+
indent-style = "tab"
62+
docstring-code-format = true
63+
line-ending = "lf"
5964

60-
[tool.pylint.master]
61-
ignore-paths = ["tests"]
65+
[tool.pyright]
66+
venvPath = "."
67+
venv = ".venv"
6268

63-
[tool.pylint.messages_control]
64-
enable = ["F", "E", "W", "R", "C"]
65-
disable = ["pointless-string-statement", "superfluous-parens"]
69+
[tool.coverage.run]
70+
branch = true
6671

6772
[tool.tox]
6873
legacy_tox_ini = """

tests/test_main.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3.9
22

3-
""" tests """
3+
"""tests"""
4+
45
from __future__ import annotations
56

67
import sys
@@ -14,9 +15,7 @@
1415

1516

1617
def test_MutableZipFile():
17-
with MutableZipFile(
18-
f"{THISDIR}/data/mutable.zip", "a", compression=ZIP_DEFLATED
19-
) as zipFile:
18+
with MutableZipFile(f"{THISDIR}/data/mutable.zip", "a", compression=ZIP_DEFLATED) as zipFile:
2019
with zipFile.open("foo.txt", "r") as file:
2120
lines = [line.strip() for line in file.readlines()]
2221
lines.append(b"new line")
@@ -26,9 +25,7 @@ def test_MutableZipFile():
2625

2726

2827
def test_ZipFile():
29-
with ZipFile(
30-
f"{THISDIR}/data/immutable.zip", "a", compression=ZIP_DEFLATED
31-
) as zipFile:
28+
with ZipFile(f"{THISDIR}/data/immutable.zip", "a", compression=ZIP_DEFLATED) as zipFile:
3229
with zipFile.open("foo.txt", "r") as file:
3330
lines = [line.strip() for line in file.readlines()]
3431
lines.append(b"new line")

0 commit comments

Comments
 (0)