Skip to content

Commit

Permalink
typing
Browse files Browse the repository at this point in the history
  • Loading branch information
EDsCODE committed Mar 26, 2024
1 parent 3307e5f commit 7c9f4a1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions posthog/hogql/autocomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ def resolve_table_field_traversers(table: Table, context: HogQLContext) -> Table
current_table_or_field: FieldOrTable = new_table
for chain in field.chain:
if isinstance(current_table_or_field, Table):
chain_field = current_table_or_field.fields.get(chain)
chain_field = current_table_or_field.fields.get(str(chain))
elif isinstance(current_table_or_field, LazyJoin):
chain_field = current_table_or_field.resolve_table(context).fields.get(chain)
chain_field = current_table_or_field.resolve_table(context).fields.get(str(chain))
elif isinstance(current_table_or_field, DatabaseField):
chain_field = current_table_or_field
else:
Expand Down
4 changes: 2 additions & 2 deletions posthog/hogql/database/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ class Table(FieldOrTable):
def has_field(self, name: str | int) -> bool:
return str(name) in self.fields

def get_field(self, name: str) -> FieldOrTable:
if self.has_field(name):
def get_field(self, name: str | int) -> FieldOrTable:
if self.has_field(str(name)):
return self.fields[name]

Check failure on line 80 in posthog/hogql/database/models.py

View workflow job for this annotation

GitHub Actions / Python code quality checks

Invalid index type "str | int" for "dict[str, FieldOrTable]"; expected type "str"

Check failure on line 80 in posthog/hogql/database/models.py

View workflow job for this annotation

GitHub Actions / Python code quality checks

Invalid index type "str | int" for "dict[str, FieldOrTable]"; expected type "str"
raise Exception(f'Field "{name}" not found on table {self.__class__.__name__}')

Expand Down

0 comments on commit 7c9f4a1

Please sign in to comment.