Just add import dolfinx.fem.petsc at the top of your file, and rewrite the command to call dolfinx.fem.petsc.NonlinearProblem.
This change is related to the changes in the main branch, see Isolate petsc4y in Python interface by garth-wells · Pull Request #2703 · FEniCS/dolfinx · GitHub
for details