If you expect to inherit something of significant value, and you also have significant debts, bankruptcy might be a way to preserve that inheritance instead of having much or all of it go to your creditors. Let's take a look at how this might work.
If you don't file bankruptcy
An inheritance of significant value, for example a fully-paid-for house or a lot of money, would probably be worth way more than you could "exempt" (protect) from your creditors if they sued you for what you owed them. That means they could take your money or get a "lien" on your house, just as if you had a loan on that house for the amount you owe your creditors.
If you file bankruptcy
You debts would be eliminated before you inherited, so whatever you receive would be free and clear of those debts.
One possible glitch
If the person you expect to inherit from dies within 180 days (approximately six months) after you file bankruptcy, the money or property you inherit would be liable for your debts just as if you had received it before you filed bankruptcy.
What to do?
If you think you may be in this situation, do yourself a favor and consult with an experienced bankruptcy attorney in your area, and do it sooner rather than later.