Potrero HIll's North Slope is very safe - everything between 22nd and Mariposa, and between De Haro and Pennsylvania is basically just fine, or at least as safe as any other neighborhood ever gets. 18th St. has really experienced a resurgence in neighborhood life, so there are good numbers of people out as late as midnight or 1am on weekends. Car break-ins (snatch-n-grabs) have been an issue, but face-to-face crime has not. As you get closer to the housing projects and to SF General, the crime maps get more crime-filled.
If you're coming up the hill from the Caltrain Station on 22nd, note that the few blocks surrounding the train station is desolate and not yet well-lit at night. I don't hear about a lot of bad things happening down there, but awareness is required. Things get more densely residential by the time you get up to 20th and Pennsylvania.