Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[config] Retain path information in validated configuration #6785

Merged
merged 5 commits into from
Jun 12, 2024

Conversation

clydebarrow
Copy link
Contributor

@clydebarrow clydebarrow commented May 20, 2024

What does this implement/fix?

Currently read_config() in esphome/config.py strips the path information from its validated config before returning.

By retaining that information, components can retrieve the source file and line associated with Ids during code generation, allowing line number directives to be inserted - e.g.:

      #line 462 "lvgl-package.yaml"
      lv_button = lv_btn_create(main_page->page);

This is already done in ESPHome for lambdas, which capture the path information which can be very helpful in identifying C++ code errors.

This is used by the LVGL PR, broken out here to keep core changes from the component PR.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other

Related issue or feature (if applicable): fixes

Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#

Test Environment

  • ESP32
  • ESP32 IDF
  • ESP8266
  • RP2040
  • BK72xx
  • RTL87xx

Example entry for config.yaml:

# Example config.yaml

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

@codecov-commenter
Copy link

codecov-commenter commented May 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 53.88%. Comparing base (4d8b5ed) to head (8ae3d98).
Report is 688 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #6785      +/-   ##
==========================================
+ Coverage   53.70%   53.88%   +0.17%     
==========================================
  Files          50       50              
  Lines        9408     9619     +211     
  Branches     1654     1698      +44     
==========================================
+ Hits         5053     5183     +130     
- Misses       4056     4112      +56     
- Partials      299      324      +25     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@clydebarrow clydebarrow changed the title Retain path information in processed config [config] Retain path information in validated configuration Jun 1, 2024
@jesserockz jesserockz merged commit 7b9fb57 into esphome:dev Jun 12, 2024
55 checks passed
@jesserockz jesserockz mentioned this pull request Jun 12, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jun 14, 2024
@clydebarrow clydebarrow deleted the config branch August 22, 2024 01:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants