Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DuniterPy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
python
DuniterPy
Commits
dce62484
Commit
dce62484
authored
6 years ago
by
Moul
Browse files
Options
Downloads
Patches
Plain Diff
[mod] __eq__(): return NotImplemented in case of equality between different classes
parent
872bbcc3
No related branches found
No related tags found
1 merge request
!55
Implement InputSource and OutputSource equality and hash methods
Pipeline
#5233
passed
6 years ago
Stage: github-sync
Stage: build
Stage: test
Stage: release
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
duniterpy/api/endpoint.py
+18
-24
18 additions, 24 deletions
duniterpy/api/endpoint.py
duniterpy/documents/block.py
+1
-1
1 addition, 1 deletion
duniterpy/documents/block.py
duniterpy/documents/block_uid.py
+1
-1
1 addition, 1 deletion
duniterpy/documents/block_uid.py
with
20 additions
and
26 deletions
duniterpy/api/endpoint.py
+
18
−
24
View file @
dce62484
...
@@ -108,10 +108,9 @@ class UnknownEndpoint(Endpoint):
...
@@ -108,10 +108,9 @@ class UnknownEndpoint(Endpoint):
return
"
{0} {1}
"
.
format
(
self
.
api
,
'
'
.
join
([
"
{0}
"
.
format
(
p
)
for
p
in
self
.
properties
]))
return
"
{0} {1}
"
.
format
(
self
.
api
,
'
'
.
join
([
"
{0}
"
.
format
(
p
)
for
p
in
self
.
properties
]))
def
__eq__
(
self
,
other
:
Any
)
->
bool
:
def
__eq__
(
self
,
other
:
Any
)
->
bool
:
if
isinstance
(
other
,
UnknownEndpoint
):
if
not
isinstance
(
other
,
UnknownEndpoint
):
return
NotImplemented
return
self
.
api
==
other
.
api
and
self
.
properties
==
other
.
properties
return
self
.
api
==
other
.
api
and
self
.
properties
==
other
.
properties
else
:
return
False
def
__hash__
(
self
)
->
int
:
def
__hash__
(
self
)
->
int
:
return
hash
((
self
.
api
,
self
.
properties
))
return
hash
((
self
.
api
,
self
.
properties
))
...
@@ -204,11 +203,10 @@ class BMAEndpoint(Endpoint):
...
@@ -204,11 +203,10 @@ class BMAEndpoint(Endpoint):
return
self
.
inline
()
return
self
.
inline
()
def
__eq__
(
self
,
other
:
Any
)
->
bool
:
def
__eq__
(
self
,
other
:
Any
)
->
bool
:
if
isinstance
(
other
,
BMAEndpoint
):
if
not
isinstance
(
other
,
BMAEndpoint
):
return
NotImplemented
return
self
.
server
==
other
.
server
and
self
.
ipv4
==
other
.
ipv4
\
return
self
.
server
==
other
.
server
and
self
.
ipv4
==
other
.
ipv4
\
and
self
.
ipv6
==
other
.
ipv6
and
self
.
port
==
other
.
port
and
self
.
ipv6
==
other
.
ipv6
and
self
.
port
==
other
.
port
else
:
return
False
def
__hash__
(
self
)
->
int
:
def
__hash__
(
self
)
->
int
:
return
hash
((
self
.
server
,
self
.
ipv4
,
self
.
ipv6
,
self
.
port
))
return
hash
((
self
.
server
,
self
.
ipv4
,
self
.
ipv6
,
self
.
port
))
...
@@ -347,11 +345,10 @@ class WS2PEndpoint(Endpoint):
...
@@ -347,11 +345,10 @@ class WS2PEndpoint(Endpoint):
return
self
.
inline
()
return
self
.
inline
()
def
__eq__
(
self
,
other
:
Any
)
->
bool
:
def
__eq__
(
self
,
other
:
Any
)
->
bool
:
if
isinstance
(
other
,
WS2PEndpoint
):
if
not
isinstance
(
other
,
WS2PEndpoint
):
return
NotImplemented
return
self
.
server
==
other
.
server
and
self
.
ws2pid
==
other
.
ws2pid
\
return
self
.
server
==
other
.
server
and
self
.
ws2pid
==
other
.
ws2pid
\
and
self
.
port
==
other
.
port
and
self
.
path
==
other
.
path
and
self
.
port
==
other
.
port
and
self
.
path
==
other
.
path
else
:
return
False
def
__hash__
(
self
)
->
int
:
def
__hash__
(
self
)
->
int
:
return
hash
((
self
.
ws2pid
,
self
.
server
,
self
.
port
,
self
.
path
))
return
hash
((
self
.
ws2pid
,
self
.
server
,
self
.
port
,
self
.
path
))
...
@@ -409,10 +406,9 @@ class ESCoreEndpoint(Endpoint):
...
@@ -409,10 +406,9 @@ class ESCoreEndpoint(Endpoint):
return
self
.
inline
()
return
self
.
inline
()
def
__eq__
(
self
,
other
:
Any
)
->
bool
:
def
__eq__
(
self
,
other
:
Any
)
->
bool
:
if
isinstance
(
other
,
ESCoreEndpoint
):
if
not
isinstance
(
other
,
ESCoreEndpoint
):
return
NotImplemented
return
self
.
server
==
other
.
server
and
self
.
port
==
other
.
port
return
self
.
server
==
other
.
server
and
self
.
port
==
other
.
port
else
:
return
False
def
__hash__
(
self
)
->
int
:
def
__hash__
(
self
)
->
int
:
return
hash
((
self
.
server
,
self
.
port
))
return
hash
((
self
.
server
,
self
.
port
))
...
@@ -470,10 +466,9 @@ class ESUserEndpoint(Endpoint):
...
@@ -470,10 +466,9 @@ class ESUserEndpoint(Endpoint):
return
self
.
inline
()
return
self
.
inline
()
def
__eq__
(
self
,
other
:
Any
)
->
bool
:
def
__eq__
(
self
,
other
:
Any
)
->
bool
:
if
isinstance
(
other
,
ESUserEndpoint
):
if
not
isinstance
(
other
,
ESUserEndpoint
):
return
NotImplemented
return
self
.
server
==
other
.
server
and
self
.
port
==
other
.
port
return
self
.
server
==
other
.
server
and
self
.
port
==
other
.
port
else
:
return
False
def
__hash__
(
self
)
->
int
:
def
__hash__
(
self
)
->
int
:
return
hash
((
self
.
server
,
self
.
port
))
return
hash
((
self
.
server
,
self
.
port
))
...
@@ -531,10 +526,9 @@ class ESSubscribtionEndpoint(Endpoint):
...
@@ -531,10 +526,9 @@ class ESSubscribtionEndpoint(Endpoint):
return
self
.
inline
()
return
self
.
inline
()
def
__eq__
(
self
,
other
:
Any
)
->
bool
:
def
__eq__
(
self
,
other
:
Any
)
->
bool
:
if
isinstance
(
other
,
ESSubscribtionEndpoint
):
if
not
isinstance
(
other
,
ESSubscribtionEndpoint
):
return
NotImplemented
return
self
.
server
==
other
.
server
and
self
.
port
==
other
.
port
return
self
.
server
==
other
.
server
and
self
.
port
==
other
.
port
else
:
return
False
def
__hash__
(
self
)
->
int
:
def
__hash__
(
self
)
->
int
:
return
hash
((
ESSubscribtionEndpoint
.
API
,
self
.
server
,
self
.
port
))
return
hash
((
ESSubscribtionEndpoint
.
API
,
self
.
server
,
self
.
port
))
...
...
This diff is collapsed.
Click to expand it.
duniterpy/documents/block.py
+
1
−
1
View file @
dce62484
...
@@ -501,7 +501,7 @@ Nonce: {nonce}
...
@@ -501,7 +501,7 @@ Nonce: {nonce}
def
__eq__
(
self
,
other
:
object
)
->
bool
:
def
__eq__
(
self
,
other
:
object
)
->
bool
:
if
not
isinstance
(
other
,
Block
):
if
not
isinstance
(
other
,
Block
):
return
False
return
NotImplemented
return
self
.
blockUID
==
other
.
blockUID
return
self
.
blockUID
==
other
.
blockUID
def
__lt__
(
self
,
other
:
object
)
->
bool
:
def
__lt__
(
self
,
other
:
object
)
->
bool
:
...
...
This diff is collapsed.
Click to expand it.
duniterpy/documents/block_uid.py
+
1
−
1
View file @
dce62484
...
@@ -51,7 +51,7 @@ class BlockUID:
...
@@ -51,7 +51,7 @@ class BlockUID:
def
__eq__
(
self
,
other
:
object
)
->
bool
:
def
__eq__
(
self
,
other
:
object
)
->
bool
:
if
not
isinstance
(
other
,
BlockUID
):
if
not
isinstance
(
other
,
BlockUID
):
return
False
return
NotImplemented
return
self
.
number
==
other
.
number
and
self
.
sha_hash
==
other
.
sha_hash
return
self
.
number
==
other
.
number
and
self
.
sha_hash
==
other
.
sha_hash
def
__lt__
(
self
,
other
:
object
)
->
bool
:
def
__lt__
(
self
,
other
:
object
)
->
bool
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment