feat: extract place lat/long coordinates #7

Open
jaredhowland wants to merge 4 commits from jaredhowland/extract-place-coordinates into main
pull from: jaredhowland/extract-place-coordinates
2 changed files with 2 additions and 27 deletions
Showing only changes of commit 747175fcef - Show all commits

No files matched your search

+2 -1
View File
@@ -211,9 +211,10 @@ class Individual:
- children: List of Individual objects - children: List of Individual objects
""" """
families = [] families = []
# Cache the subject pointer once; it doesn't change across families.
self_pointer = self.element.get_pointer()
for family in self.gedcom.get_families(self.element): for family in self.gedcom.get_families(self.element):
# Get partner # Get partner
self_pointer = self.element.get_pointer()
partners = [ partners = [
Individual(parent, self.gedcom) Individual(parent, self.gedcom)
for parent in self.gedcom.get_family_members(family, "PARENTS") for parent in self.gedcom.get_family_members(family, "PARENTS")
2
-26
View File
@@ -17,26 +17,6 @@ from gedcom_parser import GedcomParser
from individual import Individual from individual import Individual
copilot-pull-request-reviewer[bot] commented 2026-04-17 06:22:28 +02:00 (Migrated from github.com)
Review

The john_doe fixture inside the first TestIndividualBasicInfo block contains an unrelated triple-quoted module docstring (lines 28–38) and never returns an Individual, and the class name is then redefined again immediately after. This looks like an accidental paste and makes the test module confusing to maintain; please remove this stray block (or make the fixture return the expected Individual) and keep only one TestIndividualBasicInfo definition.

The `john_doe` fixture inside the first `TestIndividualBasicInfo` block contains an unrelated triple-quoted module docstring (lines 28–38) and never returns an `Individual`, and the class name is then redefined again immediately after. This looks like an accidental paste and makes the test module confusing to maintain; please remove this stray block (or make the fixture return the expected `Individual`) and keep only one `TestIndividualBasicInfo` definition.
coderabbitai[bot] commented 2026-04-17 06:23:32 +02:00 (Migrated from github.com)
Review

⚠️ Potential issue | 🔴 Critical

Blocker: file is structurally broken from a bad merge/rebase.

This file cannot be imported by pytest as-is. Multiple issues:

  1. Lines 20–40: TestIndividualBasicInfo is declared twice. The first declaration's john_doe fixture opens a triple-quoted string at Line 28 (appears to be the module docstring accidentally inlined) and never returns, then a second class TestIndividualBasicInfo starts at Line 40.

  2. Lines 353–355 (inside test_get_events_coords_nested_structure): asserts reference resi, but only event_types is assigned on Line 351. resi is undefined here (Ruff F821). The resi = [e for e in events if e["type"] == "RESI"][0] line is missing.

  3. Line 604: an orphan return Individual(john[0], parser.parser) sits at class-body scope inside TestAttributes, where john is undefined (Ruff F821). It's a leftover from the duplicated john_doe fixture below.

  4. Lines 604–1135: The entire suite (TestIndividualBasicInfo, TestBirthAndDeath, TestEvents, TestFamilyRelationships, TestImagesAndMedia, TestStories) is duplicated verbatim after TestAttributes. In this second copy, TestImagesAndMedia.test_get_images (Line 1037–1047) actually calls get_notes and asserts note content — it's the wrong body pasted in.

Please re-do the diff so only a single, clean copy of each class exists, and re-add the missing resi = [e for e in events if e["type"] == "RESI"][0] assignment in test_get_events_coords_nested_structure (consider using next(...) per the Ruff RUF015 hint).

🔧 Fix for the missing resi assignment (Lines 350–355)
         events = person.get_events()
-        event_types = [e['type'] for e in events]
+        resi = next(e for e in events if e["type"] == "RESI")

         assert resi['place'] == 'Deepplace'
         assert resi['lat'] == '48.8566'
         assert resi['long'] == '2.3522'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/test_individual.py` around lines 20 - 40, The file is broken by a bad
merge: remove the duplicated test class blocks so each test class (e.g.,
TestIndividualBasicInfo, TestBirthAndDeath, TestEvents, TestFamilyRelationships,
TestImagesAndMedia, TestStories, TestAttributes) appears exactly once; fix the
malformed TestIndividualBasicInfo.john_doe fixture by closing the stray
triple-quoted docstring and ensuring the fixture returns the Individual instance
(return Individual(...)); inside test_get_events_coords_nested_structure add the
missing assignment for the RESI event using a safe pattern (e.g., resi = next(e
for e in events if e["type"] == "RESI")) as suggested by RUF015; remove the
orphan "return Individual(john[0], parser.parser)" sitting at class scope in
TestAttributes and fix any remaining misplaced references to john; and restore
the correct body for TestImagesAndMedia.test_get_images so it calls the image
extraction helper (not get_notes). Ensure imports and fixtures referenced by
these methods remain valid after cleanup.

✅ Addressed in commits 747175f to 0ba00d0

_⚠️ Potential issue_ | _🔴 Critical_ **Blocker: file is structurally broken from a bad merge/rebase.** This file cannot be imported by pytest as-is. Multiple issues: 1. **Lines 20–40**: `TestIndividualBasicInfo` is declared twice. The first declaration's `john_doe` fixture opens a triple-quoted string at Line 28 (appears to be the module docstring accidentally inlined) and never returns, then a second `class TestIndividualBasicInfo` starts at Line 40. 2. **Lines 353–355** (inside `test_get_events_coords_nested_structure`): asserts reference `resi`, but only `event_types` is assigned on Line 351. `resi` is undefined here (Ruff F821). The `resi = [e for e in events if e["type"] == "RESI"][0]` line is missing. 3. **Line 604**: an orphan `return Individual(john[0], parser.parser)` sits at class-body scope inside `TestAttributes`, where `john` is undefined (Ruff F821). It's a leftover from the duplicated `john_doe` fixture below. 4. **Lines 604–1135**: The entire suite (`TestIndividualBasicInfo`, `TestBirthAndDeath`, `TestEvents`, `TestFamilyRelationships`, `TestImagesAndMedia`, `TestStories`) is duplicated verbatim after `TestAttributes`. In this second copy, `TestImagesAndMedia.test_get_images` (Line 1037–1047) actually calls `get_notes` and asserts note content — it's the wrong body pasted in. Please re-do the diff so only a single, clean copy of each class exists, and re-add the missing `resi = [e for e in events if e["type"] == "RESI"][0]` assignment in `test_get_events_coords_nested_structure` (consider using `next(...)` per the Ruff RUF015 hint). <details> <summary>🔧 Fix for the missing resi assignment (Lines 350–355)</summary> ```diff events = person.get_events() - event_types = [e['type'] for e in events] + resi = next(e for e in events if e["type"] == "RESI") assert resi['place'] == 'Deepplace' assert resi['lat'] == '48.8566' assert resi['long'] == '2.3522' ``` </details> <details> <summary>🤖 Prompt for AI Agents</summary> ``` Verify each finding against the current code and only fix it if needed. In `@tests/test_individual.py` around lines 20 - 40, The file is broken by a bad merge: remove the duplicated test class blocks so each test class (e.g., TestIndividualBasicInfo, TestBirthAndDeath, TestEvents, TestFamilyRelationships, TestImagesAndMedia, TestStories, TestAttributes) appears exactly once; fix the malformed TestIndividualBasicInfo.john_doe fixture by closing the stray triple-quoted docstring and ensuring the fixture returns the Individual instance (return Individual(...)); inside test_get_events_coords_nested_structure add the missing assignment for the RESI event using a safe pattern (e.g., resi = next(e for e in events if e["type"] == "RESI")) as suggested by RUF015; remove the orphan "return Individual(john[0], parser.parser)" sitting at class scope in TestAttributes and fix any remaining misplaced references to john; and restore the correct body for TestImagesAndMedia.test_get_images so it calls the image extraction helper (not get_notes). Ensure imports and fixtures referenced by these methods remain valid after cleanup. ``` </details> <!-- fingerprinting:phantom:medusa:nectarine:937c8735-1b8e-4cfd-9639-5f1b93a2103c --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commits 747175f to 0ba00d0
copilot-pull-request-reviewer[bot] commented 2026-04-17 06:36:45 +02:00 (Migrated from github.com)
Review

The file defines TestIndividualBasicInfo twice, and this first john_doe fixture appears to contain an accidentally pasted triple-quoted block and never returns an Individual instance. Please remove the stray block and keep a single TestIndividualBasicInfo definition with a fixture that returns the intended individual, to avoid dead/overwritten test code and confusing fixture behavior.

The file defines `TestIndividualBasicInfo` twice, and this first `john_doe` fixture appears to contain an accidentally pasted triple-quoted block and never returns an `Individual` instance. Please remove the stray block and keep a single `TestIndividualBasicInfo` definition with a fixture that returns the intended individual, to avoid dead/overwritten test code and confusing fixture behavior.
class TestIndividualBasicInfo:
"""Tests for basic individual information extraction."""
@pytest.fixture
def john_doe(self, sample_gedcom_file):
"""Get the John Doe individual from sample GEDCOM."""
parser = GedcomParser(sample_gedcom_file)
individuals = parser.get_individuals()
"""
Tests for the Individual data model.
This module tests individual person data extraction including:
- Names and IDs
- Birth and death information
- Events and attributes
- Family relationships
- Images and notes
- Custom story tags
"""
class TestIndividualBasicInfo: class TestIndividualBasicInfo:
"""Tests for basic individual information extraction.""" """Tests for basic individual information extraction."""
2
@@ -350,10 +330,6 @@ class TestEvents:
events = person.get_events() events = person.get_events()
event_types = [e['type'] for e in events] event_types = [e['type'] for e in events]
assert resi['place'] == 'Deepplace'
assert resi['lat'] == '48.8566'
assert resi['long'] == '2.3522'
class TestFamilyRelationships: class TestFamilyRelationships:
"""Tests for family relationship extraction.""" """Tests for family relationship extraction."""
3
@@ -601,8 +577,6 @@ class TestAttributes:
attrs = person.get_attributes() attrs = person.get_attributes()
assert len(attrs) == 0 assert len(attrs) == 0
return Individual(john[0], parser.parser)
def test_get_id(self, john_doe): def test_get_id(self, john_doe):
"""Test ID extraction without @ symbols.""" """Test ID extraction without @ symbols."""
id_value = john_doe.get_id() id_value = john_doe.get_id()