He then fired it at the man, who was sitting in a car with his girlfriend and his teenage cousin in Chapeltown.

The Recorder of Leeds, Peter Collier QC, today told him: “The use of knives and guns on the streets of this city simply cannot and will not be tolerated.”

Leeds Crown Court heard the shooting took place in Chapeltown Road at around 2am on August 28 as celebrations for the carnival’s 50th anniversary wound down.

Prosecutor Adam Birkby said the victim had twice kicked out as he tried to fend off James, causing him to fall to the ground.

James then reached for his waistband and a handgun fell to the floor. He said “You’re a dead man” and pointed the gun about one foot away from the victim, who put his arms over his face and turned his body to shield his girlfriend.

Mr Birkby said the victim described hearing a loud bang before his ears started ringing.

James ran off and the victim took his girlfriend and cousin home before going to hospital. He was found to have a superficial wound to his arm.

The court heard police found 19 wraps of crack cocaine and 14 wraps of heroin at James’ home in Hamilton Avenue, Chapeltown, when he was arrested later that day.

A gardener then found a bag containing a converted gas fired pistol, its magazine and a bullet casing in a bag on August 29.

James’ DNA was on both the trigger and the case of the bullet, which had not fired properly.

Mr Birkby said the motive for the shooting was believed to be revenge and that five years earlier there had been an “unfounded allegation” that the victim had slapped one of the women in the James family.

The court heard James had one previous conviction for possession of a knife and two for drugs offences.

He denied an original charge of attempted murder, but pleaded guilty to causing grievous bodily harm with intent, possession of a prohibited weapon, and two counts of possessing Class A drugs with intent to supply.