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
f05329a6
Unverified
Commit
f05329a6
authored
May 17, 2022
by
Branch Vincent
Committed by
GitHub
May 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore(inspection): remove type errors (#5570)
parent
797eb87c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
12 deletions
+20
-12
pyproject.toml
+1
-1
src/poetry/inspection/info.py
+18
-9
src/poetry/utils/env.py
+1
-2
No files found.
pyproject.toml
View file @
f05329a6
...
@@ -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.inspection.info'
,
'poetry.installation.chef'
,
'poetry.installation.chef'
,
'poetry.installation.chooser'
,
'poetry.installation.chooser'
,
'poetry.installation.executor'
,
'poetry.installation.executor'
,
...
@@ -148,6 +147,7 @@ module = [
...
@@ -148,6 +147,7 @@ module = [
'html
5
lib.*'
,
'html
5
lib.*'
,
'jsonschema.*'
,
'jsonschema.*'
,
'pexpect.*'
,
'pexpect.*'
,
'pkginfo.*'
,
'poetry.core.*'
,
'poetry.core.*'
,
'requests_toolbelt.*'
,
'requests_toolbelt.*'
,
'shellingham.*'
,
'shellingham.*'
,
...
...
src/poetry/inspection/info.py
View file @
f05329a6
...
@@ -10,7 +10,11 @@ import zipfile
...
@@ -10,7 +10,11 @@ import zipfile
from
pathlib
import
Path
from
pathlib
import
Path
from
tempfile
import
TemporaryDirectory
from
tempfile
import
TemporaryDirectory
from
typing
import
TYPE_CHECKING
from
typing
import
TYPE_CHECKING
from
typing
import
Any
from
typing
import
Callable
from
typing
import
ContextManager
from
typing
import
Iterator
from
typing
import
Iterator
from
typing
import
cast
import
pkginfo
import
pkginfo
...
@@ -81,9 +85,9 @@ class PackageInfo:
...
@@ -81,9 +85,9 @@ class PackageInfo:
self
.
requires_python
=
requires_python
self
.
requires_python
=
requires_python
self
.
files
=
files
or
[]
self
.
files
=
files
or
[]
self
.
_cache_version
=
cache_version
self
.
_cache_version
=
cache_version
self
.
_source_type
=
None
self
.
_source_type
:
str
|
None
=
None
self
.
_source_url
=
None
self
.
_source_url
:
str
|
None
=
None
self
.
_source_reference
=
None
self
.
_source_reference
:
str
|
None
=
None
@property
@property
def
cache_version
(
self
)
->
str
|
None
:
def
cache_version
(
self
)
->
str
|
None
:
...
@@ -100,7 +104,7 @@ class PackageInfo:
...
@@ -100,7 +104,7 @@ class PackageInfo:
self
.
_cache_version
=
other
.
cache_version
or
self
.
_cache_version
self
.
_cache_version
=
other
.
cache_version
or
self
.
_cache_version
return
self
return
self
def
asdict
(
self
)
->
dict
[
str
,
str
|
list
[
str
]
|
None
]:
def
asdict
(
self
)
->
dict
[
str
,
Any
]:
"""
"""
Helper method to convert package info into a dictionary used for caching.
Helper method to convert package info into a dictionary used for caching.
"""
"""
...
@@ -116,7 +120,7 @@ class PackageInfo:
...
@@ -116,7 +120,7 @@ class PackageInfo:
}
}
@classmethod
@classmethod
def
load
(
cls
,
data
:
dict
[
str
,
str
|
list
[
str
]
|
None
])
->
PackageInfo
:
def
load
(
cls
,
data
:
dict
[
str
,
Any
])
->
PackageInfo
:
"""
"""
Helper method to load data from a dictionary produced by `PackageInfo.asdict()`.
Helper method to load data from a dictionary produced by `PackageInfo.asdict()`.
...
@@ -169,7 +173,9 @@ class PackageInfo:
...
@@ -169,7 +173,9 @@ class PackageInfo:
if
root_dir
or
(
self
.
_source_type
in
{
"directory"
}
and
self
.
_source_url
):
if
root_dir
or
(
self
.
_source_type
in
{
"directory"
}
and
self
.
_source_url
):
# this is a local poetry project, this means we can extract "richer"
# this is a local poetry project, this means we can extract "richer"
# requirement information, eg: development requirements etc.
# requirement information, eg: development requirements etc.
poetry_package
=
self
.
_get_poetry_package
(
path
=
root_dir
or
self
.
_source_url
)
poetry_package
=
self
.
_get_poetry_package
(
path
=
root_dir
or
Path
(
cast
(
str
,
self
.
_source_url
))
)
if
poetry_package
:
if
poetry_package
:
package
.
extras
=
poetry_package
.
extras
package
.
extras
=
poetry_package
.
extras
for
dependency
in
poetry_package
.
requires
:
for
dependency
in
poetry_package
.
requires
:
...
@@ -274,6 +280,7 @@ class PackageInfo:
...
@@ -274,6 +280,7 @@ class PackageInfo:
# So, we unpack and introspect
# So, we unpack and introspect
suffix
=
path
.
suffix
suffix
=
path
.
suffix
context
:
Callable
[[
str
],
ContextManager
[
zipfile
.
ZipFile
|
tarfile
.
TarFile
]]
if
suffix
==
".zip"
:
if
suffix
==
".zip"
:
context
=
zipfile
.
ZipFile
context
=
zipfile
.
ZipFile
else
:
else
:
...
@@ -286,8 +293,8 @@ class PackageInfo:
...
@@ -286,8 +293,8 @@ class PackageInfo:
context
=
tarfile
.
open
context
=
tarfile
.
open
with
TemporaryDirectory
()
as
tmp
:
with
TemporaryDirectory
()
as
tmp
_str
:
tmp
=
Path
(
tmp
)
tmp
=
Path
(
tmp
_str
)
with
context
(
path
.
as_posix
())
as
archive
:
with
context
(
path
.
as_posix
())
as
archive
:
archive
.
extractall
(
tmp
.
as_posix
())
archive
.
extractall
(
tmp
.
as_posix
())
...
@@ -394,7 +401,7 @@ class PackageInfo:
...
@@ -394,7 +401,7 @@ class PackageInfo:
if
path
.
suffix
in
{
".dist-info"
,
".egg-info"
}:
if
path
.
suffix
in
{
".dist-info"
,
".egg-info"
}:
directories
=
[
path
]
directories
=
[
path
]
else
:
else
:
directories
=
cls
.
_find_dist_info
(
path
=
path
)
directories
=
list
(
cls
.
_find_dist_info
(
path
=
path
)
)
for
directory
in
directories
:
for
directory
in
directories
:
try
:
try
:
...
@@ -463,6 +470,7 @@ class PackageInfo:
...
@@ -463,6 +470,7 @@ class PackageInfo:
build is attempted in order to gather metadata.
build is attempted in order to gather metadata.
"""
"""
project_package
=
cls
.
_get_poetry_package
(
path
)
project_package
=
cls
.
_get_poetry_package
(
path
)
info
:
PackageInfo
|
None
if
project_package
:
if
project_package
:
info
=
cls
.
from_package
(
project_package
)
info
=
cls
.
from_package
(
project_package
)
else
:
else
:
...
@@ -480,6 +488,7 @@ class PackageInfo:
...
@@ -480,6 +488,7 @@ class PackageInfo:
# we discovered PkgInfo but no requirements were listed
# we discovered PkgInfo but no requirements were listed
assert
info
info
.
_source_type
=
"directory"
info
.
_source_type
=
"directory"
info
.
_source_url
=
path
.
as_posix
()
info
.
_source_url
=
path
.
as_posix
()
...
...
src/poetry/utils/env.py
View file @
f05329a6
...
@@ -18,7 +18,6 @@ from subprocess import CalledProcessError
...
@@ -18,7 +18,6 @@ from subprocess import CalledProcessError
from
tempfile
import
TemporaryDirectory
from
tempfile
import
TemporaryDirectory
from
typing
import
TYPE_CHECKING
from
typing
import
TYPE_CHECKING
from
typing
import
Any
from
typing
import
Any
from
typing
import
ContextManager
from
typing
import
Iterable
from
typing
import
Iterable
from
typing
import
Iterator
from
typing
import
Iterator
from
typing
import
TypeVar
from
typing
import
TypeVar
...
@@ -1830,7 +1829,7 @@ class NullEnv(SystemEnv):
...
@@ -1830,7 +1829,7 @@ class NullEnv(SystemEnv):
def
ephemeral_environment
(
def
ephemeral_environment
(
executable
:
str
|
Path
|
None
=
None
,
executable
:
str
|
Path
|
None
=
None
,
flags
:
dict
[
str
,
bool
]
=
None
,
flags
:
dict
[
str
,
bool
]
=
None
,
)
->
ContextManage
r
[
VirtualEnv
]:
)
->
Iterato
r
[
VirtualEnv
]:
with
TemporaryDirectory
()
as
tmp_dir
:
with
TemporaryDirectory
()
as
tmp_dir
:
# TODO: cache PEP 517 build environment corresponding to each project venv
# TODO: cache PEP 517 build environment corresponding to each project venv
venv_dir
=
Path
(
tmp_dir
)
/
".venv"
venv_dir
=
Path
(
tmp_dir
)
/
".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