-
Notifications
You must be signed in to change notification settings - Fork 0
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
Localization #57
base: master
Are you sure you want to change the base?
Localization #57
Conversation
…into localization
I should add more tests for this. |
raise NotImplementedError | ||
|
||
|
||
class File_C(Component): |
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.
Please can we change this to FileComponent
?
self.filename = filename | ||
|
||
|
||
class Line_C(Component): |
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.
Same as above.
self.lineno = lineno | ||
|
||
|
||
class Function_C(Component): |
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.
Same.
filename: File_C = None, | ||
line_start: int = 0, | ||
line_end: int = 0) -> None: | ||
self.funcname = funcname |
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.
Prefer hidden variables (e.g., self.__funcname
) over public variables (e.g., self.funcname
). Use the @property
decorator to ensure read-only (external) access to the variable.
try: | ||
loc = yaml.load(f) | ||
except KeyError as err: | ||
print('Error when importing', filename, '.', err) |
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.
Does this work? Prefer "foo {}; bar {}".format(x, y)
.
except KeyError as err: | ||
print('Error when importing', filename, '.', err) | ||
raise IOError | ||
return loc |
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.
What is the type of loc
? Unless I've misunderstood, yaml.load(f)
should return a dictionary? Does loc
not need to be unpacked into a Localization
object?
Stores its internal data in a file | ||
""" | ||
with open(filename, "w") as f: | ||
yaml.dump(self, f) |
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.
Prefer to dump relevant information to a dictionary rather than dumping the entire object, which may contain irrelevant and/or ephemeral information.
import yaml | ||
|
||
VERSION = "1.0" | ||
G = TypeVar('G', bound=Component) |
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.
G and S are the same?
granularity: Type[G], | ||
version: str = VERSION) -> None: | ||
|
||
self.mapping = mapping |
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.
Use hidden variables and properties.
No description provided.