Skip to content

TypeError: Consecutives.__init__() got an unexpected keyword argument 'year' #92

Closed as duplicate

Description

@danvk

I believe [2011-05-01..2018-06-24] is a valid EDTF date, equivalent to 2011-05-01/2018-06-24. (Please close this issue if not!)

Trying to parse it generates a big stack trace in the parser:

>>> import edtf
>>> edtf.parse_edtf("[2011-05-01..2018-06-24]")
trying to Consecutives.__init__(**{'year': '2018', 'month': '06', 'day': '24', 'lower': ['2011', '-', '05', '-', '01'], 'upper': ['2018', '-', '06', '-', '24']})
Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    edtf.parse_edtf("[2011-05-01..2018-06-24]")
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/danvk/github/ohm/.venv/lib/python3.14/site-packages/edtf/util.py", line 62, in remapparams_wrapper
    return func(*a, **kw)
  File "/Users/danvk/github/ohm/.venv/lib/python3.14/site-packages/edtf/parser/grammar.py", line 362, in parse_edtf
    p = edtfParser.parse_string(input_string.strip(), parse_all)
  File "/Users/danvk/github/ohm/.venv/lib/python3.14/site-packages/pyparsing/core.py", line 1334, in parse_string
    loc, tokens = self._parse(instring, 0)
                  ~~~~~~~~~~~^^^^^^^^^^^^^
  File "/Users/danvk/github/ohm/.venv/lib/python3.14/site-packages/pyparsing/core.py", line 1094, in _parseCache
    value = self._parseNoCache(instring, loc, do_actions, callPreParse)
  File "/Users/danvk/github/ohm/.venv/lib/python3.14/site-packages/pyparsing/core.py", line 956, in _parseNoCache
    loc, tokens = self.parseImpl(instring, pre_loc, do_actions)
                  ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/danvk/github/ohm/.venv/lib/python3.14/site-packages/pyparsing/core.py", line 4750, in parseImpl
    loc2, toks = expr1._parse(instring, loc, do_actions)
                 ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/danvk/github/ohm/.venv/lib/python3.14/site-packages/pyparsing/core.py", line 1094, in _parseCache
    value = self._parseNoCache(instring, loc, do_actions, callPreParse)
  File "/Users/danvk/github/ohm/.venv/lib/python3.14/site-packages/pyparsing/core.py", line 956, in _parseNoCache
    loc, tokens = self.parseImpl(instring, pre_loc, do_actions)
                  ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/danvk/github/ohm/.venv/lib/python3.14/site-packages/pyparsing/core.py", line 4750, in parseImpl
    loc2, toks = expr1._parse(instring, loc, do_actions)
                 ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/danvk/github/ohm/.venv/lib/python3.14/site-packages/pyparsing/core.py", line 1094, in _parseCache
    value = self._parseNoCache(instring, loc, do_actions, callPreParse)
  File "/Users/danvk/github/ohm/.venv/lib/python3.14/site-packages/pyparsing/core.py", line 956, in _parseNoCache
    loc, tokens = self.parseImpl(instring, pre_loc, do_actions)
                  ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/danvk/github/ohm/.venv/lib/python3.14/site-packages/pyparsing/core.py", line 4630, in parseImpl
    loc, exprtokens = e._parse(instring, loc, do_actions)
                      ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/danvk/github/ohm/.venv/lib/python3.14/site-packages/pyparsing/core.py", line 1094, in _parseCache
    value = self._parseNoCache(instring, loc, do_actions, callPreParse)
  File "/Users/danvk/github/ohm/.venv/lib/python3.14/site-packages/pyparsing/core.py", line 956, in _parseNoCache
    loc, tokens = self.parseImpl(instring, pre_loc, do_actions)
                  ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/danvk/github/ohm/.venv/lib/python3.14/site-packages/pyparsing/core.py", line 4750, in parseImpl
    loc2, toks = expr1._parse(instring, loc, do_actions)
                 ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/danvk/github/ohm/.venv/lib/python3.14/site-packages/pyparsing/core.py", line 1094, in _parseCache
    value = self._parseNoCache(instring, loc, do_actions, callPreParse)
  File "/Users/danvk/github/ohm/.venv/lib/python3.14/site-packages/pyparsing/core.py", line 995, in _parseNoCache
    tokens = fn(instring, tokens_start, ret_tokens)  # type: ignore [call-arg, arg-type]
  File "/Users/danvk/github/ohm/.venv/lib/python3.14/site-packages/pyparsing/core.py", line 290, in wrapper
    ret = func(*args[limit:])
  File "/Users/danvk/github/ohm/.venv/lib/python3.14/site-packages/edtf/parser/parser_classes.py", line 116, in parse_action
    raise e
  File "/Users/danvk/github/ohm/.venv/lib/python3.14/site-packages/edtf/parser/parser_classes.py", line 113, in parse_action
    return cls(**kwargs)  # replace the token list with the class
TypeError: Consecutives.__init__() got an unexpected keyword argument 'year'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions