<#18435 `NameError: name 'Optional' is not defined...
# github-notifications
q
#18435 `NameError: name 'Optional' is not defined` from macros after upgrade to v2.16 Issue created by danxmoran Describe the bug We've added type annotations to our
macros.py
, i.e.
Copy code
def ecr_docker_image(
    *,
    name: Optional[str] = None,
    dependencies: Optional[List[str]] = None,
    image_tags: Optional[List[str]] = None,
    git_tag_prefix: Optional[str] = None,
    latest_tag_prefix: Optional[str] = None,
    buildcache_tag: str = "buildcache",
    image_labels: Optional[Mapping[str, str]] = None,
    tags: Optional[List[str]] = None,
    extra_build_args: Optional[List[str]] = None,
    source: Optional[str] = None,
    target_stage: Optional[str] = None,
    instructions: Optional[List[str]] = None,
    repository: Optional[str] = None,
    context_root: Optional[str] = None,
    push_in_pants_ci: bool = True,
    push_latest: bool = False,
) -> None:
    ...
This worked in Pants < 2.16, but when I tried upgrading to 2.16.0a0
pants
started crashing at startup with:
Copy code
Traceback (most recent call last):
  File "/Users/dan.moran/Library/Caches/nce/496def19ed8a0f8d58b71d0640867bbd94ab2c94f2ca9a49bb59cd109e4a2821/bindings/venvs/2.16.0a0/lib/python3.9/site-packages/pants/engine/internals/build_files.py", line 106, in evaluate_preludes
    exec(content, globals, locals)
  File "build/pants/macros.py", line 6, in <module>
    name: Optional[str] = None,
NameError: name 'Optional' is not defined
Pants version 2.16.0a0 OS MacOS pantsbuild/pants