Browse Source

Fix typing error (#1379)

Jelmer Vernooij 5 months ago
parent
commit
2074102da8
3 changed files with 7 additions and 6 deletions
  1. 1 1
      .github/workflows/pythontest.yml
  2. 4 4
      dulwich/refs.py
  3. 2 1
      pyproject.toml

+ 1 - 1
.github/workflows/pythontest.yml

@@ -43,7 +43,7 @@ jobs:
           python -m ruff format --check .
       - name: Typing checks
         run: |
-          pip install --upgrade mypy types-paramiko types-requests
+          pip install --upgrade types-paramiko types-requests
           python -m mypy dulwich
         if: "matrix.python-version != 'pypy3'"
       - name: Build

+ 4 - 4
dulwich/refs.py

@@ -24,7 +24,7 @@
 import os
 import warnings
 from contextlib import suppress
-from typing import Any, Dict, Optional, Set
+from typing import Any, Dict, List, Optional, Set, Tuple
 
 from .errors import PackedRefsException, RefFormatError
 from .file import GitFile, ensure_dir_exists
@@ -53,7 +53,7 @@ class SymrefLoop(Exception):
         self.depth = depth
 
 
-def parse_symref_value(contents):
+def parse_symref_value(contents: bytes) -> bytes:
     """Parse a symref value.
 
     Args:
@@ -291,7 +291,7 @@ class RefsContainer:
         """
         raise NotImplementedError(self.read_loose_ref)
 
-    def follow(self, name):
+    def follow(self, name) -> Tuple[List[bytes], bytes]:
         """Follow a reference name.
 
         Returns: a tuple of (refnames, sha), wheres refnames are the names of
@@ -1188,7 +1188,7 @@ def _set_origin_head(refs, origin, origin_head):
 def _set_default_branch(
     refs: RefsContainer,
     origin: bytes,
-    origin_head: bytes,
+    origin_head: Optional[bytes],
     branch: bytes,
     ref_message: Optional[bytes],
 ) -> bytes:

+ 2 - 1
pyproject.toml

@@ -42,7 +42,8 @@ https = ["urllib3>=1.24.1"]
 pgp = ["gpg"]
 paramiko = ["paramiko"]
 dev = [
-    "ruff==0.6.9"
+    "ruff==0.6.9",
+    "mypy==1.12.0"
 ]
 
 [project.scripts]