<filename>weapon.py
import pygame
from player import Player


class Weapon(pygame.sprite.Sprite):
    def __init__(self, player: Player, groups):
        super().__init__(groups)
        self.sprite_type = 'weapon'

        direction = player.status.split('_')[0]

        # graphic
        full_path = f'graphics/weapons/{player.weapon}/{direction}.png'
        self.image = pygame.image.load(full_path).convert_alpha()

        # placement
        if direction == 'right':
            self.rect = self.image.get_rect(
                midleft=player.rect.midright + pygame.math.Vector2(0, 16))
        elif direction == 'left':
            self.rect = self.image.get_rect(
                midright=player.rect.midleft + pygame.math.Vector2(0, 16))
        elif direction == 'down':
            self.rect = self.image.get_rect(
                midtop=player.rect.midbottom + pygame.math.Vector2(-10, 0))
        elif direction == 'up':
            self.rect = self.image.get_rect(
                midbottom=player.rect.midtop + pygame.math.Vector2(-10, 0))
        else:
            self.rect = self.image.get_rect(center=player.rect.center)


if __name__ == '__main__':
    from main import run_game
    run_game()

<filename>weapon.py
import pygame
from player import Player


class Weapon(pygame.sprite.Sprite):
    def __init__(self, player: Player, groups):
        super().__init__(groups)
        self.sprite_type = 'weapon'

        direction = player.status.split('_')[0]

        # graphic
        full_path = f'graphics/weapons/{player.weapon}/{direction}.png'
        self.image = pygame.image.load(full_path).convert_alpha()

        # placement
        if direction == 'right':
            self.rect = self.image.get_rect(
                midleft=player.rect.midright + pygame.math.Vector2(0, 16))
        elif direction == 'left':
            self.rect = self.image.get_rect(
                midright=player.rect.midleft + pygame.math.Vector2(0, 16))
        elif direction == 'down':
            self.rect = self.image.get_rect(
                midtop=player.rect.midbottom + pygame.math.Vector2(-10, 0))
        elif direction == 'up':
            self.rect = self.image.get_rect(
                midbottom=player.rect.midtop + pygame.math.Vector2(-10, 0))
        else:
            self.rect = self.image.get_rect(center=player.rect.center)


if __name__ == '__main__':
    from main import run_game
    run_game()

# graphic # placement