Skip to content

Commit

Permalink
Replace pylint with ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
ObserverOfTime committed Jan 21, 2023
1 parent 6d922a7 commit d3db12d
Show file tree
Hide file tree
Showing 8 changed files with 315 additions and 445 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install Poetry
uses: abatilo/actions-poetry@v2.2.0
with:
poetry-version: 1.3.1
poetry-version: 1.3.2
- name: Deploy to PyPI
run: poetry publish --build
env:
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: ['3.10']
python: ['3.10', '3.11']
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -25,14 +25,13 @@ jobs:
- name: Install Poetry
uses: abatilo/actions-poetry@v2.2.0
with:
poetry-version: 1.3.1
poetry-version: 1.3.2
- name: Install dependencies
run: poetry install
- name: Lint project
run: >-
poetry run pylint yaenv &&
poetry run mypy -p yaenv &&
poetry run pydocstyle yaenv
poetry run ruff yaenv &&
poetry run mypy -p yaenv
- name: Run tests
run: poetry run pytest --cov-report=xml
- name: Upload coverage to codecov
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ venv.bak/
.dmypy.json
dmypy.json

# ruff
.ruff_cache/

# Pyre type checker
.pyre/

Expand All @@ -195,4 +198,4 @@ tags
[._]*.un~

# Configuration
.lvimrc
.nvimrc
665 changes: 265 additions & 400 deletions poetry.lock

Large diffs are not rendered by default.

67 changes: 35 additions & 32 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "yaenv"
version = "1.6.3.post2"
version = "1.6.4.dev1"
readme = "README.rst"
license = "BSD-3-Clause"
description = "Yet another dotenv parser for Python."
Expand Down Expand Up @@ -35,61 +35,64 @@ include = "yaenv"
[tool.poetry.dependencies]
python = "^3.10"

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
mypy = "^0.991"
pylint = "^2.15.9"
pytest = "^7.2.0"
pytest = "^7.2.1"
pytest-cov = "^4.0.0"
pytest-pspec = "^0.0.4"
sphinx = "~5.1.1"
sphinx-rtd-theme = "^1.1.1"

[tool.poetry.dev-dependencies."pydocstyle"]
version = "^6.1.1"
extras = ["toml"]
ruff = "^0.0.229"

[tool.poetry.urls]
"Bug tracker" = "https://github.com/ObserverOfTime/yaenv/issues"
"Donations" = "https://github.com/sponsors/ObserverOfTime"

[tool.coverage]
run = {source = ["yaenv"]}
report = {fail_under = 90}
[tool.coverage.run]
source = ["yaenv"]

[tool.coverage.report]
fail_under = 90

[tool.pytest.ini_options]
testpaths = ["tests"]
required_plugins = ["pytest-cov", "pytest-pspec"]
addopts = ["--pspec", "--cov", "--cov-report=term"]

[tool.pylint.message_control]
max-line-length = 80
disable = [
"invalid-name",
"too-many-branches",
"wrong-import-order",
"raise-missing-from",
"unspecified-encoding",
"undefined-loop-variable",
"unsupported-assignment-operation"
[tool.ruff]
line-length = 80
format = "grouped"
select = ["F", "E", "W", "D", "I", "Q"]
ignore = [
"D107",
"D203",
"D212",
"D402",
"D413",
"D416"
]
extend-select = [
"ANN001",
"ANN201",
"ANN204",
"ANN205",
"ANN206",
"RUF100"
]

[tool.pydocstyle]
convention = "numpy"
add-select = "D213,D415,D417"
[tool.ruff.isort]
combine-as-imports = true

[tool.ruff.flake8-quotes]
inline-quotes = "single"
multiline-quotes = "single"

[tool.mypy]
pretty = true
strict = true
warn_return_any = false
allow_any_generics = true

[tool.isort]
balanced_wrapping = true
combine_as_imports = true
default_section = "THIRDPARTY"
length_sort = false
multi_line_output = 6

[build-system]
requires = ["poetry>=1.1"]
requires = ["poetry>=1.3"]
build-backend = "poetry.masonry.api"
4 changes: 2 additions & 2 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,14 @@ def test_single_quoted(self):
assert e.value == 'value'
assert not e._interpolate

def test_blank(self):
def test_blank_value(self):
"""it can parse blank variables"""
assert yaenv.core.EnvVar('key=').value == ''
assert yaenv.core.EnvVar('key=""').value == ''
assert yaenv.core.EnvVar("key=''").value == ''
assert yaenv.core.EnvVar('key= ').value == ''

def test_blank(self):
def test_blank_line(self):
"""it ignores blank lines"""
assert yaenv.core.EnvVar('\n') is None
assert yaenv.core.EnvVar(' \t ') is None
Expand Down
6 changes: 3 additions & 3 deletions yaenv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

from functools import cached_property
from os import PathLike, environ, fspath, path
from re import compile as regex
from re import Match, compile as regex
from secrets import token_urlsafe
from shlex import shlex
from shutil import move
from tempfile import mkstemp
from typing import overload, Iterator, Literal
from typing import Iterator, Literal, overload

from . import db, email, utils

Expand Down Expand Up @@ -342,7 +342,7 @@ def __repr__(self) -> str: # pragma: no cover
@cached_property
def vars(self) -> dict[str, str]:
"""`dict[str, str]` : Get the environment variables as a ``dict``."""
def _sub_callback(match): # type: ignore
def _sub_callback(match: Match) -> str:
return (self.ENV | result).get(match.group(1), '')

with open(self.envfile, 'r') as f:
Expand Down
2 changes: 1 addition & 1 deletion yaenv/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Useful utilities."""
"""Miscellaneous utilities."""

from typing import Any

Expand Down

0 comments on commit d3db12d

Please sign in to comment.