Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
140 changes: 140 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-ast
exclude: ^(tests|samples)/
- id: sort-simple-yaml
exclude: ^(tests|samples)/
- id: check-yaml
exclude: |
(?x)^(
meta.yaml
| tests/
| samples/
)$
- id: check-xml
exclude: ^(tests|samples)/
- id: check-toml
exclude: ^(tests|samples)/
- id: check-docstring-first
exclude: ^(tests|samples)/
- id: check-json
exclude: ^(tests|samples)/
- id: fix-encoding-pragma
exclude: ^(tests|samples)/
- id: detect-private-key
exclude: ^(tests|samples)/
- id: trailing-whitespace
exclude: ^(tests|samples)/
- repo: https://github.com/asottile/add-trailing-comma
rev: v3.1.0
hooks:
- id: add-trailing-comma
exclude: ^(tests|samples)/
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.7.0
hooks:
- id: mypy
exclude:
(?x)(
pb2\.py$
| grpc\.py$
| ^docs
| ^tests/
| ^samples/
| \.html$
)
args: [
--ignore-missing-imports,
--disable-error-code=var-annotated,
--disable-error-code=union-attr,
--disable-error-code=assignment,
--disable-error-code=attr-defined,
--disable-error-code=import-untyped,
--disable-error-code=truthy-function,
--follow-imports=skip,
--explicit-package-bases,
]
Comment on lines +48 to +58

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The mypy configuration is very permissive, with many checks disabled. While this can be a starting point, it significantly reduces the benefits of static type checking. For example, --ignore-missing-imports can hide import errors. It would be beneficial to create a plan to gradually remove these disabled checks to improve the type safety and robustness of the codebase.

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
args: [ --line-length=79 ]
exclude: ^(tests|samples)/
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
args: [ "--extend-ignore=E203"]
exclude: ^(tests|samples)/
- repo: https://github.com/pylint-dev/pylint
rev: v3.0.2
hooks:
- id: pylint
exclude:
(?x)(
^docs
| ^tests/
| ^samples/
| pb2\.py$
| grpc\.py$
| \.demo$
| \.md$
| \.html$
)
args: [
--disable=W0511,
--disable=W0718,
--disable=W0122,
--disable=C0103,
--disable=R0913,
--disable=E0401,
--disable=E1101,
--disable=C0415,
--disable=W0603,
--disable=R1705,
--disable=R0914,
--disable=E0601,
--disable=W0602,
--disable=W0604,
--disable=R0801,
--disable=R0902,
--disable=R0903,
--disable=C0123,
--disable=W0231,
--disable=W1113,
--disable=W0221,
--disable=R0401,
--disable=W0632,
--disable=W0123,
--disable=C3001,
--disable=W0201,
--disable=C0302,
--disable=W1203,
--disable=C2801,
--disable=C0114, # Disable missing module docstring for quick dev
--disable=C0115, # Disable missing class docstring for quick dev
--disable=C0116, # Disable missing function or method docstring for quick dev
Comment on lines +116 to +118

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Disabling docstring checks (C0114, C0115, C0116) for "quick dev" is not a good practice for a library, as it can lead to poor documentation and lower maintainability. It's better to enforce docstrings and add them where they are missing. I suggest removing these disable flags.

]
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v7.32.0
hooks:
- id: eslint
files: \.(js|jsx)$
exclude: '(.*js_third_party.*|^tests/|^samples/)'
args: [ '--fix' ]
- repo: https://github.com/thibaudcolas/pre-commit-stylelint
rev: v14.4.0
hooks:
- id: stylelint
files: \.(css)$
exclude: '(.*css_third_party.*|^tests/|^samples/)'
args: [ '--fix' ]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: 'v3.0.0'
hooks:
- id: prettier
additional_dependencies: [ 'prettier@3.0.0' ]
files: \.(tsx?)$
exclude: ^(tests|samples)/
152 changes: 90 additions & 62 deletions dashscope/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright (c) Alibaba, Inc. and its affiliates.

import logging
Expand All @@ -7,89 +8,116 @@
from dashscope.aigc.conversation import Conversation, History, HistoryItem
from dashscope.aigc.generation import AioGeneration, Generation
from dashscope.aigc.image_synthesis import ImageSynthesis
from dashscope.aigc.multimodal_conversation import MultiModalConversation, AioMultiModalConversation
from dashscope.aigc.multimodal_conversation import (
MultiModalConversation,
AioMultiModalConversation,
)
from dashscope.aigc.video_synthesis import VideoSynthesis
from dashscope.app.application import Application
from dashscope.assistants import Assistant, AssistantList, Assistants
from dashscope.assistants.assistant_types import AssistantFile, DeleteResponse
from dashscope.audio.asr.transcription import Transcription
from dashscope.audio.tts.speech_synthesizer import SpeechSynthesizer
from dashscope.common.api_key import save_api_key
from dashscope.common.env import (api_key, api_key_file_path,
base_http_api_url, base_websocket_api_url)
from dashscope.common.env import (
api_key,
api_key_file_path,
base_http_api_url,
base_websocket_api_url,
)
from dashscope.customize.deployments import Deployments
from dashscope.customize.finetunes import FineTunes
from dashscope.embeddings.batch_text_embedding import BatchTextEmbedding
from dashscope.embeddings.batch_text_embedding_response import \
BatchTextEmbeddingResponse
from dashscope.embeddings.batch_text_embedding_response import (
BatchTextEmbeddingResponse,
)
from dashscope.embeddings.multimodal_embedding import (
MultiModalEmbedding, MultiModalEmbeddingItemAudio,
MultiModalEmbeddingItemImage, MultiModalEmbeddingItemText, AioMultiModalEmbedding)
MultiModalEmbedding,
MultiModalEmbeddingItemAudio,
MultiModalEmbeddingItemImage,
MultiModalEmbeddingItemText,
AioMultiModalEmbedding,
)
from dashscope.embeddings.text_embedding import TextEmbedding
from dashscope.files import Files
from dashscope.models import Models
from dashscope.nlp.understanding import Understanding
from dashscope.rerank.text_rerank import TextReRank
from dashscope.threads import (MessageFile, Messages, Run, RunList, Runs,
RunStep, RunStepList, Steps, Thread,
ThreadMessage, ThreadMessageList, Threads)
from dashscope.tokenizers import (Tokenization, Tokenizer, get_tokenizer,
list_tokenizers)

__all__ = [
base_http_api_url,
base_websocket_api_url,
api_key,
api_key_file_path,
save_api_key,
AioGeneration,
Conversation,
Generation,
History,
HistoryItem,
ImageSynthesis,
Transcription,
Files,
Deployments,
FineTunes,
Models,
TextEmbedding,
MultiModalEmbedding,
AioMultiModalEmbedding,
MultiModalEmbeddingItemAudio,
MultiModalEmbeddingItemImage,
MultiModalEmbeddingItemText,
SpeechSynthesizer,
MultiModalConversation,
AioMultiModalConversation,
BatchTextEmbedding,
BatchTextEmbeddingResponse,
Understanding,
CodeGeneration,
Tokenization,
Tokenizer,
get_tokenizer,
list_tokenizers,
Application,
TextReRank,
Assistants,
Threads,
from dashscope.threads import (
MessageFile,
Messages,
Runs,
Assistant,
ThreadMessage,
Run,
Steps,
AssistantList,
ThreadMessageList,
RunList,
Runs,
RunStep,
RunStepList,
Steps,
Thread,
DeleteResponse,
RunStep,
MessageFile,
AssistantFile,
VideoSynthesis,
ThreadMessage,
ThreadMessageList,
Threads,
)
from dashscope.tokenizers import (
Tokenization,
Tokenizer,
get_tokenizer,
list_tokenizers,
)

__all__ = [
"base_http_api_url",
"base_websocket_api_url",
"api_key",
"api_key_file_path",
"save_api_key",
"AioGeneration",
"Conversation",
"Generation",
"History",
"HistoryItem",
"ImageSynthesis",
"Transcription",
"Files",
"Deployments",
"FineTunes",
"Models",
"TextEmbedding",
"MultiModalEmbedding",
"AioMultiModalEmbedding",
"MultiModalEmbeddingItemAudio",
"MultiModalEmbeddingItemImage",
"MultiModalEmbeddingItemText",
"SpeechSynthesizer",
"MultiModalConversation",
"AioMultiModalConversation",
"BatchTextEmbedding",
"BatchTextEmbeddingResponse",
"Understanding",
"CodeGeneration",
"Tokenization",
"Tokenizer",
"get_tokenizer",
"list_tokenizers",
"Application",
"TextReRank",
"Assistants",
"Threads",
"Messages",
"Runs",
"Assistant",
"ThreadMessage",
"Run",
"Steps",
"AssistantList",
"ThreadMessageList",
"RunList",
"RunStepList",
"Thread",
"DeleteResponse",
"RunStep",
"MessageFile",
"AssistantFile",
"VideoSynthesis",
]

logging.getLogger(__name__).addHandler(NullHandler())
28 changes: 16 additions & 12 deletions dashscope/aigc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
# -*- coding: utf-8 -*-
# Copyright (c) Alibaba, Inc. and its affiliates.
from .conversation import Conversation, History, HistoryItem
from .generation import Generation, AioGeneration
from .image_synthesis import ImageSynthesis, AioImageSynthesis
from .multimodal_conversation import MultiModalConversation, AioMultiModalConversation
from .multimodal_conversation import (
MultiModalConversation,
AioMultiModalConversation,
)
from .video_synthesis import VideoSynthesis, AioVideoSynthesis

__all__ = [
Generation,
AioGeneration,
Conversation,
HistoryItem,
History,
ImageSynthesis,
AioImageSynthesis,
MultiModalConversation,
AioMultiModalConversation,
VideoSynthesis,
AioVideoSynthesis,
"Generation",
"AioGeneration",
"Conversation",
"HistoryItem",
"History",
"ImageSynthesis",
"AioImageSynthesis",
"MultiModalConversation",
"AioMultiModalConversation",
"VideoSynthesis",
"AioVideoSynthesis",
]
Loading