Skip to content

Commit

Permalink
Merge pull request #387 from fizyk/ruff
Browse files Browse the repository at this point in the history
Use ruff instead of pycodestyle and pydocstyle - closes #359
  • Loading branch information
fizyk authored Oct 11, 2023
2 parents 27e9a00 + 6740513 commit 786b2c0
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 38 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ jobs:
with:
mypy: true
black: true
pycodestyle: true
pydocstyle: true
ruff: true
3 changes: 1 addition & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ webtest = "==3"
towncrier = "==23.6.0"
pytest-cov = "==4.1.0"
coverage = "==7.3.2"
pycodestyle = "==2.11.0"
mypy = "==1.6.0"
black = "==23.9.1"
pydocstyle = {version = "==6.3.0", extras = ["toml"]}
tbump = "==6.11.0"
ruff = "==0.0.292"
2 changes: 2 additions & 0 deletions newsfragments/359.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Use ruff instead of pydocstyle and pycodestyle.
Increase line-length limit to 90 characters
13 changes: 9 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,19 @@ showcontent = true
name = "Miscellaneus"
showcontent = false

[tool.pydocstyle]
ignore = "D203,D212"

[tool.black]
line-length = 80
line-length = 90
target-version = ['py39']
include = '.*\.pyi?$'

[tool.ruff]
line-length = 90
select = [
"E", # pycodestyle
"F", # pyflakes
"I", # isort
"D", # pydocstyle
]

[tool.tbump]
# Uncomment this if your project is hosted on GitHub:
Expand Down
13 changes: 5 additions & 8 deletions pytest_pyramid/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
"""Pytest's fixture factories."""

import os
from typing import Dict, Any, Callable
from configparser import ConfigParser
from typing import Any, Callable, Dict

import pytest
from _pytest.fixtures import FixtureRequest
from webtest import TestApp
from pyramid.config import Configurator

from configparser import ConfigParser
from webtest import TestApp


def _load_settings(cpath: str, io_settings: Dict[str, Any]) -> None:
Expand All @@ -33,8 +32,7 @@ def _load_settings(cpath: str, io_settings: Dict[str, Any]) -> None:
def pyramid_config(
config_path: str = None, settings: Dict[str, Any] = None
) -> Callable[[FixtureRequest], Configurator]:
"""
Pyramid_config fixture factory.
"""Pyramid_config fixture factory.
Used to create aditional fixtures returning pyramid's
:class:`~pyramid.config.Configurator` object.
Expand Down Expand Up @@ -68,8 +66,7 @@ def pyramid_config(request: FixtureRequest) -> Configurator:
def pyramid_app(
config_fixture_name: str, *additional_fixtures: str
) -> Callable[[FixtureRequest], TestApp]:
"""
pyramid_app fixture factory.
"""pyramid_app fixture factory.
Creates a TestApp instance based on.
Expand Down
3 changes: 0 additions & 3 deletions setup.cfg

This file was deleted.

6 changes: 2 additions & 4 deletions tests/app.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
"""Define dummy app for tests."""
from typing import Dict, Any
from typing import Any, Dict

from pyramid.config import Configurator


def main(
global_config: Dict[str, Any], **settings: Dict[str, Any]
) -> Configurator:
def main(global_config: Dict[str, Any], **settings: Dict[str, Any]) -> Configurator:
"""App configurator."""
return Configurator(settings)
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""Conftest module."""
from pytest_pyramid.plugin import *
from pytest_pyramid.plugin import * # noqa: F403
20 changes: 6 additions & 14 deletions tests/test_fixture.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Testing fixtures."""
import pytest
from _pytest.fixtures import FixtureRequest
from pyramid.config import Configurator
import pytest
from webtest import TestApp

from pytest_pyramid import factories
Expand All @@ -10,8 +10,7 @@


def test_pyramid_app(pyramid_app: TestApp) -> None:
"""
Make sure we have everything needed for pyramid integration tests running.
"""Make sure we have everything needed for pyramid integration tests running.
Check if:
- app is instance of TestApp
Expand All @@ -23,9 +22,7 @@ def test_pyramid_app(pyramid_app: TestApp) -> None:
assert res.status_code == 404


pyramid_config_path = factories.pyramid_config(
config_path="tests/pyramid.test.ini"
)
pyramid_config_path = factories.pyramid_config(config_path="tests/pyramid.test.ini")
pyramid_config_inheritance = factories.pyramid_config(
config_path="tests/pyramid.use.test.ini"
)
Expand All @@ -40,10 +37,7 @@ def test_pyramid_config(
assert isinstance(pyramid_config, Configurator)
assert isinstance(pyramid_config_path, Configurator)
assert pyramid_config_path != pyramid_config
assert (
pyramid_config_path.registry.settings
== pyramid_config.registry.settings
)
assert pyramid_config_path.registry.settings == pyramid_config.registry.settings


def test_pyramid_config_settings(pyramid_config_settings: Configurator) -> None:
Expand All @@ -56,8 +50,7 @@ def test_pyramid_config_settings(pyramid_config_settings: Configurator) -> None:
def test_pyramid_inheritance_config(
pyramid_config_path: Configurator, pyramid_config_inheritance: Configurator
) -> None:
"""
Test reading inheriting config through pytest_pyramid.
"""Test reading inheriting config through pytest_pyramid.
Given:
- that one config inherits the other,
Expand Down Expand Up @@ -104,8 +97,7 @@ def dummy_fixture() -> None:
def test_pyramid_app_with_additional_fixtures(
pyramid_app_with_additional_fixtures: TestApp, request: FixtureRequest
) -> None:
"""
Test that pyramid_app factory works with additional_fixtures.
"""Test that pyramid_app factory works with additional_fixtures.
It checks if additional_fixtures are loaded for the test.
"""
Expand Down

0 comments on commit 786b2c0

Please sign in to comment.