Skip to content

Commit

Permalink
precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
armandobelardo committed Aug 8, 2024
1 parent fdbf988 commit 99685a2
Showing 22 changed files with 3,338 additions and 12 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -57,4 +57,8 @@ packages/**/generated

**/.idea/*

.python-version
.python-version

# This file is too large to be included in the repository without LFS
seed/python-sdk/trace/snippet-templates.json
seed/python-sdk/**/output.prof
6 changes: 3 additions & 3 deletions generators/python/sdk/Dockerfile
Original file line number Diff line number Diff line change
@@ -30,14 +30,14 @@ COPY ./src ./src

RUN poetry install

# ENTRYPOINT ["python", "-m", "src.fern_python.generators.sdk.cli"]
ENTRYPOINT ["python", "-m", "src.fern_python.generators.sdk.cli"]

## NOTE: Uncomment the below to generate a flame graph for the python generator.
## To visualize the flamegraph you can run:
## - poetry add snakeviz
## - poetry run snakeviz output.prof
RUN mkdir -p /fern/output
# RUN mkdir -p /fern/output
## For a time-limited run, uncomment the below line and comment the next line.
ENTRYPOINT ["timeout", "-s", "INT", "10m", "python", "-m", "cProfile", "-o", "/fern/output/output.prof", "/src/fern_python/generators/sdk/cli.py"]
# ENTRYPOINT ["timeout", "-s", "INT", "5m", "python", "-m", "cProfile", "-o", "/fern/output/output.prof", "/src/fern_python/generators/sdk/cli.py"]
## For a regularly profiled run, uncomment the below line and comment the previous line.
# ENTRYPOINT ["python", "-m", "cProfile", "-o", "/fern/output/output.prof", "/src/fern_python/generators/sdk/cli.py"]
2 changes: 1 addition & 1 deletion generators/python/sdk/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.6.0
3.7.0
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from types import TracebackType
from typing import List, Optional, Sequence, Set, Tuple, Type
from typing import List, Optional, Sequence, Tuple, Type

import fern.ir.resources as ir_types

@@ -181,7 +181,9 @@ def _must_import_after_current_declaration(self, type_name: ir_types.DeclaredTyp
type_id_to_reference = self._type_id_for_forward_ref()
is_circular_reference = False
if type_id_to_reference is not None:
is_circular_reference = self._context.does_type_reference_other_type(type_id=type_name.type_id, other_type_id=type_id_to_reference)
is_circular_reference = self._context.does_type_reference_other_type(
type_id=type_name.type_id, other_type_id=type_id_to_reference
)

if is_circular_reference:
self._model_contains_forward_refs = True
Original file line number Diff line number Diff line change
@@ -278,7 +278,9 @@ def generate(self) -> None:
forward_refed_types = [
referenced_type_id
for referenced_type_id in referenced_type_ids
if self._context.does_type_reference_other_type(type_id=referenced_type_id, other_type_id=self._name.type_id)
if self._context.does_type_reference_other_type(
type_id=referenced_type_id, other_type_id=self._name.type_id
)
]

if len(forward_refed_types) > 0:
Original file line number Diff line number Diff line change
@@ -159,7 +159,7 @@ def _finish(self, type_alias_declaration: AST.TypeAliasDeclaration) -> None:
# There are some types that will not cause their dependent types to rebuild
# for example other unions, and so to make sure those types are rebuilt
# we import them all here.
for type_id in (self._context.maybe_get_type_ids_for_type_reference(referenced_type) or []):
for type_id in self._context.maybe_get_type_ids_for_type_reference(referenced_type) or []:
type_alias_declaration.add_ghost_reference(
self._context.get_class_reference_for_type_id(
type_id,
@@ -184,9 +184,9 @@ def _update_forward_refs_for_single_property_member(
) -> None:
referenced_type_ids: Set[ir_types.TypeId] = single_union_type.shape.visit(
same_properties_as_object=lambda _: set(),
single_property=lambda single_property: set(self._context.get_referenced_types_of_type_reference(
single_property.type
) or []),
single_property=lambda single_property: set(
self._context.get_referenced_types_of_type_reference(single_property.type) or []
),
no_properties=lambda: set(),
)

1 change: 1 addition & 0 deletions seed/python-sdk/trace/.mock/generators.yml

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

Loading

0 comments on commit 99685a2

Please sign in to comment.