Skip to content

investigate __future__ import bug#4802

Closed
pjmagee wants to merge 3 commits intomicrosoft:mainfrom
pjmagee:__future__import-fix
Closed

investigate __future__ import bug#4802
pjmagee wants to merge 3 commits intomicrosoft:mainfrom
pjmagee:__future__import-fix

Conversation

@pjmagee
Copy link

@pjmagee pjmagee commented Jun 10, 2024

fixes #4600 Is this the right place to be looking?

@baywet
Copy link
Member

baywet commented Jun 12, 2024

@pjmagee yes, it's the right place. Thanks for starting this and let us know if you have questions

@pjmagee pjmagee force-pushed the __future__import-fix branch from 22b0b47 to a3f2f74 Compare June 12, 2024 22:43
@pjmagee
Copy link
Author

pjmagee commented Jun 12, 2024

This is so odd, running VS Code Python Launcher and modifying to use my spec and output, the future seems to be sorted correctly, but not when I'm using the released docker image approach.

Tempted to see if running the .NET tool variant behaves any differently. I'll look into that tomorrow if I have any spare time.

@baywet
Copy link
Member

baywet commented Jun 13, 2024

That might be because the order by, or the them by in your commented code doesn't pass a comparer. And the defaults on each platform might be slightly different

@pjmagee
Copy link
Author

pjmagee commented Jun 13, 2024

That might be because the order by, or the them by in your commented code doesn't pass a comparer. And the defaults on each platform might be slightly different

I didn't change anything, the commented code I placed in the LINQ statements to handle the _future_ was only going to be applied once i had failing testing with the existing code.

@pjmagee
Copy link
Author

pjmagee commented Jun 13, 2024

Tried using the .devcontainer to see if running inside there and running python on a linux env would do anything differently, but it was generating correctly. This makes no sense

@pjmagee
Copy link
Author

pjmagee commented Jun 13, 2024

Wow, i got around the problem, but it's strange....

So instead of using the Kiota docker image, i use a .NET SDK 8 base image, install the kiota dotnet tool and then use that to generate the python code, and the problem has gone away.

This leads me to believe it's something around culture or modifications made in the published kiota docker image which is having different behaviour than how we develop/test and run code. But that's really odd to me.

I think the default (not the code I added, i mean the original code as it is right now) OrderBy should somehow also take a specified CultureInfo of invariant? Maybe something funky is going on because this is missing, similar to what you had said about my commented out code, which I never ended up using, because i cant get the tests to fail first.

I want failing tests and then to write the solution and confirm the tests pass, struggling to do that.

@rcleveng
Copy link
Contributor

rcleveng commented Jun 7, 2025

It's certainly the chiseled [variants](See https://github.com/dotnet/dotnet-docker/blob/main/documentation/image-variants.md) of the distribution, that's the difference This diff fixes it. I don't know enough about dotnet to know what exactly is causing this.

According to the docs:
By default, these images do not include icu or tzdata, meaning that these images
only work with apps that are configured for globalization-invariant mode.
See https://learn.microsoft.com/en-us/dotnet/core/runtime-config/globalization

diff --git a/Dockerfile b/Dockerfile
index ca44fdc38..0f01d340e 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -11,7 +11,12 @@ RUN if [ -z "$version_suffix" ]; then \
     dotnet publish ./src/kiota/kiota.csproj -c Release -p:TreatWarningsAsErrors=false -f net9.0 --version-suffix "$version_suffix"; \
     fi
 
-FROM mcr.microsoft.com/dotnet/runtime:9.0-noble-chiseled AS runtime
+#FROM mcr.microsoft.com/dotnet/runtime:9.0-noble-chiseled AS runtime
+FROM mcr.microsoft.com/dotnet/runtime:9.0 AS runtime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Python] SyntaxError: from __future__ imports must occur at the beginning of the file

3 participants