Skip to content

Append-renumber for objects without numbers yet #880

@tjlaboss

Description

@tjlaboss

Is your feature request related to a problem? Please describe.

I'm always frustrated when...

appending an object created from scratch (that does not have a number assigned yet) to a NumberedObjectCollection.

If no number is assigned, it results in the following error:

Traceback (most recent call last):
  File "./prototype.py", line 156, in <module>
    main()
    ~~~~^^
  File "./prototype.py", line 151, in main
    something(deck, pos=f1)
    ~~~~~~~~~^^^^^^^^^^^^^^
  File "./prototype.py", line 131, in something
    deck.cells.append_renumber(cell)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "./montepy/numbered_object_collection.py", line 613, in append_renumber
    number = obj.number if obj.number > 0 else 1
                           ^^^^^^^^^^^^^^
TypeError: '>' not supported between instances of 'NoneType' and 'int'

Describe the solution you'd like

When obj.number is None, then NumberedObjectCollection.append_renumber() should just assign the next available number.

Describe alternatives you've considered

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsA deviation from expected behavior that does not reach the level of being reportable as an "Error".good first issueGood for newcomers

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions