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
e0bc7f3f
Commit
e0bc7f3f
authored
Jul 27, 2022
by
David Hotham
Committed by
Bjorn Neergaard
Jul 29, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more typechecking
parent
ec610a34
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
34 additions
and
42 deletions
+34
-42
src/poetry/console/application.py
+7
-6
src/poetry/console/commands/debug/resolve.py
+3
-7
src/poetry/console/commands/plugin/add.py
+2
-1
src/poetry/console/commands/plugin/remove.py
+3
-7
src/poetry/console/commands/plugin/show.py
+1
-7
src/poetry/console/commands/self/update.py
+3
-7
src/poetry/factory.py
+2
-1
src/poetry/installation/executor.py
+1
-0
src/poetry/plugins/application_plugin.py
+1
-0
src/poetry/publishing/publisher.py
+2
-3
src/poetry/publishing/uploader.py
+2
-2
src/poetry/puzzle/provider.py
+1
-0
src/poetry/utils/env.py
+6
-1
No files found.
src/poetry/console/application.py
View file @
e0bc7f3f
...
...
@@ -38,13 +38,13 @@ if TYPE_CHECKING:
from
poetry.poetry
import
Poetry
def
load_command
(
name
:
str
)
->
Callable
[[],
type
[
Command
]
]:
def
_load
()
->
type
[
Command
]
:
def
load_command
(
name
:
str
)
->
Callable
[[],
Command
]:
def
_load
()
->
Command
:
words
=
name
.
split
(
" "
)
module
=
import_module
(
"poetry.console.commands."
+
"."
.
join
(
words
))
command_class
=
getattr
(
module
,
""
.
join
(
c
.
title
()
for
c
in
words
)
+
"Command"
)
command
_type
:
type
[
Command
]
=
command_class
()
return
command
_type
command
:
Command
=
command_class
()
return
command
return
_load
...
...
@@ -136,7 +136,8 @@ class Application(BaseApplication): # type: ignore[misc]
@property
def
command_loader
(
self
)
->
CommandLoader
:
command_loader
:
CommandLoader
=
self
.
_command_loader
command_loader
:
CommandLoader
|
None
=
self
.
_command_loader
assert
command_loader
is
not
None
return
command_loader
def
reset_poetry
(
self
)
->
None
:
...
...
@@ -333,7 +334,7 @@ class Application(BaseApplication): # type: ignore[misc]
installer
.
use_executor
(
poetry
.
config
.
get
(
"experimental.new-installer"
,
False
))
command
.
set_installer
(
installer
)
def
_load_plugins
(
self
,
io
:
IO
=
None
)
->
None
:
def
_load_plugins
(
self
,
io
:
IO
|
None
=
None
)
->
None
:
if
self
.
_plugins_loaded
:
return
...
...
src/poetry/console/commands/debug/resolve.py
View file @
e0bc7f3f
from
__future__
import
annotations
from
typing
import
TYPE_CHECKING
from
cleo.helpers
import
argument
from
cleo.helpers
import
option
from
cleo.io.outputs.output
import
Verbosity
from
poetry.console.commands.init
import
InitCommand
if
TYPE_CHECKING
:
from
poetry.console.commands.show
import
ShowCommand
from
poetry.console.commands.show
import
ShowCommand
class
DebugResolveCommand
(
InitCommand
):
...
...
@@ -94,7 +89,8 @@ class DebugResolveCommand(InitCommand):
self
.
line
(
""
)
if
self
.
option
(
"tree"
):
show_command
:
ShowCommand
=
self
.
application
.
find
(
"show"
)
show_command
=
self
.
application
.
find
(
"show"
)
assert
isinstance
(
show_command
,
ShowCommand
)
show_command
.
init_styles
(
self
.
io
)
packages
=
[
op
.
package
for
op
in
ops
]
...
...
src/poetry/console/commands/plugin/add.py
View file @
e0bc7f3f
...
...
@@ -45,7 +45,8 @@ It works similarly to the <c1>add</c1> command:
self
.
line_error
(
self
.
deprecation
)
application
=
self
.
get_application
()
command
:
SelfAddCommand
=
application
.
find
(
"self add"
)
command
=
application
.
find
(
"self add"
)
assert
isinstance
(
command
,
SelfAddCommand
)
application
.
configure_installer_for_command
(
command
,
self
.
io
)
argv
:
list
[
str
]
=
[
"add"
,
*
self
.
argument
(
"plugins"
)]
...
...
src/poetry/console/commands/plugin/remove.py
View file @
e0bc7f3f
from
__future__
import
annotations
from
typing
import
TYPE_CHECKING
from
cleo.helpers
import
argument
from
cleo.helpers
import
option
from
cleo.io.inputs.string_input
import
StringInput
from
cleo.io.io
import
IO
from
poetry.console.commands.command
import
Command
if
TYPE_CHECKING
:
from
poetry.console.commands.self.remove
import
SelfRemoveCommand
from
poetry.console.commands.self.remove
import
SelfRemoveCommand
class
PluginRemoveCommand
(
Command
):
...
...
@@ -43,7 +38,8 @@ class PluginRemoveCommand(Command):
self
.
line_error
(
self
.
help
)
application
=
self
.
get_application
()
command
:
SelfRemoveCommand
=
application
.
find
(
"self remove"
)
command
=
application
.
find
(
"self remove"
)
assert
isinstance
(
command
,
SelfRemoveCommand
)
application
.
configure_installer_for_command
(
command
,
self
.
io
)
argv
:
list
[
str
]
=
[
"remove"
,
*
self
.
argument
(
"plugins"
)]
...
...
src/poetry/console/commands/plugin/show.py
View file @
e0bc7f3f
from
__future__
import
annotations
from
typing
import
TYPE_CHECKING
from
cleo.io.inputs.string_input
import
StringInput
from
cleo.io.io
import
IO
from
poetry.console.commands.command
import
Command
if
TYPE_CHECKING
:
from
poetry.console.commands.self.show.plugins
import
SelfShowPluginsCommand
class
PluginShowCommand
(
Command
):
name
=
"plugin show"
...
...
@@ -26,7 +20,7 @@ class PluginShowCommand(Command):
self
.
line_error
(
self
.
help
)
application
=
self
.
get_application
()
command
:
SelfShowPluginsCommand
=
application
.
find
(
"self show plugins"
)
command
=
application
.
find
(
"self show plugins"
)
exit_code
:
int
=
command
.
run
(
IO
(
...
...
src/poetry/console/commands/self/update.py
View file @
e0bc7f3f
from
__future__
import
annotations
from
typing
import
TYPE_CHECKING
from
cleo.helpers
import
argument
from
cleo.helpers
import
option
from
cleo.io.inputs.string_input
import
StringInput
from
cleo.io.io
import
IO
from
poetry.console.commands.add
import
AddCommand
from
poetry.console.commands.self.self_command
import
SelfCommand
if
TYPE_CHECKING
:
from
poetry.console.commands.add
import
AddCommand
class
SelfUpdateCommand
(
SelfCommand
):
name
=
"self update"
description
=
"Updates Poetry to the latest version."
...
...
@@ -40,7 +35,8 @@ environment.
def
_system_project_handle
(
self
)
->
int
:
self
.
write
(
"<info>Updating Poetry version ...</info>
\n\n
"
)
application
=
self
.
get_application
()
add_command
:
AddCommand
=
application
.
find
(
"add"
)
add_command
=
application
.
find
(
"add"
)
assert
isinstance
(
add_command
,
AddCommand
)
add_command
.
set_env
(
self
.
env
)
application
.
configure_installer_for_command
(
add_command
,
self
.
io
)
...
...
src/poetry/factory.py
View file @
e0bc7f3f
...
...
@@ -45,6 +45,7 @@ class Factory(BaseFactory):
def
create_poetry
(
self
,
cwd
:
Path
|
None
=
None
,
with_groups
:
bool
=
True
,
io
:
IO
|
None
=
None
,
disable_plugins
:
bool
=
False
,
disable_cache
:
bool
=
False
,
...
...
@@ -52,7 +53,7 @@ class Factory(BaseFactory):
if
io
is
None
:
io
=
NullIO
()
base_poetry
=
super
()
.
create_poetry
(
cwd
)
base_poetry
=
super
()
.
create_poetry
(
cwd
=
cwd
,
with_groups
=
with_groups
)
locker
=
Locker
(
base_poetry
.
file
.
parent
/
"poetry.lock"
,
base_poetry
.
local_config
...
...
src/poetry/installation/executor.py
View file @
e0bc7f3f
...
...
@@ -258,6 +258,7 @@ class Executor:
try
:
from
cleo.ui.exception_trace
import
ExceptionTrace
io
:
IO
|
SectionOutput
if
not
self
.
supports_fancy_output
():
io
=
self
.
_io
else
:
...
...
src/poetry/plugins/application_plugin.py
View file @
e0bc7f3f
...
...
@@ -23,4 +23,5 @@ class ApplicationPlugin(BasePlugin):
def
activate
(
self
,
application
:
Application
)
->
None
:
for
command
in
self
.
commands
:
assert
command
.
name
is
not
None
application
.
command_loader
.
register_factory
(
command
.
name
,
lambda
:
command
())
src/poetry/publishing/publisher.py
View file @
e0bc7f3f
...
...
@@ -11,8 +11,7 @@ from poetry.utils.authenticator import Authenticator
if
TYPE_CHECKING
:
from
pathlib
import
Path
from
cleo.io
import
BufferedIO
from
cleo.io
import
ConsoleIO
from
cleo.io.io
import
IO
from
poetry.poetry
import
Poetry
...
...
@@ -24,7 +23,7 @@ class Publisher:
Registers and publishes packages to remote repositories.
"""
def
__init__
(
self
,
poetry
:
Poetry
,
io
:
BufferedIO
|
Console
IO
)
->
None
:
def
__init__
(
self
,
poetry
:
Poetry
,
io
:
IO
)
->
None
:
self
.
_poetry
=
poetry
self
.
_package
=
poetry
.
package
self
.
_io
=
io
...
...
src/poetry/publishing/uploader.py
View file @
e0bc7f3f
...
...
@@ -27,7 +27,7 @@ from poetry.utils.patterns import wheel_file_re
if
TYPE_CHECKING
:
from
cleo.io.
null_io
import
Null
IO
from
cleo.io.
io
import
IO
from
poetry.poetry
import
Poetry
...
...
@@ -52,7 +52,7 @@ class UploadError(Exception):
class
Uploader
:
def
__init__
(
self
,
poetry
:
Poetry
,
io
:
Null
IO
)
->
None
:
def
__init__
(
self
,
poetry
:
Poetry
,
io
:
IO
)
->
None
:
self
.
_poetry
=
poetry
self
.
_package
=
poetry
.
package
self
.
_io
=
io
...
...
src/poetry/puzzle/provider.py
View file @
e0bc7f3f
...
...
@@ -79,6 +79,7 @@ class Indicator(ProgressIndicator): # type: ignore[misc]
return
f
" <c1>{Indicator.CONTEXT}</> "
def
_formatter_elapsed
(
self
)
->
str
:
assert
self
.
_start_time
is
not
None
elapsed
=
time
.
time
()
-
self
.
_start_time
return
f
"{elapsed:.1f}s"
...
...
src/poetry/utils/env.py
View file @
e0bc7f3f
...
...
@@ -1909,7 +1909,10 @@ def build_environment(
"""
if
not
env
or
poetry
.
package
.
build_script
:
with
ephemeral_environment
(
executable
=
env
.
python
if
env
else
None
)
as
venv
:
overwrite
=
io
and
io
.
output
.
is_decorated
()
and
not
io
.
is_debug
()
overwrite
=
(
io
is
not
None
and
io
.
output
.
is_decorated
()
and
not
io
.
is_debug
()
)
if
io
:
if
not
overwrite
:
io
.
write_line
(
""
)
...
...
@@ -1923,6 +1926,7 @@ def build_environment(
"<b>Preparing</b> build environment with build-system requirements"
f
" {', '.join(requires)}"
)
venv
.
run_pip
(
"install"
,
"--disable-pip-version-check"
,
...
...
@@ -1931,6 +1935,7 @@ def build_environment(
)
if
overwrite
:
assert
io
is
not
None
io
.
write_line
(
""
)
yield
venv
...
...
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