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 sys
from . import UpstreamPackage
from .buildsystem import NoBuildToolsFound
from .buildsystem import NoBuildToolsFound, detect_buildsystems
from .build import run_build
from .clean import run_clean
from .dist import run_dist

View file

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

View file

@ -24,15 +24,17 @@ import os
import re
import subprocess
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 (
Deb822,
PkgRelation,
Release,
)
)
from debian.changelog import Version
from breezy.commit import PointlessCommit
from breezy.mutabletree import MutableTree
from breezy.tree import Tree
from debmutate.control import (
ensure_some_version,
@ -122,13 +124,18 @@ class CircularDependency(Exception):
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.subpath = subpath
self.committer = committer
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)
@ -266,9 +273,9 @@ def add_test_dependency(
)
def commit_debian_changes(
tree, subpath, summary, committer=None, update_changelog=True
):
def commit_debian_changes(tree: MutableTree, subpath: str,
summary: str, committer: Optional[str] = None,
update_changelog: bool = True) -> bool:
with tree.lock_write():
try:
if update_changelog:

View file

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

View file

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