Skip to content

Replace obsolete kwargs to _add_message & pre-release lint#410

Merged
sadielbartholomew merged 6 commits into
NCAS-CMS:mainfrom
sadielbartholomew:fix-conformance-add-message
Jul 6, 2026
Merged

Replace obsolete kwargs to _add_message & pre-release lint#410
sadielbartholomew merged 6 commits into
NCAS-CMS:mainfrom
sadielbartholomew:fix-conformance-add-message

Conversation

@sadielbartholomew

@sadielbartholomew sadielbartholomew commented Jul 3, 2026

Copy link
Copy Markdown
Member

Fixes an issue from a partially bodged merge conflict resolution in #373, namely that some of the new & old calls to _add_message were using the old API where variable was a valid keyword - in that PR it was updated to the more informative direct_parent_ncvar (see this commit which outlines the change to the method itself) but in resolving conflicts in that PR somehow some of the old code was left in there, resulting in errors such as:

Traceback (most recent call last):
  File "/home/slb93/git-repos/cf-python/docs/source/test_tutorial/../tutorial.py", line 6, in <module>
    y = cf.read('*.nc')
  File "/home/slb93/git-repos/cfdm/cfdm/decorators.py", line 171, in verbose_override_wrapper
    return method_with_verbose_kwarg(*args, **kwargs)
  File "/home/slb93/git-repos/cf-python/cf/read_write/read.py", line 545, in __new__
    return super().__new__(**kwargs)
           ~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/home/slb93/git-repos/cfdm/cfdm/decorators.py", line 171, in verbose_override_wrapper
    return method_with_verbose_kwarg(*args, **kwargs)
  File "/home/slb93/git-repos/cfdm/cfdm/read_write/read.py", line 328, in __new__
    self._read(dataset)
    ~~~~~~~~~~^^^^^^^^^
  File "/home/slb93/git-repos/cf-python/cf/read_write/read.py", line 689, in _read
    super()._read(dataset)
    ~~~~~~~~~~~~~^^^^^^^^^
  File "/home/slb93/git-repos/cfdm/cfdm/read_write/read.py", line 669, in _read
    self.dataset_contents = self.netcdf_read(dataset)
                            ~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/slb93/git-repos/cfdm/cfdm/decorators.py", line 171, in verbose_override_wrapper
    return method_with_verbose_kwarg(*args, **kwargs)
  File "/home/slb93/git-repos/cfdm/cfdm/read_write/netcdf/netcdfread.py", line 2482, in read
    field_or_domain = self._create_field_or_domain(
        ncvar, domain=domain
    )
  File "/home/slb93/git-repos/cfdm/cfdm/read_write/netcdf/netcdfread.py", line 4752, in _create_field_or_domain
    self._check_formula_terms(
    ~~~~~~~~~~~~~~~~~~~~~~~~~^
        field_ncvar,
        ^^^^^^^^^^^^
    ...<2 lines>...
        z_ncdim=g["variable_dimensions"][coord_ncvar][0],
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/slb93/git-repos/cfdm/cfdm/read_write/netcdf/checker.py", line 1484, in _check_formula_terms
    self._add_message(
    ~~~~~~~~~~~~~~~~~^
        field_ncvar,
        ^^^^^^^^^^^^
    ...<7 lines>...
        variable=coord_ncvar,
        ^^^^^^^^^^^^^^^^^^^^^
    )
    ^
TypeError: Report._add_message() got an unexpected keyword argument 'variable'

downstream in cf-python code.

Note testing on the conformance checking will be extended in coverage etc. in future - this ideally would have been caught in the cfdm test suite pre-release, but at present it isn't being detected and only through the cf-python tutorial code testing did we notice it.

Also includes pre-bug-fix-release linting, mostly to fix docstring line wrapping though note like in the cf-python pre-commit config. I've disabled docsformatter which is very strict and would change most Python modules in the codebase - so is too much clutter for now. (We can configure and re-enable in future.)

@sadielbartholomew sadielbartholomew self-assigned this Jul 3, 2026
@sadielbartholomew sadielbartholomew added bug Something isn't working linting Related to linting tests labels Jul 3, 2026

@davidhassell davidhassell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Sadie - following our discussion on Wednesday - this looks great. Thanks

@sadielbartholomew

sadielbartholomew commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

Thanks David. Note the linting/pre-commit CI job is failing for due to upstream issues not related to the PR:

Error: getCacheEntry failed: <\h2>Our services aren't available right now</\h2>

We're working to restore all services as soon as possible. Please check back soon.

so we can ignore that. Merging now.

@sadielbartholomew
sadielbartholomew merged commit 6a4bcfc into NCAS-CMS:main Jul 6, 2026
0 of 2 checks passed
@sadielbartholomew
sadielbartholomew deleted the fix-conformance-add-message branch July 6, 2026 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working linting Related to linting tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants