Skip to content

Commit

Permalink
chore: remove @generated, remove gen, code fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ii64 committed Apr 8, 2024
1 parent b8205dd commit 8d5712a
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 36 deletions.
29 changes: 0 additions & 29 deletions gen.sh

This file was deleted.

11 changes: 9 additions & 2 deletions src/betterproto/compile/importing.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ def parse_source_type_name(field_type_name: str) -> Tuple[str, str]:


def get_type_reference(
*, package: str, imports: set, source_type: str, unwrap: bool = True, pydantic: bool = False,
*,
package: str,
imports: set,
source_type: str,
unwrap: bool = True,
pydantic: bool = False,
) -> str:
"""
Return a Python type name for a proto type reference. Adds the import if
Expand All @@ -69,7 +74,9 @@ def get_type_reference(
compiling_google_protobuf = current_package == ["google", "protobuf"]
importing_google_protobuf = py_package == ["google", "protobuf"]
if importing_google_protobuf and not compiling_google_protobuf:
py_package = ["betterproto", "lib"] + (["pydantic"] if pydantic else []) + py_package
py_package = (
["betterproto", "lib"] + (["pydantic"] if pydantic else []) + py_package
)

if py_package[:1] == ["betterproto"]:
return reference_absolute(imports, py_package, py_type)
Expand Down
2 changes: 1 addition & 1 deletion src/betterproto/lib/google/protobuf/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from betterproto.lib.std.google.protobuf import *
from betterproto.lib.std.google.protobuf import *
2 changes: 1 addition & 1 deletion src/betterproto/lib/google/protobuf/compiler/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from betterproto.lib.std.google.protobuf.compiler import *
from betterproto.lib.std.google.protobuf.compiler import *
2 changes: 1 addition & 1 deletion src/betterproto/lib/pydantic/google/protobuf/__init__.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/betterproto/lib/std/google/protobuf/__init__.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion tests/test_get_ref_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def test_reference_google_wellknown_types_non_wrappers(
google_type: str, expected_name: str, expected_import: str
):
imports = set()
name = get_type_reference(package="", imports=imports, source_type=google_type, pydantic=False)
name = get_type_reference(
package="", imports=imports, source_type=google_type, pydantic=False
)

assert name == expected_name
assert imports.__contains__(
Expand Down

0 comments on commit 8d5712a

Please sign in to comment.