How high can the static bonus to an attack roll get?

I was considering this Q&A: What is the highest possible AC?

I was curious about whether any attack roll could ever get high enough to hit such an AC (short of scoring a critical hit, which ignores AC), and that got me thinking: How high can the static bonus to an attack roll get?

I’m not interested in the amount of damage done, just the static bonus, hence I’m also not interested in the actual number rolled on the die, but if it matters, assume it’s not a critical hit. The bonus can be temporary or situational, hence buff spells are allowed.

Any magic items, help from friends, feats, official races or classes or subclasses are allowed, but UA is not allowed, and nor is anything involving any kind of polymorph/wild shape. Also assume that the maximum ability score range is 20, with the exception of Barbarians going up to 24 in STR and CON at level 20 (in other words, no Manuals/Tomes to get to 30, and no other magic items that increase your maximum, but class features that do the same are OK). We can also assume rolling ability scores with lucky rolls so we can have almost any ability score at 20.

The best I can think of off the top of my head is a level 20 Ranger (so proficiency bonus of +6) with 20 DEX, the Archery Fighting Style (+2), and is shooting their +3 Longbow at one of their favoured enemies, thus adding their WIS (also 20) to the attack roll, so that’s 6 + 5 + 5 + 3 + 2 = +21 bonus. (There are also probably some buffs that can be added to this, but I can’t recall any at the moment, but I’m sure something exists…)

Can we do better than that within the restrictions I’ve specified above?