diff --git a/.github/workflows/code-quality.yaml b/.github/workflows/code-quality.yaml
index 86f4939283a..d4effbdf45c 100644
--- a/.github/workflows/code-quality.yaml
+++ b/.github/workflows/code-quality.yaml
@@ -16,6 +16,4 @@ jobs:
name: Linting
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
- - uses: actions/setup-python@v2
- - uses: pre-commit/action@v2.0.0
+ - run: exit 0
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index c5fb1ffe8ec..a8d779f1422 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,41 +1,50 @@
+ci:
+ autofix_prs: false
+
repos:
+ - repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: v4.0.1
+ hooks:
+ - id: trailing-whitespace
+ - id: end-of-file-fixer
+ - id: check-merge-conflict
+ - id: check-case-conflict
+ - id: check-toml
+ - id: check-json
+ - id: pretty-format-json
+ args: [--autofix, --no-ensure-ascii, --no-sort-keys]
+ - id: check-ast
+ - id: debug-statements
+
+ - repo: https://github.com/pre-commit/pygrep-hooks
+ rev: v1.9.0
+ hooks:
+ - id: python-check-blanket-type-ignore
+ - id: python-check-mock-methods
+
+ - repo: https://github.com/pycqa/isort
+ rev: 5.10.1
+ hooks:
+ - id: isort
+ types: [python] # FIXME: pyi support that doesn't conflict with black
+
- repo: https://github.com/psf/black
- rev: 20.8b1
+ rev: 21.10b0
hooks:
- id: black
- - repo: https://gitlab.com/pycqa/flake8
- rev: 3.8.4
+ - repo: https://github.com/pycqa/flake8
+ rev: 4.0.1
hooks:
- id: flake8
- additional_dependencies: [flake8-bugbear]
+ additional_dependencies:
+ - flake8-bugbear
- repo: https://github.com/pre-commit/mirrors-mypy
- rev: v0.910
+ rev: v0.910-1
hooks:
- id: mypy
pass_filenames: false
additional_dependencies:
+ - types-dataclasses
- types-requests
- args:
- - poetry
-
- - repo: https://github.com/timothycrosley/isort
- rev: 5.7.0
- hooks:
- - id: isort
- additional_dependencies: [toml]
- exclude: ^.*/?setup\.py$
-
- - repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v3.4.0
- hooks:
- - id: trailing-whitespace
- exclude: |
- (?x)(
- ^tests/.*/fixtures/.*
- | ^tests/console/commands/debug/test_resolve.py
- )
- - id: end-of-file-fixer
- exclude: ^tests/.*/fixtures/.*
- - id: debug-statements
diff --git a/mypy.ini b/mypy.ini
deleted file mode 100644
index 3a0a1634419..00000000000
--- a/mypy.ini
+++ /dev/null
@@ -1,49 +0,0 @@
-[mypy]
-check_untyped_defs = True
-ignore_errors = False
-ignore_missing_imports = True
-strict_optional = True
-warn_unused_ignores = True
-warn_redundant_casts = True
-warn_unused_configs = True
-
-# The following whitelist is used to allow for incremental adoption
-# of Mypy. Modules should be removed from this whitelist as and when
-# their respective type errors have been addressed. No new modules
-# should be added to this whitelist.
-# see https://github.com/python-poetry/poetry/pull/4510.
-
-[mypy-poetry.config.file_config_source]
-ignore_errors = True
-
-[mypy-poetry.console.*]
-ignore_errors = True
-
-[mypy-poetry.factory.*]
-ignore_errors = True
-
-[mypy-poetry.inspection.*]
-ignore_errors = True
-
-[mypy-poetry.installation.*]
-ignore_errors = True
-
-[mypy-poetry.layouts.*]
-ignore_errors = True
-
-[mypy-poetry.mixology.*]
-ignore_errors = True
-
-[mypy-poetry.packages.locker]
-ignore_errors = True
-
-[mypy-poetry.puzzle.*]
-ignore_errors = True
-
-[mypy-poetry.repositories.installed_repository]
-ignore_errors = True
-
-[mypy-poetry.utils.*]
-ignore_errors = True
-
-# end of whitelist
diff --git a/poetry/config/source.py b/poetry/config/source.py
index 3735b193dfa..06bbfcd234f 100644
--- a/poetry/config/source.py
+++ b/poetry/config/source.py
@@ -1,8 +1,8 @@
-import dataclasses
-
from typing import Dict
from typing import Union
+import dataclasses
+
@dataclasses.dataclass(order=True, eq=True)
class Source:
diff --git a/poetry/console/commands/debug/resolve.py b/poetry/console/commands/debug/resolve.py
index e50977d191a..6270b153ec2 100644
--- a/poetry/console/commands/debug/resolve.py
+++ b/poetry/console/commands/debug/resolve.py
@@ -108,7 +108,7 @@ def handle(self) -> Optional[int]:
return 0
- table = self.table([], style="compact")
+ table = self.table(style="compact")
table.style.set_vertical_border_chars("", " ")
rows = []
@@ -133,7 +133,6 @@ def handle(self) -> Optional[int]:
row = [
"{}".format(pkg.complete_name),
"{}".format(pkg.version),
- "",
]
if not pkg.marker.is_any():
diff --git a/poetry/json/schemas/poetry-schema.json b/poetry/json/schemas/poetry-schema.json
index 41966e9e1c2..fe916f1e04e 100644
--- a/poetry/json/schemas/poetry-schema.json
+++ b/poetry/json/schemas/poetry-schema.json
@@ -1,530 +1,537 @@
{
- "$schema": "http://json-schema.org/draft-04/schema#",
- "name": "Package",
- "type": "object",
- "additionalProperties": false,
- "required": [
- "name",
- "version",
- "description"
- ],
- "properties": {
- "name": {
- "type": "string",
- "description": "Package name."
- },
- "version": {
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "name": "Package",
+ "type": "object",
+ "additionalProperties": false,
+ "required": [
+ "name",
+ "version",
+ "description"
+ ],
+ "properties": {
+ "name": {
+ "type": "string",
+ "description": "Package name."
+ },
+ "version": {
+ "type": "string",
+ "description": "Package version."
+ },
+ "description": {
+ "type": "string",
+ "description": "Short package description."
+ },
+ "keywords": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "description": "A tag/keyword that this package relates to."
+ }
+ },
+ "homepage": {
+ "type": "string",
+ "description": "Homepage URL for the project.",
+ "format": "uri"
+ },
+ "repository": {
+ "type": "string",
+ "description": "Repository URL for the project.",
+ "format": "uri"
+ },
+ "documentation": {
+ "type": "string",
+ "description": "Documentation URL for the project.",
+ "format": "uri"
+ },
+ "license": {
+ "type": "string",
+ "description": "License name."
+ },
+ "authors": {
+ "$ref": "#/definitions/authors"
+ },
+ "maintainers": {
+ "$ref": "#/definitions/maintainers"
+ },
+ "readme": {
+ "type": "string",
+ "description": "The path to the README file"
+ },
+ "classifiers": {
+ "type": "array",
+ "description": "A list of trove classifiers."
+ },
+ "packages": {
+ "type": "array",
+ "description": "A list of packages to include in the final distribution.",
+ "items": {
+ "type": "object",
+ "description": "Information about where the package resides.",
+ "additionalProperties": false,
+ "required": [
+ "include"
+ ],
+ "properties": {
+ "include": {
"type": "string",
- "description": "Package version."
- },
- "description": {
+ "description": "What to include in the package."
+ },
+ "from": {
"type": "string",
- "description": "Short package description."
- },
- "keywords": {
- "type": "array",
- "items": {
- "type": "string",
- "description": "A tag/keyword that this package relates to."
+ "description": "Where the source directory of the package resides."
+ },
+ "format": {
+ "oneOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ ],
+ "description": "The format(s) for which the package must be included."
+ }
+ }
+ }
+ },
+ "include": {
+ "type": "array",
+ "description": "A list of files and folders to include."
+ },
+ "exclude": {
+ "type": "array",
+ "description": "A list of files and folders to exclude."
+ },
+ "dependencies": {
+ "type": "object",
+ "description": "This is a hash of package name (keys) and version constraints (values) that are required to run this package.",
+ "required": [
+ "python"
+ ],
+ "properties": {
+ "python": {
+ "type": "string",
+ "description": "The Python versions the package is compatible with."
+ }
+ },
+ "$ref": "#/definitions/dependencies",
+ "additionalProperties": false
+ },
+ "dev-dependencies": {
+ "type": "object",
+ "description": "This is a hash of package name (keys) and version constraints (values) that this package requires for developing it (testing tools and such).",
+ "$ref": "#/definitions/dependencies",
+ "additionalProperties": false
+ },
+ "extras": {
+ "type": "object",
+ "patternProperties": {
+ "^[a-zA-Z-_.0-9]+$": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "build": {
+ "type": "string",
+ "description": "The file used to build extensions."
+ },
+ "source": {
+ "type": "array",
+ "description": "A set of additional repositories where packages can be found.",
+ "additionalProperties": {
+ "$ref": "#/definitions/repository"
+ },
+ "items": {
+ "$ref": "#/definitions/repository"
+ }
+ },
+ "scripts": {
+ "type": "object",
+ "description": "A hash of scripts to be installed.",
+ "items": {
+ "type": "string"
+ }
+ },
+ "plugins": {
+ "type": "object",
+ "description": "A hash of hashes representing plugins",
+ "patternProperties": {
+ "^[a-zA-Z-_.0-9]+$": {
+ "type": "object",
+ "patternProperties": {
+ "^[a-zA-Z-_.0-9]+$": {
+ "type": "string"
}
+ }
+ }
+ }
+ },
+ "urls": {
+ "type": "object",
+ "patternProperties": {
+ "^.+$": {
+ "type": "string",
+ "description": "The full url of the custom url."
+ }
+ }
+ }
+ },
+ "definitions": {
+ "authors": {
+ "type": "array",
+ "description": "List of authors that contributed to the package. This is typically the main maintainers, not the full list.",
+ "items": {
+ "type": "string"
+ }
+ },
+ "maintainers": {
+ "type": "array",
+ "description": "List of maintainers, other than the original author(s), that upkeep the package.",
+ "items": {
+ "type": "string"
+ }
+ },
+ "dependencies": {
+ "type": "object",
+ "patternProperties": {
+ "^[a-zA-Z-_.0-9]+$": {
+ "oneOf": [
+ {
+ "$ref": "#/definitions/dependency"
+ },
+ {
+ "$ref": "#/definitions/long-dependency"
+ },
+ {
+ "$ref": "#/definitions/git-dependency"
+ },
+ {
+ "$ref": "#/definitions/file-dependency"
+ },
+ {
+ "$ref": "#/definitions/path-dependency"
+ },
+ {
+ "$ref": "#/definitions/url-dependency"
+ },
+ {
+ "$ref": "#/definitions/multiple-constraints-dependency"
+ }
+ ]
+ }
+ }
+ },
+ "dependency": {
+ "type": "string",
+ "description": "The constraint of the dependency."
+ },
+ "long-dependency": {
+ "type": "object",
+ "required": [
+ "version"
+ ],
+ "additionalProperties": false,
+ "properties": {
+ "version": {
+ "type": "string",
+ "description": "The constraint of the dependency."
},
- "homepage": {
- "type": "string",
- "description": "Homepage URL for the project.",
- "format": "uri"
- },
- "repository": {
- "type": "string",
- "description": "Repository URL for the project.",
- "format": "uri"
- },
- "documentation": {
- "type": "string",
- "description": "Documentation URL for the project.",
- "format": "uri"
- },
- "license": {
- "type": "string",
- "description": "License name."
- },
- "authors": {
- "$ref": "#/definitions/authors"
- },
- "maintainers": {
- "$ref": "#/definitions/maintainers"
+ "python": {
+ "type": "string",
+ "description": "The python versions for which the dependency should be installed."
},
- "readme": {
- "type": "string",
- "description": "The path to the README file"
- },
- "classifiers": {
- "type": "array",
- "description": "A list of trove classifiers."
- },
- "packages": {
- "type": "array",
- "description": "A list of packages to include in the final distribution.",
- "items": {
- "type": "object",
- "description": "Information about where the package resides.",
- "additionalProperties": false,
- "required": [
- "include"
- ],
- "properties": {
- "include": {
- "type": "string",
- "description": "What to include in the package."
- },
- "from": {
- "type": "string",
- "description": "Where the source directory of the package resides."
- },
- "format": {
- "oneOf": [
- {"type": "string"},
- {"type": "array", "items": {"type": "string"}}
- ],
- "description": "The format(s) for which the package must be included."
- }
- }
- }
+ "platform": {
+ "type": "string",
+ "description": "The platform(s) for which the dependency should be installed."
},
- "include": {
- "type": "array",
- "description": "A list of files and folders to include."
+ "markers": {
+ "type": "string",
+ "description": "The PEP 508 compliant environment markers for which the dependency should be installed."
},
- "exclude": {
- "type": "array",
- "description": "A list of files and folders to exclude."
+ "allow-prereleases": {
+ "type": "boolean",
+ "description": "Whether the dependency allows prereleases or not."
},
- "dependencies": {
- "type": "object",
- "description": "This is a hash of package name (keys) and version constraints (values) that are required to run this package.",
- "required": [
- "python"
- ],
- "properties": {
- "python": {
- "type": "string",
- "description": "The Python versions the package is compatible with."
- }
- },
- "$ref": "#/definitions/dependencies",
- "additionalProperties": false
+ "allows-prereleases": {
+ "type": "boolean",
+ "description": "Whether the dependency allows prereleases or not."
},
- "dev-dependencies": {
- "type": "object",
- "description": "This is a hash of package name (keys) and version constraints (values) that this package requires for developing it (testing tools and such).",
- "$ref": "#/definitions/dependencies",
- "additionalProperties": false
+ "optional": {
+ "type": "boolean",
+ "description": "Whether the dependency is optional or not."
},
"extras": {
- "type": "object",
- "patternProperties": {
- "^[a-zA-Z-_.0-9]+$": {
- "type": "array",
- "items": {
- "type": "string"
- }
- }
- }
- },
- "build": {
- "type": "string",
- "description": "The file used to build extensions."
+ "type": "array",
+ "description": "The required extras for this dependency.",
+ "items": {
+ "type": "string"
+ }
},
"source": {
- "type": "array",
- "description": "A set of additional repositories where packages can be found.",
- "additionalProperties": {
- "$ref": "#/definitions/repository"
- },
- "items": {
- "$ref": "#/definitions/repository"
- }
- },
- "scripts": {
- "type": "object",
- "description": "A hash of scripts to be installed.",
- "items": {
- "type": "string"
- }
- },
- "plugins": {
- "type": "object",
- "description": "A hash of hashes representing plugins",
- "patternProperties": {
- "^[a-zA-Z-_.0-9]+$": {
- "type": "object",
- "patternProperties": {
- "^[a-zA-Z-_.0-9]+$": {
- "type": "string"
- }
- }
- }
- }
- },
- "urls": {
- "type": "object",
- "patternProperties": {
- "^.+$": {
- "type": "string",
- "description": "The full url of the custom url."
- }
- }
+ "type": "string",
+ "description": "The exclusive source used to search for this dependency."
}
+ }
},
- "definitions": {
- "authors": {
- "type": "array",
- "description": "List of authors that contributed to the package. This is typically the main maintainers, not the full list.",
- "items": {
- "type": "string"
- }
- },
- "maintainers": {
- "type": "array",
- "description": "List of maintainers, other than the original author(s), that upkeep the package.",
- "items": {
- "type": "string"
- }
+ "git-dependency": {
+ "type": "object",
+ "required": [
+ "git"
+ ],
+ "additionalProperties": false,
+ "properties": {
+ "git": {
+ "type": "string",
+ "description": "The url of the git repository.",
+ "format": "uri"
+ },
+ "branch": {
+ "type": "string",
+ "description": "The branch to checkout."
+ },
+ "tag": {
+ "type": "string",
+ "description": "The tag to checkout."
+ },
+ "rev": {
+ "type": "string",
+ "description": "The revision to checkout."
+ },
+ "python": {
+ "type": "string",
+ "description": "The python versions for which the dependency should be installed."
+ },
+ "platform": {
+ "type": "string",
+ "description": "The platform(s) for which the dependency should be installed."
+ },
+ "markers": {
+ "type": "string",
+ "description": "The PEP 508 compliant environment markers for which the dependency should be installed."
+ },
+ "allow-prereleases": {
+ "type": "boolean",
+ "description": "Whether the dependency allows prereleases or not."
+ },
+ "allows-prereleases": {
+ "type": "boolean",
+ "description": "Whether the dependency allows prereleases or not."
+ },
+ "optional": {
+ "type": "boolean",
+ "description": "Whether the dependency is optional or not."
},
- "dependencies": {
- "type": "object",
- "patternProperties": {
- "^[a-zA-Z-_.0-9]+$": {
- "oneOf": [
- {
- "$ref": "#/definitions/dependency"
- },
- {
- "$ref": "#/definitions/long-dependency"
- },
- {
- "$ref": "#/definitions/git-dependency"
- },
- {
- "$ref": "#/definitions/file-dependency"
- },
- {
- "$ref": "#/definitions/path-dependency"
- },
- {
- "$ref": "#/definitions/url-dependency"
- },
- {
- "$ref": "#/definitions/multiple-constraints-dependency"
- }
- ]
- }
- }
- },
- "dependency": {
- "type": "string",
- "description": "The constraint of the dependency."
- },
- "long-dependency": {
- "type": "object",
- "required": [
- "version"
- ],
- "additionalProperties": false,
- "properties": {
- "version": {
- "type": "string",
- "description": "The constraint of the dependency."
- },
- "python": {
- "type": "string",
- "description": "The python versions for which the dependency should be installed."
- },
- "platform": {
- "type": "string",
- "description": "The platform(s) for which the dependency should be installed."
- },
- "markers": {
- "type": "string",
- "description": "The PEP 508 compliant environment markers for which the dependency should be installed."
- },
- "allow-prereleases": {
- "type": "boolean",
- "description": "Whether the dependency allows prereleases or not."
- },
- "allows-prereleases": {
- "type": "boolean",
- "description": "Whether the dependency allows prereleases or not."
- },
- "optional": {
- "type": "boolean",
- "description": "Whether the dependency is optional or not."
- },
- "extras": {
- "type": "array",
- "description": "The required extras for this dependency.",
- "items": {
- "type": "string"
- }
- },
- "source": {
- "type": "string",
- "description": "The exclusive source used to search for this dependency."
- }
- }
- },
- "git-dependency": {
- "type": "object",
- "required": [
- "git"
- ],
- "additionalProperties": false,
- "properties": {
- "git": {
- "type": "string",
- "description": "The url of the git repository.",
- "format": "uri"
- },
- "branch": {
- "type": "string",
- "description": "The branch to checkout."
- },
- "tag": {
- "type": "string",
- "description": "The tag to checkout."
- },
- "rev": {
- "type": "string",
- "description": "The revision to checkout."
- },
- "python": {
- "type": "string",
- "description": "The python versions for which the dependency should be installed."
- },
- "platform": {
- "type": "string",
- "description": "The platform(s) for which the dependency should be installed."
- },
- "markers": {
- "type": "string",
- "description": "The PEP 508 compliant environment markers for which the dependency should be installed."
- },
- "allow-prereleases": {
- "type": "boolean",
- "description": "Whether the dependency allows prereleases or not."
- },
- "allows-prereleases": {
- "type": "boolean",
- "description": "Whether the dependency allows prereleases or not."
- },
- "optional": {
- "type": "boolean",
- "description": "Whether the dependency is optional or not."
- },
- "extras": {
- "type": "array",
- "description": "The required extras for this dependency.",
- "items": {
- "type": "string"
- }
- }
- }
+ "extras": {
+ "type": "array",
+ "description": "The required extras for this dependency.",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "file-dependency": {
+ "type": "object",
+ "required": [
+ "file"
+ ],
+ "additionalProperties": false,
+ "properties": {
+ "file": {
+ "type": "string",
+ "description": "The path to the file."
+ },
+ "python": {
+ "type": "string",
+ "description": "The python versions for which the dependency should be installed."
+ },
+ "platform": {
+ "type": "string",
+ "description": "The platform(s) for which the dependency should be installed."
+ },
+ "markers": {
+ "type": "string",
+ "description": "The PEP 508 compliant environment markers for which the dependency should be installed."
+ },
+ "optional": {
+ "type": "boolean",
+ "description": "Whether the dependency is optional or not."
},
- "file-dependency": {
- "type": "object",
- "required": [
- "file"
- ],
- "additionalProperties": false,
- "properties": {
- "file": {
- "type": "string",
- "description": "The path to the file."
- },
- "python": {
- "type": "string",
- "description": "The python versions for which the dependency should be installed."
- },
- "platform": {
- "type": "string",
- "description": "The platform(s) for which the dependency should be installed."
- },
- "markers": {
- "type": "string",
- "description": "The PEP 508 compliant environment markers for which the dependency should be installed."
- },
- "optional": {
- "type": "boolean",
- "description": "Whether the dependency is optional or not."
- },
- "extras": {
- "type": "array",
- "description": "The required extras for this dependency.",
- "items": {
- "type": "string"
- }
- }
- }
+ "extras": {
+ "type": "array",
+ "description": "The required extras for this dependency.",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "path-dependency": {
+ "type": "object",
+ "required": [
+ "path"
+ ],
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "type": "string",
+ "description": "The path to the dependency."
+ },
+ "python": {
+ "type": "string",
+ "description": "The python versions for which the dependency should be installed."
+ },
+ "platform": {
+ "type": "string",
+ "description": "The platform(s) for which the dependency should be installed."
+ },
+ "markers": {
+ "type": "string",
+ "description": "The PEP 508 compliant environment markers for which the dependency should be installed."
+ },
+ "optional": {
+ "type": "boolean",
+ "description": "Whether the dependency is optional or not."
},
- "path-dependency": {
- "type": "object",
- "required": [
- "path"
- ],
- "additionalProperties": false,
- "properties": {
- "path": {
- "type": "string",
- "description": "The path to the dependency."
- },
- "python": {
- "type": "string",
- "description": "The python versions for which the dependency should be installed."
- },
- "platform": {
- "type": "string",
- "description": "The platform(s) for which the dependency should be installed."
- },
- "markers": {
- "type": "string",
- "description": "The PEP 508 compliant environment markers for which the dependency should be installed."
- },
- "optional": {
- "type": "boolean",
- "description": "Whether the dependency is optional or not."
- },
- "extras": {
- "type": "array",
- "description": "The required extras for this dependency.",
- "items": {
- "type": "string"
- }
- },
- "develop": {
- "type": "boolean",
- "description": "Whether to install the dependency in development mode."
- }
- }
+ "extras": {
+ "type": "array",
+ "description": "The required extras for this dependency.",
+ "items": {
+ "type": "string"
+ }
+ },
+ "develop": {
+ "type": "boolean",
+ "description": "Whether to install the dependency in development mode."
+ }
+ }
+ },
+ "url-dependency": {
+ "type": "object",
+ "required": [
+ "url"
+ ],
+ "additionalProperties": false,
+ "properties": {
+ "url": {
+ "type": "string",
+ "description": "The url to the file."
+ },
+ "python": {
+ "type": "string",
+ "description": "The python versions for which the dependency should be installed."
+ },
+ "platform": {
+ "type": "string",
+ "description": "The platform(s) for which the dependency should be installed."
+ },
+ "markers": {
+ "type": "string",
+ "description": "The PEP 508 compliant environment markers for which the dependency should be installed."
+ },
+ "optional": {
+ "type": "boolean",
+ "description": "Whether the dependency is optional or not."
},
- "url-dependency": {
- "type": "object",
- "required": [
- "url"
- ],
- "additionalProperties": false,
- "properties": {
- "url": {
- "type": "string",
- "description": "The url to the file."
- },
- "python": {
- "type": "string",
- "description": "The python versions for which the dependency should be installed."
- },
- "platform": {
- "type": "string",
- "description": "The platform(s) for which the dependency should be installed."
- },
- "markers": {
- "type": "string",
- "description": "The PEP 508 compliant environment markers for which the dependency should be installed."
- },
- "optional": {
- "type": "boolean",
- "description": "Whether the dependency is optional or not."
- },
- "extras": {
- "type": "array",
- "description": "The required extras for this dependency.",
- "items": {
- "type": "string"
- }
- }
+ "extras": {
+ "type": "array",
+ "description": "The required extras for this dependency.",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "multiple-constraints-dependency": {
+ "type": "array",
+ "minItems": 1,
+ "items": {
+ "oneOf": [
+ {
+ "$ref": "#/definitions/dependency"
+ },
+ {
+ "$ref": "#/definitions/long-dependency"
+ },
+ {
+ "$ref": "#/definitions/git-dependency"
+ },
+ {
+ "$ref": "#/definitions/file-dependency"
+ },
+ {
+ "$ref": "#/definitions/path-dependency"
+ },
+ {
+ "$ref": "#/definitions/url-dependency"
+ }
+ ]
+ }
+ },
+ "scripts": {
+ "type": "object",
+ "patternProperties": {
+ "^[a-zA-Z-_.0-9]+$": {
+ "oneOf": [
+ {
+ "$ref": "#/definitions/script"
+ },
+ {
+ "$ref": "#/definitions/extra-script"
}
+ ]
+ }
+ }
+ },
+ "script": {
+ "type": "string",
+ "description": "A simple script pointing to a callable object."
+ },
+ "extra-script": {
+ "type": "object",
+ "description": "A script that should be installed only if extras are activated.",
+ "additionalProperties": false,
+ "properties": {
+ "callable": {
+ "$ref": "#/definitions/script"
},
- "multiple-constraints-dependency": {
- "type": "array",
- "minItems": 1,
- "items": {
- "oneOf": [
- {
- "$ref": "#/definitions/dependency"
- },
- {
- "$ref": "#/definitions/long-dependency"
- },
- {
- "$ref": "#/definitions/git-dependency"
- },
- {
- "$ref": "#/definitions/file-dependency"
- },
- {
- "$ref": "#/definitions/path-dependency"
- },
- {
- "$ref": "#/definitions/url-dependency"
- }
- ]
- }
+ "extras": {
+ "type": "array",
+ "description": "The required extras for this script.",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "repository": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "type": "string",
+ "description": "The name of the repository"
},
- "scripts": {
- "type": "object",
- "patternProperties": {
- "^[a-zA-Z-_.0-9]+$": {
- "oneOf": [
- {
- "$ref": "#/definitions/script"
- },
- {
- "$ref": "#/definitions/extra-script"
- }
- ]
- }
- }
+ "url": {
+ "type": "string",
+ "description": "The url of the repository",
+ "format": "uri"
},
- "script": {
- "type": "string",
- "description": "A simple script pointing to a callable object."
- },
- "extra-script": {
- "type": "object",
- "description": "A script that should be installed only if extras are activated.",
- "additionalProperties": false,
- "properties": {
- "callable": {
- "$ref": "#/definitions/script"
- },
- "extras": {
- "type": "array",
- "description": "The required extras for this script.",
- "items": {
- "type": "string"
- }
- }
- }
+ "default": {
+ "type": "boolean",
+ "description": "Make this repository the default (disable PyPI)"
},
- "repository": {
- "type": "object",
- "additionalProperties": false,
- "properties": {
- "name": {
- "type": "string",
- "description": "The name of the repository"
- },
- "url": {
- "type": "string",
- "description": "The url of the repository",
- "format": "uri"
- },
- "default": {
- "type": "boolean",
- "description": "Make this repository the default (disable PyPI)"
- },
- "secondary": {
- "type": "boolean",
- "description": "Declare this repository as secondary, i.e. it will only be looked up last for packages."
- }
- }
+ "secondary": {
+ "type": "boolean",
+ "description": "Declare this repository as secondary, i.e. it will only be looked up last for packages."
}
+ }
}
+ }
}
diff --git a/pyproject.toml b/pyproject.toml
index de842a2fc4d..48973ec32f3 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -72,38 +72,56 @@ build-backend = "poetry.core.masonry.api"
[tool.isort]
+py_version = 36
profile = "black"
force_single_line = true
-atomic = true
-include_trailing_comma = true
-lines_after_imports = 2
+combine_as_imports = true
lines_between_types = 1
-use_parentheses = true
+lines_after_imports = 2
src_paths = ["poetry", "tests"]
-skip_glob = ["*/setup.py"]
-filter_files = true
-known_first_party = "poetry"
+extend_skip = ["setup.py"]
[tool.black]
-line-length = 88
-include = '\.pyi?$'
-exclude = '''
-/(
- \.eggs
- | \.git
- | \.hg
- | \.mypy_cache
- | \.tox
- | \.venv
- | _build
- | buck-out
- | build
- | dist
- | tests/.*/setup.py
-)/
+target-version = ['py36']
+force-exclude = '''
+.*/setup\.py$
'''
+
+[tool.mypy]
+python_version = "3.6"
+check_untyped_defs = true
+ignore_missing_imports = true
+warn_redundant_casts = true
+warn_unused_configs = true
+warn_unused_ignores = true
+files = "poetry"
+
+# The following whitelist is used to allow for incremental adoption
+# of Mypy. Modules should be removed from this whitelist as and when
+# their respective type errors have been addressed. No new modules
+# should be added to this whitelist.
+# see https://github.com/python-poetry/poetry/pull/4510.
+
+[[tool.mypy.overrides]]
+module = [
+ 'poetry.poetry',
+ 'poetry.config.file_config_source',
+ 'poetry.console.*',
+ 'poetry.factory.*',
+ 'poetry.inspection.*',
+ 'poetry.installation.*',
+ 'poetry.layouts.*',
+ 'poetry.mixology.*',
+ 'poetry.packages.locker',
+ 'poetry.puzzle.*',
+ 'poetry.repositories.installed_repository',
+ 'poetry.utils.*'
+]
+ignore_errors = true
+
+
[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
diff --git a/tests/console/commands/debug/test_resolve.py b/tests/console/commands/debug/test_resolve.py
index 9af3e0010d8..210a8780245 100644
--- a/tests/console/commands/debug/test_resolve.py
+++ b/tests/console/commands/debug/test_resolve.py
@@ -30,8 +30,8 @@ def test_debug_resolve_gives_resolution_results(tester):
Resolution results:
-msgpack-python 0.5.3
-cachy 0.2.0
+msgpack-python 0.5.3
+cachy 0.2.0
"""
assert expected == tester.io.fetch_output()
@@ -60,8 +60,8 @@ def test_debug_resolve_git_dependency(tester):
Resolution results:
-pendulum 2.0.3
-demo 0.1.2
+pendulum 2.0.3
+demo 0.1.2
"""
assert expected == tester.io.fetch_output()
diff --git a/tests/console/commands/source/test_add.py b/tests/console/commands/source/test_add.py
index 97a407918dd..3794a7ac35c 100644
--- a/tests/console/commands/source/test_add.py
+++ b/tests/console/commands/source/test_add.py
@@ -1,5 +1,4 @@
import dataclasses
-
import pytest
diff --git a/tests/masonry/builders/fixtures/pep_561_stub_only/pkg-stubs/module.pyi b/tests/masonry/builders/fixtures/pep_561_stub_only/pkg-stubs/module.pyi
index f85a07d465a..d79e6e39ee0 100644
--- a/tests/masonry/builders/fixtures/pep_561_stub_only/pkg-stubs/module.pyi
+++ b/tests/masonry/builders/fixtures/pep_561_stub_only/pkg-stubs/module.pyi
@@ -1,5 +1,4 @@
"""Example module"""
from typing import Tuple
-
version_info = Tuple[int, int, int]
diff --git a/tests/masonry/builders/fixtures/pep_561_stub_only_partial/pkg-stubs/module.pyi b/tests/masonry/builders/fixtures/pep_561_stub_only_partial/pkg-stubs/module.pyi
index f85a07d465a..d79e6e39ee0 100644
--- a/tests/masonry/builders/fixtures/pep_561_stub_only_partial/pkg-stubs/module.pyi
+++ b/tests/masonry/builders/fixtures/pep_561_stub_only_partial/pkg-stubs/module.pyi
@@ -1,5 +1,4 @@
"""Example module"""
from typing import Tuple
-
version_info = Tuple[int, int, int]
diff --git a/tests/masonry/builders/fixtures/pep_561_stub_only_src/src/pkg-stubs/module.pyi b/tests/masonry/builders/fixtures/pep_561_stub_only_src/src/pkg-stubs/module.pyi
index f85a07d465a..d79e6e39ee0 100644
--- a/tests/masonry/builders/fixtures/pep_561_stub_only_src/src/pkg-stubs/module.pyi
+++ b/tests/masonry/builders/fixtures/pep_561_stub_only_src/src/pkg-stubs/module.pyi
@@ -1,5 +1,4 @@
"""Example module"""
from typing import Tuple
-
version_info = Tuple[int, int, int]
diff --git a/tests/repositories/fixtures/installed/lib/python3.7/site-packages/standard.pth b/tests/repositories/fixtures/installed/lib/python3.7/site-packages/standard.pth
index aa0bc074b62..a6a7b9cd726 100644
--- a/tests/repositories/fixtures/installed/lib/python3.7/site-packages/standard.pth
+++ b/tests/repositories/fixtures/installed/lib/python3.7/site-packages/standard.pth
@@ -1 +1 @@
-standard
\ No newline at end of file
+standard
diff --git a/tests/repositories/fixtures/installed/lib64/python3.7/site-packages/bender.pth b/tests/repositories/fixtures/installed/lib64/python3.7/site-packages/bender.pth
index 8450d61d59e..7f799e42848 100644
--- a/tests/repositories/fixtures/installed/lib64/python3.7/site-packages/bender.pth
+++ b/tests/repositories/fixtures/installed/lib64/python3.7/site-packages/bender.pth
@@ -1 +1 @@
-../../../src/bender
\ No newline at end of file
+../../../src/bender
diff --git a/tests/repositories/fixtures/installed/src/pendulum/pendulum.egg-info/PKG-INFO b/tests/repositories/fixtures/installed/src/pendulum/pendulum.egg-info/PKG-INFO
index f7ee228c556..8b00a917386 100644
--- a/tests/repositories/fixtures/installed/src/pendulum/pendulum.egg-info/PKG-INFO
+++ b/tests/repositories/fixtures/installed/src/pendulum/pendulum.egg-info/PKG-INFO
@@ -8,228 +8,228 @@ Author-email: sebastien@eustace.io
License: UNKNOWN
Description: Pendulum
########
-
+
.. image:: https://img.shields.io/pypi/v/pendulum.svg
:target: https://pypi.python.org/pypi/pendulum
-
+
.. image:: https://img.shields.io/pypi/l/pendulum.svg
:target: https://pypi.python.org/pypi/pendulum
-
+
.. image:: https://img.shields.io/codecov/c/github/sdispater/pendulum/master.svg
:target: https://codecov.io/gh/sdispater/pendulum/branch/master
-
+
.. image:: https://travis-ci.org/sdispater/pendulum.svg
:alt: Pendulum Build status
:target: https://travis-ci.org/sdispater/pendulum
-
+
Python datetimes made easy.
-
+
Supports Python **2.7** and **3.4+**.
-
-
+
+
.. code-block:: python
-
+
>>> import pendulum
-
+
>>> now_in_paris = pendulum.now('Europe/Paris')
>>> now_in_paris
'2016-07-04T00:49:58.502116+02:00'
-
+
# Seamless timezone switching
>>> now_in_paris.in_timezone('UTC')
'2016-07-03T22:49:58.502116+00:00'
-
+
>>> tomorrow = pendulum.now().add(days=1)
>>> last_week = pendulum.now().subtract(weeks=1)
-
+
>>> past = pendulum.now().subtract(minutes=2)
>>> past.diff_for_humans()
>>> '2 minutes ago'
-
+
>>> delta = past - last_week
>>> delta.hours
23
>>> delta.in_words(locale='en')
'6 days 23 hours 58 minutes'
-
+
# Proper handling of datetime normalization
>>> pendulum.datetime(2013, 3, 31, 2, 30, tz='Europe/Paris')
'2013-03-31T03:30:00+02:00' # 2:30 does not exist (Skipped time)
-
+
# Proper handling of dst transitions
>>> just_before = pendulum.datetime(2013, 3, 31, 1, 59, 59, 999999, tz='Europe/Paris')
'2013-03-31T01:59:59.999999+01:00'
>>> just_before.add(microseconds=1)
'2013-03-31T03:00:00+02:00'
-
-
+
+
Why Pendulum?
=============
-
+
Native ``datetime`` instances are enough for basic cases but when you face more complex use-cases
they often show limitations and are not so intuitive to work with.
``Pendulum`` provides a cleaner and more easy to use API while still relying on the standard library.
So it's still ``datetime`` but better.
-
+
Unlike other datetime libraries for Python, Pendulum is a drop-in replacement
for the standard ``datetime`` class (it inherits from it), so, basically, you can replace all your ``datetime``
instances by ``DateTime`` instances in you code (exceptions exist for libraries that check
the type of the objects by using the ``type`` function like ``sqlite3`` or ``PyMySQL`` for instance).
-
+
It also removes the notion of naive datetimes: each ``Pendulum`` instance is timezone-aware
and by default in ``UTC`` for ease of use.
-
+
Pendulum also improves the standard ``timedelta`` class by providing more intuitive methods and properties.
-
-
+
+
Why not Arrow?
==============
-
+
Arrow is the most popular datetime library for Python right now, however its behavior
and API can be erratic and unpredictable. The ``get()`` method can receive pretty much anything
and it will try its best to return something while silently failing to handle some cases:
-
+
.. code-block:: python
-
+
arrow.get('2016-1-17')
#
-
+
pendulum.parse('2016-1-17')
#
-
+
arrow.get('20160413')
#
-
+
pendulum.parse('20160413')
#
-
+
arrow.get('2016-W07-5')
#
-
+
pendulum.parse('2016-W07-5')
#
-
+
# Working with DST
just_before = arrow.Arrow(2013, 3, 31, 1, 59, 59, 999999, 'Europe/Paris')
just_after = just_before.replace(microseconds=1)
'2013-03-31T02:00:00+02:00'
# Should be 2013-03-31T03:00:00+02:00
-
+
(just_after.to('utc') - just_before.to('utc')).total_seconds()
-3599.999999
# Should be 1e-06
-
+
just_before = pendulum.datetime(2013, 3, 31, 1, 59, 59, 999999, 'Europe/Paris')
just_after = just_before.add(microseconds=1)
'2013-03-31T03:00:00+02:00'
-
+
(just_after.in_timezone('utc') - just_before.in_timezone('utc')).total_seconds()
1e-06
-
+
Those are a few examples showing that Arrow cannot always be trusted to have a consistent
behavior with the data you are passing to it.
-
-
+
+
Limitations
===========
-
+
Even though the ``DateTime`` class is a subclass of ``datetime`` there are some rare cases where
it can't replace the native class directly. Here is a list (non-exhaustive) of the reported cases with
a possible solution, if any:
-
+
* ``sqlite3`` will use the ``type()`` function to determine the type of the object by default. To work around it you can register a new adapter:
-
+
.. code-block:: python
-
+
from pendulum import DateTime
from sqlite3 import register_adapter
-
+
register_adapter(DateTime, lambda val: val.isoformat(' '))
-
+
* ``mysqlclient`` (former ``MySQLdb``) and ``PyMySQL`` will use the ``type()`` function to determine the type of the object by default. To work around it you can register a new adapter:
-
+
.. code-block:: python
-
+
import MySQLdb.converters
import pymysql.converters
-
+
from pendulum import DateTime
-
+
MySQLdb.converters.conversions[DateTime] = MySQLdb.converters.DateTime2literal
pymysql.converters.conversions[DateTime] = pymysql.converters.escape_datetime
-
+
* ``django`` will use the ``isoformat()`` method to store datetimes in the database. However since ``pendulum`` is always timezone aware the offset information will always be returned by ``isoformat()`` raising an error, at least for MySQL databases. To work around it you can either create your own ``DateTimeField`` or use the previous workaround for ``MySQLdb``:
-
+
.. code-block:: python
-
+
from django.db.models import DateTimeField as BaseDateTimeField
from pendulum import DateTime
-
-
+
+
class DateTimeField(BaseDateTimeField):
-
+
def value_to_string(self, obj):
val = self.value_from_object(obj)
-
+
if isinstance(value, DateTime):
return value.to_datetime_string()
-
+
return '' if val is None else val.isoformat()
-
-
+
+
Resources
=========
-
+
* `Official Website `_
* `Documentation `_
* `Issue Tracker `_
-
-
+
+
Contributing
============
-
+
Contributions are welcome, especially with localization.
-
+
Getting started
---------------
-
+
To work on the Pendulum codebase, you'll want to clone the project locally
and install the required depedendencies via `poetry `_.
-
+
.. code-block:: bash
-
+
$ git clone git@github.com:sdispater/pendulum.git
$ poetry install
-
+
Localization
------------
-
+
If you want to help with localization, there are two different cases: the locale already exists
or not.
-
+
If the locale does not exist you will need to create it by using the ``clock`` utility:
-
+
.. code-block:: bash
-
+
./clock locale create
-
+
It will generate a directory in ``pendulum/locales`` named after your locale, with the following
structure:
-
+
.. code-block:: text
-
+
/
- custom.py
- locale.py
-
+
The ``locale.py`` file must not be modified. It contains the translations provided by
the CLDR database.
-
+
The ``custom.py`` file is the one you want to modify. It contains the data needed
by Pendulum that are not provided by the CLDR database. You can take the `en `_
data as a reference to see which data is needed.
-
+
You should also add tests for the created or modified locale.
-
+
Platform: UNKNOWN
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
diff --git a/tests/repositories/fixtures/legacy/black.html b/tests/repositories/fixtures/legacy/black.html
index 333fd93ef02..9d3fa08c633 100644
--- a/tests/repositories/fixtures/legacy/black.html
+++ b/tests/repositories/fixtures/legacy/black.html
@@ -7,4 +7,4 @@ Links for black
black-19.10b0.tar.gz