Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
hallvictoria committed Aug 22, 2024
1 parent 68433e5 commit c0c6762
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 25 deletions.
5 changes: 2 additions & 3 deletions azure/functions/eventgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@ class EventGridEventOutConverter(meta.OutConverter, binding="eventGrid"):
def check_output_type_annotation(cls, pytype: type) -> bool:
valid_types = (str, bytes, azf_eventgrid.EventGridOutputEvent,
List[azf_eventgrid.EventGridOutputEvent])
return (meta.is_supported_union_annotation(pytype, valid_types)
or meta.is_iterable_type_annotation(pytype, str)
return (meta.is_iterable_type_annotation(pytype, str)
or meta.is_iterable_type_annotation(
pytype,
azf_eventgrid.EventGridOutputEvent)
or (isinstance(pytype, type)
and issubclass(pytype, valid_types)))
and issubclass(pytype, valid_types)))

@classmethod
def encode(cls, obj: Any, *, expected_type:
Expand Down
3 changes: 1 addition & 2 deletions azure/functions/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
)



def is_iterable_type_annotation(annotation: object, pytype: object) -> bool:
is_iterable_anno = (
typing_inspect.is_generic_type(annotation)
Expand All @@ -46,7 +45,7 @@ def is_iterable_type_annotation(annotation: object, pytype: object) -> bool:
def is_supported_union_annotation(annotation: object, pytype) -> bool:
"""Allows for Union annotation in function apps to be used as a type
hint, as long as the types in the Union are supported. This is
supported for bindings that allow for cardinality=many.
supported for bindings that allow for multiple types.
"""
origin = get_origin(annotation)
if origin is not Union:
Expand Down
20 changes: 0 additions & 20 deletions tests/test_eventgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Licensed under the MIT License.

from datetime import datetime
import sys
import unittest
from typing import List

Expand All @@ -28,25 +27,6 @@ def test_eventgrid_output_type(self):
self.assertTrue(check_output_type(bytes))
self.assertTrue(check_output_type(List[str]))

@unittest.skipIf(sys.version_info < (3, 10),
reason="requires Python 3.10 or above")
def test_eventgrid_output_type_above_310(self):
check_output_type = azf_event_grid.EventGridEventOutConverter. \
check_output_type_annotation

self.assertTrue(check_output_type(
func.EventGridOutputEvent | List[func.EventGridOutputEvent]))
self.assertTrue(check_output_type(
func.EventGridOutputEvent | List[str]))
self.assertTrue(check_output_type(
str | List[func.EventGridOutputEvent]))
self.assertTrue(check_output_type(str | List[str]))
self.assertTrue(check_output_type(
func.EventGridOutputEvent | List[bytes]))
self.assertTrue(check_output_type(
bytes | List[func.EventGridOutputEvent]))
self.assertTrue(check_output_type(bytes | List[bytes]))

def test_eventgrid_decode(self):
eventGridEvent = azf_event_grid.EventGridEventInConverter.decode(
data=self._generate_single_eventgrid_datum(), trigger_metadata=None
Expand Down

0 comments on commit c0c6762

Please sign in to comment.