Skip to content

Commit

Permalink
Using ruff format (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
coactive-tomas authored Oct 24, 2023
1 parent 488e963 commit b2896c2
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 55 deletions.
19 changes: 14 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "pyrgo"
version = "1.0.1"
version = "1.0.2"
readme = "README.md"
requires-python = ">=3.9"
classifiers = [
Expand All @@ -17,9 +17,8 @@ authors = [
]
dependencies = [
"click",
"ruff",
"ruff>=0.1.2",
"mypy",
"black",
"pip-tools>=7.0.0",
"pytest",
"result",
Expand All @@ -41,7 +40,18 @@ Source = "https://github.com/Tomperez98/pyrgo"

[tool.ruff]
line-length = 88
ignore = ["ANN101", "D203", "D212"]
ignore = [
"ANN101",
"D203",
"D212",
"COM812",
"COM819",
"D206",
"E501",
"ISC001",
"Q",
"W191",
]
select = ["ALL"]
fix = false
exclude = [
Expand Down Expand Up @@ -73,7 +83,6 @@ exclude = [

[tool.ruff.isort]
known-first-party = ["pyrgo"]
force-wrap-aliases = true
combine-as-imports = true
required-imports = ["from __future__ import annotations"]

Expand Down
2 changes: 1 addition & 1 deletion pyrgo/cli/cmds/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def ensure_env_exist_in_lock_file(env: str, config: PyrgoConf) -> None:
if env not in locked_envs:
click.echo(
click.style(
f"`{env}` not found in available envs.\nAvailable envs: {locked_envs}", # noqa: E501
f"`{env}` not found in available envs.\nAvailable envs: {locked_envs}",
fg="red",
),
)
Expand Down
7 changes: 3 additions & 4 deletions pyrgo/cli/cmds/fmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ def fmt() -> None:
"""Format code with `ruff` and `black`."""
configuration = PyrgoConf.new()
ruff_command = PythonCommandExec.new(program="ruff").add_args(args=["--fix-only"])
black_command = PythonCommandExec.new(program="black")

for command in [ruff_command, black_command]:
fmt_command = PythonCommandExec.new(program="ruff").add_args(args=["format", "."])
for command in [ruff_command, fmt_command]:
command.add_args(args=configuration.relevant_paths)

program_execution = inform_and_run_program(commands=[ruff_command, black_command])
program_execution = inform_and_run_program(commands=[ruff_command, fmt_command])
if not isinstance(program_execution, Ok):
sys.exit(1)
sys.exit(0)
1 change: 0 additions & 1 deletion pyrgo/command_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

PyrgoProgram: TypeAlias = Literal[
"ruff",
"black",
"mypy.dmypy",
"piptools",
"pip",
Expand Down
2 changes: 1 addition & 1 deletion pyrgo/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, path: pathlib.Path) -> None: # noqa: D107

def _configure_logger(logger: loguru.Logger) -> loguru.Logger:
logger.remove()
fmt = "<lvl>[{level}]</lvl> {message} <green>{name}:{function}:{line}</green> @ {time:HH:mm:ss}" # noqa: E501
fmt = "<lvl>[{level}]</lvl> {message} <green>{name}:{function}:{line}</green> @ {time:HH:mm:ss}"
logger.add(sys.stderr, format=fmt)
return logger

Expand Down
18 changes: 16 additions & 2 deletions pyrgo/resources/new-project/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,21 @@ dev = ["pyrgo"]

[tool.ruff]
line-length = 88
ignore = ["ANN101", "D203", "D212"]
ignore = [
"ANN101",
"D203",
"D212",
"COM812",
"COM819",
"D206",
"E501",
"ISC001",
"Q000",
"Q001",
"Q002",
"Q003",
"W191",
]
select = ["ALL"]
fix = false
exclude = [
Expand Down Expand Up @@ -51,7 +65,7 @@ exclude = [

[tool.ruff.isort]
known-first-party = ["pyrgo"]
force-wrap-aliases = true
force-wrap-aliases = false
combine-as-imports = true
required-imports = ["from __future__ import annotations"]

Expand Down
24 changes: 5 additions & 19 deletions requirements/core.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,20 @@
#
# pip-compile --output-file=requirements/core.txt pyproject.toml
#
--trusted-host pypi.python.org
--trusted-host pypi.org
--trusted-host files.pythonhosted.org

black==23.3.0
# via pyrgo (pyproject.toml)
build==0.10.0
# via
# pip-tools
# pyrgo (pyproject.toml)
cachecontrol[filecache]==0.13.1
# via pip-audit
# via
# cachecontrol
# pip-audit
certifi==2023.5.7
# via requests
charset-normalizer==3.1.0
# via requests
click==8.1.3
# via
# black
# pip-tools
# pyrgo (pyproject.toml)
cyclonedx-python-lib==2.7.1
Expand All @@ -48,20 +43,15 @@ msgpack==1.0.5
mypy==1.3.0
# via pyrgo (pyproject.toml)
mypy-extensions==1.0.0
# via
# black
# mypy
# via mypy
packageurl-python==0.11.1
# via cyclonedx-python-lib
packaging==23.1
# via
# black
# build
# pip-audit
# pip-requirements-parser
# pytest
pathspec==0.11.1
# via black
pip-api==0.0.30
# via pip-audit
pip-audit==2.5.6
Expand All @@ -70,8 +60,6 @@ pip-requirements-parser==32.0.1
# via pip-audit
pip-tools==7.3.0
# via pyrgo (pyproject.toml)
platformdirs==3.5.1
# via black
pluggy==1.0.0
# via pytest
pygments==2.15.1
Expand All @@ -90,7 +78,7 @@ result==0.10.0
# via pyrgo (pyproject.toml)
rich==13.4.1
# via pip-audit
ruff==0.0.272
ruff==0.1.2
# via pyrgo (pyproject.toml)
six==1.16.0
# via html5lib
Expand All @@ -102,15 +90,13 @@ toml==0.10.2
# pip-audit
tomli==2.0.1
# via
# black
# build
# mypy
# pip-tools
# pyproject-hooks
# pytest
typing-extensions==4.6.3
# via
# black
# mypy
# result
urllib3==1.26.16
Expand Down
28 changes: 8 additions & 20 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,26 @@
#
# pip-compile --extra=dev --output-file=requirements/dev.txt pyproject.toml
#
--trusted-host pypi.python.org
--trusted-host pypi.org
--trusted-host files.pythonhosted.org

black==23.7.0
# via pyrgo (pyproject.toml)
build==0.10.0
# via
# pip-tools
# pyrgo (pyproject.toml)
cachecontrol[filecache]==0.13.1
# via pip-audit
# via
# cachecontrol
# pip-audit
certifi==2023.7.22
# via requests
charset-normalizer==3.2.0
# via requests
click==8.1.7
# via
# black
# pip-tools
# pyrgo (pyproject.toml)
coverage[toml]==7.3.0
# via pytest-cov
# via
# coverage
# pytest-cov
cyclonedx-python-lib==4.0.1
# via pip-audit
defusedxml==0.7.1
Expand All @@ -52,20 +49,15 @@ msgpack==1.0.5
mypy==1.5.1
# via pyrgo (pyproject.toml)
mypy-extensions==1.0.0
# via
# black
# mypy
# via mypy
packageurl-python==0.11.2
# via cyclonedx-python-lib
packaging==23.1
# via
# black
# build
# pip-audit
# pip-requirements-parser
# pytest
pathspec==0.11.2
# via black
pip-api==0.0.30
# via pip-audit
pip-audit==2.6.1
Expand All @@ -74,8 +66,6 @@ pip-requirements-parser==32.0.1
# via pip-audit
pip-tools==7.3.0
# via pyrgo (pyproject.toml)
platformdirs==3.10.0
# via black
pluggy==1.2.0
# via pytest
py-serializable==0.11.1
Expand All @@ -100,7 +90,7 @@ result==0.13.1
# via pyrgo (pyproject.toml)
rich==13.5.2
# via pip-audit
ruff==0.0.285
ruff==0.1.2
# via pyrgo (pyproject.toml)
six==1.16.0
# via html5lib
Expand All @@ -110,7 +100,6 @@ toml==0.10.2
# via pip-audit
tomli==2.0.1
# via
# black
# build
# coverage
# mypy
Expand All @@ -119,7 +108,6 @@ tomli==2.0.1
# pytest
typing-extensions==4.7.1
# via
# black
# mypy
# result
urllib3==2.0.4
Expand Down
4 changes: 2 additions & 2 deletions tests/test_command_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@pytest.mark.unit()
class TestPythonCommandExec:
@pytest.mark.parametrize(argnames="program", argvalues=["black", "pip"])
@pytest.mark.parametrize(argnames="program", argvalues=["ruff", "pip"])
def test_new(self, program: PyrgoProgram) -> None:
assert PythonCommandExec.new(program=program).args == [
sys.executable,
Expand All @@ -20,7 +20,7 @@ def test_new(self, program: PyrgoProgram) -> None:
@pytest.mark.parametrize(
argnames=["command", "args", "expected"],
argvalues=[
(PythonCommandExec.new(program="black"), ["1", "2"], ["black", "1", "2"]),
(PythonCommandExec.new(program="pip"), ["1", "2"], ["pip", "1", "2"]),
],
)
def test_add_args(
Expand Down

0 comments on commit b2896c2

Please sign in to comment.