Add a name to be imported and return the name reference. The import will be internal to the stub (i.e don't reexport).
(self, fullname: str, require: bool = True)
| 662 | return resolved_name |
| 663 | |
| 664 | def add_name(self, fullname: str, require: bool = True) -> str: |
| 665 | """Add a name to be imported and return the name reference. |
| 666 | |
| 667 | The import will be internal to the stub (i.e don't reexport). |
| 668 | """ |
| 669 | module, name = fullname.rsplit(".", 1) |
| 670 | alias = "_" + name if name in self.defined_names else None |
| 671 | while alias in self.defined_names: |
| 672 | alias = "_" + alias |
| 673 | if module != "builtins" or alias: # don't import from builtins unless needed |
| 674 | self.import_tracker.add_import_from(module, [(name, alias)], require=require) |
| 675 | return alias or name |
| 676 | |
| 677 | def add_import_line(self, line: str) -> None: |
| 678 | """Add a line of text to the import section, unless it's already there.""" |
no test coverage detected