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
Hide 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"]
[[tool.mypy.overrides]]
module
=
[
'poetry.inspection.info'
,
'poetry.installation.chef'
,
'poetry.installation.chooser'
,
'poetry.installation.executor'
,
...
...
@@ -148,6 +147,7 @@ module = [
'html
5
lib.*'
,
'jsonschema.*'
,
'pexpect.*'
,
'pkginfo.*'
,
'poetry.core.*'
,
'requests_toolbelt.*'
,
'shellingham.*'
,
...
...
src/poetry/inspection/info.py
View file @
f05329a6
...
...
@@ -10,7 +10,11 @@ import zipfile
from
pathlib
import
Path
from
tempfile
import
TemporaryDirectory
from
typing
import
TYPE_CHECKING
from
typing
import
Any
from
typing
import
Callable
from
typing
import
ContextManager
from
typing
import
Iterator
from
typing
import
cast
import
pkginfo
...
...
@@ -81,9 +85,9 @@ class PackageInfo:
self
.
requires_python
=
requires_python
self
.
files
=
files
or
[]
self
.
_cache_version
=
cache_version
self
.
_source_type
=
None
self
.
_source_url
=
None
self
.
_source_reference
=
None
self
.
_source_type
:
str
|
None
=
None
self
.
_source_url
:
str
|
None
=
None
self
.
_source_reference
:
str
|
None
=
None
@property
def
cache_version
(
self
)
->
str
|
None
:
...
...
@@ -100,7 +104,7 @@ class PackageInfo:
self
.
_cache_version
=
other
.
cache_version
or
self
.
_cache_version
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.
"""
...
...
@@ -116,7 +120,7 @@ class PackageInfo:
}
@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()`.
...
...
@@ -169,7 +173,9 @@ class PackageInfo:
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"
# 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
:
package
.
extras
=
poetry_package
.
extras
for
dependency
in
poetry_package
.
requires
:
...
...
@@ -274,6 +280,7 @@ class PackageInfo:
# So, we unpack and introspect
suffix
=
path
.
suffix
context
:
Callable
[[
str
],
ContextManager
[
zipfile
.
ZipFile
|
tarfile
.
TarFile
]]
if
suffix
==
".zip"
:
context
=
zipfile
.
ZipFile
else
:
...
...
@@ -286,8 +293,8 @@ class PackageInfo:
context
=
tarfile
.
open
with
TemporaryDirectory
()
as
tmp
:
tmp
=
Path
(
tmp
)
with
TemporaryDirectory
()
as
tmp
_str
:
tmp
=
Path
(
tmp
_str
)
with
context
(
path
.
as_posix
())
as
archive
:
archive
.
extractall
(
tmp
.
as_posix
())
...
...
@@ -394,7 +401,7 @@ class PackageInfo:
if
path
.
suffix
in
{
".dist-info"
,
".egg-info"
}:
directories
=
[
path
]
else
:
directories
=
cls
.
_find_dist_info
(
path
=
path
)
directories
=
list
(
cls
.
_find_dist_info
(
path
=
path
)
)
for
directory
in
directories
:
try
:
...
...
@@ -463,6 +470,7 @@ class PackageInfo:
build is attempted in order to gather metadata.
"""
project_package
=
cls
.
_get_poetry_package
(
path
)
info
:
PackageInfo
|
None
if
project_package
:
info
=
cls
.
from_package
(
project_package
)
else
:
...
...
@@ -480,6 +488,7 @@ class PackageInfo:
# we discovered PkgInfo but no requirements were listed
assert
info
info
.
_source_type
=
"directory"
info
.
_source_url
=
path
.
as_posix
()
...
...
src/poetry/utils/env.py
View file @
f05329a6
...
...
@@ -18,7 +18,6 @@ from subprocess import CalledProcessError
from
tempfile
import
TemporaryDirectory
from
typing
import
TYPE_CHECKING
from
typing
import
Any
from
typing
import
ContextManager
from
typing
import
Iterable
from
typing
import
Iterator
from
typing
import
TypeVar
...
...
@@ -1830,7 +1829,7 @@ class NullEnv(SystemEnv):
def
ephemeral_environment
(
executable
:
str
|
Path
|
None
=
None
,
flags
:
dict
[
str
,
bool
]
=
None
,
)
->
ContextManage
r
[
VirtualEnv
]:
)
->
Iterato
r
[
VirtualEnv
]:
with
TemporaryDirectory
()
as
tmp_dir
:
# TODO: cache PEP 517 build environment corresponding to each project 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