Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitac521c6

Browse files
committed
♻️ Remove a static method from Regex redundant with PythonRegex
1 parent298bc3e commitac521c6

File tree

2 files changed

+3
-31
lines changed

2 files changed

+3
-31
lines changed

‎pyformlang/regular_expression/regex.py‎

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -543,31 +543,3 @@ def accepts(self, word: Iterable[str]) -> bool:
543543
ifself._enfaisNone:
544544
self._enfa=self.to_epsilon_nfa()
545545
returnself._enfa.accepts(word)
546-
547-
@classmethod
548-
deffrom_python_regex(cls,regex):
549-
"""
550-
Creates a regex from a string using the python way to write it.
551-
552-
Careful:
553-
Not everything is implemented, check PythonRegex class\
554-
documentation for more details.
555-
556-
It is equivalent to calling PythonRegex constructor directly.
557-
558-
Parameters
559-
----------
560-
regex : str
561-
The regex given as a string or compile regex
562-
563-
Returns
564-
-------
565-
python_regex : :class:`~pyformlang.regular_expression.PythonRegex`
566-
The regex
567-
568-
Examples
569-
--------
570-
>>> Regex.from_python_regex("a+[cd]")
571-
572-
"""
573-
returnregular_expression.PythonRegex(regex)

‎pyformlang/regular_expression/tests/test_regex.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Tests for regular expressions
33
"""
4-
frompyformlang.regular_expressionimportRegex,MisformedRegexError
4+
frompyformlang.regular_expressionimportRegex,MisformedRegexError,PythonRegex
55
frompyformlangimportfinite_automaton
66
importpytest
77

@@ -173,13 +173,13 @@ def test_accepts(self):
173173
assertnotregex.accepts(["a","b"])
174174

175175
deftest_from_python_simple(self):
176-
regex=Regex.from_python_regex("abc")
176+
regex=PythonRegex("abc")
177177
assertregex.accepts(["a","b","c"])
178178
assertnotregex.accepts(["a","b","b"])
179179
assertnotregex.accepts(["a","b"])
180180

181181
deftest_from_python_brackets(self):
182-
regex=Regex.from_python_regex("a[bc]")
182+
regex=PythonRegex("a[bc]")
183183
assertregex.accepts(["a","b"])
184184
assertregex.accepts(["a","c"])
185185
assertnotregex.accepts(["a","b","c"])

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp