Add tests for coordinates
This pull request significantly refactors and enhances the Individual class and related code to improve how GEDCOM data is parsed and represented, especially regarding event information and media handling. The main improvements include adding support for extracting and storing event coordinates (latitude/longitude), simplifying and optimizing methods for retrieving family relationships, and consolidating media (OBJE) resolution logic. There are also updates to the Markdown generator to include coordinates in the output.
Event and Coordinate Extraction Enhancements:
Added extraction of latitude and longitude for birth, death, and marriage events, including new helper methods (_extract_date_place_and_coords, _extract_lat_long_from_node, _get_event_info) to recursively parse these details from GEDCOM nodes. Event info dictionaries now include lat and long keys. ([[1]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL103-R149), [[2]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL209-R242), [[3]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL316-R426))
Refactored event parsing to use a shared set of event tags and centralized event extraction logic, ensuring consistency and reducing code duplication. ([[1]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dR18), [[2]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL316-R426))
Family Relationship Methods Simplification:
Refactored get_children and get_partners to use concise list comprehensions, improving readability and efficiency. ([[1]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL168-R183), [[2]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL186-R200))
Simplified get_families and get_families_as_child to use helper methods for resolving parent IDs and event info, reducing logic complexity and improving maintainability. ([[1]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL209-R242), [[2]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dR259-R271))
Media (OBJE) Handling Consolidation:
Centralized OBJE/media reference resolution into a new _get_obje_info helper, used by both get_images and get_stories, to avoid code duplication and ensure consistent media extraction. ([[1]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL348-R441), [[2]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL470-R549), [[3]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dR559-R578))
Markdown Output Improvements:
Updated the Markdown generator to include birth and death coordinates (if available) in the generated frontmatter, using a new _coordinate_values helper. ([[1]](diffhunk://#diff-a9e8aa895b2187229fd9091ee3c8b6f034452e6c5d13a454db20da45829cf431R60-R70), [[2]](diffhunk://#diff-a9e8aa895b2187229fd9091ee3c8b6f034452e6c5d13a454db20da45829cf431R153-R166))
These changes collectively improve maintainability and the extracted genealogical data.
Summary by CodeRabbit
Release Notes
New Features
Birth and death records now capture and display geographic coordinates when available.
Marriage events now include location coordinates in generated documentation.
All supported event types can now display latitude and longitude data.
Tests
Expanded test coverage for coordinate extraction and documentation rendering.
* Show coordinates for any place that has them
* Add tests for coordinates
This pull request significantly refactors and enhances the `Individual` class and related code to improve how GEDCOM data is parsed and represented, especially regarding event information and media handling. The main improvements include adding support for extracting and storing event coordinates (latitude/longitude), simplifying and optimizing methods for retrieving family relationships, and consolidating media (OBJE) resolution logic. There are also updates to the Markdown generator to include coordinates in the output.
**Event and Coordinate Extraction Enhancements:**
* Added extraction of latitude and longitude for birth, death, and marriage events, including new helper methods (`_extract_date_place_and_coords`, `_extract_lat_long_from_node`, `_get_event_info`) to recursively parse these details from GEDCOM nodes. Event info dictionaries now include `lat` and `long` keys. (`[[1]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL103-R149)`, `[[2]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL209-R242)`, `[[3]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL316-R426)`)
* Refactored event parsing to use a shared set of event tags and centralized event extraction logic, ensuring consistency and reducing code duplication. (`[[1]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dR18)`, `[[2]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL316-R426)`)
**Family Relationship Methods Simplification:**
* Refactored `get_children` and `get_partners` to use concise list comprehensions, improving readability and efficiency. (`[[1]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL168-R183)`, `[[2]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL186-R200)`)
* Simplified `get_families` and `get_families_as_child` to use helper methods for resolving parent IDs and event info, reducing logic complexity and improving maintainability. (`[[1]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL209-R242)`, `[[2]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dR259-R271)`)
**Media (OBJE) Handling Consolidation:**
* Centralized OBJE/media reference resolution into a new `_get_obje_info` helper, used by both `get_images` and `get_stories`, to avoid code duplication and ensure consistent media extraction. (`[[1]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL348-R441)`, `[[2]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL470-R549)`, `[[3]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dR559-R578)`)
**Markdown Output Improvements:**
* Updated the Markdown generator to include birth and death coordinates (if available) in the generated frontmatter, using a new `_coordinate_values` helper. (`[[1]](diffhunk://#diff-a9e8aa895b2187229fd9091ee3c8b6f034452e6c5d13a454db20da45829cf431R60-R70)`, `[[2]](diffhunk://#diff-a9e8aa895b2187229fd9091ee3c8b6f034452e6c5d13a454db20da45829cf431R153-R166)`)
These changes collectively improve maintainability and the extracted genealogical data.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
## Release Notes
* **New Features**
* Birth and death records now capture and display geographic coordinates when available.
* Marriage events now include location coordinates in generated documentation.
* All supported event types can now display latitude and longitude data.
* **Tests**
* Expanded test coverage for coordinate extraction and documentation rendering.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@jaredhowland has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 1 seconds before requesting another review.
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 12 minutes and 1 seconds.
⌛ How to resolve this issue?
After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.
We recommend that you space out your commits to avoid hitting the rate limit.
🚦 How do rate limits work?
CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Reviewing files that changed from the base of the PR and between 2108325252 and 2071c01317.
📒 Files selected for processing (3)
src/individual.py
src/markdown_generator.py
tests/test_individual.py
📝 Walkthrough
Walkthrough
Extended birth, death, and event data extraction to include geographic coordinates parsed from GEDCOM place mappings. Refactored coordinate and event parsing into shared helper methods, simplified parent resolution logic, and deduplicated OBJE reference handling. Updated markdown output to display coordinate values for births, deaths, events, and marriages.
Changes
Cohort / File(s)
Summary
Coordinate data extraction src/individual.py
Added coordinate extraction from GEDCOM PLAC → MAP → LATI/LONG nodes to birth/death/event data. Introduced _extract_date_place_and_coords(), _get_event_info(), _get_obje_info(), and gender/coordinate helper methods. Refactored get_events(), get_families(), get_children(), get_partners(), and get_families_as_child() to use shared helpers and list comprehensions. (+224/-155 lines)
Added _coordinate_values() helper to extract latitude/longitude pairs. Updated frontmatter generation to include "Birth/Death coordinates:" lines. Enhanced event and family markdown output to display "Coordinates:" and "Marriage coordinates:" bullets when available. (+41/-12 lines)
Test coverage tests/test_individual.py, tests/test_markdown_generator.py
Extensive new pytest coverage for event/birth/death extraction, coordinate parsing from nested GEDCOM structures, family relationships, media/notes, and missing-data handling. Added test_coordinates_written to verify coordinate markdown output. (+744/-6 lines)
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
AlexKucera/gedcom-to-markdown#1: Directly related as both PRs modify core parsing logic in src/individual.py and output formatting in src/markdown_generator.py, particularly the event/birth/death data extraction and coordinate handling infrastructure.
Poem
A rabbit hops through GEDCOM trees,
Finding latitude, longitude with ease,
Birth, death, and marriage paths unfold,
With coordinates in coordinates we behold! 🐰📍
Comment @coderabbitai help to get the list of available commands and usage tips.
<!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- This is an auto-generated comment: rate limited by coderabbit.ai -->
> [!WARNING]
> ## Rate limit exceeded
>
> `@jaredhowland` has exceeded the limit for the number of commits that can be reviewed per hour. Please wait **12 minutes and 1 seconds** before requesting another review.
>
> Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in **12 minutes and 1 seconds**.
>
> <details>
> <summary>⌛ How to resolve this issue?</summary>
>
> After the wait time has elapsed, a review can be triggered using the `@coderabbitai review` command as a PR comment. Alternatively, push new commits to this PR.
>
> We recommend that you space out your commits to avoid hitting the rate limit.
>
> </details>
>
>
> <details>
> <summary>🚦 How do rate limits work?</summary>
>
> CodeRabbit enforces hourly rate limits for each developer per organization.
>
> Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
>
> Please see our [FAQ](https://docs.coderabbit.ai/faq) for further information.
>
> </details>
>
> <details>
> <summary>ℹ️ Review info</summary>
>
> <details>
> <summary>⚙️ Run configuration</summary>
>
> **Configuration used**: defaults
>
> **Review profile**: CHILL
>
> **Plan**: Pro
>
> **Run ID**: `c55cef2c-39dc-4ae7-be5f-178a802a12b5`
>
> </details>
>
> <details>
> <summary>📥 Commits</summary>
>
> Reviewing files that changed from the base of the PR and between 21083252524afcc342e54a1d0797aaf62e4eae05 and 2071c01317b6aad2f55d88dae77ae4b39fb2f553.
>
> </details>
>
> <details>
> <summary>📒 Files selected for processing (3)</summary>
>
> * `src/individual.py`
> * `src/markdown_generator.py`
> * `tests/test_individual.py`
>
> </details>
>
> </details>
<!-- end of auto-generated comment: rate limited by coderabbit.ai -->
<!-- walkthrough_start -->
<details>
<summary>📝 Walkthrough</summary>
## Walkthrough
Extended birth, death, and event data extraction to include geographic coordinates parsed from GEDCOM place mappings. Refactored coordinate and event parsing into shared helper methods, simplified parent resolution logic, and deduplicated OBJE reference handling. Updated markdown output to display coordinate values for births, deaths, events, and marriages.
## Changes
|Cohort / File(s)|Summary|
|---|---|
|**Coordinate data extraction** <br> `src/individual.py`|Added coordinate extraction from GEDCOM `PLAC` → `MAP` → `LATI`/`LONG` nodes to birth/death/event data. Introduced `_extract_date_place_and_coords()`, `_get_event_info()`, `_get_obje_info()`, and gender/coordinate helper methods. Refactored `get_events()`, `get_families()`, `get_children()`, `get_partners()`, and `get_families_as_child()` to use shared helpers and list comprehensions. (+224/-155 lines)|
|**Markdown output formatting** <br> `src/markdown_generator.py`|Added `_coordinate_values()` helper to extract latitude/longitude pairs. Updated frontmatter generation to include "Birth/Death coordinates:" lines. Enhanced event and family markdown output to display "Coordinates:" and "Marriage coordinates:" bullets when available. (+41/-12 lines)|
|**Test coverage** <br> `tests/test_individual.py`, `tests/test_markdown_generator.py`|Extensive new pytest coverage for event/birth/death extraction, coordinate parsing from nested GEDCOM structures, family relationships, media/notes, and missing-data handling. Added `test_coordinates_written` to verify coordinate markdown output. (+744/-6 lines)|
## Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
## Possibly related PRs
- **AlexKucera/gedcom-to-markdown#1**: Directly related as both PRs modify core parsing logic in `src/individual.py` and output formatting in `src/markdown_generator.py`, particularly the event/birth/death data extraction and coordinate handling infrastructure.
## Poem
> A rabbit hops through GEDCOM trees,
> Finding latitude, longitude with ease,
> Birth, death, and marriage paths unfold,
> With coordinates in coordinates we behold! 🐰📍
</details>
<!-- walkthrough_end -->
<!-- pre_merge_checks_walkthrough_start -->
<details>
<summary>🚥 Pre-merge checks | ✅ 3</summary>
<details>
<summary>✅ Passed checks (3 passed)</summary>
| Check name | Status | Explanation |
| :----------------: | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- |
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly and concisely summarizes the main change: extracting and including latitude/longitude coordinates from GEDCOM place data for events. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
</details>
<sub>✏️ Tip: You can configure your own custom pre-merge checks in the settings.</sub>
</details>
<!-- pre_merge_checks_walkthrough_end -->
<!-- finishing_touch_checkbox_start -->
<details>
<summary>✨ Finishing Touches</summary>
<details>
<summary>🧪 Generate unit tests (beta)</summary>
- [ ] <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Create PR with unit tests
</details>
</details>
<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->
---
Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=AlexKucera/gedcom-to-markdown&utm_content=7)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
<details>
<summary>❤️ Share</summary>
- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
</details>
<sub>Comment `@coderabbitai help` to get the list of available commands and usage tips.</sub>
<!-- tips_end -->
<!-- internal state start -->
<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKPR1AGxJcAZiWpcJAAeuFRiPB5oDCSQkbgA9B74GEQK+BS08BjU0pCQBgByjgKUXADskIAoBJCwuLjciBzx8UTqsNgCGkzM8QCCXkEA0tjRVC103WAEYMzOANa0+ADuGPHc2B4e8RX5AKqIpZBCznSwy5EY9PkAyvjYFNGQAlQYDLCBIWG4YNyR0WBMdKZbI0ZCAJMIYM5SLgni83lxZlk8gZrrhqNhGvxuGRkTYSBJ4CQlpRMQBhfDceBJGH5UkUfw0egBSAAJgADCyAGxgNkAFjAAEYytA+RwBQBOMVlABaRgAItIGBR4NxxMlIAAKHxRXDIZIeWQASg4BigvVotGQwVCOvg6sw9EQBCopH4Pli1HU2CUiWSrVw3piPnSkHx7GQGrUFFwsAANJAlNQ45BZhRlWhSIaNJACkSaiQPNiKJiAPrWr4l2g5Eu/KIkEsOkuAjKIeNlz46ktxLt+ks+CgsEsYRQkeMOyAl6FlqQYXAlrLB7MAURnMIX+AT8DEduyytyw6WKFeHkDHph46SKUgcxIskQGlNkDx2rE6Stq54zkQWVSBEgGJiNB7FgE5HRIGF8HdMNZ0gNEiGQcdolnKgPH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pNz1XOnPZMYMiI13KCkAUvt1ogBj3NOOPPPMgg7gCs/0iJokisxCoCS1sgaBshsgACkNuCARyqADgdmW4hILuMAzG9IAAjtgE9NPtFGcN5CgMgMVRq1q9qwS4c0S7M/M+S480y2syY3MPy28xXRw5PTw2HdOpE7SrgLYDk8qHk4XW88VbyCUOKGyAID4LyMbdqMVQKLyOKNmz4IBQILQHFsVXQMVSyGgNLZyGgHFvQyQLLbLWyAwAKMVeKNLYBeKCm6W3Fv4BbT4MVQIGUEs+tjG7YBc+E9Fj4D27yD4CyNLQIBm5yGUD4GyAKNLbW+KJyJyMVSrWyGW6m1EOW1u3FnWz4AwCVcuwW+KGgOKO28VUoMVZyNLbQGUPqmcwYLww3FAB7WwGafWFcx5Ovm7eLeTQQGMgBELRK/WAHVbSHeO06FYOTakb0LgHiKIXQPHWxNE3cLOGnWyD+8TRB/gFBwcDB9WKB47EAA== -->
<!-- internal state end -->
copilot-pull-request-reviewer[bot]
(Migrated from github.com)
left a comment
Copy link
Copy source
Pull request overview
Adds support for extracting latitude/longitude coordinates from GEDCOM place structures and rendering them into generated Markdown notes, alongside related refactors to Individual event/family/media parsing.
Changes:
Extract PLAC/MAP (and nested) LATI/LONG values into event info (birth/death/marriage and general events).
Render extracted coordinates in Markdown output (frontmatter + life events + family sections).
Add/extend tests intended to cover coordinate extraction and output.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
File
Description
tests/test_markdown_generator.py
Adds a test asserting coordinates appear in generated Markdown output.
tests/test_individual.py
Adds tests for coordinate extraction and additional coverage, but currently includes breaking test-module issues.
src/markdown_generator.py
Adds a helper to format coordinates and writes them into frontmatter/events/families output.
src/individual.py
Refactors event parsing to include coordinates; simplifies family relationship methods and centralizes OBJE resolution.
## Pull request overview
Adds support for extracting latitude/longitude coordinates from GEDCOM place structures and rendering them into generated Markdown notes, alongside related refactors to `Individual` event/family/media parsing.
**Changes:**
- Extract PLAC/MAP (and nested) LATI/LONG values into event info (birth/death/marriage and general events).
- Render extracted coordinates in Markdown output (frontmatter + life events + family sections).
- Add/extend tests intended to cover coordinate extraction and output.
### Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
| ---- | ----------- |
| tests/test_markdown_generator.py | Adds a test asserting coordinates appear in generated Markdown output. |
| tests/test_individual.py | Adds tests for coordinate extraction and additional coverage, but currently includes breaking test-module issues. |
| src/markdown_generator.py | Adds a helper to format coordinates and writes them into frontmatter/events/families output. |
| src/individual.py | Refactors event parsing to include coordinates; simplifies family relationship methods and centralizes OBJE resolution. |
---
💡 <a href="/AlexKucera/gedcom-to-markdown/new/main?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
self_pointer = self.element.get_pointer() is recomputed on every iteration of the for family in ... loop, but it cannot change during the loop. Move it just before the loop to avoid repeated method calls and keep the loop body focused on per-family work.
`self_pointer = self.element.get_pointer()` is recomputed on every iteration of the `for family in ...` loop, but it cannot change during the loop. Move it just before the loop to avoid repeated method calls and keep the loop body focused on per-family work.
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.
test_get_events_coords_nested_structure asserts on resi[...] but resi is never defined in this test (only events/event_types are). This will raise a NameError and fail the suite; extract the RESI event (as in the other coordinate tests) before asserting on its place/lat/long values, and drop the unused event_types variable if not needed.
`test_get_events_coords_nested_structure` asserts on `resi[...]` but `resi` is never defined in this test (only `events`/`event_types` are). This will raise a `NameError` and fail the suite; extract the RESI event (as in the other coordinate tests) before asserting on its `place/lat/long` values, and drop the unused `event_types` variable if not needed.
In test_get_attributes_empty, the function ends with return Individual(john[0], parser.parser) but john is undefined. This will error at runtime after the assertions and break the test run. Remove this return line (and any accidentally pasted code below it) so the test simply asserts and exits.
In `test_get_attributes_empty`, the function ends with `return Individual(john[0], parser.parser)` but `john` is undefined. This will error at runtime after the assertions and break the test run. Remove this return line (and any accidentally pasted code below it) so the test simply asserts and exits.
```suggestion
```
coderabbitai[bot]
(Migrated from github.com)
left a comment
Copy link
Copy source
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/markdown_generator.py (1)
149-166: ⚠️ Potential issue | 🟡 Minor
Coordinates are silently dropped when place is missing.
Birth/death coordinates are only emitted inside the if birth["place"]: / if death["place"]: blocks. If a GEDCOM record has LATI/LONG under PLAC but the PLAC line itself has no text value (valid per GEDCOM — a PLAC node can be empty and still carry MAP children), the coords will be parsed and stored on the individual but never written. The same pattern applies to _write_events (Line 220-225) and _write_families (Line 262-269).
If that's intentional (no place label ⇒ no coords), consider a brief comment. Otherwise, lift the coord write out of the place guard:
🔧 Suggested fix (birth section)
# Birth details
if birth["date"]:
f.write(f"Born: {birth['date']}\n")
if birth["place"]:
f.write(f"Place of birth: {birth['place']}\n")
- # Birth coordinates if available
- birth_coords = self._coordinate_values(birth)
- if birth_coords:
- f.write(f"Birth coordinates: {', '.join(birth_coords)}\n")
+ # Birth coordinates if available (independent of place text)
+ birth_coords = self._coordinate_values(birth)
+ if birth_coords:
+ f.write(f"Birth coordinates: {', '.join(birth_coords)}\n")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/markdown_generator.py` around lines 149 - 166, The code currently only
writes birth/death coordinates inside the place-present guards, so LATI/LONG
parsed into the birth/death dict are dropped when PLAC is empty; update
markdown_generator.py to emit coordinates regardless of whether birth["place"]
or death["place"] is truthy by moving the coordinate-writing logic out of those
if-blocks (use the existing helper _coordinate_values to get
birth_coords/death_coords and write them if non-empty). Apply the same change
pattern in _write_events and _write_families (ensure coordinate emission does
not depend on a non-empty "place" string), or add a brief comment near
_coordinate_values usage if omitting coords when place is empty was intentional.
🧹 Nitpick comments (5)
tests/test_individual.py (1)
262-262: Minor: prefer next(...) over [...][0] slicing (RUF015).
Applies to all the resi = [e for e in events if e["type"] == "RESI"][0] lines flagged by Ruff. After you've collapsed the duplicated test classes, consolidating to next(e for e in events if e["type"] == "RESI") avoids building a throw-away list and gives a clearer StopIteration if the event is missing.
Also applies to: 291-291, 320-320, 817-817, 846-846, 875-875, 906-906
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@tests/test_individual.py` at line 262, Replace the list-comprehension + [0]
pattern used to find the RESI event with a generator expression passed to next
so you don't build a throw-away list and get a clear StopIteration when missing;
e.g. change occurrences like resi = [e for e in events if e["type"] ==
"RESI"][0] to resi = next(e for e in events if e["type"] == "RESI"), and make
the same change for all flagged occurrences (the lines using the variable name
resi and the iterable events).
src/markdown_generator.py (1)
60-69: Nit: avoid double dict.get per key.
Each key is looked up twice. Not hot-path, but trivially cleaner:
♻️ Optional refactor
def _coordinate_values(
self, data: dict, lat_key: str = "lat", long_key: str = "long"
) -> List[str]:
"""Return non-empty coordinate values from a mapping in latitude/longitude order."""
- coords = []
- if data.get(lat_key):
- coords.append(data.get(lat_key))
- if data.get(long_key):
- coords.append(data.get(long_key))
- return coords
+ return [v for v in (data.get(lat_key), data.get(long_key)) if v]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/markdown_generator.py` around lines 60 - 69, In _coordinate_values,
you're calling data.get(lat_key) and data.get(long_key) twice; cache each lookup
in local variables (e.g., lat_val = data.get(lat_key), long_val =
data.get(long_key)) then check those variables and append non-empty values to
coords to avoid duplicate dict.get calls and make the logic clearer.
src/individual.py (3)
216-221: Nit: hoist self_pointer out of the loop.
self_pointer = self.element.get_pointer() is recomputed each iteration of for family in self.gedcom.get_families(self.element):. Compute once before the loop (as you already do correctly in get_families_as_child at Line 259).
♻️ Suggested fix
- families = []
- for family in self.gedcom.get_families(self.element):
- # Get partner
- self_pointer = self.element.get_pointer()
+ families = []
+ self_pointer = self.element.get_pointer()
+ for family in self.gedcom.get_families(self.element):
+ # Get partner
partners = [
Individual(parent, self.gedcom)
for parent in self.gedcom.get_family_members(family, "PARENTS")
if parent.get_pointer() != self_pointer
]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/individual.py` around lines 216 - 221, The code recomputes self_pointer
by calling self.element.get_pointer() inside the loop over families; hoist that
call out of the loop by assigning self_pointer = self.element.get_pointer() once
before iterating over self.gedcom.get_families(self.element) so the list
comprehension that builds partners (which uses Individual(...) and
parent.get_pointer()) reuses the precomputed self_pointer.
114-114: Avoid long as a local variable name.
long is not a Python 3 builtin, but it's still a keyword in ctypes / numpy / typing contexts and a well-known Python-2 carryover; using it as a local here hurts readability and can trip future readers. Prefer lati/longi (consistent with your helper internals) or lat/lon.
♻️ Suggested rename
- birth_date, birth_place, lat, long = self._get_event_info("BIRT")
+ birth_date, birth_place, lat, lon = self._get_event_info("BIRT")
...
return {
"date": birth_date or "",
"place": birth_place or "",
"year": birth_year,
"lat": lat,
- "long": long,
+ "long": lon,
}
(apply the same in get_death_info at Line 140.)
Also applies to: 140-140
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/individual.py` at line 114, Rename the local variable "long" to avoid
shadowing/reserving issues—use a consistent name like "lon" or "longi" (matching
your helper internals) where you unpack _get_event_info("BIRT") into birth_date,
birth_place, lat, long (e.g., birth_date, birth_place, lat, lon) and make the
identical change in get_death_info where you unpack the death event; update all
subsequent uses in those methods to the new variable name.
395-425: Recursion descends into LATI/LONG nodes unnecessarily.
When a direct child is LATI or LONG, you set the value and still call self._extract_lat_long_from_node(child) on that leaf. Harmless for normal GEDCOM (LATI/LONG have no children), but wasteful and slightly surprising if an export ever attaches sub-tags (e.g., NOTE). Consider continue after consuming a LATI/LONG to skip descent.
♻️ Suggested refactor
for child in node.get_child_elements():
tag = child.get_tag()
if tag == "LATI" and not lati:
lati = child.get_value() or ""
+ if lati and longi:
+ return lati, longi
+ continue
elif tag == "LONG" and not longi:
longi = child.get_value() or ""
-
- if lati and longi:
- return lati, longi
+ if lati and longi:
+ return lati, longi
+ continue
nested_lati, nested_longi = self._extract_lat_long_from_node(child)
if nested_lati and not lati:
lati = nested_lati
if nested_longi and not longi:
longi = nested_longi
if lati and longi:
return lati, longi
return lati, longi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/individual.py` around lines 395 - 425, The _extract_lat_long_from_node
method currently recurses into a child even after consuming a LATI or LONG
value; update the loop in _extract_lat_long_from_node so that when tag == "LATI"
or tag == "LONG" sets lati or longi you immediately continue the for-loop (skip
calling self._extract_lat_long_from_node(child)) to avoid descending into those
leaf nodes, while preserving the existing short-circuit returns when both lati
and longi are found; reference the variables lati, longi and the helper calls
get_child_elements(), get_tag(), and get_value() to locate the logic to change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/test_individual.py`:
- Around line 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.
---
Outside diff comments:
In `@src/markdown_generator.py`:
- Around line 149-166: The code currently only writes birth/death coordinates
inside the place-present guards, so LATI/LONG parsed into the birth/death dict
are dropped when PLAC is empty; update markdown_generator.py to emit coordinates
regardless of whether birth["place"] or death["place"] is truthy by moving the
coordinate-writing logic out of those if-blocks (use the existing helper
_coordinate_values to get birth_coords/death_coords and write them if
non-empty). Apply the same change pattern in _write_events and _write_families
(ensure coordinate emission does not depend on a non-empty "place" string), or
add a brief comment near _coordinate_values usage if omitting coords when place
is empty was intentional.
---
Nitpick comments:
In `@src/individual.py`:
- Around line 216-221: The code recomputes self_pointer by calling
self.element.get_pointer() inside the loop over families; hoist that call out of
the loop by assigning self_pointer = self.element.get_pointer() once before
iterating over self.gedcom.get_families(self.element) so the list comprehension
that builds partners (which uses Individual(...) and parent.get_pointer())
reuses the precomputed self_pointer.
- Line 114: Rename the local variable "long" to avoid shadowing/reserving
issues—use a consistent name like "lon" or "longi" (matching your helper
internals) where you unpack _get_event_info("BIRT") into birth_date,
birth_place, lat, long (e.g., birth_date, birth_place, lat, lon) and make the
identical change in get_death_info where you unpack the death event; update all
subsequent uses in those methods to the new variable name.
- Around line 395-425: The _extract_lat_long_from_node method currently recurses
into a child even after consuming a LATI or LONG value; update the loop in
_extract_lat_long_from_node so that when tag == "LATI" or tag == "LONG" sets
lati or longi you immediately continue the for-loop (skip calling
self._extract_lat_long_from_node(child)) to avoid descending into those leaf
nodes, while preserving the existing short-circuit returns when both lati and
longi are found; reference the variables lati, longi and the helper calls
get_child_elements(), get_tag(), and get_value() to locate the logic to change.
In `@src/markdown_generator.py`:
- Around line 60-69: In _coordinate_values, you're calling data.get(lat_key) and
data.get(long_key) twice; cache each lookup in local variables (e.g., lat_val =
data.get(lat_key), long_val = data.get(long_key)) then check those variables and
append non-empty values to coords to avoid duplicate dict.get calls and make the
logic clearer.
In `@tests/test_individual.py`:
- Line 262: Replace the list-comprehension + [0] pattern used to find the RESI
event with a generator expression passed to next so you don't build a throw-away
list and get a clear StopIteration when missing; e.g. change occurrences like
resi = [e for e in events if e["type"] == "RESI"][0] to resi = next(e for e in
events if e["type"] == "RESI"), and make the same change for all flagged
occurrences (the lines using the variable name resi and the iterable events).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
Push a commit to this branch (recommended)
Create a new PR with the fixes
ℹ️ Review info⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f1b7e04b-f536-411b-a936-f11e54bfa4bc
📥 Commits
Reviewing files that changed from the base of the PR and between 48e339c119 and 2108325252.
📒 Files selected for processing (4)
src/individual.py
src/markdown_generator.py
tests/test_individual.py
tests/test_markdown_generator.py
**Actionable comments posted: 1**
> [!CAUTION]
> Some comments are outside the diff and can’t be posted inline due to platform limitations.
>
>
>
> <details>
> <summary>⚠️ Outside diff range comments (1)</summary><blockquote>
>
> <details>
> <summary>src/markdown_generator.py (1)</summary><blockquote>
>
> `149-166`: _⚠️ Potential issue_ | _🟡 Minor_
>
> **Coordinates are silently dropped when place is missing.**
>
> Birth/death coordinates are only emitted inside the `if birth["place"]:` / `if death["place"]:` blocks. If a GEDCOM record has `LATI`/`LONG` under `PLAC` but the `PLAC` line itself has no text value (valid per GEDCOM — a PLAC node can be empty and still carry MAP children), the coords will be parsed and stored on the individual but never written. The same pattern applies to `_write_events` (Line 220-225) and `_write_families` (Line 262-269).
>
> If that's intentional (no place label ⇒ no coords), consider a brief comment. Otherwise, lift the coord write out of the place guard:
>
> <details>
> <summary>🔧 Suggested fix (birth section)</summary>
>
> ```diff
> # Birth details
> if birth["date"]:
> f.write(f"Born: {birth['date']}\n")
> if birth["place"]:
> f.write(f"Place of birth: {birth['place']}\n")
> - # Birth coordinates if available
> - birth_coords = self._coordinate_values(birth)
> - if birth_coords:
> - f.write(f"Birth coordinates: {', '.join(birth_coords)}\n")
> + # Birth coordinates if available (independent of place text)
> + birth_coords = self._coordinate_values(birth)
> + if birth_coords:
> + f.write(f"Birth coordinates: {', '.join(birth_coords)}\n")
> ```
> </details>
>
> <details>
> <summary>🤖 Prompt for AI Agents</summary>
>
> ```
> Verify each finding against the current code and only fix it if needed.
>
> In `@src/markdown_generator.py` around lines 149 - 166, The code currently only
> writes birth/death coordinates inside the place-present guards, so LATI/LONG
> parsed into the birth/death dict are dropped when PLAC is empty; update
> markdown_generator.py to emit coordinates regardless of whether birth["place"]
> or death["place"] is truthy by moving the coordinate-writing logic out of those
> if-blocks (use the existing helper _coordinate_values to get
> birth_coords/death_coords and write them if non-empty). Apply the same change
> pattern in _write_events and _write_families (ensure coordinate emission does
> not depend on a non-empty "place" string), or add a brief comment near
> _coordinate_values usage if omitting coords when place is empty was intentional.
> ```
>
> </details>
>
> </blockquote></details>
>
> </blockquote></details>
<details>
<summary>🧹 Nitpick comments (5)</summary><blockquote>
<details>
<summary>tests/test_individual.py (1)</summary><blockquote>
`262-262`: **Minor: prefer `next(...)` over `[...][0]` slicing (RUF015).**
Applies to all the `resi = [e for e in events if e["type"] == "RESI"][0]` lines flagged by Ruff. After you've collapsed the duplicated test classes, consolidating to `next(e for e in events if e["type"] == "RESI")` avoids building a throw-away list and gives a clearer `StopIteration` if the event is missing.
Also applies to: 291-291, 320-320, 817-817, 846-846, 875-875, 906-906
<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` at line 262, Replace the list-comprehension + [0]
pattern used to find the RESI event with a generator expression passed to next
so you don't build a throw-away list and get a clear StopIteration when missing;
e.g. change occurrences like resi = [e for e in events if e["type"] ==
"RESI"][0] to resi = next(e for e in events if e["type"] == "RESI"), and make
the same change for all flagged occurrences (the lines using the variable name
resi and the iterable events).
```
</details>
</blockquote></details>
<details>
<summary>src/markdown_generator.py (1)</summary><blockquote>
`60-69`: **Nit: avoid double `dict.get` per key.**
Each key is looked up twice. Not hot-path, but trivially cleaner:
<details>
<summary>♻️ Optional refactor</summary>
```diff
def _coordinate_values(
self, data: dict, lat_key: str = "lat", long_key: str = "long"
) -> List[str]:
"""Return non-empty coordinate values from a mapping in latitude/longitude order."""
- coords = []
- if data.get(lat_key):
- coords.append(data.get(lat_key))
- if data.get(long_key):
- coords.append(data.get(long_key))
- return coords
+ return [v for v in (data.get(lat_key), data.get(long_key)) if v]
```
</details>
<details>
<summary>🤖 Prompt for AI Agents</summary>
```
Verify each finding against the current code and only fix it if needed.
In `@src/markdown_generator.py` around lines 60 - 69, In _coordinate_values,
you're calling data.get(lat_key) and data.get(long_key) twice; cache each lookup
in local variables (e.g., lat_val = data.get(lat_key), long_val =
data.get(long_key)) then check those variables and append non-empty values to
coords to avoid duplicate dict.get calls and make the logic clearer.
```
</details>
</blockquote></details>
<details>
<summary>src/individual.py (3)</summary><blockquote>
`216-221`: **Nit: hoist `self_pointer` out of the loop.**
`self_pointer = self.element.get_pointer()` is recomputed each iteration of `for family in self.gedcom.get_families(self.element):`. Compute once before the loop (as you already do correctly in `get_families_as_child` at Line 259).
<details>
<summary>♻️ Suggested fix</summary>
```diff
- families = []
- for family in self.gedcom.get_families(self.element):
- # Get partner
- self_pointer = self.element.get_pointer()
+ families = []
+ self_pointer = self.element.get_pointer()
+ for family in self.gedcom.get_families(self.element):
+ # Get partner
partners = [
Individual(parent, self.gedcom)
for parent in self.gedcom.get_family_members(family, "PARENTS")
if parent.get_pointer() != self_pointer
]
```
</details>
<details>
<summary>🤖 Prompt for AI Agents</summary>
```
Verify each finding against the current code and only fix it if needed.
In `@src/individual.py` around lines 216 - 221, The code recomputes self_pointer
by calling self.element.get_pointer() inside the loop over families; hoist that
call out of the loop by assigning self_pointer = self.element.get_pointer() once
before iterating over self.gedcom.get_families(self.element) so the list
comprehension that builds partners (which uses Individual(...) and
parent.get_pointer()) reuses the precomputed self_pointer.
```
</details>
---
`114-114`: **Avoid `long` as a local variable name.**
`long` is not a Python 3 builtin, but it's still a keyword in `ctypes` / numpy / typing contexts and a well-known Python-2 carryover; using it as a local here hurts readability and can trip future readers. Prefer `lati`/`longi` (consistent with your helper internals) or `lat`/`lon`.
<details>
<summary>♻️ Suggested rename</summary>
```diff
- birth_date, birth_place, lat, long = self._get_event_info("BIRT")
+ birth_date, birth_place, lat, lon = self._get_event_info("BIRT")
...
return {
"date": birth_date or "",
"place": birth_place or "",
"year": birth_year,
"lat": lat,
- "long": long,
+ "long": lon,
}
```
(apply the same in `get_death_info` at Line 140.)
</details>
Also applies to: 140-140
<details>
<summary>🤖 Prompt for AI Agents</summary>
```
Verify each finding against the current code and only fix it if needed.
In `@src/individual.py` at line 114, Rename the local variable "long" to avoid
shadowing/reserving issues—use a consistent name like "lon" or "longi" (matching
your helper internals) where you unpack _get_event_info("BIRT") into birth_date,
birth_place, lat, long (e.g., birth_date, birth_place, lat, lon) and make the
identical change in get_death_info where you unpack the death event; update all
subsequent uses in those methods to the new variable name.
```
</details>
---
`395-425`: **Recursion descends into `LATI`/`LONG` nodes unnecessarily.**
When a direct child is `LATI` or `LONG`, you set the value and still call `self._extract_lat_long_from_node(child)` on that leaf. Harmless for normal GEDCOM (LATI/LONG have no children), but wasteful and slightly surprising if an export ever attaches sub-tags (e.g., NOTE). Consider `continue` after consuming a LATI/LONG to skip descent.
<details>
<summary>♻️ Suggested refactor</summary>
```diff
for child in node.get_child_elements():
tag = child.get_tag()
if tag == "LATI" and not lati:
lati = child.get_value() or ""
+ if lati and longi:
+ return lati, longi
+ continue
elif tag == "LONG" and not longi:
longi = child.get_value() or ""
-
- if lati and longi:
- return lati, longi
+ if lati and longi:
+ return lati, longi
+ continue
nested_lati, nested_longi = self._extract_lat_long_from_node(child)
if nested_lati and not lati:
lati = nested_lati
if nested_longi and not longi:
longi = nested_longi
if lati and longi:
return lati, longi
return lati, longi
```
</details>
<details>
<summary>🤖 Prompt for AI Agents</summary>
```
Verify each finding against the current code and only fix it if needed.
In `@src/individual.py` around lines 395 - 425, The _extract_lat_long_from_node
method currently recurses into a child even after consuming a LATI or LONG
value; update the loop in _extract_lat_long_from_node so that when tag == "LATI"
or tag == "LONG" sets lati or longi you immediately continue the for-loop (skip
calling self._extract_lat_long_from_node(child)) to avoid descending into those
leaf nodes, while preserving the existing short-circuit returns when both lati
and longi are found; reference the variables lati, longi and the helper calls
get_child_elements(), get_tag(), and get_value() to locate the logic to change.
```
</details>
</blockquote></details>
</blockquote></details>
<details>
<summary>🤖 Prompt for all review comments with AI agents</summary>
```
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/test_individual.py`:
- Around line 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.
---
Outside diff comments:
In `@src/markdown_generator.py`:
- Around line 149-166: The code currently only writes birth/death coordinates
inside the place-present guards, so LATI/LONG parsed into the birth/death dict
are dropped when PLAC is empty; update markdown_generator.py to emit coordinates
regardless of whether birth["place"] or death["place"] is truthy by moving the
coordinate-writing logic out of those if-blocks (use the existing helper
_coordinate_values to get birth_coords/death_coords and write them if
non-empty). Apply the same change pattern in _write_events and _write_families
(ensure coordinate emission does not depend on a non-empty "place" string), or
add a brief comment near _coordinate_values usage if omitting coords when place
is empty was intentional.
---
Nitpick comments:
In `@src/individual.py`:
- Around line 216-221: The code recomputes self_pointer by calling
self.element.get_pointer() inside the loop over families; hoist that call out of
the loop by assigning self_pointer = self.element.get_pointer() once before
iterating over self.gedcom.get_families(self.element) so the list comprehension
that builds partners (which uses Individual(...) and parent.get_pointer())
reuses the precomputed self_pointer.
- Line 114: Rename the local variable "long" to avoid shadowing/reserving
issues—use a consistent name like "lon" or "longi" (matching your helper
internals) where you unpack _get_event_info("BIRT") into birth_date,
birth_place, lat, long (e.g., birth_date, birth_place, lat, lon) and make the
identical change in get_death_info where you unpack the death event; update all
subsequent uses in those methods to the new variable name.
- Around line 395-425: The _extract_lat_long_from_node method currently recurses
into a child even after consuming a LATI or LONG value; update the loop in
_extract_lat_long_from_node so that when tag == "LATI" or tag == "LONG" sets
lati or longi you immediately continue the for-loop (skip calling
self._extract_lat_long_from_node(child)) to avoid descending into those leaf
nodes, while preserving the existing short-circuit returns when both lati and
longi are found; reference the variables lati, longi and the helper calls
get_child_elements(), get_tag(), and get_value() to locate the logic to change.
In `@src/markdown_generator.py`:
- Around line 60-69: In _coordinate_values, you're calling data.get(lat_key) and
data.get(long_key) twice; cache each lookup in local variables (e.g., lat_val =
data.get(lat_key), long_val = data.get(long_key)) then check those variables and
append non-empty values to coords to avoid duplicate dict.get calls and make the
logic clearer.
In `@tests/test_individual.py`:
- Line 262: Replace the list-comprehension + [0] pattern used to find the RESI
event with a generator expression passed to next so you don't build a throw-away
list and get a clear StopIteration when missing; e.g. change occurrences like
resi = [e for e in events if e["type"] == "RESI"][0] to resi = next(e for e in
events if e["type"] == "RESI"), and make the same change for all flagged
occurrences (the lines using the variable name resi and the iterable events).
```
</details>
<details>
<summary>🪄 Autofix (Beta)</summary>
Fix all unresolved CodeRabbit comments on this PR:
- [ ] <!-- {"checkboxId": "4b0d0e0a-96d7-4f10-b296-3a18ea78f0b9"} --> Push a commit to this branch (recommended)
- [ ] <!-- {"checkboxId": "ff5b1114-7d8c-49e6-8ac1-43f82af23a33"} --> Create a new PR with the fixes
</details>
---
<details>
<summary>ℹ️ Review info</summary>
<details>
<summary>⚙️ Run configuration</summary>
**Configuration used**: defaults
**Review profile**: CHILL
**Plan**: Pro
**Run ID**: `f1b7e04b-f536-411b-a936-f11e54bfa4bc`
</details>
<details>
<summary>📥 Commits</summary>
Reviewing files that changed from the base of the PR and between 48e339c1199a7abe69ac3c565c77b4d86fa027fd and 21083252524afcc342e54a1d0797aaf62e4eae05.
</details>
<details>
<summary>📒 Files selected for processing (4)</summary>
* `src/individual.py`
* `src/markdown_generator.py`
* `tests/test_individual.py`
* `tests/test_markdown_generator.py`
</details>
</details>
<!-- This is an auto-generated comment by CodeRabbit for review status -->
Blocker: file is structurally broken from a bad merge/rebase.
This file cannot be imported by pytest as-is. Multiple issues:
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.
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.
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.
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.
_⚠️ 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
## Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
---
💡 <a href="/AlexKucera/gedcom-to-markdown/new/main?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
The get_families_as_child docstring says it returns the parents’ GEDCOM IDs, but the implementation returns parent.get_pointer() values (e.g. "@I1@"). Please update the docstring to match the actual return shape (pointer vs ID) so callers know what to expect.
The `get_families_as_child` docstring says it returns the parents’ GEDCOM IDs, but the implementation returns `parent.get_pointer()` values (e.g. "@I1@"). Please update the docstring to match the actual return shape (pointer vs ID) so callers know what to expect.
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.
test_get_events_coords_nested_structure asserts on resi[...], but resi is never assigned in this test (only event_types is created). This will raise NameError if the test is executed. Assign resi the RESI event (as done in the other coordinate tests) or update the assertions accordingly.
event_types = [e['type'] for e in events]
resi = next(e for e in events if e['type'] == 'RESI')
assert 'RESI' in event_types
`test_get_events_coords_nested_structure` asserts on `resi[...]`, but `resi` is never assigned in this test (only `event_types` is created). This will raise `NameError` if the test is executed. Assign `resi` the RESI event (as done in the other coordinate tests) or update the assertions accordingly.
```suggestion
event_types = [e['type'] for e in events]
resi = next(e for e in events if e['type'] == 'RESI')
assert 'RESI' in event_types
```
This TestAttributes block looks like an accidental duplicate: the test method includes return Individual(john[0], ...) where john is undefined, and additional unrelated tests appear to be indented as methods on this class. Even if later redefinitions mask it, it’s dead/broken code that should be removed to keep the test suite understandable and prevent fixture-resolution issues if the ordering changes.
This `TestAttributes` block looks like an accidental duplicate: the test method includes `return Individual(john[0], ...)` where `john` is undefined, and additional unrelated tests appear to be indented as methods on this class. Even if later redefinitions mask it, it’s dead/broken code that should be removed to keep the test suite understandable and prevent fixture-resolution issues if the ordering changes.
TestImagesAndMedia is redefined later in this file, which overwrites the earlier TestImagesAndMedia class that actually tests get_images(). In the final definition, test_get_images calls get_notes() instead of get_images(), so image extraction is no longer being tested. Please avoid redefining the same test class name and ensure the image test calls get_images() (or rename the class/method to match what it verifies).
`TestImagesAndMedia` is redefined later in this file, which overwrites the earlier `TestImagesAndMedia` class that actually tests `get_images()`. In the final definition, `test_get_images` calls `get_notes()` instead of `get_images()`, so image extraction is no longer being tested. Please avoid redefining the same test class name and ensure the image test calls `get_images()` (or rename the class/method to match what it verifies).
You are not authorized to merge this pull request.
This pull request can be merged automatically.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
This pull request significantly refactors and enhances the
Individualclass and related code to improve how GEDCOM data is parsed and represented, especially regarding event information and media handling. The main improvements include adding support for extracting and storing event coordinates (latitude/longitude), simplifying and optimizing methods for retrieving family relationships, and consolidating media (OBJE) resolution logic. There are also updates to the Markdown generator to include coordinates in the output.Event and Coordinate Extraction Enhancements:
_extract_date_place_and_coords,_extract_lat_long_from_node,_get_event_info) to recursively parse these details from GEDCOM nodes. Event info dictionaries now includelatandlongkeys. ([[1]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL103-R149),[[2]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL209-R242),[[3]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL316-R426))[[1]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dR18),[[2]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL316-R426))Family Relationship Methods Simplification:
get_childrenandget_partnersto use concise list comprehensions, improving readability and efficiency. ([[1]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL168-R183),[[2]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL186-R200))get_familiesandget_families_as_childto use helper methods for resolving parent IDs and event info, reducing logic complexity and improving maintainability. ([[1]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL209-R242),[[2]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dR259-R271))Media (OBJE) Handling Consolidation:
_get_obje_infohelper, used by bothget_imagesandget_stories, to avoid code duplication and ensure consistent media extraction. ([[1]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL348-R441),[[2]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dL470-R549),[[3]](diffhunk://#diff-5970aee268369fb7d9b04b06813482ba972c417300314083b4baca9881488f6dR559-R578))Markdown Output Improvements:
_coordinate_valueshelper. ([[1]](diffhunk://#diff-a9e8aa895b2187229fd9091ee3c8b6f034452e6c5d13a454db20da45829cf431R60-R70),[[2]](diffhunk://#diff-a9e8aa895b2187229fd9091ee3c8b6f034452e6c5d13a454db20da45829cf431R153-R166))These changes collectively improve maintainability and the extracted genealogical data.
Summary by CodeRabbit
Release Notes
New Features
Tests
📝 Walkthrough
Walkthrough
Extended birth, death, and event data extraction to include geographic coordinates parsed from GEDCOM place mappings. Refactored coordinate and event parsing into shared helper methods, simplified parent resolution logic, and deduplicated OBJE reference handling. Updated markdown output to display coordinate values for births, deaths, events, and marriages.
Changes
src/individual.pyPLAC→MAP→LATI/LONGnodes to birth/death/event data. Introduced_extract_date_place_and_coords(),_get_event_info(),_get_obje_info(), and gender/coordinate helper methods. Refactoredget_events(),get_families(),get_children(),get_partners(), andget_families_as_child()to use shared helpers and list comprehensions. (+224/-155 lines)src/markdown_generator.py_coordinate_values()helper to extract latitude/longitude pairs. Updated frontmatter generation to include "Birth/Death coordinates:" lines. Enhanced event and family markdown output to display "Coordinates:" and "Marriage coordinates:" bullets when available. (+41/-12 lines)tests/test_individual.py,tests/test_markdown_generator.pytest_coordinates_writtento verify coordinate markdown output. (+744/-6 lines)Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
src/individual.pyand output formatting insrc/markdown_generator.py, particularly the event/birth/death data extraction and coordinate handling infrastructure.Poem
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands and usage tips.Pull request overview
Adds support for extracting latitude/longitude coordinates from GEDCOM place structures and rendering them into generated Markdown notes, alongside related refactors to
Individualevent/family/media parsing.Changes:
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@@ -335,0 +359,4 @@if child.get_tag() == event_tag:return self._extract_date_place_and_coords(child)return "", "", "", ""self_pointer = self.element.get_pointer()is recomputed on every iteration of thefor family in ...loop, but it cannot change during the loop. Move it just before the loop to avoid repeated method calls and keep the loop body focused on per-family work.@@ -17,6 +17,7 @@ from gedcom_parser import GedcomParserfrom individual import IndividualThe
john_doefixture inside the firstTestIndividualBasicInfoblock contains an unrelated triple-quoted module docstring (lines 28–38) and never returns anIndividual, 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 expectedIndividual) and keep only oneTestIndividualBasicInfodefinition.@@ -217,0 +222,4 @@assert resi['place'] == 'New York'assert resi['lat'] == ''assert resi['long'] == ''test_get_events_coords_nested_structureasserts onresi[...]butresiis never defined in this test (onlyevents/event_typesare). This will raise aNameErrorand fail the suite; extract the RESI event (as in the other coordinate tests) before asserting on itsplace/lat/longvalues, and drop the unusedevent_typesvariable if not needed.In
test_get_attributes_empty, the function ends withreturn Individual(john[0], parser.parser)butjohnis undefined. This will error at runtime after the assertions and break the test run. Remove this return line (and any accidentally pasted code below it) so the test simply asserts and exits.Actionable comments posted: 1
🧹 Nitpick comments (5)
🤖 Prompt for all review comments with AI agents
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID:
f1b7e04b-f536-411b-a936-f11e54bfa4bc📥 Commits
Reviewing files that changed from the base of the PR and between
48e339c119and2108325252.📒 Files selected for processing (4)
src/individual.pysrc/markdown_generator.pytests/test_individual.pytests/test_markdown_generator.py@@ -17,6 +17,7 @@ from gedcom_parser import GedcomParserfrom individual import Individual⚠️ Potential issue | 🔴 Critical
Blocker: file is structurally broken from a bad merge/rebase.
This file cannot be imported by pytest as-is. Multiple issues:
Lines 20–40:
TestIndividualBasicInfois declared twice. The first declaration'sjohn_doefixture opens a triple-quoted string at Line 28 (appears to be the module docstring accidentally inlined) and never returns, then a secondclass TestIndividualBasicInfostarts at Line 40.Lines 353–355 (inside
test_get_events_coords_nested_structure): asserts referenceresi, but onlyevent_typesis assigned on Line 351.resiis undefined here (Ruff F821). Theresi = [e for e in events if e["type"] == "RESI"][0]line is missing.Line 604: an orphan
return Individual(john[0], parser.parser)sits at class-body scope insideTestAttributes, wherejohnis undefined (Ruff F821). It's a leftover from the duplicatedjohn_doefixture below.Lines 604–1135: The entire suite (
TestIndividualBasicInfo,TestBirthAndDeath,TestEvents,TestFamilyRelationships,TestImagesAndMedia,TestStories) is duplicated verbatim afterTestAttributes. In this second copy,TestImagesAndMedia.test_get_images(Line 1037–1047) actually callsget_notesand 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 intest_get_events_coords_nested_structure(consider usingnext(...)per the Ruff RUF015 hint).🔧 Fix for the missing resi assignment (Lines 350–355)
🤖 Prompt for AI Agents
✅ Addressed in commits
747175fto0ba00d0Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@@ -248,3 +255,2 @@List of dictionaries with family information including:- father: str (father's GEDCOM ID) or None- mother: str (mother's GEDCOM ID) or None- father: str (father's GEDCOM pointer, including surrounding '@' characters, e.g. '@I1@') or NoneThe
get_families_as_childdocstring says it returns the parents’ GEDCOM IDs, but the implementation returnsparent.get_pointer()values (e.g. "@I1@"). Please update the docstring to match the actual return shape (pointer vs ID) so callers know what to expect.@@ -17,6 +17,7 @@ from gedcom_parser import GedcomParserfrom individual import IndividualThe file defines
TestIndividualBasicInfotwice, and this firstjohn_doefixture appears to contain an accidentally pasted triple-quoted block and never returns anIndividualinstance. Please remove the stray block and keep a singleTestIndividualBasicInfodefinition with a fixture that returns the intended individual, to avoid dead/overwritten test code and confusing fixture behavior.@@ -217,0 +222,4 @@assert resi['place'] == 'New York'assert resi['lat'] == ''assert resi['long'] == ''test_get_events_coords_nested_structureasserts onresi[...], butresiis never assigned in this test (onlyevent_typesis created). This will raiseNameErrorif the test is executed. Assignresithe RESI event (as done in the other coordinate tests) or update the assertions accordingly.This
TestAttributesblock looks like an accidental duplicate: the test method includesreturn Individual(john[0], ...)wherejohnis undefined, and additional unrelated tests appear to be indented as methods on this class. Even if later redefinitions mask it, it’s dead/broken code that should be removed to keep the test suite understandable and prevent fixture-resolution issues if the ordering changes.TestImagesAndMediais redefined later in this file, which overwrites the earlierTestImagesAndMediaclass that actually testsget_images(). In the final definition,test_get_imagescallsget_notes()instead ofget_images(), so image extraction is no longer being tested. Please avoid redefining the same test class name and ensure the image test callsget_images()(or rename the class/method to match what it verifies).View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.