Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No optional type hinting on some optional constructor args #4454

Open
DominicOram opened this issue Feb 28, 2025 · 0 comments · May be fixed by #4455
Open

No optional type hinting on some optional constructor args #4454

DominicOram opened this issue Feb 28, 2025 · 0 comments · May be fixed by #4455
Labels
bug Something isn't working

Comments

@DominicOram
Copy link

Describe your environment

OS: RHEL 8
Python version: 3.11
SDK version: 1.30.0
API version: 1.30.0

What happened?

The latest version of pyright is stricter and raises errors if a constructor argument is not typed as optional and a caller does not provide it.

Steps to Reproduce

Run the latest pyright against something like:

    traceProvider = TracerProvider(resource=resource)
    processor = BatchSpanProcessor(
        OTLPSpanExporter(endpoint="http://0.0.0.0:4318/v1/traces")
    )
    traceProvider.add_span_processor(processor)
    trace.set_tracer_provider(traceProvider)

    reader = PeriodicExportingMetricReader(
        OTLPMetricExporter(endpoint="http://0.0.0.0:4318/v1/metrics")
    )

and see errors like:

 - error: Argument of type "None" cannot be assigned to parameter "max_queue_size" of type "int" in function "__init__"
    "None" is not assignable to "int" (reportArgumentType)
- error: Argument of type "None" cannot be assigned to parameter "schedule_delay_millis" of type "float" in function "__init__"
    "None" is not assignable to "float" (reportArgumentType)
- error: Argument of type "None" cannot be assigned to parameter "max_export_batch_size" of type "int" in function "__init__"
    "None" is not assignable to "int" (reportArgumentType)
- error: Argument of type "None" cannot be assigned to parameter "export_timeout_millis" of type "float" in function "__init__"
    "None" is not assignable to "float" (reportArgumentType)
- error: Argument of type "None" cannot be assigned to parameter "preferred_temporality" of type "Dict[type, AggregationTemporality]" in function "__init__"
    "None" is not assignable to "Dict[type, AggregationTemporality]" (reportArgumentType)
- error: Argument of type "None" cannot be assigned to parameter "preferred_aggregation" of type "Dict[type, Aggregation]" in function "__init__"
    "None" is not assignable to "Dict[type, Aggregation]" (reportArgumentType)
6 errors, 0 warnings, 0 informations 

Expected Result

No pyright errors on the above snippet

Actual Result

The above errors

Additional context

No response

Would you like to implement a fix?

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant