Closed gazpachoking closed 4 years ago
Yea, this is a problem inherited from rebulk which uses regex
as a drop-in replacement for the built in re
package if it is installed. Although not a requirement for guessit, regex
is installed by many popular packages, e.g. black. As a result, due to a recent API change in regex
, guessit's use of rebulk will break if regex
is installed.
Heres is another exception report:
===================== Guessit Exception Report =====================
version=3.1.0
string=/Users/jkwill87/Sync/Development/mnamer/demo/Ninja Turtles (1990).mkv
options={'type': None}
--------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/jkwill87/Sync/Development/mnamer/venv/lib/python3.8/site-packages/guessit/api.py", line 192, in guessit
config = self.configure(options, sanitize_options=False)
File "/Users/jkwill87/Sync/Development/mnamer/venv/lib/python3.8/site-packages/guessit/api.py", line 163, in configure
self.rebulk = rules_builder(advanced_config)
File "/Users/jkwill87/Sync/Development/mnamer/venv/lib/python3.8/site-packages/guessit/rules/__init__.py", line 56, in rebulk_builder
rebulk.rebulk(episodes(_config('episodes')))
File "/Users/jkwill87/Sync/Development/mnamer/venv/lib/python3.8/site-packages/guessit/rules/properties/episodes.py", line 168, in episodes
rebulk.chain(
File "/Users/jkwill87/Sync/Development/mnamer/venv/lib/python3.8/site-packages/rebulk/builder.py", line 179, in regex
return self.pattern(self.build_re(*pattern, **kwargs))
File "/Users/jkwill87/Sync/Development/mnamer/venv/lib/python3.8/site-packages/rebulk/builder.py", line 107, in build_re
return RePattern(*pattern, **kwargs)
File "/Users/jkwill87/Sync/Development/mnamer/venv/lib/python3.8/site-packages/rebulk/pattern.py", line 441, in __init__
pattern = call(re.compile, pattern, **self._kwargs)
File "/Users/jkwill87/Sync/Development/mnamer/venv/lib/python3.8/site-packages/rebulk/loose.py", line 60, in call
return function(*call_args, **call_kwargs)
File "/Users/jkwill87/Sync/Development/mnamer/venv/lib/python3.8/site-packages/regex/regex.py", line 348, in compile
return _compile(pattern, flags, ignore_unused, kwargs)
File "/Users/jkwill87/Sync/Development/mnamer/venv/lib/python3.8/site-packages/regex/regex.py", line 585, in _compile
raise ValueError('unused keyword argument {!a}'.format(any_one))
ValueError: unused keyword argument 'tags'
--------------------------------------------------------------------
Please report at https://github.com/guessit-io/guessit/issues.
====================================================================
Ideal upstream fixes would be for rebulk to offer another option than an environment variable to disable using the regex
package or to use the ignore_unused kwarg when calling re.compile.
As a quick fix you can add from os import environ; environ["REGEX_DISABLED"] = "1"
before importing guessit. For example, as done here.
I'd prefer the ultimate answer to not be an environment variable. Having to set that from the importing package before the import happens isn't a very nice interface. (But at the moment, we are also setting that env variable.)
So what is the environment variable for those of us who would like to work around this issue?
Never mind, I see:
REGEX_DISABLED=1
Fixed with rebulk 2.0.1, just released.
Seems there is an issue when the lastest release of the 'regex' module is installed. There is a ticket on that repo about the change as well. It would also be nice if there was a way to disable the use of that module other than setting the env variable.
https://bitbucket.org/mrabarnett/mrab-regex/issues/357/new-exception-valueerror-unused-keyword
Here's a traceback of what's happening: