anaconda / percy

A tool to work on recipes from aggregate.
BSD 3-Clause "New" or "Revised" License
9 stars 0 forks source link

Using default renderer causes exception #34

Closed schuylermartin45 closed 1 year ago

schuylermartin45 commented 1 year ago

I get a NoneType exception when I construct a Recipe with just a file path specified.

I think this is caused by renderer=None in the constructor. Based off of the anaconda-linter project it looks like I should be setting it to RendererType.RUAMEL. I'm guessing support for alternative renderers is limited right now, so should we elect to require this argument or pick another default?

Traceback (most recent call last):
  File "/Users/smartin/anaconda_3/anaconda3/envs/perseverance-scripts/bin/pscripts", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/Users/smartin/anaconda_3/anaconda3/envs/perseverance-scripts/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/smartin/anaconda_3/anaconda3/envs/perseverance-scripts/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/smartin/anaconda_3/anaconda3/envs/perseverance-scripts/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/smartin/anaconda_3/anaconda3/envs/perseverance-scripts/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/smartin/anaconda_3/anaconda3/envs/perseverance-scripts/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/smartin/work/perseverance-scripts/perseverance_scripts/commands/recipe_bootstrapper.py", line 131, in recipe_bootstrapper
    recipe_reset_build_number(recipe)  # type: ignore[misc]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/smartin/work/perseverance-scripts/perseverance_scripts/commands/recipe_bootstrapper.py", line 30, in recipe_reset_build_number
    recipe.patch(  # type: ignore[misc]
  File "/Users/smartin/anaconda_3/anaconda3/envs/perseverance-scripts/lib/python3.11/site-packages/percy/render/recipe.py", line 637, in patch
    self.render()
  File "/Users/smartin/anaconda_3/anaconda3/envs/perseverance-scripts/lib/python3.11/site-packages/percy/render/recipe.py", line 276, in render
    bld = self.meta.get("build", {})
          ^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'
schuylermartin45 commented 1 year ago

So this might be partly my fault. I wasn't aware of the from_file factory method until I noticed that my recipe wasn't loading the contents of a file using the default constructor.

That being said, I don't see any docs suggesting that I should be using a factory method over the constructor, so I'm sure other devs might make that same mistake.

schuylermartin45 commented 1 year ago

We envision a future where the parse-tree mode becomes the primary parser. When that integration is done, this ticket is no longer relevant. Closing.