Skip to content

Commit

Permalink
add test for doc strings
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiedemaria committed Dec 11, 2023
1 parent 8908719 commit f1d3dcf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from contextvars import ContextVar
from inspect import (
_empty as EmptyAnnotation,
isfunction,
)
from typing import (
AbstractSet,
Expand All @@ -21,8 +20,6 @@

import dagster._check as check
from dagster._annotations import (
T_Annotatable,
_get_annotation_target,
deprecated,
experimental,
public,
Expand Down Expand Up @@ -59,7 +56,6 @@
from dagster._core.instance import DagsterInstance
from dagster._core.log_manager import DagsterLogManager
from dagster._core.storage.dagster_run import DagsterRun
from dagster._utils.cached_method import cached_method
from dagster._utils.forked_pdb import ForkedPdb
from dagster._utils.warnings import (
deprecation_warning,
Expand Down Expand Up @@ -1363,10 +1359,8 @@ def get() -> "OpExecutionContext":
return ctx.get_op_execution_context()


def _copy_docs_from_op_execution_context(obj: T_Annotatable) -> T_Annotatable:
target = _get_annotation_target(obj)
if isfunction(target):
setattr(target, "__doc__", getattr(OpExecutionContext, target.__name__).__doc__)
def _copy_docs_from_op_execution_context(obj):
setattr(obj, "__doc__", getattr(OpExecutionContext, obj.__name__).__doc__)
return obj


Expand Down Expand Up @@ -1739,7 +1733,6 @@ def typed_event_stream_error_message(self) -> Optional[str]:
def set_requires_typed_event_stream(self, *, error_message: Optional[str] = None) -> None:
self.op_execution_context.set_requires_typed_event_stream(error_message=error_message)

@cached_method
def get_op_execution_context(self) -> "OpExecutionContext":
return self.op_execution_context

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from dagster import AssetExecutionContext, OpExecutionContext


def test_doc_strings():
ignores = [
"_abc_impl",
"_events",
"_output_metadata",
"_pdb",
"_step_execution_context",
]
for attr_name in dir(OpExecutionContext):
if attr_name.startswith("__") or attr_name in ignores:
continue
if hasattr(AssetExecutionContext, attr_name):
op_attr = getattr(OpExecutionContext, attr_name)
asset_attr = getattr(AssetExecutionContext, attr_name)

assert op_attr.__doc__ == asset_attr.__doc__

0 comments on commit f1d3dcf

Please sign in to comment.