-
Notifications
You must be signed in to change notification settings - Fork 7
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
add ruff formatter #297
add ruff formatter #297
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,12 +1,19 @@ | ||||||
def get_setup_version_and_pattern(setup_content): | ||||||
depend_lst, version_lst = [], [] | ||||||
for l in setup_content: | ||||||
if '==' in l: | ||||||
lst = l.split('[')[-1].split(']')[0].replace(' ', '').replace('"', '').replace("'", '').split(',') | ||||||
if "==" in l: | ||||||
lst = ( | ||||||
l.split("[")[-1] | ||||||
.split("]")[0] | ||||||
.replace(" ", "") | ||||||
.replace('"', "") | ||||||
.replace("'", "") | ||||||
.split(",") | ||||||
) | ||||||
for dep in lst: | ||||||
if dep != '\n': | ||||||
version_lst.append(dep.split('==')[1]) | ||||||
depend_lst.append(dep.split('==')[0]) | ||||||
if dep != "\n": | ||||||
version_lst.append(dep.split("==")[1]) | ||||||
depend_lst.append(dep.split("==")[0]) | ||||||
|
||||||
version_high_dict = {d: v for d, v in zip(depend_lst, version_lst)} | ||||||
return version_high_dict | ||||||
|
@@ -16,14 +23,14 @@ def get_env_version(env_content): | |||||
read_flag = False | ||||||
depend_lst, version_lst = [], [] | ||||||
for l in env_content: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename the variable - for l in env_content:
+ for line in env_content: Committable suggestion
Suggested change
|
||||||
if 'dependencies:' in l: | ||||||
if "dependencies:" in l: | ||||||
read_flag = True | ||||||
elif read_flag: | ||||||
lst = l.replace('-', '').replace(' ', '').replace('\n', '').split("=") | ||||||
lst = l.replace("-", "").replace(" ", "").replace("\n", "").split("=") | ||||||
if len(lst) == 2: | ||||||
depend_lst.append(lst[0]) | ||||||
version_lst.append(lst[1]) | ||||||
return {d:v for d, v in zip(depend_lst, version_lst)} | ||||||
return {d: v for d, v in zip(depend_lst, version_lst)} | ||||||
|
||||||
|
||||||
def update_dependencies(setup_content, version_low_dict, version_high_dict): | ||||||
|
@@ -35,27 +42,29 @@ def update_dependencies(setup_content, version_low_dict, version_high_dict): | |||||
version_combo_dict[dep] = dep + "==" + ver | ||||||
|
||||||
setup_content_new = "" | ||||||
pattern_dict = {d:d + "==" + v for d, v in version_high_dict.items()} | ||||||
pattern_dict = {d: d + "==" + v for d, v in version_high_dict.items()} | ||||||
for l in setup_content: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename the variable - for l in setup_content:
+ for line in setup_content: Committable suggestion
Suggested change
|
||||||
for k, v in pattern_dict.items(): | ||||||
if v in l: | ||||||
l = l.replace(v, version_combo_dict[k]) | ||||||
setup_content_new +=l | ||||||
setup_content_new += l | ||||||
return setup_content_new | ||||||
|
||||||
|
||||||
if __name__ == "__main__": | ||||||
with open('pyproject.toml', "r") as f: | ||||||
with open("pyproject.toml", "r") as f: | ||||||
setup_content = f.readlines() | ||||||
|
||||||
with open('environment.yml', "r") as f: | ||||||
with open("environment.yml", "r") as f: | ||||||
env_content = f.readlines() | ||||||
|
||||||
setup_content_new = update_dependencies( | ||||||
setup_content=setup_content[2:], | ||||||
version_low_dict=get_env_version(env_content=env_content), | ||||||
version_high_dict=get_setup_version_and_pattern(setup_content=setup_content[2:]), | ||||||
version_high_dict=get_setup_version_and_pattern( | ||||||
setup_content=setup_content[2:] | ||||||
), | ||||||
) | ||||||
|
||||||
with open('pyproject.toml', "w") as f: | ||||||
with open("pyproject.toml", "w") as f: | ||||||
f.writelines("".join(setup_content[:2]) + setup_content_new) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
repos: | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.4.4 | ||
hooks: | ||
- id: ruff | ||
name: ruff lint | ||
args: ["--fix"] | ||
files: ^pysqa/ | ||
- id: ruff-format | ||
name: ruff format |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
|
||
from ._version import get_versions | ||
|
||
__all__ = [QueueAdapter] | ||
__version__ = get_versions()["version"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
from pysqa.executor.executor import Executor | ||
|
||
__all__ = [Executor] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ | |
setup( | ||
version=versioneer.get_version(), | ||
cmdclass=versioneer.get_cmdclass(), | ||
) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename the variable
l
to a more descriptive name for clarity.Committable suggestion