Commit 6d443e4 František Nečas
committed
1 parent 58572af commit 6d443e4 Copy full SHA for 6d443e4
File tree 8 files changed +39
-30
lines changed
8 files changed +39
-30
lines changed Original file line number Diff line number Diff line change @@ -1009,7 +1009,7 @@ def set(
1009
1009
raise NotImplementedError ()
1010
1010
1011
1011
@property
1012
- def created (self ) -> Optional [ datetime .datetime ] :
1012
+ def created (self ) -> datetime .datetime :
1013
1013
"""Datetime of creating the commit status."""
1014
1014
raise NotImplementedError ()
1015
1015
@@ -1112,7 +1112,11 @@ def body(self) -> str:
1112
1112
1113
1113
@property
1114
1114
def git_tag (self ) -> GitTag :
1115
- """Object that represents tag tied to the release."""
1115
+ """Object that represents tag tied to the release.
1116
+
1117
+ Raises:
1118
+ OgrException, if the tag is not found.
1119
+ """
1116
1120
raise NotImplementedError ()
1117
1121
1118
1122
@property
@@ -1337,7 +1341,7 @@ def __init__(
1337
1341
1338
1342
- GitHub: username or org name.
1339
1343
- GitLab: username or org name.
1340
- - Pagure: namespace (e.g. `"rpms"`). May be none .
1344
+ - Pagure: namespace (e.g. `"rpms"`). May be `None`, i.e. no namespace present .
1341
1345
1342
1346
In case of forks: `"fork/{username}/{namespace}"`.
1343
1347
"""
Original file line number Diff line number Diff line change @@ -10,14 +10,14 @@ class RepoUrl:
10
10
Class that represents repo URL.
11
11
12
12
Attributes:
13
- repo (Optional[str]) : Name of the repository. Can be None if parsing is being done.
14
- namespace (Optional[str]) : Namespace of the repository, if has any.
15
- username (Optional[str]) : Username of the repository owner, if can be
13
+ repo: Name of the repository. Can be ` None` if parsing is being done.
14
+ namespace: Namespace of the repository, if has any.
15
+ username: Username of the repository owner, if can be
16
16
specified.
17
- is_fork (bool) : Flag denoting if repository is a fork, if can be
17
+ is_fork: Flag denoting if repository is a fork, if can be
18
18
specified (Pagure).
19
- hostname (Optional[str]) : Hostname of host of the repository.
20
- scheme (Optional[str]) : Protocol used to access repository.
19
+ hostname: Hostname of host of the repository.
20
+ scheme: Protocol used to access repository.
21
21
"""
22
22
23
23
def __init__ (
Original file line number Diff line number Diff line change 9
9
from ogr .abstract import CommitFlag , CommitStatus
10
10
from ogr .services import github as ogr_github
11
11
from ogr .services .base import BaseCommitFlag
12
+ from ogr .exceptions import OgrException
12
13
13
14
14
15
class GithubCommitFlag (BaseCommitFlag ):
@@ -64,10 +65,10 @@ def set(
64
65
return GithubCommitFlag (project = project , raw_commit_flag = status , commit = commit )
65
66
66
67
@property
67
- def created (self ) -> Optional [ datetime .datetime ] :
68
- if self ._raw_commit_flag :
69
- return self . _raw_commit_flag . created_at
70
- return None
68
+ def created (self ) -> datetime .datetime :
69
+ if not self ._raw_commit_flag :
70
+ raise OgrException ( "Raw commit flag not set, this should not happen." )
71
+ return self . _raw_commit_flag . created_at
71
72
72
73
@property
73
74
def edited (self ) -> Optional [datetime .datetime ]:
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ def create(
86
86
body : str ,
87
87
private : Optional [bool ] = None ,
88
88
labels : Optional [List [str ]] = None ,
89
- assignees : Optional [list ] = None ,
89
+ assignees : Optional [List [ str ] ] = None ,
90
90
) -> "Issue" :
91
91
if private :
92
92
raise OperationNotSupported ("Private issues are not supported by Github" )
Original file line number Diff line number Diff line change 3
3
4
4
import logging
5
5
import datetime
6
- from typing import List , Optional
6
+ from typing import List
7
7
8
8
import gitlab
9
9
10
10
from ogr .abstract import CommitFlag , CommitStatus
11
- from ogr .exceptions import GitlabAPIException , OperationNotSupported
11
+ from ogr .exceptions import GitlabAPIException , OperationNotSupported , OgrException
12
12
from ogr .services import gitlab as ogr_gitlab
13
13
from ogr .services .base import BaseCommitFlag
14
14
@@ -93,13 +93,12 @@ def set(
93
93
return GitlabCommitFlag (raw_commit_flag = raw_status , project = project )
94
94
95
95
@property
96
- def created (self ) -> Optional [datetime .datetime ]:
97
- return (
98
- datetime .datetime .strptime (
99
- self ._raw_commit_flag .created_at , "%Y-%m-%dT%H:%M:%S.%fZ"
100
- )
101
- if self ._raw_commit_flag
102
- else None
96
+ def created (self ) -> datetime .datetime :
97
+ if not self ._raw_commit_flag :
98
+ raise OgrException ("Raw commit flag not set, this should not happen." )
99
+
100
+ return datetime .datetime .strptime (
101
+ self ._raw_commit_flag .created_at , "%Y-%m-%dT%H:%M:%S.%fZ"
103
102
)
104
103
105
104
@property
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ def url(self) -> str:
47
47
return self ._raw_issue .web_url
48
48
49
49
@property
50
- def assignees (self ) -> Optional [list ]:
50
+ def assignees (self ) -> Optional [List [ str ] ]:
51
51
try :
52
52
return self ._raw_issue .assignees
53
53
except AttributeError :
Original file line number Diff line number Diff line change 8
8
from ogr .abstract import CommitFlag , CommitStatus
9
9
from ogr .services import pagure as ogr_pagure
10
10
from ogr .services .base import BaseCommitFlag
11
+ from ogr .exceptions import OgrException
11
12
12
13
13
14
class PagureCommitFlag (BaseCommitFlag ):
@@ -73,11 +74,11 @@ def set(
73
74
)
74
75
75
76
@property
76
- def created (self ) -> Optional [ datetime .datetime ] :
77
- return (
78
- datetime . datetime . fromtimestamp ( int ( self . _raw_commit_flag [ "date_created" ]) )
79
- if self . _raw_commit_flag
80
- else None
77
+ def created (self ) -> datetime .datetime :
78
+ if not self . _raw_commit_flag :
79
+ raise OgrException ( "Raw commit flag not set, this should not happen." )
80
+ return datetime . datetime . fromtimestamp (
81
+ int ( self . _raw_commit_flag [ "date_created" ])
81
82
)
82
83
83
84
@property
Original file line number Diff line number Diff line change @@ -71,8 +71,12 @@ def create(
71
71
message : str ,
72
72
ref : Optional [str ] = None ,
73
73
) -> "Release" :
74
+ """
75
+ Raises:
76
+ ValueError, if ref is not specified.
77
+ """
74
78
if not ref :
75
- raise PagureAPIException ("Release ref must be specified" )
79
+ raise ValueError ("Release ref must be specified" )
76
80
payload = {
77
81
"tagname" : tag ,
78
82
"commit_hash" : ref ,
You can’t perform that action at this time.
0 commit comments