Skip to content

Commit

Permalink
WIP: mypy & type hinting
Browse files Browse the repository at this point in the history
  • Loading branch information
craigds committed Nov 8, 2024
1 parent 1451f74 commit 82e14fd
Show file tree
Hide file tree
Showing 35 changed files with 612 additions and 506 deletions.
11 changes: 5 additions & 6 deletions kart/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import importlib
import logging
import os
import platform
import sys

L = logging.getLogger("kart.__init__")
Expand Down Expand Up @@ -40,17 +39,17 @@
)

try:
import _kart_env
import _kart_env # type: ignore[import]

L.debug("Found _kart_env configuration module")
except ImportError:
L.debug("No _kart_env configuration module found")
_kart_env = None

is_frozen = getattr(sys, "frozen", None) and hasattr(sys, "_MEIPASS")
is_darwin = platform.system() == "Darwin"
is_linux = platform.system() == "Linux"
is_windows = platform.system() == "Windows"
is_darwin = sys.platform == "darwin"
is_linux = sys.platform == "linux"
is_windows = sys.platform == "win32"

if is_darwin:
libsuffix = "dylib"
Expand Down Expand Up @@ -146,7 +145,7 @@ def _env_path(path):
os.environ["PATH"] = (
os.pathsep.join(path_extras) + os.pathsep + os.environ.get("PATH", "")
)
if is_windows:
if sys.platform == "win32":
os.add_dll_directory(prefix if is_frozen else os.path.join(prefix, "lib"))
# FIXME: git2.dll is in the package directory, but isn't setup for ctypes to use
_pygit2_spec = importlib.util.find_spec("pygit2")
Expand Down
6 changes: 4 additions & 2 deletions kart/annotations/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import json
import logging
import threading

from typing import TypeAlias
import sqlalchemy

from kart.sqlalchemy.sqlite import sqlite_engine
Expand All @@ -13,7 +13,9 @@
from sqlalchemy.schema import CreateTable

L = logging.getLogger(__name__)
Base = declarative_base()

# TODO: remove this type ignore when we upgrade sqlalchemy to 2.0 and replace with DeclarativeBase
Base: TypeAlias = declarative_base() # type: ignore[valid-type]


class KartAnnotation(Base):
Expand Down
Loading

0 comments on commit 82e14fd

Please sign in to comment.