Skip to content

Commit

Permalink
Misc. clean up: Development dependencies, doc build action, tox for d…
Browse files Browse the repository at this point in the history
…oc builds, pre-commit hook updates (#2814)

* docs: move build dependencies to tox environment

* provider: mark wheel as unsafe package

* Fix tox default configuration

* pre-commit: update hooks

* actions: add workflow for doc sanity build

* isort: update configuration to v5

* flake8: fix issues
abn authored Aug 20, 2020

Verified

This commit was signed with the committer’s verified signature.
axelboc Axel Bocciarelli
1 parent 5de6203 commit d2fd581
Showing 26 changed files with 460 additions and 740 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Documentation

on:
push:
paths:
- 'docs/**'
- '.github/workflows/docs.yml'
branches:
- master
pull_request:
paths:
- 'docs/**'
- '.github/workflows/docs.yml'
branches:
- '**'

jobs:
docs:
name: Documentation Build
runs-on: Ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install tox
run: pip install tox
- name: Build documentation
run: tox -e doc
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
repos:
- repo: https://github.com/psf/black
rev: stable
rev: 19.10b0
hooks:
- id: black

- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.8
rev: 3.8.3
hooks:
- id: flake8

- repo: https://github.com/timothycrosley/isort
rev: 4.3.21-2
rev: 5.4.2
hooks:
- id: isort
additional_dependencies: [toml]
exclude: ^.*/?setup\.py$

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
rev: v3.2.0
hooks:
- id: trailing-whitespace
exclude: ^tests/.*/fixtures/.*
1,055 changes: 371 additions & 684 deletions poetry.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion poetry/console/commands/add.py
Original file line number Diff line number Diff line change
@@ -63,9 +63,10 @@ class AddCommand(InstallerCommand, InitCommand):
loggers = ["poetry.repositories.pypi_repository", "poetry.inspection.info"]

def handle(self):
from poetry.core.semver import parse_constraint
from tomlkit import inline_table

from poetry.core.semver import parse_constraint

packages = self.argument("name")
is_dev = self.option("dev")

1 change: 1 addition & 0 deletions poetry/console/commands/cache/clear.py
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ class CacheClearCommand(Command):

def handle(self):
from cachy import CacheManager

from poetry.locations import REPOSITORY_CACHE_DIR

cache = self.argument("cache")
2 changes: 1 addition & 1 deletion poetry/console/commands/init.py
Original file line number Diff line number Diff line change
@@ -62,10 +62,10 @@ def __init__(self):
self._pool = None

def handle(self):
from poetry.core.vcs.git import GitConfig
from poetry.layouts import layout
from poetry.utils._compat import Path
from poetry.utils.env import SystemEnv
from poetry.core.vcs.git import GitConfig

if (Path.cwd() / "pyproject.toml").exists():
self.line("<error>A pyproject.toml file already exists.</error>")
2 changes: 1 addition & 1 deletion poetry/console/commands/install.py
Original file line number Diff line number Diff line change
@@ -48,8 +48,8 @@ class InstallCommand(InstallerCommand):
_loggers = ["poetry.repositories.pypi_repository", "poetry.inspection.info"]

def handle(self):
from poetry.masonry.builders import EditableBuilder
from poetry.core.masonry.utils.module import ModuleOrPackageNotFound
from poetry.masonry.builders import EditableBuilder

self._installer.use_executor(
self.poetry.config.get("experimental.new-installer", False)
4 changes: 2 additions & 2 deletions poetry/console/commands/new.py
Original file line number Diff line number Diff line change
@@ -20,11 +20,11 @@ class NewCommand(Command):
]

def handle(self):
from poetry.layouts import layout
from poetry.core.semver import parse_constraint
from poetry.core.vcs.git import GitConfig
from poetry.layouts import layout
from poetry.utils._compat import Path
from poetry.utils.env import SystemEnv
from poetry.core.vcs.git import GitConfig

if self.option("src"):
layout_ = layout("src")
2 changes: 1 addition & 1 deletion poetry/console/commands/self/update.py
Original file line number Diff line number Diff line change
@@ -78,8 +78,8 @@ def lib_backup(self):

def handle(self):
from poetry.__version__ import __version__
from poetry.repositories.pypi_repository import PyPiRepository
from poetry.core.semver import Version
from poetry.repositories.pypi_repository import PyPiRepository

self._check_recommended_installation()

4 changes: 3 additions & 1 deletion poetry/console/commands/show.py
Original file line number Diff line number Diff line change
@@ -34,8 +34,9 @@ class ShowCommand(EnvCommand):

def handle(self):
from clikit.utils.terminal import Terminal
from poetry.repositories.installed_repository import InstalledRepository

from poetry.core.semver import Version
from poetry.repositories.installed_repository import InstalledRepository

package = self.argument("package")

@@ -321,6 +322,7 @@ def init_styles(self, io):

def find_latest_package(self, package, include_dev):
from clikit.io import NullIO

from poetry.puzzle.provider import Provider
from poetry.version.version_selector import VersionSelector

3 changes: 2 additions & 1 deletion poetry/factory.py
Original file line number Diff line number Diff line change
@@ -126,7 +126,8 @@ def create_legacy_repository(
): # type: (Dict[str, str], Config) -> LegacyRepository
from .repositories.auth import Auth
from .repositories.legacy_repository import LegacyRepository
from .utils.helpers import get_client_cert, get_cert
from .utils.helpers import get_cert
from .utils.helpers import get_client_cert
from .utils.password_manager import PasswordManager

if "url" in source:
1 change: 1 addition & 0 deletions poetry/installation/chooser.py
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
from typing import Tuple

from packaging.tags import Tag

from poetry.core.packages.package import Package
from poetry.core.packages.utils.link import Link
from poetry.repositories.pool import Pool
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@

class PythonRequirementSolution(Solution):
def __init__(self, exception):
from poetry.mixology.incompatibility_cause import PythonCause
from poetry.core.semver import parse_constraint
from poetry.mixology.incompatibility_cause import PythonCause

self._title = "Check your dependencies Python requirement."

2 changes: 1 addition & 1 deletion poetry/puzzle/provider.py
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ def _formatter_elapsed(self):

class Provider:

UNSAFE_PACKAGES = {"setuptools", "distribute", "pip"}
UNSAFE_PACKAGES = {"setuptools", "distribute", "pip", "wheel"}

def __init__(
self, package, pool, io, env=None
7 changes: 6 additions & 1 deletion poetry/repositories/pool.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from typing import TYPE_CHECKING
from typing import Dict
from typing import List
from typing import Optional
@@ -7,6 +8,10 @@
from .repository import Repository


if TYPE_CHECKING:
from poetry.core.packages import Package


class Pool(BaseRepository):
def __init__(
self, repositories=None, ignore_repository_names=False
@@ -108,7 +113,7 @@ def has_package(self, package):

def package(
self, name, version, extras=None, repository=None
): # type: (str, str, List[str], str) -> "Package"
): # type: (str, str, List[str], str) -> Package
if repository is not None:
repository = repository.lower()

5 changes: 4 additions & 1 deletion poetry/utils/_compat.py
Original file line number Diff line number Diff line change
@@ -12,8 +12,9 @@
from glob import glob

try:
from importlib import metadata
import zipfile as zipp

from importlib import metadata
except ImportError:
import importlib_metadata as metadata
import zipp
@@ -76,9 +77,11 @@

if PY35:
import subprocess as subprocess

from subprocess import CalledProcessError
else:
import subprocess32 as subprocess

from subprocess32 import CalledProcessError


9 changes: 4 additions & 5 deletions poetry/utils/env.py
Original file line number Diff line number Diff line change
@@ -17,17 +17,16 @@
from typing import Tuple
from typing import Union

import tomlkit

from clikit.api.io import IO

import packaging.tags
import tomlkit
import virtualenv

from clikit.api.io import IO
from packaging.tags import Tag
from packaging.tags import interpreter_name
from packaging.tags import interpreter_version
from packaging.tags import sys_tags

from poetry.core.semver import parse_constraint
from poetry.core.semver.version import Version
from poetry.core.version.markers import BaseMarker
@@ -1017,8 +1016,8 @@ def get_paths(self): # type: () -> Dict[str, str]
# on some distributions it does not return the proper paths
# (those used by pip for instance). We go through distutils
# to get the proper ones.
from distutils.core import Distribution
from distutils.command.install import SCHEME_KEYS # noqa
from distutils.core import Distribution

d = Distribution()
d.parse_config_files()
33 changes: 3 additions & 30 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -66,17 +66,11 @@ pytest = [
{version = "^5.4.3", python = ">=3.5"}
]
pytest-cov = "^2.5"
mkdocs = { version = "^1.0", python = "~2.7.9 || ^3.4" }
pymdown-extensions = "^6.0"
pygments = "^2.2"
pytest-mock = "^1.9"
pygments-github-lexers = "^0.0.5"
black = { version = "^19.10b0", python = "^3.6" }
pre-commit = { version = "^2.5.1", python = "^3.6.1" }
pre-commit = { version = "^2.6", python = "^3.6.1" }
tox = "^3.0"
pytest-sugar = "^0.9.2"
httpretty = "^0.9.6"
markdown-include = "^0.5.1"

[tool.poetry.scripts]
poetry = "poetry.console:main"
@@ -88,38 +82,17 @@ build-backend = "poetry.core.masonry.api"


[tool.isort]
line_length = 88
profile = "black"
force_single_line = true
atomic = true
include_trailing_comma = true
lines_after_imports = 2
lines_between_types = 1
multi_line_output = 3
use_parentheses = true
not_skip = "__init__.py"
src_paths = ["poetry", "tests"]
skip_glob = ["*/setup.py"]
filter_files = true

known_first_party = "poetry"
known_third_party = [
"cachecontrol",
"cachy",
"cleo",
"clikit",
"html5lib",
"httpretty",
"jsonschema",
"keyring",
"pexpect",
"pkginfo",
"poetry_core",
"pyparsing",
"pytest",
"requests",
"requests_toolbelt",
"shellingham",
"tomlkit",
]


[tool.black]
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -56,6 +56,7 @@ def auth_config_source():
@pytest.fixture
def config(config_source, auth_config_source, mocker):
import keyring

from keyring.backends.fail import Keyring

keyring.set_keyring(Keyring())
1 change: 1 addition & 0 deletions tests/console/commands/test_cache.py
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
@pytest.fixture
def repository_cache_dir(monkeypatch, tmpdir):
import poetry.locations

from poetry.utils._compat import Path

path = Path(str(tmpdir))
2 changes: 1 addition & 1 deletion tests/console/commands/test_show.py
Original file line number Diff line number Diff line change
@@ -714,7 +714,7 @@ def test_show_outdated_local_dependencies(app, poetry, installed, repo):
my-package 0.1.1 ../project_with_setup 0.1.2 ../project_with_setup
"""
assert expected.rstrip() == "\n".join(
l.rstrip() for l in tester.io.fetch_output().splitlines()
line.rstrip() for line in tester.io.fetch_output().splitlines()
)


1 change: 1 addition & 0 deletions tests/installation/test_chef.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from packaging.tags import Tag

from poetry.core.packages.utils.link import Link
from poetry.installation.chef import Chef
from poetry.utils._compat import Path
1 change: 1 addition & 0 deletions tests/installation/test_chooser.py
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
import pytest

from packaging.tags import Tag

from poetry.core.packages.package import Package
from poetry.installation.chooser import Chooser
from poetry.repositories.legacy_repository import LegacyRepository
3 changes: 2 additions & 1 deletion tests/repositories/test_installed_repository.py
Original file line number Diff line number Diff line change
@@ -2,14 +2,15 @@

import pytest

from pytest_mock.plugin import MockFixture

from poetry.core.packages import Package
from poetry.repositories.installed_repository import InstalledRepository
from poetry.utils._compat import PY36
from poetry.utils._compat import Path
from poetry.utils._compat import metadata
from poetry.utils._compat import zipp
from poetry.utils.env import MockEnv as BaseMockEnv
from pytest_mock.plugin import MockFixture


FIXTURES_DIR = Path(__file__).parent / "fixtures"
2 changes: 2 additions & 0 deletions tests/utils/test_password_manager.py
Original file line number Diff line number Diff line change
@@ -43,6 +43,7 @@ def mock_available_backend(backend):
@pytest.fixture()
def mock_unavailable_backend():
import keyring

from keyring.backends.fail import Keyring

keyring.set_keyring(Keyring())
@@ -54,6 +55,7 @@ def mock_chainer_backend(mocker):

mocker.patch("keyring.backend.get_all_keyring", [Keyring()])
import keyring

from keyring.backends.chainer import ChainerBackend

keyring.set_keyring(ChainerBackend())
17 changes: 14 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
[tox]
minversion = 3.3.0
isolated_build = True
envlist = py27, py35, py36, py37, py38
envlist = py27, py35, py36, py37, py38, doc

[testenv]
whitelist_externals = poetry
skip_install = true
commands =
poetry install -vv
poetry install -vv --no-root
poetry run pytest {posargs} tests/

[testenv:doc]
whitelist_externals =
skip_install = true
deps =
markdown-include
mkdocs
pygments
pygments-github-lexers
pymdown-extensions
commands =
mkdocs build -f docs/mkdocs.yml

0 comments on commit d2fd581

Please sign in to comment.