-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix vulnerability report docs * Add `FirstDict`
- Loading branch information
Showing
8 changed files
with
79 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# harborapi.models.mappings | ||
|
||
Custom mapping types. | ||
|
||
::: harborapi.models.mappings | ||
options: | ||
show_if_no_docstring: true | ||
show_source: true | ||
show_bases: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from __future__ import annotations | ||
|
||
import sys | ||
from typing import Optional | ||
from typing import TypeVar | ||
|
||
if sys.version_info >= (3, 9): | ||
from collections import OrderedDict | ||
else: | ||
from typing import OrderedDict | ||
|
||
|
||
_KT = TypeVar("_KT") # key type | ||
_VT = TypeVar("_VT") # value type | ||
|
||
|
||
# NOTE: How to parametrize a normal dict in 3.8? In >=3.9 we can do `dict[_KT, _VT]` | ||
class FirstDict(OrderedDict[_KT, _VT]): | ||
"""Dict with method to get its first value.""" | ||
|
||
def first(self) -> Optional[_VT]: | ||
"""Return the first value in the dict or None if dict is empty.""" | ||
return next(iter(self.values()), None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.