Skip to content

Commit a82128d

Browse files
Fix pyparsing deprecation warnings
Update to new pyparsing API (snake_case): - setResultsName -> set_results_name - delimitedList -> DelimitedList - parseString -> parse_string - parseAll -> parse_all - endQuoteChar -> end_quote_char - unquoteResults -> unquote_results Reduces test warnings from 5854 to 3. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c96581e commit a82128d

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/datajoint/declare.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ def build_foreign_key_parser_old():
106106
left = pp.Literal("(").suppress()
107107
right = pp.Literal(")").suppress()
108108
attribute_name = pp.Word(pp.srange("[a-z]"), pp.srange("[a-z0-9_]"))
109-
new_attrs = pp.Optional(left + pp.delimitedList(attribute_name) + right).setResultsName("new_attrs")
109+
new_attrs = pp.Optional(left + pp.DelimitedList(attribute_name) + right).set_results_name("new_attrs")
110110
arrow = pp.Literal("->").suppress()
111111
lbracket = pp.Literal("[").suppress()
112112
rbracket = pp.Literal("]").suppress()
113113
option = pp.Word(pp.srange("[a-zA-Z]"))
114-
options = pp.Optional(lbracket + pp.delimitedList(option) + rbracket).setResultsName("options")
115-
ref_table = pp.Word(pp.alphas, pp.alphanums + "._").setResultsName("ref_table")
116-
ref_attrs = pp.Optional(left + pp.delimitedList(attribute_name) + right).setResultsName("ref_attrs")
114+
options = pp.Optional(lbracket + pp.DelimitedList(option) + rbracket).set_results_name("options")
115+
ref_table = pp.Word(pp.alphas, pp.alphanums + "._").set_results_name("ref_table")
116+
ref_attrs = pp.Optional(left + pp.DelimitedList(attribute_name) + right).set_results_name("ref_attrs")
117117
return new_attrs + arrow + options + ref_table + ref_attrs
118118

119119

@@ -122,21 +122,21 @@ def build_foreign_key_parser():
122122
lbracket = pp.Literal("[").suppress()
123123
rbracket = pp.Literal("]").suppress()
124124
option = pp.Word(pp.srange("[a-zA-Z]"))
125-
options = pp.Optional(lbracket + pp.delimitedList(option) + rbracket).setResultsName("options")
126-
ref_table = pp.restOfLine.setResultsName("ref_table")
125+
options = pp.Optional(lbracket + pp.DelimitedList(option) + rbracket).set_results_name("options")
126+
ref_table = pp.restOfLine.set_results_name("ref_table")
127127
return arrow + options + ref_table
128128

129129

130130
def build_attribute_parser():
131131
quoted = pp.QuotedString('"') ^ pp.QuotedString("'")
132132
colon = pp.Literal(":").suppress()
133-
attribute_name = pp.Word(pp.srange("[a-z]"), pp.srange("[a-z0-9_]")).setResultsName("name")
133+
attribute_name = pp.Word(pp.srange("[a-z]"), pp.srange("[a-z0-9_]")).set_results_name("name")
134134
data_type = (
135135
pp.Combine(pp.Word(pp.alphas) + pp.SkipTo("#", ignore=quoted))
136-
^ pp.QuotedString("<", endQuoteChar=">", unquoteResults=False)
137-
).setResultsName("type")
138-
default = pp.Literal("=").suppress() + pp.SkipTo(colon, ignore=quoted).setResultsName("default")
139-
comment = pp.Literal("#").suppress() + pp.restOfLine.setResultsName("comment")
136+
^ pp.QuotedString("<", end_quote_char=">", unquote_results=False)
137+
).set_results_name("type")
138+
default = pp.Literal("=").suppress() + pp.SkipTo(colon, ignore=quoted).set_results_name("default")
139+
comment = pp.Literal("#").suppress() + pp.restOfLine.set_results_name("comment")
140140
return attribute_name + pp.Optional(default) + colon + data_type + comment
141141

142142

@@ -171,7 +171,7 @@ def compile_foreign_key(line, context, attributes, primary_key, attr_sql, foreig
171171
from .table import Table
172172

173173
try:
174-
result = foreign_key_parser.parseString(line)
174+
result = foreign_key_parser.parse_string(line)
175175
except pp.ParseException as err:
176176
raise DataJointError('Parsing error in line "%s". %s.' % (line, err))
177177

@@ -494,7 +494,7 @@ def compile_attribute(line, in_key, foreign_key_sql, context):
494494
:returns: (name, sql, store) -- attribute name, sql code for its declaration, and optional store name
495495
"""
496496
try:
497-
match = attribute_parser.parseString(line + "#", parseAll=True)
497+
match = attribute_parser.parse_string(line + "#", parse_all=True)
498498
except pp.ParseException as err:
499499
raise DataJointError(
500500
"Declaration error in position {pos} in line:\n {line}\n{msg}".format(

0 commit comments

Comments
 (0)