Please solve the programming task below using a self-contained code snippet in a markdown code block.

Given a binary array nums and an integer goal, return the number of non-empty subarrays with a sum goal.
A subarray is a contiguous part of the array.
 
Please complete the following python code precisely:
```python
class Solution:
    def numSubarraysWithSum(self, nums: List[int], goal: int) -> int:
```