Fix typing.

This commit is contained in:
Jelmer Vernooij 2021-02-09 03:05:16 +00:00
parent fa222a6ae4
commit 4b1591d864
No known key found for this signature in database
GPG key ID: 579C160D4C9E23E8
5 changed files with 18 additions and 12 deletions

View file

@ -19,7 +19,7 @@ import logging
import os import os
import sys import sys
from . import UpstreamPackage from . import UpstreamPackage
from .buildsystem import NoBuildToolsFound from .buildsystem import NoBuildToolsFound, detect_buildsystems
from .build import run_build from .build import run_build
from .clean import run_clean from .clean import run_clean
from .dist import run_dist from .dist import run_dist

View file

@ -413,7 +413,7 @@ class Cargo(BuildSystem):
name = 'cargo' name = 'cargo'
def __init__(self, path): def __init__(self, path):
from toml.decoder import load, TomlDecodeError from toml.decoder import load
with open(path, 'r') as f: with open(path, 'r') as f:
self.cargo = load(f) self.cargo = load(f)
@ -505,7 +505,6 @@ def detect_buildsystems(path):
cabal_filenames) cabal_filenames)
if os.path.exists(os.path.join(path, '.travis.yml')): if os.path.exists(os.path.join(path, '.travis.yml')):
import yaml
import ruamel.yaml.reader import ruamel.yaml.reader
with open('.travis.yml', 'rb') as f: with open('.travis.yml', 'rb') as f:
try: try:

View file

@ -24,15 +24,17 @@ import os
import re import re
import subprocess import subprocess
import sys import sys
from typing import Iterator, List, Callable, Type, Tuple, Set from typing import Iterator, List, Callable, Type, Tuple, Set, Optional
from debian.deb822 import ( from debian.deb822 import (
Deb822, Deb822,
PkgRelation, PkgRelation,
Release, Release,
) )
from debian.changelog import Version
from breezy.commit import PointlessCommit from breezy.commit import PointlessCommit
from breezy.mutabletree import MutableTree
from breezy.tree import Tree from breezy.tree import Tree
from debmutate.control import ( from debmutate.control import (
ensure_some_version, ensure_some_version,
@ -122,13 +124,18 @@ class CircularDependency(Exception):
class DependencyContext(object): class DependencyContext(object):
def __init__(self, tree, subpath="", committer=None, update_changelog=True):
def __init__(self, tree: MutableTree,
subpath: str = '', committer: Optional[str] = None,
update_changelog: bool = True):
self.tree = tree self.tree = tree
self.subpath = subpath self.subpath = subpath
self.committer = committer self.committer = committer
self.update_changelog = update_changelog self.update_changelog = update_changelog
def add_dependency(self, package, minimum_version=None): def add_dependency(
self, package: str,
minimum_version: Optional[Version] = None) -> bool:
raise NotImplementedError(self.add_dependency) raise NotImplementedError(self.add_dependency)
@ -266,9 +273,9 @@ def add_test_dependency(
) )
def commit_debian_changes( def commit_debian_changes(tree: MutableTree, subpath: str,
tree, subpath, summary, committer=None, update_changelog=True summary: str, committer: Optional[str] = None,
): update_changelog: bool = True) -> bool:
with tree.lock_write(): with tree.lock_write():
try: try:
if update_changelog: if update_changelog:

View file

@ -120,7 +120,7 @@ def create_dist_schroot(
include_controldir: bool = True, include_controldir: bool = True,
subdir: Optional[str] = None) -> str: subdir: Optional[str] = None) -> str:
from .buildsystem import detect_buildsystems from .buildsystem import detect_buildsystems
from .apt import AptResolver from .resolver import AptResolver
if subdir is None: if subdir is None:
subdir = "package" subdir = "package"
with SchrootSession(chroot) as session: with SchrootSession(chroot) as session:

View file

@ -65,7 +65,7 @@ class AptResolver(Resolver):
if req.family == 'python3': if req.family == 'python3':
yield 'python3-%s' % req.name yield 'python3-%s' % req.name
else: else:
path = list(self._possible_paths(req)) list(self._possible_paths(req))
raise NotImplementedError raise NotImplementedError