Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bob schumaker/python312 #523

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pathlib import Path
import re
try:
import json
Expand All @@ -11,7 +12,7 @@

def pytest_collect_file(path, parent):
if path.ext == ".docopt" and path.basename.startswith("test"):
return DocoptTestFile(path, parent)
return DocoptTestFile.from_parent(parent, path=Path(path))


def parse_test(raw):
Expand Down
10 changes: 5 additions & 5 deletions docopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ def single_match(self, left):

@classmethod
def parse(class_, source):
name = re.findall('(<\S*?>)', source)[0]
value = re.findall('\[default: (.*)\]', source, flags=re.I)
name = re.findall(r'(<\S*?>)', source)[0]
value = re.findall(r'\[default: (.*)\]', source, flags=re.I)
return class_(name, value[0] if value else None)


Expand Down Expand Up @@ -197,7 +197,7 @@ def parse(class_, option_description):
else:
argcount = 1
if argcount:
matched = re.findall('\[default: (.*)\]', description, flags=re.I)
matched = re.findall(r'\[default: (.*)\]', description, flags=re.I)
value = matched[0] if matched else None
return class_(short, long, argcount, value)

Expand Down Expand Up @@ -288,7 +288,7 @@ def __init__(self, source, error=DocoptExit):
@staticmethod
def from_pattern(source):
source = re.sub(r'([\[\]\(\)\|]|\.\.\.)', r' \1 ', source)
source = [s for s in re.split('\s+|(\S*<.*?>)', source) if s]
source = [s for s in re.split(r'\s+|(\S*<.*?>)', source) if s]
return Tokens(source, error=DocoptLanguageError)

def move(self):
Expand Down Expand Up @@ -454,7 +454,7 @@ def parse_defaults(doc):
for s in parse_section('options:', doc):
# FIXME corner case "bla: options: --foo"
_, _, s = s.partition(':') # get rid of "options:"
split = re.split('\n[ \t]*(-\S+?)', '\n' + s)[1:]
split = re.split(r'\n[ \t]*(-\S+?)', '\n' + s)[1:]
split = [s1 + s2 for s1, s2 in zip(split[::2], split[1::2])]
options = [Option.parse(s) for s in split if s.startswith('-')]
defaults += options
Expand Down