| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -2229,7 +2229,12 @@ def _module_and_class(self, fields): | |
| return module, cls | ||
|
|
||
|
|
||
| def parse_file(filename, *, verify=True, output=None): | ||
| def parse_file( | ||
| filename: str, | ||
| *, | ||
| verify: bool = True, | ||
| output: str | None = None | ||
| ) -> None: | ||
| if not output: | ||
| output = filename | ||
|
|
||
| Expand Down Expand Up | @@ -2261,7 +2266,10 @@ def parse_file(filename, *, verify=True, output=None): | |
| write_file(fn, data) | ||
|
|
||
|
|
||
| def compute_checksum(input, length=None): | ||
| def compute_checksum( | ||
| input: str | None, | ||
| length: int | None = None | ||
| ) -> str: | ||
| input = input or '' | ||
| s = hashlib.sha1(input.encode('utf-8')).hexdigest() | ||
| if length: | ||
| Expand All | @@ -2272,44 +2280,61 @@ def compute_checksum(input, length=None): | |
|
|
||
|
|
||
| class PythonParser: | ||
| def __init__(self, clinic): | ||
| def __init__(self, clinic: Clinic) -> None: | ||
| pass | ||
|
|
||
| def parse(self, block): | ||
| def parse(self, block: Block) -> None: | ||
| s = io.StringIO() | ||
| with OverrideStdioWith(s): | ||
| exec(block.input) | ||
| block.output = s.getvalue() | ||
|
|
||
|
|
||
| ModuleDict = dict[str, "Module"] | ||
|
|
||
| class Module: | ||
| def __init__(self, name, module=None): | ||
| def __init__( | ||
| self, | ||
| name: str, | ||
| module = None | ||
| ) -> None: | ||
| self.name = name | ||
| self.module = self.parent = module | ||
|
|
||
| self.modules = collections.OrderedDict() | ||
| self.classes = collections.OrderedDict() | ||
| self.functions = [] | ||
| self.modules: ModuleDict = collections.OrderedDict() | ||
| self.classes: ClassDict = collections.OrderedDict() | ||
|
Comment thread
Comment on lines
+2304
to
+2305
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualitySince we're touching these lines anyway: do these need to be OrderedDicts anymore? Regular dicts are guaranteed by the language spec to be ordered on 3.7+ (and clinic now requires 3.10+), and regular dicts are faster than OrderedDicts. OrderedDicts are mainly there for backwards compatibility these days (they have a few fancy methods that dicts don't have, but I really doubt we need any of them in clinic.py).
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityCould leave this to another PR, though
Sorry, something went wrong.
erlend-aasland reacted with thumbs up emoji
All reactions
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityYes, regular dicts should be fine post 3.7.
Sorry, something went wrong.
All reactions
|
||
| self.functions: list[Function] = [] | ||
|
|
||
| def __repr__(self): | ||
| def __repr__(self) -> str: | ||
| return "<clinic.Module " + repr(self.name) + " at " + str(id(self)) + ">" | ||
|
|
||
|
|
||
| ClassDict = dict[str, "Class"] | ||
|
|
||
| class Class: | ||
| def __init__(self, name, module=None, cls=None, typedef=None, type_object=None): | ||
| def __init__( | ||
| self, | ||
| name: str, | ||
| module: Module | None = None, | ||
| cls = None, | ||
| typedef: str | None = None, | ||
| type_object: str | None = None | ||
| ) -> None: | ||
| self.name = name | ||
| self.module = module | ||
| self.cls = cls | ||
| self.typedef = typedef | ||
| self.type_object = type_object | ||
| self.parent = cls or module | ||
|
|
||
| self.classes = collections.OrderedDict() | ||
| self.functions = [] | ||
| self.classes: ClassDict = collections.OrderedDict() | ||
| self.functions: list[Function] = [] | ||
|
|
||
| def __repr__(self): | ||
| def __repr__(self) -> str: | ||
| return "<clinic.Class " + repr(self.name) + " at " + str(id(self)) + ">" | ||
|
|
||
| unsupported_special_methods = set(""" | ||
|
|
||
| unsupported_special_methods: set[str] = set(""" | ||
|
|
||
| __abs__ | ||
| __add__ | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.