Skip to content

Commit c8fcaf6

Browse files
committed
Update coding a little bit
- config: drop dead cached_property backport fallback - errors: raise OSError instead of the IOError alias (and its tests) - setup.py: use text=True and stdlib logging (log.warning) - delete setup.cfg, the legacy pycodestyle config (superseded by ruff) Assisted-by: Kimi Code K3
1 parent f0a982f commit c8fcaf6

6 files changed

Lines changed: 9 additions & 17 deletions

File tree

‎AGENTS.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ modules:
6969
also copies `git2.dll` into the package (see `BuildWithDLLs`).
7070
- **`pyproject.toml`** — Build-system requirements, `cibuildwheel`
7171
configuration, `ruff` settings, and `codespell` settings.
72-
- **`setup.cfg`** — Legacy pycodestyle configuration.
7372
- **`pytest.ini`** — pytest configuration (`--capture=no -ra --verbose`,
7473
`testpaths = test/`).
7574
- **`mypy.ini`** — mypy configuration with strict settings.

‎pygit2/config.py‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,10 @@
2424
# Boston, MA 02110-1301, USA.
2525

2626
from collections.abc import Callable, Iterator
27+
from functools import cached_property
2728
from os import PathLike
2829
from typing import TYPE_CHECKING, Any, Optional, Self
2930

30-
try:
31-
from functools import cached_property
32-
except ImportError:
33-
from cached_property import cached_property # type: ignore
34-
3531
# Import from pygit2
3632
from .enums import ConfigLevel
3733
from .errors import GitError, InvalidError, check_error

‎pygit2/errors.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def check_error(
105105

106106
if err == C.GIT_ENOTFOUND:
107107
if io:
108-
raise IOError(message)
108+
raise OSError(message)
109109

110110
raise NotFoundError(message)
111111

‎setup.cfg‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎setup.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
# mypy: disable-error-code="import-not-found, import-untyped"
2727

2828
# Import setuptools before distutils to avoid user warning
29+
import logging
2930
import os
3031
import sys
31-
from distutils import log # type: ignore[attr-defined]
3232
from distutils.command.build import build
3333
from distutils.command.sdist import sdist
3434
from pathlib import Path
@@ -42,15 +42,15 @@
4242

4343
del sys.path[0]
4444

45+
log = logging.getLogger(__name__)
46+
4547

4648
libgit2_bin, libgit2_kw = get_libgit2_paths()
4749

4850

4951
class sdist_files_from_git(sdist):
5052
def get_file_list(self) -> None:
51-
popen = Popen(
52-
['git', 'ls-files'], stdout=PIPE, stderr=PIPE, universal_newlines=True
53-
)
53+
popen = Popen(['git', 'ls-files'], stdout=PIPE, stderr=PIPE, text=True)
5454
stdoutdata, stderrdata = popen.communicate()
5555
if popen.returncode != 0:
5656
print(stderrdata)
@@ -118,7 +118,7 @@ def _get_dlls(self) -> list[tuple[Path, Path]]:
118118
ret.append((f, target))
119119
break
120120
else:
121-
log.warn(f'Could not find required DLL {dll} to include')
121+
log.warning(f'Could not find required DLL {dll} to include')
122122
log.debug(f'(looked in {look_dirs})')
123123
return ret
124124

‎test/test_config.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ def test_config(config: Config) -> None:
5151
def test_global_config() -> None:
5252
try:
5353
assert Config.get_global_config() is not None
54-
except IOError as e:
54+
except OSError as e:
5555
settings = Settings()
5656
pytest.skip(f'Unavailable for testing with home dir = {settings.homedir}: {e}')
5757

5858

5959
def test_system_config() -> None:
6060
try:
6161
assert Config.get_system_config() is not None
62-
except IOError as e:
62+
except OSError as e:
6363
pytest.skip(f'Unavailable for testing: {e}')
6464

6565

0 commit comments

Comments
 (0)