micropython-stubber icon indicating copy to clipboard operation
micropython-stubber copied to clipboard

Fix/literals ordering in class defs and modules

Open Josverl opened this issue 3 years ago • 9 comments

Fix for a problem that surfaces when enriching the 'firmware stubs' with information from the 'doc stubs'

As the firmware stubs did not enforce any particular order when dumping module/class/object attributes to be processed, the order of class literals and class methods in the resulting firmware stub file was purely dependant on the order returned by the firmware.

when adding parameters and parameter defaults from the documentation this resulted in multiple cases where a class literal was referred in a method before it was defined a few lines later.

  • esp32.pyi class partition , wrong ordering of class literals/constants , not defined at the top of the class this then causes an issue with one off the class methods.
  • machine.pyi class SoftSPI.init refers to class literal MSB which is defined later

The fix consists of two parts:

  1. sort the found attibutes to put the literals before methods and functions
  2. move the staticly generated init method to be the last on all class methods this is a bit of a shortcut but is simpler to implement than ClassDef > Literals > init > other methods

fixes: https://github.com/Josverl/micropython-stubs/issues/680 partial fix for https://github.com/Josverl/micropython-stubber/issues/262

Josverl avatar Oct 09 '22 11:10 Josverl

Codecov Report

Merging #267 (1b697b5) into main (17aada1) will decrease coverage by 0.01%. The diff coverage is 73.77%.

:exclamation: Current head 1b697b5 differs from pull request most recent head c1183b0. Consider uploading reports for the commit c1183b0 to get more accurate results

@@            Coverage Diff             @@
##             main     #267      +/-   ##
==========================================
- Coverage   87.75%   87.74%   -0.02%     
==========================================
  Files          54       54              
  Lines        2687     2741      +54     
  Branches      486      493       +7     
==========================================
+ Hits         2358     2405      +47     
+ Misses        218      215       -3     
- Partials      111      121      +10     
Impacted Files Coverage Δ
src/stubber/basicgit.py 77.19% <0.00%> (-4.63%) :arrow_down:
src/stubber/commands/config_cmd.py 86.66% <50.00%> (-13.34%) :arrow_down:
src/stubber/utils/config.py 90.00% <55.55%> (-10.00%) :arrow_down:
src/stubber/publish/merge_docstubs.py 66.66% <60.00%> (+42.34%) :arrow_up:
src/stubber/codemod/enrich.py 77.55% <80.00%> (+1.99%) :arrow_up:
src/stubber/publish/stubpacker.py 86.00% <83.87%> (-1.03%) :arrow_down:
src/stubber/publish/publish.py 80.68% <85.71%> (-0.22%) :arrow_down:
src/stubber/commands/clone_cmd.py 100.00% <100.00%> (ø)
src/stubber/commands/merge_cmd.py 100.00% <100.00%> (ø)
src/stubber/commands/minify_cmd.py 100.00% <100.00%> (ø)
... and 8 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Oct 09 '22 11:10 codecov[bot]

This pull request introduces 1 alert and fixes 2 when merging a0af91f366b48526fa7e46f7f5756e63ecf6c845 into 6c7e399adc4ec21ff4ae2a54e86a3024a99e9b5a - view on LGTM.com

new alerts:

  • 1 for Unused import

fixed alerts:

  • 2 for Unused import

lgtm-com[bot] avatar Oct 09 '22 11:10 lgtm-com[bot]

This pull request introduces 1 alert and fixes 2 when merging 694cdaca444482eafd2621537eff3ee216dbf110 into 6c7e399adc4ec21ff4ae2a54e86a3024a99e9b5a - view on LGTM.com

new alerts:

  • 1 for Unused import

fixed alerts:

  • 2 for Unused import

lgtm-com[bot] avatar Oct 09 '22 15:10 lgtm-com[bot]

This pull request introduces 1 alert and fixes 2 when merging f4467b328e4846f9795f97133d5132a315dcc7d1 into 6c7e399adc4ec21ff4ae2a54e86a3024a99e9b5a - view on LGTM.com

new alerts:

  • 1 for Unused import

fixed alerts:

  • 2 for Unused import

lgtm-com[bot] avatar Oct 09 '22 15:10 lgtm-com[bot]

This pull request introduces 1 alert and fixes 2 when merging 1b959308318ed3f7e62dc03baefb671032305a19 into 6c7e399adc4ec21ff4ae2a54e86a3024a99e9b5a - view on LGTM.com

new alerts:

  • 1 for Unused import

fixed alerts:

  • 2 for Unused import

lgtm-com[bot] avatar Oct 09 '22 17:10 lgtm-com[bot]

This pull request introduces 4 alerts and fixes 2 when merging cf1e416c29feee5235a69da44f6deab89b49ce41 into 6c7e399adc4ec21ff4ae2a54e86a3024a99e9b5a - view on LGTM.com

new alerts:

  • 3 for Unused import
  • 1 for Unreachable code

fixed alerts:

  • 2 for Unused import

lgtm-com[bot] avatar Oct 10 '22 21:10 lgtm-com[bot]

This pull request introduces 4 alerts and fixes 2 when merging e0755d204193f46ac19417b945c78413b01fcb8c into 6c7e399adc4ec21ff4ae2a54e86a3024a99e9b5a - view on LGTM.com

new alerts:

  • 3 for Unused import
  • 1 for Unreachable code

fixed alerts:

  • 2 for Unused import

lgtm-com[bot] avatar Oct 10 '22 21:10 lgtm-com[bot]

This pull request introduces 4 alerts and fixes 2 when merging fedc6e69c8c5879ff0c3057da8ee065b9ededf98 into 6c7e399adc4ec21ff4ae2a54e86a3024a99e9b5a - view on LGTM.com

new alerts:

  • 3 for Unused import
  • 1 for Unreachable code

fixed alerts:

  • 2 for Unused import

lgtm-com[bot] avatar Oct 10 '22 22:10 lgtm-com[bot]

This pull request introduces 1 alert and fixes 2 when merging 1b697b52ea37353d97798a6dc2909f0b861a680c into 6c7e399adc4ec21ff4ae2a54e86a3024a99e9b5a - view on LGTM.com

new alerts:

  • 1 for Unreachable code

fixed alerts:

  • 2 for Unused import

lgtm-com[bot] avatar Oct 11 '22 22:10 lgtm-com[bot]

This pull request introduces 5 alerts and fixes 2 when merging 123153322fa01ceef3dbb276421b4a4add10898a into 6c7e399adc4ec21ff4ae2a54e86a3024a99e9b5a - view on LGTM.com

new alerts:

  • 4 for Unused import
  • 1 for Unreachable code

fixed alerts:

  • 2 for Unused import

lgtm-com[bot] avatar Oct 15 '22 15:10 lgtm-com[bot]

This pull request introduces 5 alerts and fixes 2 when merging c1183b0458bc22592394848815cb7571467eb073 into 6c7e399adc4ec21ff4ae2a54e86a3024a99e9b5a - view on LGTM.com

new alerts:

  • 4 for Unused import
  • 1 for Unreachable code

fixed alerts:

  • 2 for Unused import

lgtm-com[bot] avatar Oct 21 '22 16:10 lgtm-com[bot]