| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,7 +24,7 @@ class Blob(base.IndexObject): | |||
| 24 | 24 | __slots__ = () | |
| 25 | 25 | ||
| 26 | 26 | @property | |
| 27 | - def mime_type(self) -> Union[None, Tuple[Union[None, str], Union[None, str]]]: | ||
| 27 | + def mime_type(self) -> Union[None, str, Tuple[Union[None, str], Union[None, str]]]: | ||
| 28 | 28 | """ | |
| 29 | 29 | :return: String describing the mime type of this file (based on the filename) | |
| 30 | 30 | :note: Defaults to 'text/plain' in case the actual file type is unknown. """ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,6 +17,15 @@ | |||
| 17 | 17 | import calendar | |
| 18 | 18 | from datetime import datetime, timedelta, tzinfo | |
| 19 | 19 | ||
| 20 | + | ||
| 21 | + from typing import TYPE_CHECKING, Union | ||
| 22 | + | ||
| 23 | + if TYPE_CHECKING: | ||
| 24 | + from .commit import Commit | ||
| 25 | + from .blob import Blob | ||
| 26 | + from .tag import TagObject | ||
| 27 | + from .tree import Tree | ||
| 28 | + | ||
| 20 | 29 | __all__ = ('get_object_type_by_name', 'parse_date', 'parse_actor_and_date', | |
| 21 | 30 | 'ProcessStreamAdapter', 'Traversable', 'altz_to_utctz_str', 'utctz_to_altz', | |
| 22 | 31 | 'verify_utctz', 'Actor', 'tzoffset', 'utc') | |
@@ -26,7 +35,7 @@ | |||
| 26 | 35 | #{ Functions | |
| 27 | 36 | ||
| 28 | 37 | ||
| 29 | - def mode_str_to_int(modestr): | ||
| 38 | + def mode_str_to_int(modestr: str) -> int: | ||
| 30 | 39 | """ | |
| 31 | 40 | :param modestr: string like 755 or 644 or 100644 - only the last 6 chars will be used | |
| 32 | 41 | :return: | |
@@ -41,7 +50,7 @@ def mode_str_to_int(modestr): | |||
| 41 | 50 | return mode | |
| 42 | 51 | ||
| 43 | 52 | ||
| 44 | - def get_object_type_by_name(object_type_name): | ||
| 53 | + def get_object_type_by_name(object_type_name: str) -> Union['Commit', 'TagObject', 'Tree', 'Blob']: | ||
| 45 | 54 | """ | |
| 46 | 55 | :return: type suitable to handle the given object type name. | |
| 47 | 56 | Use the type to create new instances. | |
@@ -65,15 +74,15 @@ def get_object_type_by_name(object_type_name): | |||
| 65 | 74 | raise ValueError("Cannot handle unknown object type: %s" % object_type_name) | |
| 66 | 75 | ||
| 67 | 76 | ||
| 68 | - def utctz_to_altz(utctz): | ||
| 77 | + def utctz_to_altz(utctz: str) -> int: | ||
| 69 | 78 | """we convert utctz to the timezone in seconds, it is the format time.altzone | |
| 70 | 79 | returns. Git stores it as UTC timezone which has the opposite sign as well, | |
| 71 | 80 | which explains the -1 * ( that was made explicit here ) | |
| 72 | 81 | :param utctz: git utc timezone string, i.e. +0200""" | |
| 73 | 82 | return -1 * int(float(utctz) / 100 * 3600) | |
| 74 | 83 | ||
| 75 | 84 | ||
| 76 | - def altz_to_utctz_str(altz): | ||
| 85 | + def altz_to_utctz_str(altz: int) -> str: | ||
| 77 | 86 | """As above, but inverses the operation, returning a string that can be used | |
| 78 | 87 | in commit objects""" | |
| 79 | 88 | utci = -1 * int((float(altz) / 3600) * 100) | |
@@ -83,7 +92,7 @@ def altz_to_utctz_str(altz): | |||
| 83 | 92 | return prefix + utcs | |
| 84 | 93 | ||
| 85 | 94 | ||
| 86 | - def verify_utctz(offset): | ||
| 95 | + def verify_utctz(offset: str) -> str: | ||
| 87 | 96 | """:raise ValueError: if offset is incorrect | |
| 88 | 97 | :return: offset""" | |
| 89 | 98 | fmt_exc = ValueError("Invalid timezone offset format: %s" % offset) | |
@@ -101,6 +110,7 @@ def verify_utctz(offset): | |||
| 101 | 110 | ||
| 102 | 111 | ||
| 103 | 112 | class tzoffset(tzinfo): | |
| 113 | + | ||
| 104 | 114 | def __init__(self, secs_west_of_utc, name=None): | |
| 105 | 115 | self._offset = timedelta(seconds=-secs_west_of_utc) | |
| 106 | 116 | self._name = name or 'fixed' | |
| Back | FazBrowse Home | New Git URL |
0 commit comments