If you file for Chapter 7 bankruptcy, what happens to the inheritance depends on when the person who gave it to you passed away. If the death of the testator occurred within 180 days prior to your bankruptcy filing, the inheritance you received will form part of your bankruptcy estate and will have to be handed over to the bankruptcy trustee who will use it to pay your creditors. If the testator passed away more than 180 days before you filed for Chapter 7 bankruptcy, then the inheritance is yours to keep.
Note that the 180 days is counted from the date of death of the person who gave you the inheritance, not the date you received the inheritance. For example, if your distant relative gave you $1 million in his will, and you received it only 1 year after he died, the money will become part of the assets in your bankruptcy if the death occurred within 180 days prior to your bankruptcy filing.
On the other hand, if you file for Chapter 13 bankruptcy, the 180 day limit does not apply. As long as your bankruptcy is still ongoing, the inheritance will form part of your bankruptcy estate and will be used to calculate how much you should repay your creditors. So in the example above, regardless of when you received the inheritance, as long as your debts in bankruptcy have not been discharged, your inheritance is taken into account to calculate your repayment amount.