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
ff8ae327
Commit
ff8ae327
authored
Jul 17, 2022
by
David Hotham
Committed by
Bjorn Neergaard
Jul 18, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use packaging.utils.canonicalize_name()
parent
c32395b4
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
20 additions
and
48 deletions
+20
-48
src/poetry/config/config.py
+1
-1
src/poetry/console/commands/add.py
+1
-1
src/poetry/console/commands/init.py
+1
-1
src/poetry/console/commands/remove.py
+1
-1
src/poetry/console/commands/self/show/plugins.py
+2
-1
src/poetry/console/commands/show.py
+1
-1
src/poetry/installation/installer.py
+1
-1
src/poetry/layouts/layout.py
+4
-5
src/poetry/repositories/installed_repository.py
+1
-1
src/poetry/repositories/legacy_repository.py
+1
-1
src/poetry/repositories/link_sources/base.py
+4
-2
src/poetry/utils/extras.py
+1
-1
src/poetry/utils/helpers.py
+0
-11
tests/console/commands/test_init.py
+1
-1
tests/utils/test_helpers.py
+0
-19
No files found.
src/poetry/config/config.py
View file @
ff8ae327
...
@@ -10,8 +10,8 @@ from pathlib import Path
...
@@ -10,8 +10,8 @@ from pathlib import Path
from
typing
import
TYPE_CHECKING
from
typing
import
TYPE_CHECKING
from
typing
import
Any
from
typing
import
Any
from
packaging.utils
import
canonicalize_name
from
poetry.core.toml
import
TOMLFile
from
poetry.core.toml
import
TOMLFile
from
poetry.core.utils.helpers
import
canonicalize_name
from
poetry.config.dict_config_source
import
DictConfigSource
from
poetry.config.dict_config_source
import
DictConfigSource
from
poetry.config.file_config_source
import
FileConfigSource
from
poetry.config.file_config_source
import
FileConfigSource
...
...
src/poetry/console/commands/add.py
View file @
ff8ae327
...
@@ -6,12 +6,12 @@ from typing import Any
...
@@ -6,12 +6,12 @@ from typing import Any
from
cleo.helpers
import
argument
from
cleo.helpers
import
argument
from
cleo.helpers
import
option
from
cleo.helpers
import
option
from
packaging.utils
import
canonicalize_name
from
poetry.core.packages.dependency_group
import
MAIN_GROUP
from
poetry.core.packages.dependency_group
import
MAIN_GROUP
from
tomlkit.toml_document
import
TOMLDocument
from
tomlkit.toml_document
import
TOMLDocument
from
poetry.console.commands.init
import
InitCommand
from
poetry.console.commands.init
import
InitCommand
from
poetry.console.commands.installer_command
import
InstallerCommand
from
poetry.console.commands.installer_command
import
InstallerCommand
from
poetry.utils.helpers
import
canonicalize_name
class
AddCommand
(
InstallerCommand
,
InitCommand
):
class
AddCommand
(
InstallerCommand
,
InitCommand
):
...
...
src/poetry/console/commands/init.py
View file @
ff8ae327
...
@@ -10,12 +10,12 @@ from typing import Mapping
...
@@ -10,12 +10,12 @@ from typing import Mapping
from
typing
import
Union
from
typing
import
Union
from
cleo.helpers
import
option
from
cleo.helpers
import
option
from
packaging.utils
import
canonicalize_name
from
tomlkit
import
inline_table
from
tomlkit
import
inline_table
from
poetry.console.commands.command
import
Command
from
poetry.console.commands.command
import
Command
from
poetry.console.commands.env_command
import
EnvCommand
from
poetry.console.commands.env_command
import
EnvCommand
from
poetry.utils.dependency_specification
import
parse_dependency_specification
from
poetry.utils.dependency_specification
import
parse_dependency_specification
from
poetry.utils.helpers
import
canonicalize_name
if
TYPE_CHECKING
:
if
TYPE_CHECKING
:
...
...
src/poetry/console/commands/remove.py
View file @
ff8ae327
...
@@ -4,11 +4,11 @@ from typing import Any
...
@@ -4,11 +4,11 @@ from typing import Any
from
cleo.helpers
import
argument
from
cleo.helpers
import
argument
from
cleo.helpers
import
option
from
cleo.helpers
import
option
from
packaging.utils
import
canonicalize_name
from
poetry.core.packages.dependency_group
import
MAIN_GROUP
from
poetry.core.packages.dependency_group
import
MAIN_GROUP
from
tomlkit.toml_document
import
TOMLDocument
from
tomlkit.toml_document
import
TOMLDocument
from
poetry.console.commands.installer_command
import
InstallerCommand
from
poetry.console.commands.installer_command
import
InstallerCommand
from
poetry.utils.helpers
import
canonicalize_name
class
RemoveCommand
(
InstallerCommand
):
class
RemoveCommand
(
InstallerCommand
):
...
...
src/poetry/console/commands/self/show/plugins.py
View file @
ff8ae327
...
@@ -49,12 +49,13 @@ commands respectively.
...
@@ -49,12 +49,13 @@ commands respectively.
"""
"""
def
_system_project_handle
(
self
)
->
int
:
def
_system_project_handle
(
self
)
->
int
:
from
packaging.utils
import
canonicalize_name
from
poetry.plugins.application_plugin
import
ApplicationPlugin
from
poetry.plugins.application_plugin
import
ApplicationPlugin
from
poetry.plugins.plugin
import
Plugin
from
poetry.plugins.plugin
import
Plugin
from
poetry.plugins.plugin_manager
import
PluginManager
from
poetry.plugins.plugin_manager
import
PluginManager
from
poetry.repositories.installed_repository
import
InstalledRepository
from
poetry.repositories.installed_repository
import
InstalledRepository
from
poetry.utils.env
import
EnvManager
from
poetry.utils.env
import
EnvManager
from
poetry.utils.helpers
import
canonicalize_name
from
poetry.utils.helpers
import
pluralize
from
poetry.utils.helpers
import
pluralize
plugins
:
dict
[
str
,
PluginPackage
]
=
{}
plugins
:
dict
[
str
,
PluginPackage
]
=
{}
...
...
src/poetry/console/commands/show.py
View file @
ff8ae327
...
@@ -4,9 +4,9 @@ from typing import TYPE_CHECKING
...
@@ -4,9 +4,9 @@ from typing import TYPE_CHECKING
from
cleo.helpers
import
argument
from
cleo.helpers
import
argument
from
cleo.helpers
import
option
from
cleo.helpers
import
option
from
packaging.utils
import
canonicalize_name
from
poetry.console.commands.group_command
import
GroupCommand
from
poetry.console.commands.group_command
import
GroupCommand
from
poetry.utils.helpers
import
canonicalize_name
if
TYPE_CHECKING
:
if
TYPE_CHECKING
:
...
...
src/poetry/installation/installer.py
View file @
ff8ae327
...
@@ -3,6 +3,7 @@ from __future__ import annotations
...
@@ -3,6 +3,7 @@ from __future__ import annotations
from
typing
import
TYPE_CHECKING
from
typing
import
TYPE_CHECKING
from
cleo.io.null_io
import
NullIO
from
cleo.io.null_io
import
NullIO
from
packaging.utils
import
canonicalize_name
from
poetry.installation.executor
import
Executor
from
poetry.installation.executor
import
Executor
from
poetry.installation.operations
import
Install
from
poetry.installation.operations
import
Install
...
@@ -14,7 +15,6 @@ from poetry.repositories import Repository
...
@@ -14,7 +15,6 @@ from poetry.repositories import Repository
from
poetry.repositories.installed_repository
import
InstalledRepository
from
poetry.repositories.installed_repository
import
InstalledRepository
from
poetry.repositories.lockfile_repository
import
LockfileRepository
from
poetry.repositories.lockfile_repository
import
LockfileRepository
from
poetry.utils.extras
import
get_extra_package_names
from
poetry.utils.extras
import
get_extra_package_names
from
poetry.utils.helpers
import
canonicalize_name
from
poetry.utils.helpers
import
pluralize
from
poetry.utils.helpers
import
pluralize
...
...
src/poetry/layouts/layout.py
View file @
ff8ae327
...
@@ -4,15 +4,14 @@ from pathlib import Path
...
@@ -4,15 +4,14 @@ from pathlib import Path
from
typing
import
TYPE_CHECKING
from
typing
import
TYPE_CHECKING
from
typing
import
Any
from
typing
import
Any
from
packaging.utils
import
canonicalize_name
from
poetry.core.pyproject.toml
import
PyProjectTOML
from
poetry.core.pyproject.toml
import
PyProjectTOML
from
poetry.core.utils.helpers
import
module_name
from
tomlkit
import
inline_table
from
tomlkit
import
inline_table
from
tomlkit
import
loads
from
tomlkit
import
loads
from
tomlkit
import
table
from
tomlkit
import
table
from
tomlkit.toml_document
import
TOMLDocument
from
tomlkit.toml_document
import
TOMLDocument
from
poetry.utils.helpers
import
canonicalize_name
from
poetry.utils.helpers
import
module_name
if
TYPE_CHECKING
:
if
TYPE_CHECKING
:
from
typing
import
Mapping
from
typing
import
Mapping
...
@@ -52,9 +51,9 @@ class Layout:
...
@@ -52,9 +51,9 @@ class Layout:
dependencies
:
dict
[
str
,
str
|
Mapping
[
str
,
Any
]]
|
None
=
None
,
dependencies
:
dict
[
str
,
str
|
Mapping
[
str
,
Any
]]
|
None
=
None
,
dev_dependencies
:
dict
[
str
,
str
|
Mapping
[
str
,
Any
]]
|
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
)
self
.
_package_path_relative
=
Path
(
self
.
_package_path_relative
=
Path
(
*
(
module_name
(
part
)
for
part
in
canonicalize_name
(
project
)
.
split
(
"."
))
*
(
module_name
(
part
)
for
part
in
project
.
split
(
"."
))
)
)
self
.
_package_name
=
"."
.
join
(
self
.
_package_path_relative
.
parts
)
self
.
_package_name
=
"."
.
join
(
self
.
_package_path_relative
.
parts
)
self
.
_version
=
version
self
.
_version
=
version
...
...
src/poetry/repositories/installed_repository.py
View file @
ff8ae327
...
@@ -7,9 +7,9 @@ import logging
...
@@ -7,9 +7,9 @@ import logging
from
pathlib
import
Path
from
pathlib
import
Path
from
typing
import
TYPE_CHECKING
from
typing
import
TYPE_CHECKING
from
packaging.utils
import
canonicalize_name
from
poetry.core.packages.package
import
Package
from
poetry.core.packages.package
import
Package
from
poetry.core.packages.utils.utils
import
url_to_path
from
poetry.core.packages.utils.utils
import
url_to_path
from
poetry.core.utils.helpers
import
canonicalize_name
from
poetry.core.utils.helpers
import
module_name
from
poetry.core.utils.helpers
import
module_name
from
poetry.repositories.repository
import
Repository
from
poetry.repositories.repository
import
Repository
...
...
src/poetry/repositories/legacy_repository.py
View file @
ff8ae327
...
@@ -3,6 +3,7 @@ from __future__ import annotations
...
@@ -3,6 +3,7 @@ from __future__ import annotations
from
typing
import
TYPE_CHECKING
from
typing
import
TYPE_CHECKING
from
typing
import
Any
from
typing
import
Any
from
packaging.utils
import
canonicalize_name
from
poetry.core.packages.package
import
Package
from
poetry.core.packages.package
import
Package
from
poetry.core.semver.version
import
Version
from
poetry.core.semver.version
import
Version
...
@@ -10,7 +11,6 @@ from poetry.inspection.info import PackageInfo
...
@@ -10,7 +11,6 @@ from poetry.inspection.info import PackageInfo
from
poetry.repositories.exceptions
import
PackageNotFound
from
poetry.repositories.exceptions
import
PackageNotFound
from
poetry.repositories.http
import
HTTPRepository
from
poetry.repositories.http
import
HTTPRepository
from
poetry.repositories.link_sources.html
import
SimpleRepositoryPage
from
poetry.repositories.link_sources.html
import
SimpleRepositoryPage
from
poetry.utils.helpers
import
canonicalize_name
if
TYPE_CHECKING
:
if
TYPE_CHECKING
:
...
...
src/poetry/repositories/link_sources/base.py
View file @
ff8ae327
...
@@ -6,10 +6,10 @@ import re
...
@@ -6,10 +6,10 @@ import re
from
abc
import
abstractmethod
from
abc
import
abstractmethod
from
typing
import
TYPE_CHECKING
from
typing
import
TYPE_CHECKING
from
packaging.utils
import
canonicalize_name
from
poetry.core.packages.package
import
Package
from
poetry.core.packages.package
import
Package
from
poetry.core.semver.version
import
Version
from
poetry.core.semver.version
import
Version
from
poetry.utils.helpers
import
canonicalize_name
from
poetry.utils.patterns
import
sdist_file_re
from
poetry.utils.patterns
import
sdist_file_re
from
poetry.utils.patterns
import
wheel_file_re
from
poetry.utils.patterns
import
wheel_file_re
...
@@ -69,7 +69,9 @@ class LinkSource:
...
@@ -69,7 +69,9 @@ class LinkSource:
@classmethod
@classmethod
def
link_package_data
(
cls
,
link
:
Link
)
->
Package
|
None
:
def
link_package_data
(
cls
,
link
:
Link
)
->
Package
|
None
:
name
,
version_string
,
version
=
None
,
None
,
None
name
:
str
|
None
=
None
version_string
:
str
|
None
=
None
version
:
Version
|
None
=
None
m
=
wheel_file_re
.
match
(
link
.
filename
)
or
sdist_file_re
.
match
(
link
.
filename
)
m
=
wheel_file_re
.
match
(
link
.
filename
)
or
sdist_file_re
.
match
(
link
.
filename
)
if
m
:
if
m
:
...
...
src/poetry/utils/extras.py
View file @
ff8ae327
...
@@ -25,7 +25,7 @@ def get_extra_package_names(
...
@@ -25,7 +25,7 @@ def get_extra_package_names(
in the `extras` section of `poetry.lock`.
in the `extras` section of `poetry.lock`.
:param extra_names: A list of strings specifying names of extra groups to resolve.
:param extra_names: A list of strings specifying names of extra groups to resolve.
"""
"""
from
p
oetry.utils.helper
s
import
canonicalize_name
from
p
ackaging.util
s
import
canonicalize_name
if
not
extra_names
:
if
not
extra_names
:
return
[]
return
[]
...
...
src/poetry/utils/helpers.py
View file @
ff8ae327
...
@@ -27,17 +27,6 @@ if TYPE_CHECKING:
...
@@ -27,17 +27,6 @@ if TYPE_CHECKING:
from
poetry.utils.authenticator
import
Authenticator
from
poetry.utils.authenticator
import
Authenticator
_canonicalize_regex
=
re
.
compile
(
"[-_]+"
)
def
canonicalize_name
(
name
:
str
)
->
str
:
return
_canonicalize_regex
.
sub
(
"-"
,
name
)
.
lower
()
def
module_name
(
name
:
str
)
->
str
:
return
canonicalize_name
(
name
)
.
replace
(
"."
,
"_"
)
.
replace
(
"-"
,
"_"
)
@contextmanager
@contextmanager
def
directory
(
path
:
Path
)
->
Iterator
[
Path
]:
def
directory
(
path
:
Path
)
->
Iterator
[
Path
]:
cwd
=
Path
.
cwd
()
cwd
=
Path
.
cwd
()
...
...
tests/console/commands/test_init.py
View file @
ff8ae327
...
@@ -10,11 +10,11 @@ from typing import TYPE_CHECKING
...
@@ -10,11 +10,11 @@ from typing import TYPE_CHECKING
import
pytest
import
pytest
from
cleo.testers.command_tester
import
CommandTester
from
cleo.testers.command_tester
import
CommandTester
from
packaging.utils
import
canonicalize_name
from
poetry.console.commands.init
import
InitCommand
from
poetry.console.commands.init
import
InitCommand
from
poetry.repositories
import
Pool
from
poetry.repositories
import
Pool
from
poetry.utils._compat
import
decode
from
poetry.utils._compat
import
decode
from
poetry.utils.helpers
import
canonicalize_name
from
tests.helpers
import
PoetryTestApplication
from
tests.helpers
import
PoetryTestApplication
from
tests.helpers
import
get_package
from
tests.helpers
import
get_package
...
...
tests/utils/test_helpers.py
View file @
ff8ae327
from
__future__
import
annotations
from
__future__
import
annotations
import
pytest
from
poetry.core.utils.helpers
import
parse_requires
from
poetry.core.utils.helpers
import
parse_requires
from
poetry.utils.helpers
import
canonicalize_name
from
poetry.utils.helpers
import
safe_extra
from
poetry.utils.helpers
import
safe_extra
...
@@ -64,22 +61,6 @@ isort@ git+git://github.com/timothycrosley/isort.git@e63ae06ec7d70b06df9e5283576
...
@@ -64,22 +61,6 @@ isort@ git+git://github.com/timothycrosley/isort.git@e63ae06ec7d70b06df9e5283576
assert
result
==
expected
assert
result
==
expected
test_canonicalize_name_cases
=
[
(
"flask"
,
"flask"
),
(
"Flask"
,
"flask"
),
(
"FLASK"
,
"flask"
),
(
"FlAsK"
,
"flask"
),
(
"fLaSk57"
,
"flask57"
),
(
"flask-57"
,
"flask-57"
),
]
@pytest.mark.parametrize
(
"test, expected"
,
test_canonicalize_name_cases
)
def
test_canonicalize_name
(
test
:
str
,
expected
:
str
):
canonicalized_name
=
canonicalize_name
(
test
)
assert
canonicalized_name
==
expected
def
test_safe_extra
():
def
test_safe_extra
():
extra
=
"pandas.CSVDataSet"
extra
=
"pandas.CSVDataSet"
result
=
safe_extra
(
extra
)
result
=
safe_extra
(
extra
)
...
...
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