Skip to content

fix: update pyparsing method names to resolve deprecation warnings#113

Open
RobertSundling wants to merge 2 commits intopython-periodictable:masterfrom
RobertSundling:fix-pyparsing-deprecation-warnings
Open

fix: update pyparsing method names to resolve deprecation warnings#113
RobertSundling wants to merge 2 commits intopython-periodictable:masterfrom
RobertSundling:fix-pyparsing-deprecation-warnings

Conversation

@RobertSundling
Copy link

@RobertSundling RobertSundling commented Feb 4, 2026

Summary

Updates pyparsing method calls in formulas.py to use PEP8-compliant names, resolving deprecation warnings introduced in pyparsing 3.3.0 in December 2025. The PEP8-compliant names were introduced in pyparsing 3.0.0 in August 2021.

Problem

Starting with pyparsing 3.3.0, the library emits PyparsingDeprecationWarning for methods using the old camelCase naming convention:

PyparsingDeprecationWarning: 'setParseAction' deprecated - use 'set_parse_action'
PyparsingDeprecationWarning: 'setName' deprecated - use 'set_name'
PyparsingDeprecationWarning: 'parseString' deprecated - use 'parse_string'

These warnings appear when using periodictable for formula parsing, creating noise in applications and test suites.

Changes

Updated all pyparsing method calls in periodictable/formulas.py to use the new PEP8-compliant method names:

Old Method New Method
setParseAction() set_parse_action()
setName() set_name()
parseString() parse_string()

This was done using the pyparsing-provided migration tool: pyparsing.tools.cvt_pyparsing_pep8_names

Testing

  • All existing tests pass (aside an from existing warning about the invalid escape code of \d inside a comment on line 529 of periodictable/xsf.py)
  • Confirmed deprecation warnings are eliminated

References

@bmaranville
Copy link
Collaborator

This seems like a very straightforward change... will you want a patch release on pypi after this, or are you working from source?

@RobertSundling
Copy link
Author

will you want a patch release on pypi after this, or are you working from source?

For my projects that use periodictable, it's via pip and pypi. So it would be preferable if there could be a patch release there, too. (I do know that makes things a lot more complicated for you.)

@RobertSundling
Copy link
Author

I also added >= 3.0.0 to the pyparsing line in pyproject.toml since this change will now also require at least version 3.0.0 of pyparsing.

@bmaranville
Copy link
Collaborator

I defer to @pkienzle on publishing new versions of periodictable, but I suspect we can do it next week. We have a publishing GH action set up, so we just have to update the release notes and push a new tag, after this is merged.

@pkienzle
Copy link
Collaborator

Some of these were addressed in #109. Need to compare against fix-104-type-hinting to see if I missed any.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants