Skip to content

Conversation

@HSY-999
Copy link

@HSY-999 HSY-999 commented Nov 21, 2025

see #3467

there are a couple different solutions. this is the one i made.

for my solution, i have to assume that the key name inside DictionaryObject == __init__ parameter names. for example /Vertices and vertices. with these changes the example in #3467 exits normally.

i had to modify the __init__ logic for Polygon and PolyLine, as they both expected tuples which is not the format they are stored in DictionaryObject

if we agree this is acceptable solution, i will also add test case adapted from the issue.

@HSY-999 HSY-999 changed the title BUG: fix for merge page #3467 BUG: fix for merge page with annotation #3467 Nov 21, 2025
Copy link
Collaborator

@stefan6419846 stefan6419846 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please have a look at the test failures and add appropriate tests.

Additionally, while your current approach might work for the current cases, I see some limitations/aspects to discuss:

  • What happens to keyword-only arguments?
  • What happens to unmatched keys?
  • What happens to keys which have to renamed for some reasons, for example because they conflict with an existing name (like a builtin)?

Please provide some details on how you think about this and what your proposals for mitigating them are.

super().__init__(**kwargs)
if len(vertices) == 0:
raise ValueError("A polygon needs at least 1 vertex with two coordinates")
if len(vertices) == 0 or len(vertices) % 2 != 0:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this new check relate to your changes and why does the error message need a rewording?

for x, y in vertices:
coord_list.append(NumberObject(x))
coord_list.append(NumberObject(y))
if type(vertices) is ArrayObject:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not isinstance(vertices, ArrayObject)?

if type(vertices) is ArrayObject:
import itertools
coord_list = vertices
vertices = [vertex for vertex in itertools.batched(vertices, 2)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

itertools.batched requires Python >= 3.12, while we have to support Python >= 3.9.

super().__init__(**kwargs)
if len(vertices) == 0:
raise ValueError("A polygon needs at least 1 vertex with two coordinates")
if len(vertices) == 0 or len(vertices) % 2 != 0:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid unnecessary repetition by extracting common functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants