From 62715ffe2bcd3a41955eff8732ec656c1a533427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Ho=CC=88nicke?= Date: Fri, 2 Jun 2023 19:36:43 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9E=95=20refactor:=20summarize=20error=20mes?= =?UTF-8?q?sage=20without=20line=20number?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dev_gpt/apis/pypi.py | 5 ++++- test/unit/test_api.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dev_gpt/apis/pypi.py b/dev_gpt/apis/pypi.py index a712695..55663ba 100644 --- a/dev_gpt/apis/pypi.py +++ b/dev_gpt/apis/pypi.py @@ -60,8 +60,11 @@ def clean_requirements_txt(previous_microservice_path): updated_requirements = [] for line in requirements_txt.split('\n'): + # replace comment at the end of the line + pattern = r'#.+' + line = re.sub(pattern, '', line) line = line.strip() - if not line or line.startswith('#'): + if not line: continue split = re.split(r'==|>=|<=|>|<|~=', line) diff --git a/test/unit/test_api.py b/test/unit/test_api.py index 60b898b..03a2bd0 100644 --- a/test/unit/test_api.py +++ b/test/unit/test_api.py @@ -58,6 +58,8 @@ requests streamlit # invalid version 1.0beta5prerelease google-api-python-client +# with comment +language-tool-python==2.5.3 # requires Java """ requirements_clean = """\ jina==111.222.333 @@ -67,7 +69,8 @@ pydub~=0.25.1 pdfminer.six~=20201018 requests~=2.26.0 streamlit~=0.89.0 -google-api-python-client~=2.23.0""" +google-api-python-client~=2.23.0 +language-tool-python==2.5.3""" requirements_txt_path = os.path.join(tmpdir, "requirements.txt") with open(requirements_txt_path, "w", encoding="utf-8") as f: f.write(requirements_content)