Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: add type hints to gitlab/utils.py#1330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
max-wittig merged 1 commit intopython-gitlab:masterfromJohnVillalovos:jlvillal/mypy_utils
Feb 25, 2021
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletionsgitlab/utils.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,15 +15,23 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from typing import Any, Callable, Dict, Optional
from urllib.parse import urlparse

import requests


class _StdoutStream(object):
def __call__(self, chunk):
def __call__(self, chunk) -> None:
print(chunk)


def response_content(response, streamed, action, chunk_size):
def response_content(
response: requests.Response,
streamed: bool,
action: Optional[Callable],
chunk_size: int,
):
if streamed is False:
return response.content

Expand All@@ -35,7 +43,7 @@ def response_content(response, streamed, action, chunk_size):
action(chunk)


def copy_dict(dest,src):
def copy_dict(dest: Dict[str, Any],src: Dict[str, Any]) -> None:
for k, v in src.items():
if isinstance(v, dict):
# Transform dict values to new attributes. For example:
Expand All@@ -47,7 +55,7 @@ def copy_dict(dest, src):
dest[k] = v


def clean_str_id(id):
def clean_str_id(id: str) -> str:
return id.replace("/", "%2F").replace("#", "%23")


Expand All@@ -59,11 +67,11 @@ def sanitize_parameters(value):
return value


def sanitized_url(url):
def sanitized_url(url: str) -> str:
parsed = urlparse(url)
new_path = parsed.path.replace(".", "%2E")
return parsed._replace(path=new_path).geturl()


def remove_none_from_dict(data):
def remove_none_from_dict(data: Dict[str, Any]) -> Dict[str, Any]:
return {k: v for k, v in data.items() if v is not None}

[8]ページ先頭

©2009-2025 Movatter.jp