Ansible molecule finds wrong Python version but Ansible works fine directly

I have a strange thing happening in one of your projects, maybe someone has an idea what is happening.
We basically have the following configuration.
It is a project where we use Ansible and Ansible Molecule for testing.
In the dev-shell everything feels and behaves normally.

Recently we created a custom Ansible module with additional dependencies.
It works fine when we run it directly from the within the dev-shell.

But when run Molecule tests (a container based test framework) the path to ansible python module location in the store is different and doesn’t point to our dev environment anymore.

Everything gets installed through poetry2nix so I’m a bit lost why it should be different between the dev shell and molecule.

system = "x86_64-linux";
pkgs = inputs.nixpkgs.legacyPackages.${system};
poetry2nix = inputs.poetry2nix.lib.mkPoetry2Nix { inherit pkgs; };
python = pkgs.python310;
root = ./.;
pythonDevEnvironment = poetry2nix.mkPoetryEnv {
  groups = [
    "main"
    "dev"
  ];
  projectDir = root;
  inherit python;
};

What we get inside molecule for ansible-playbook --version.
Expected:

ansible-playbook [core 2.17.8]
  config file = /home/andreas/git_repos/work/contria_ansible/ansible.cfg
  configured module search path = ['/home/andreas/git_repos/work/contria_ansible/library']
  ansible python module location = /nix/store/kz7p8bg8jk3ypa3h6pxlifcsy9q4b5z2-python3-3.10.16-env/lib/python3.10/site-packages/ansible
  ansible collection location = /nix/store/fpm91wbb3hzm70xdhcf74ik1f04qkxny-galaxy-requirements:/home/andreas/git_repos/work/contria_ansible/collections/ansible_collections
  executable location = /nix/store/vmjwcq9kq819haqs7r6xrxp75sbai916-python3.10-ansible-core-2.17.8/bin/ansible-playbook
  python version = 3.10.16 (main, Dec  3 2024, 17:27:57) [GCC 13.3.0] (/nix/store/kz7p8bg8jk3ypa3h6pxlifcsy9q4b5z2-python3-3.10.16-env/bin/python3.10)
  jinja version = 3.1.5
  libyaml = True

Output inside molecule:

ansible-playbook [core 2.17.8]
  config file = /home/andreas/git_repos/work/contria_ansible/.devenv/state/molecule/ansible.cfg
  configured module search path = ['/home/andreas/git_repos/work/contria_ansible/library']
  ansible python module location = /nix/store/vmjwcq9kq819haqs7r6xrxp75sbai916-python3.10-ansible-core-2.17.8/lib/python3.10/site-packages/ansible
  ansible collection location = /nix/store/fpm91wbb3hzm70xdhcf74ik1f04qkxny-galaxy-requirements:/home/andreas/git_repos/work/contria_ansible/collections/ansible_collections
  executable location = /nix/store/vmjwcq9kq819haqs7r6xrxp75sbai916-python3.10-ansible-core-2.17.8/bin/ansible-playbook
  python version = 3.10.16 (main, Dec  3 2024, 17:27:57) [GCC 13.3.0] (/nix/store/v5x90j46fchzh3b891hcc1h3pajbcsc7-python3-3.10.16/bin/python3.10)
  jinja version = 3.1.5
  libyaml = True