Preheat your oven to 350°F (175°C). Grease a 9-inch pie pan with cooking spray or butter.
In a large mixing bowl, combine the sugar, flour, cocoa powder, and salt. Mix well.
Add the melted butter, eggs, and vanilla extract to the dry ingredients. Stir until fully combined and smooth.
Fold in the chopped walnuts and chocolate chips if using.
Pour the batter into the prepared pie pan and spread it evenly.
Bake in the preheated oven for 25-30 minutes, or until the edges are set but the center is still slightly soft.
Remove from the oven and let it cool for about 10 minutes before serving.