-
Notifications
You must be signed in to change notification settings - Fork 560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make namespace module flake8-compliant, change exceptions in that mod… #711
Conversation
…ule to specific ones
ping @gromgull for your kind consideration |
rdflib/namespace.py
Outdated
@@ -120,7 +120,7 @@ def __getattr__(self, name): | |||
return self.term(name) | |||
|
|||
def __repr__(self): | |||
return "Namespace(%s)"%text_type.__repr__(self) | |||
return "Namespace(%s)" % text_type.__repr__(self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we just replace this with "Namespace(%r)" % text_type(self)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joernhees there's a lot of code here that looks suspicious to me :) as first pass at this module I just took care of some flake8 style fixes which are ancillary to main purpose of this PR (making exception types raised here more specific). I think we should have a separate effort around standardizing code a bit more (switch to use .format() rather than % for string interpolation, etc. etc.). Probably not in scope for this PR though
rdflib/namespace.py
Outdated
@@ -150,8 +150,7 @@ def format(self, *args, **kwargs): | |||
return URIRef(text_type.format(self, *args, **kwargs)) | |||
|
|||
def __repr__(self): | |||
return "URIPattern(%r)"%text_type.__repr__(self) | |||
|
|||
return "URIPattern(%r)" % text_type.__repr__(self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is double repr
, should probably be "URIPattern(%r)" % text_type(self)
namespace, name = split_uri(uri) | ||
namespace = URIRef(namespace) | ||
prefix = self.store.prefix(namespace) | ||
if prefix is None: | ||
if not generate: | ||
raise Exception( | ||
"No known prefix for %s and generate=False") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was a great exception :D
ok, i just overrode the very weird stuff (wrt. wrt. |
merged... thanks :) |
doctest-ignore-unicode
dependency in run_tests.py docs for running tests, update it to suggest using pip (without sudo - use virtualenv!)I Opted to use built in exception types that seemed most appropriate, ideally we should define our own custom error hierarchy, but for now this seems a good start.