-
Notifications
You must be signed in to change notification settings - Fork 130
Python split imports into local and shared sets #2063
Python split imports into local and shared sets #2063
Conversation
4a8efe8
to
456fb83
Compare
Codecov Report
@@ Coverage Diff @@
## master #2063 +/- ##
============================================
+ Coverage 86.83% 86.85% +0.02%
- Complexity 4987 4989 +2
============================================
Files 448 448
Lines 19722 19739 +17
Branches 2080 2083 +3
============================================
+ Hits 17125 17144 +19
+ Misses 1889 1886 -3
- Partials 708 709 +1
Continue to review full report at Codecov.
|
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.
I'm not really familiar with the codebase, but the changes here do seem to address the requirement expressed in #2058.
456fb83
to
390f0cf
Compare
390f0cf
to
1271a05
Compare
PTAL |
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.TreeSet; | ||
|
||
/* Creates the import sections of GAPIC generated code for Python. */ | ||
public class PythonImportSectionTransformer implements ImportSectionTransformer { | ||
|
||
private enum IMPORT_TYPE { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Map<String, IMPORT_TYPE> importNamesAndTypes = new HashMap<>(); | ||
|
||
List<ProtoElement> elements = Lists.newArrayList(model.getRoots()); | ||
String serviceFullName = elements.get(0).getFullName(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
} | ||
return ImmutableList.<ImportFileView>builder().addAll(imports).build(); | ||
importView.localImports(ImmutableList.<ImportFileView>builder().addAll(localImports).build()); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
appImports.add(generateAppImport(importFullName, entry.getValue().getNickname())); | ||
switch (importNamesAndTypes.get(importFullName)) { | ||
case LOCAL: | ||
localImports.add(generateAppImport(importFullName, entry.getValue().getNickname())); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
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.
Also, we have been slowly getting around to refactoring python snippet files to make it such that there are no extraneous function calls.
While we are in py/types.snip
can you remove the @private body
and @private header
methods moving it's contents into the @snippet generate
method?
public abstract List<ImportFileView> appImports(); | ||
|
||
/** Used in Python. */ |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
3465fe3
to
cdf8057
Compare
PTAL |
6c23e88
to
903d2f5
Compare
LGTM but perhaps Python folks to sign off. |
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.
LGTM
Resolves #2058
Using this PR to regen python bigquerydatatransfer client results in googleapis/google-cloud-python#5478