#39 Fixed bug where f-string was unterminated#41
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request fixes a bug with an unterminated f-string in SQL filter construction and refactors the code for improved readability by separating the string joining logic from the conditional filter creation.
- Extracts ID list joining into separate variables (
ids_fkb_str,ids_osm_str) - Simplifies the ternary operator expressions for
fkb_filterandosm_filter - Resolves the unterminated f-string syntax issue mentioned in the PR title
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+181
to
+182
| ids_fkb_str = ", ".join(f"'{v}'" for v in ids_fkb) | ||
| ids_osm_str = ", ".join(f"'{v}'" for v in ids_osm) |
There was a problem hiding this comment.
[nitpick] The string joining operations are performed unconditionally, even when ids_fkb or ids_osm are empty lists. This creates unnecessary string operations that won't be used when the filters evaluate to "FALSE". Consider moving the join operations inside the ternary expressions or using lazy evaluation to avoid this overhead.
Example:
fkb_filter = "FALSE" if not ids_fkb else f"external_id IN ({', '.join(f\"'{v}'\" for v in ids_fkb)})"
osm_filter = "FALSE" if not ids_osm else f"external_id IN ({', '.join(f\"'{v}'\" for v in ids_osm)})"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors the way SQL filter strings are constructed for FKB and OSM IDs in the
merge_fkb_osmmethod to improve readability and maintainability. The logic for building the filter strings is now separated into explicit string variables before use.Refactoring for SQL filter construction:
fkb_filterandosm_filterSQL filter strings by first joining the ID lists into string variables (ids_fkb_strandids_osm_str), improving clarity and reducing code duplication. (src/infra/infrastructure/services/conflation_service.py, src/infra/infrastructure/services/conflation_service.pyL181-R185)