Skip to content

[BUG CLIENT]: files.upload(purpose="ocr") type mismatch #196

Open
@marmor7

Description

@marmor7

Python -VV

Python 3.13.2 | packaged by Anaconda, Inc. | (main, Feb  6 2025, 12:55:35) [Clang 14.0.6 ]

Pip Freeze

docling==2.25.1
graphviz==0.20.3
mistralai==1.5.1
prettytable==3.14.0
python-Levenshtein==0.26.1
seaborn==0.13.2
streamlit==1.42.2
google-auth-oauthlib==1.2.1
google-api-python-client==2.162.0
vision-parse==0.1.13
## The following requirements were added by pip freeze:
aioboto3==13.4.0
aiobotocore==2.18.0
aiocache==0.12.3
aiofiles==24.1.0
aiohappyeyeballs==2.4.6
aiohttp==3.11.13
aioitertools==0.12.0
aiosignal==1.3.2
aiosqlite==0.21.0
altair==5.5.0
annotated-types==0.7.0
anyio==4.8.0
argcomplete==3.5.3
ariadne-codegen==0.14.0
asyncmy==0.2.10
attrs==25.1.0
audioop-lts==0.2.1
autoflake==2.3.1
azure-ai-documentintelligence==1.0.0
azure-core==1.32.0
azure-identity==1.20.0
backoff==2.2.1
beautifulsoup4==4.13.3
black==25.1.0
blessed==1.20.0
blinker==1.9.0
boto3==1.36.1
boto3-stubs==1.36.26
botocore==1.36.1
botocore-stubs==1.37.1
cachetools==5.5.2
certifi==2025.1.31
cffi==1.17.1
charset-normalizer==3.4.1
click==8.1.8
cobble==0.1.4
contourpy==1.3.1
coverage==7.6.12
cryptography==44.0.1
cycler==0.12.1
datamodel-code-generator==0.28.2
debugpy==1.8.12
defusedxml==0.7.1
dill==0.3.9
diskcache==5.6.3
distro==1.9.0
dnspython==2.7.0
docker-pycreds==0.4.0
docling-core==2.21.1
docling-ibm-models==3.4.1
docling-parse==3.4.0
easyocr==1.7.2
email_validator==2.2.0
emoji==2.14.1
enlighten==1.13.0
et_xmlfile==2.0.0
eval_type_backport==0.2.2
fastapi==0.115.11
fastapi-cli==0.0.7
filelock==3.17.0
filetype==1.2.0
flake8==7.1.2
fonttools==4.56.0
frozenlist==1.5.0
fsspec==2025.2.0
fuzzywuzzy==0.18.0
genson==1.3.0
gitdb==4.0.12
GitPython==3.1.44
google-ai-generativelanguage==0.6.10
google-api-core==2.24.1
google-auth==2.38.0
google-auth-httplib2==0.2.0
google-generativeai==0.8.3
googleapis-common-protos==1.68.0
gprof2dot==2024.6.6
gql==3.5.1
graphql-core==3.2.3
greenlet==3.1.1
groq==0.18.0
grpcio==1.71.0rc2
grpcio-status==1.71.0rc2
h11==0.14.0
httpcore==1.0.7
httplib2==0.22.0
httptools==0.6.4
httpx==0.28.1
huggingface-hub==0.29.1
idna==3.10
imageio==2.37.0
inflect==5.6.2
iniconfig==2.0.0
isodate==0.7.2
isort==6.0.0
Jinja2==3.1.5
jiter==0.8.2
jmespath==1.0.1
joblib==1.4.2
json_repair==0.39.1
jsonlines==3.1.0
jsonpatch==1.33
jsonpath-python==1.0.6
jsonpointer==3.0.0
jsonref==1.1.0
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
kiwisolver==1.4.8
langchain==0.3.19
langchain-core==0.3.40
langchain-text-splitters==0.3.6
langsmith==0.3.11
latex2mathml==3.77.0
lazy_loader==0.4
Levenshtein==0.26.1
log-with-context==0.6.0
lxml==5.3.1
lz4==4.4.3
mammoth==1.9.0
markdown-it-py==3.0.0
markdownify==1.0.0
markitdown==0.0.1a5
marko==2.1.2
MarkupSafe==3.0.2
matplotlib==3.10.1
mccabe==0.7.0
mdurl==0.1.2
mpire==2.10.2
mpmath==1.3.0
msal==1.31.1
msal-extensions==1.2.0
multidict==6.1.0
multiprocess==0.70.17
mypy-boto3-cloudformation==1.36.15
mypy-boto3-cloudwatch==1.36.0
mypy-boto3-dynamodb==1.36.0
mypy-boto3-ec2==1.36.18
mypy-boto3-lambda==1.36.0
mypy-boto3-rds==1.36.25
mypy-boto3-s3==1.36.21
mypy-boto3-sns==1.36.3
mypy-boto3-sqs==1.36.0
mypy-extensions==1.0.0
mysql-connector-python==9.2.0
narwhals==1.28.0
nest-asyncio==1.6.0
networkx==3.4.2
ninja==1.11.1.3
nodeenv==1.9.1
oauthlib==3.2.2
ocrmac==1.0.0
olefile==0.47
ollama==0.4.7
openai==1.63.2
opencv-python==4.11.0.86
opencv-python-headless==4.11.0.86
openpyxl==3.1.5
orjson==3.10.15
packaging==24.2
pandas==2.2.3
pandas-stubs==2.2.3.241126
pathspec==0.12.1
pathvalidate==3.2.3
pdfminer.six==20240706
pillow==11.1.0
pinecone==6.0.1
pinecone-plugin-interface==0.0.7
platformdirs==4.3.6
pluggy==1.5.0
portalocker==2.10.1
prefixed==0.9.0
propcache==0.3.0
proto-plus==1.26.0
protobuf==5.29.3
protoc-gen-openapiv2==0.0.1
psutil==7.0.0
puremagic==1.28
pyarrow==19.0.1
pyasn1==0.6.1
pyasn1_modules==0.4.1
pyclipper==1.3.0.post6
pycodestyle==2.12.1
pycparser==2.22
pydantic==2.10.6
pydantic-settings==2.8.1
pydantic_core==2.27.2
pydeck==0.9.1
pydub==0.25.1
pyflakes==3.2.0
Pygments==2.19.1
PyJWT==2.10.1
PyMuPDF==1.25.3
PyMySQL==1.1.1
pyobjc-core==11.0
pyobjc-framework-Cocoa==11.0
pyobjc-framework-CoreML==11.0
pyobjc-framework-Quartz==11.0
pyobjc-framework-Vision==11.0
pyparsing==3.2.1
PyPDF2==3.0.1
pypdfium2==4.30.1
PyPika==0.48.9
pyright==1.1.396
pytest==8.3.4
pytest-asyncio==0.25.3
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-profiling==1.8.1
python-bidi==0.6.6
python-dateutil==2.9.0.post0
python-docx==1.1.2
python-dotenv==1.0.1
python-magic==0.4.27
python-multipart==0.0.20
python-pptx==1.0.2
python-rapidjson==1.20
pytz==2025.1
PyYAML==6.0.2
RapidFuzz==3.12.1
redis==5.2.1
referencing==0.36.2
regex==2024.11.6
requests==2.32.3
requests-oauthlib==2.0.0
requests-toolbelt==1.0.0
rich==13.9.4
rich-toolkit==0.13.2
rpds-py==0.23.1
rsa==4.9
Rtree==1.3.0
s3transfer==0.11.2
safetensors==0.5.3
scikit-image==0.25.2
scikit-learn==1.6.1
scipy==1.15.2
semchunk==2.2.2
sentry-sdk==2.22.0
setproctitle==1.3.5
setuptools==72.1.0
shapely==2.0.7
shellingham==1.5.4
six==1.17.0
smmap==5.0.2
sniffio==1.3.1
soupsieve==2.6
SpeechRecognition==3.14.1
sqlacodegen-v2==0.1.4
SQLAlchemy==2.0.38
sqlmodel==0.0.23
standard-aifc==3.13.0
standard-chunk==3.13.0
starlette==0.45.3
sympy==1.13.1
tabulate==0.9.0
tenacity==9.0.0
threadpoolctl==3.5.0
tifffile==2025.2.18
tiktoken==0.9.0
tokenizers==0.21.0
toml==0.10.2
torch==2.6.0
torchvision==0.21.0
tornado==6.4.2
tqdm==4.67.1
transformers==4.49.0
treelib==1.7.0
typer==0.12.5
types-aioboto3==13.4.0
types-aiobotocore==2.20.0
types-aiobotocore-cloudformation==2.18.0
types-aiobotocore-cloudwatch==2.18.0
types-aiobotocore-dynamodb==2.18.0
types-aiobotocore-ec2==2.18.0
types-aiobotocore-lambda==2.18.0
types-aiobotocore-rds==2.18.0
types-aiobotocore-s3==2.18.0.post1
types-aiobotocore-sns==2.18.0
types-aiobotocore-sqs==2.18.0
types-awscrt==0.23.10
types-pytz==2025.1.0.20250204
types-s3transfer==0.11.2
typing-inspect==0.9.0
typing_extensions==4.12.2
tzdata==2025.1
untruncate_json==1.1.0
uritemplate==4.1.1
urllib3==2.3.0
uuid_utils==0.10.0
uvicorn==0.34.0
uvloop==0.21.0
wandb==0.19.7
watchdog==6.0.0
watchfiles==1.0.4
wcwidth==0.2.13
weave==0.51.35
websockets==15.0
wheel==0.45.1
wrapt==1.17.2
xlrd==2.0.1
XlsxWriter==3.2.2
yarl==1.18.3
youtube-transcript-api==0.6.3
zstandard==0.23.0

Reproduction Steps

  1. Official docs here, show example code:
client.files.upload(
    file={
        "file_name": "uploaded_file.pdf",
        "content": open("uploaded_file.pdf", "rb"),
    },
    purpose="ocr"
)  
  1. Add that into your code
  2. Run pyright --warnings
  3. Get pyright error:
error: Argument of type "Literal['ocr']" cannot be assigned to parameter "purpose" of type "FilePurpose | None" in function "upload"
    Type "Literal['ocr']" is not assignable to type "FilePurpose | None"
      "Literal['ocr']" is not assignable to "UnrecognizedStr"
      "Literal['ocr']" is not assignable to "None"
      "Literal['ocr']" is not assignable to type "Literal['fine-tune']"
      "Literal['ocr']" is not assignable to type "Literal['batch']" (reportArgumentType)

Expected Behavior

"ocr" should be recognized in type FilePurpose.

Additional Context

No response

Suggested Solutions

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions