I need a special quaternion to euler function

Truthfully it isn't really that special, but it is a bit cancerous as I only have atan() and not atan2()...
What's special about it is every other function I see seems to be intrinsic with 1 axis needing a sqrt() to manage singularities,
where what I'm looking to achieve is an extrinsic function that shouldn't have to care about singularities.

If it helps with anything, converting to mtx33 before euler might help in singularity management, as mtx33 is extrinsic by default.
(I've just recently learned a mtx33 was just an over-glorified semi-scalar NBT vector)

I'm not a mathematician though, so I'm not sure how much help that'll actually be...
but I AM certain the output code can be done without the need of managing singularities:

atan2(x,y),
atan2(x,y),
atan2(x,y)

instead of:

atan2(x,y),      # X pitch
atan2(x,sqrt()), # Y yaw
atan2(x,y)       # Z roll

as this causes 1 axis (yaw in this case) to lock up and not move >90 degrees without intrinsic measures applied to X and Z.

Also yes, I'm just using atan2 as an example here as I actually can't use it in what I'm doing...

There actually isn't a tag for what I'm doing as while it involves XML, it's actually somewhat C-like,
so in this case I'm requesting python just because it's easier to follow. :P

I can translate that to this:

<eval expr="eulerX = atan(Y/X)" display_error="false" display_result="false" comment=""/>

+1 if you actually know what I'm working with (irrelevant)

Is there anything that would fit what I need??