Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
a00eb5c3
Commit
a00eb5c3
authored
May 17, 2022
by
Branch Vincent
Committed by
Bjorn Neergaard
May 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore(console): remove type errors
parent
839f7c40
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
16 deletions
+17
-16
pyproject.toml
+0
-1
src/poetry/console/commands/init.py
+14
-13
src/poetry/layouts/layout.py
+3
-2
No files found.
pyproject.toml
View file @
a00eb5c3
...
@@ -116,7 +116,6 @@ enable_error_code = ["ignore-without-code"]
...
@@ -116,7 +116,6 @@ enable_error_code = ["ignore-without-code"]
[[tool.mypy.overrides]]
[[tool.mypy.overrides]]
module
=
[
module
=
[
'poetry.console.commands.init'
,
'poetry.inspection.info'
,
'poetry.inspection.info'
,
'poetry.installation.chef'
,
'poetry.installation.chef'
,
'poetry.installation.chooser'
,
'poetry.installation.chooser'
,
...
...
src/poetry/console/commands/init.py
View file @
a00eb5c3
...
@@ -5,7 +5,9 @@ import sys
...
@@ -5,7 +5,9 @@ import sys
from
pathlib
import
Path
from
pathlib
import
Path
from
typing
import
TYPE_CHECKING
from
typing
import
TYPE_CHECKING
from
typing
import
Any
from
typing
import
Any
from
typing
import
Dict
from
typing
import
Mapping
from
typing
import
Mapping
from
typing
import
Union
from
cleo.helpers
import
option
from
cleo.helpers
import
option
from
tomlkit
import
inline_table
from
tomlkit
import
inline_table
...
@@ -22,6 +24,8 @@ if TYPE_CHECKING:
...
@@ -22,6 +24,8 @@ if TYPE_CHECKING:
from
poetry.repositories
import
Pool
from
poetry.repositories
import
Pool
Requirements
=
Dict
[
str
,
Union
[
str
,
Mapping
[
str
,
Any
]]]
class
InitCommand
(
Command
):
class
InitCommand
(
Command
):
name
=
"init"
name
=
"init"
...
@@ -162,7 +166,7 @@ The <c1>init</c1> command creates a basic <comment>pyproject.toml</> file in the
...
@@ -162,7 +166,7 @@ The <c1>init</c1> command creates a basic <comment>pyproject.toml</> file in the
if
self
.
io
.
is_interactive
():
if
self
.
io
.
is_interactive
():
self
.
line
(
""
)
self
.
line
(
""
)
requirements
=
{}
requirements
:
Requirements
=
{}
if
self
.
option
(
"dependency"
):
if
self
.
option
(
"dependency"
):
requirements
=
self
.
_format_requirements
(
requirements
=
self
.
_format_requirements
(
self
.
_determine_requirements
(
self
.
option
(
"dependency"
))
self
.
_determine_requirements
(
self
.
option
(
"dependency"
))
...
@@ -192,7 +196,7 @@ You can specify a package in the following forms:
...
@@ -192,7 +196,7 @@ You can specify a package in the following forms:
if
self
.
io
.
is_interactive
():
if
self
.
io
.
is_interactive
():
self
.
line
(
""
)
self
.
line
(
""
)
dev_requirements
:
dict
[
str
,
str
]
=
{}
dev_requirements
:
Requirements
=
{}
if
self
.
option
(
"dev-dependency"
):
if
self
.
option
(
"dev-dependency"
):
dev_requirements
=
self
.
_format_requirements
(
dev_requirements
=
self
.
_format_requirements
(
self
.
_determine_requirements
(
self
.
option
(
"dev-dependency"
))
self
.
_determine_requirements
(
self
.
option
(
"dev-dependency"
))
...
@@ -264,9 +268,9 @@ You can specify a package in the following forms:
...
@@ -264,9 +268,9 @@ You can specify a package in the following forms:
requires
:
list
[
str
],
requires
:
list
[
str
],
allow_prereleases
:
bool
=
False
,
allow_prereleases
:
bool
=
False
,
source
:
str
|
None
=
None
,
source
:
str
|
None
=
None
,
)
->
list
[
dict
[
str
,
str
|
list
[
str
]
]]:
)
->
list
[
dict
[
str
,
Any
]]:
if
not
requires
:
if
not
requires
:
re
quires
=
[]
re
sult
=
[]
package
=
self
.
ask
(
package
=
self
.
ask
(
"Search for package to add (or leave blank to continue):"
"Search for package to add (or leave blank to continue):"
...
@@ -280,7 +284,7 @@ You can specify a package in the following forms:
...
@@ -280,7 +284,7 @@ You can specify a package in the following forms:
or
"version"
in
constraint
or
"version"
in
constraint
):
):
self
.
line
(
f
"Adding <info>{package}</info>"
)
self
.
line
(
f
"Adding <info>{package}</info>"
)
re
quires
.
append
(
constraint
)
re
sult
.
append
(
constraint
)
package
=
self
.
ask
(
"
\n
Add a package:"
)
package
=
self
.
ask
(
"
\n
Add a package:"
)
continue
continue
...
@@ -337,16 +341,15 @@ You can specify a package in the following forms:
...
@@ -337,16 +341,15 @@ You can specify a package in the following forms:
constraint
[
"version"
]
=
package_constraint
constraint
[
"version"
]
=
package_constraint
if
package
is
not
False
:
if
package
is
not
False
:
re
quires
.
append
(
constraint
)
re
sult
.
append
(
constraint
)
if
self
.
io
.
is_interactive
():
if
self
.
io
.
is_interactive
():
package
=
self
.
ask
(
"
\n
Add a package:"
)
package
=
self
.
ask
(
"
\n
Add a package:"
)
return
re
quires
return
re
sult
requires
=
self
.
_parse_requirements
(
requires
)
result
=
[]
result
=
[]
for
requirement
in
requires
:
for
requirement
in
self
.
_parse_requirements
(
requires
)
:
if
"git"
in
requirement
or
"url"
in
requirement
or
"path"
in
requirement
:
if
"git"
in
requirement
or
"url"
in
requirement
or
"path"
in
requirement
:
result
.
append
(
requirement
)
result
.
append
(
requirement
)
continue
continue
...
@@ -414,10 +417,8 @@ You can specify a package in the following forms:
...
@@ -414,10 +417,8 @@ You can specify a package in the following forms:
for
requirement
in
requirements
for
requirement
in
requirements
]
]
def
_format_requirements
(
def
_format_requirements
(
self
,
requirements
:
list
[
dict
[
str
,
str
]])
->
Requirements
:
self
,
requirements
:
list
[
dict
[
str
,
str
]]
requires
:
Requirements
=
{}
)
->
Mapping
[
str
,
str
|
Mapping
[
str
,
str
]]:
requires
=
{}
for
requirement
in
requirements
:
for
requirement
in
requirements
:
name
=
requirement
.
pop
(
"name"
)
name
=
requirement
.
pop
(
"name"
)
constraint
:
str
|
InlineTable
constraint
:
str
|
InlineTable
...
...
src/poetry/layouts/layout.py
View file @
a00eb5c3
...
@@ -3,6 +3,7 @@ from __future__ import annotations
...
@@ -3,6 +3,7 @@ from __future__ import annotations
from
pathlib
import
Path
from
pathlib
import
Path
from
typing
import
TYPE_CHECKING
from
typing
import
TYPE_CHECKING
from
typing
import
Any
from
typing
import
Any
from
typing
import
Mapping
from
tomlkit
import
dumps
from
tomlkit
import
dumps
from
tomlkit
import
inline_table
from
tomlkit
import
inline_table
...
@@ -50,8 +51,8 @@ class Layout:
...
@@ -50,8 +51,8 @@ class Layout:
author
:
str
|
None
=
None
,
author
:
str
|
None
=
None
,
license
:
str
|
None
=
None
,
license
:
str
|
None
=
None
,
python
:
str
=
"*"
,
python
:
str
=
"*"
,
dependencies
:
dict
[
str
,
str
]
|
None
=
None
,
dependencies
:
dict
[
str
,
str
|
Mapping
[
str
,
Any
]
]
|
None
=
None
,
dev_dependencies
:
dict
[
str
,
str
]
|
None
=
None
,
dev_dependencies
:
dict
[
str
,
str
|
Mapping
[
str
,
Any
]
]
|
None
=
None
,
)
->
None
:
)
->
None
:
self
.
_project
=
canonicalize_name
(
project
)
.
replace
(
"."
,
"-"
)
self
.
_project
=
canonicalize_name
(
project
)
.
replace
(
"."
,
"-"
)
self
.
_package_path_relative
=
Path
(
self
.
_package_path_relative
=
Path
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment