Q:

How to create narrow collision detection between a player's melee weapon and an enemy

Whenever the player is in range of a particular enemy, then the player can swing their sword and cause damage to that enemy that is in front of them.   I have this code here that demonstrates the system I have in place now:
for event in pygame.event.get():
     if event.type == pygame. MOUSEBUTTONDOWN:
         if event.button == 1: #Event called when left click
             for enemy in enemies: #An array that holds instances of enemies 
                 if (math.sqrt( ( (enemy.x - x) **2) + ( (enemy.y - y)**2) ) < (100+reachBonus) ): #Using distance forumla to calculate player x and y values in corresondance to an enemies x and y position 
                     enemy.health -= woodenSword.damageAmount #subtracts the enemies health by the amount of damage that the woodenSword does 

The problem with this system is that I'm only checking if the player is within a specific range, so technically it will work in a circular range around the enemy.   This would work for something like an explosion, but since I am working on a fighting system and the player has to be looking directly at an enemy, this wouldn't really work.   
As possible approach I consider raytracing.  I am used to Unreal Engine, where you can send out a line trace, which is basically an invisible line that will return True if it has hit something directly.  This would be an option if I cast several rays in front of the player and see if it collides with enemy, but I did not find how to do in pygame and it feels like not very effective solution as I may need to send multiple rays to start with.  Also that is common for 3d space - maybe 2d game I have can go with basic math instead. 
What can I do to fix my mechanic so it will only work if the player is looking straight at the enemy, and not just in range?  

A:

It looks like you are attempting to re-invent the wheel for features that already exist within pygame. 
You are attempting to determine whether or not the sword is making contact with a mob. 
This is already covered by pygame's collision detection features. 
Instead of calculating the proximity of your character to each mob, instead generate a sprite on mouse click for the area of the sword attack.   Then test for a collision between the mobs and the weapon sprite.   If there is a collision, do the damage calculation. 
https://www.pygame.org/docs/ref/sprite.html
With regard to raycasting, this would be useful if you are attempting to calculate an endpoint for some sort of a laser or rope or something else where you are constructing a solid "thing" between a start and end point and need to know the end point before generating the "thing" on screen.   For a typical melee attack it isn't necessary.