Skip to content

Commit

Permalink
Fix missing type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
rjwills28 committed Jun 29, 2023
1 parent be605b8 commit 9cb88a3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/coniql/strawberry_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from coniql.types import ChannelStatus as TypeChannelStatus
from coniql.types import ChannelTime as TypeChannelTime
from coniql.types import ChannelValue as TypeChannelValue
from coniql.types import TypeFloatAlias

store_global = PluginStore()
store_global.add_plugin("ssim", SimPlugin())
Expand Down Expand Up @@ -89,13 +90,15 @@ class ChannelValue:
"""

# The current value formatted as a Float, Null if not expressable
float = strawberry.field(resolver=resolve_float)
float: Optional[TypeFloatAlias] = strawberry.field(resolver=resolve_float)
# The current value formatted as a string
string = strawberry.field(resolver=resolve_string)
string: Optional[str] = strawberry.field(resolver=resolve_string)
# Array of base64 encoded numbers, Null if not expressable
base64Array = strawberry.field(resolver=resolve_base64Array)
base64Array: Optional[TypeBase64Array] = strawberry.field(
resolver=resolve_base64Array
)
# Array of strings, Null if not expressable
stringArray = strawberry.field(resolver=resolve_stringArray)
stringArray: Optional[List[str]] = strawberry.field(resolver=resolve_stringArray)


@strawberry.type
Expand Down Expand Up @@ -171,7 +174,7 @@ def get_channel(id: strawberry.ID, timeout: float = 5.0) -> TypeChannel:
@strawberry.type
class Query:
# Get the current value of a Channel
getChannel: Channel = strawberry.field(resolver=get_channel)
getChannel: Channel = strawberry.field(resolver=get_channel) # type: ignore


async def subscribe_channel(id: strawberry.ID) -> AsyncGenerator[TypeChannel, None]:
Expand Down
4 changes: 4 additions & 0 deletions src/coniql/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ def get_channel_quality_str(cls, severity: int) -> str:
DisplayForm.ENGINEERING,
]

# GraphQL schema has a variable named 'float', which is an inbuilt type in Python
# and can lead to problems when used in type hinting. Create alias inbuilt float type.
TypeFloatAlias = float


@strawberry.type
class ChannelDisplay:
Expand Down

0 comments on commit 9cb88a3

Please sign in to comment.