Skip to content
GitLab
Explore
Sign in
Commits on Source (2)
Improve typing of DownloadableBinaries abstract methods
· af9c54d6
Dom Sekotill
authored
Jun 28, 2024
af9c54d6
Add tool caches to gitignore
· 57375a01
Dom Sekotill
authored
Jun 29, 2024
57375a01
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
57375a01
...
@@ -4,3 +4,5 @@ dist/
...
@@ -4,3 +4,5 @@ dist/
# Testing
# Testing
/results/
/results/
/.*_cache/
behave_utils/binaries.py
View file @
57375a01
...
@@ -20,6 +20,7 @@ from pathlib import Path
...
@@ -20,6 +20,7 @@ from pathlib import Path
from
shutil
import
copyfileobj
from
shutil
import
copyfileobj
from
tarfile
import
TarFile
from
tarfile
import
TarFile
from
typing
import
IO
from
typing
import
IO
from
typing
import
TYPE_CHECKING
import
requests
import
requests
from
packaging.version
import
Version
from
packaging.version
import
Version
...
@@ -28,6 +29,9 @@ from xdg_base_dirs import xdg_cache_home
...
@@ -28,6 +29,9 @@ from xdg_base_dirs import xdg_cache_home
from
behave_utils.json
import
JSONObject
from
behave_utils.json
import
JSONObject
from
behave_utils.url
import
URL
from
behave_utils.url
import
URL
if
TYPE_CHECKING
:
from
.types
import
Readable
CACHE_DIR
:
Path
=
xdg_cache_home
()
/
"
behave-testing
"
CACHE_DIR
:
Path
=
xdg_cache_home
()
/
"
behave-testing
"
...
@@ -92,7 +96,7 @@ class DownloadableExecutable(ABC):
...
@@ -92,7 +96,7 @@ class DownloadableExecutable(ABC):
raise
NotImplementedError
raise
NotImplementedError
@abstractmethod
@abstractmethod
def
get_stream
(
self
,
session
:
requests
.
Session
,
version
:
str
)
->
IO
[
bytes
]:
def
get_stream
(
self
,
session
:
requests
.
Session
,
version
:
str
)
->
Readable
[
bytes
]:
"""
"""
Return a stream that emits the requested version of a supported binary
Return a stream that emits the requested version of a supported binary
...
...
behave_utils/types.pyi
0 → 100644
View file @
57375a01
# Copyright 2024 Dominik Sekotill <dom.sekotill@kodo.org.uk>
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
"""
General type definitions
"""
from
typing
import
Protocol
from
typing
import
TypeVar
S_co
=
TypeVar
(
"
S_co
"
,
bound
=
str
|
bytes
,
covariant
=
True
)
class
Readable
(
Protocol
[
S_co
]):
"""
Protocol for types that implement the read() method of file-like objects
"""
def
read
(
self
,
_s
:
int
=
...,
/
)
->
S_co
:
...